示例#1
0
void AGameObject::CheckNextCommand()
{
  // If explicitly asked to DoNextCommand.
  if( IsReadyToRunNextCommand )
  {
    // When a command completes, remove the flag for it (if any) and pop it from the queue
    if( commands.size() )
    {
      // If there are still commands left, execute the next one.
      exec( GetCurrentCommand() );
      IsReadyToRunNextCommand = 0;
    }
  }

  if( Idling() )
  {
    // Once we are idling, we can pop the current command and try to exec the next one
    if( commands.size() )
    {
      Game->ClearFlag( GetCurrentCommand().CommandID );
      commands.pop_front(); // pop out the front item in the queue
    }
    IsReadyToRunNextCommand = 1;
  }

}
示例#2
0
void Animal::Update(double dt)
{
	int probability = rand() % 2;
	
	counting++;

	if (counting > 20)
	{
		switch (probability)
		{
		case IDLING:
			Idling();
			break;

		case PATROL:
			Patrolling(dt);
			break;

		case EATING:
			Eating(dt);
			break;

		case DIES:
			Dying(dt);
			break;
		}
		counting = 0.0f;
		timeLimit = rand() % 30 + 20;
	}
	cout << counting << endl;

	if (walking)
		Patrolling(dt);
}