Пример #1
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);
}
Пример #2
0
void Guards::Update(int worldWidth, int worldHeight, int tileSize, double dt)
{
	if(GetUpdate() == true)
	{
		if (stun && checkTimer < stunTimer)
		{
			checkTimer += dt;

			Character::changeAni(StateMachine::IDLE_STATE);
			this->changeAni(Guards_StateMachine::IDLE_STATE);
			
			int dir = Math::RandIntMinMax(1, 4);

			switch (dir)
			{
			case 1:
				{
					this->dir.Set(1, 0);
					break;
				}
			case 2:
				{
					this->dir.Set(-1, 0);
					break;
				}
			case 3:
				{
					this->dir.Set(0, 1);
					break;
				}
			case 4:
				{
					this->dir.Set(0, -1);
					break;
				}
			}

			if (checkTimer >= stunTimer)
			{
				stun = false;
				chase = false;
				checkTimer = 0;
			}
		}

		else
		{
			if (chase == false)
			{
				Patrolling(worldWidth, worldHeight, tileSize, dt);
			}
			else
			{
				Chasing(worldWidth, worldHeight, tileSize, dt);
			}
		}

		AI::Update(dt);
	}
}
Пример #3
0
void Farmer::UpdateFarmer(double dt, PathManager& ppman)
{
	/******************** FSM ********************/
	switch (state)
	{
	case FARMING:
		Farming(dt, ppman);
		break;
	case SHOOT:
		Shooting(dt, ppman);
		break;
	case PATROL:
		Patrolling(dt, ppman);
		break;
	}
}