コード例 #1
0
void RandomWanderingBot::think(Game *game, Bot *bot, bool following)
{
	// EACH FRAME WE'LL TEST THIS BOT TO SEE IF WE NEED
	// TO PICK A DIFFERENT DIRECTION TO FLOAT IN
	TopDownSprite *player = game->getGSM()->getSpriteManager()->getPlayer();
	RandomWanderingBot* customer = dynamic_cast<RandomWanderingBot*>(bot);
	GridPathfinder* pathfinder = game->getGSM()->getSpriteManager()->getPathfinder();

	if (cyclesRemainingBeforeThinking == 0)
	{
		GameStateManager *gsm = game->getGSM();
		pickRandomCyclesInRange();
		if (currentState != L"STANDING")
		{
			if (getCurrentPathToFollow()->empty() == true)
			{
				pickRandomVelocity();
			}
		}

		if (player->getNumCollisions() >= TOTAL_COLLISION_TOLERANCE){
			if (customer->getIsFollowingPlayer() == false){
				//player->increaseNumFollowers();
				customer->setIsFollowingPlayer(true);
			}
			pathfinder->mapPath(customer, player->getX(), player->getY());
		}
		
		if (customer->getIsFollowingPlayer() == false){
			game->getGSM()->getSpriteManager()->shouldMobPlayer(customer);
		}

		if (customer->getIsFollowingPlayer() == true){

			if (customer->getCurrentPathToFollow()->empty() == true){
				pathfinder->mapPath(customer, player->getX(), player->getY());
			}
			else{
				pathfinder->updatePath(customer);
			}

		}
		else{
			if (getCurrentPathToFollow()->empty() == true)
			{
				pickRandomVelocity();
			}
		}
		pathfinder->updatePath(customer);
		
	}
	else{
		cyclesRemainingBeforeThinking--;
	}
	pathfinder->updatePath(customer);
	body->ApplyForceToCenter(velocity, true);
}
コード例 #2
0
/*
	This private constructor is only to be used for cloning bots, note
	that this does not setup the velocity for this bot.
*/
RandomJumpingBot::RandomJumpingBot(	unsigned int initMin, 
										unsigned int initMax, 
										unsigned int initMaxVelocity)
{
	// INIT THE BASIC STUFF
	initBot(initMin, initMax, initMaxVelocity);

	cyclesRemainingBeforeThinking = 30;
	body->SetTransform(*new b2Vec2(0,0),0);

	pickRandomCyclesInRange();
}
コード例 #3
0
/*
	This private constructor is only to be used for cloning bots, note
	that this does not setup the velocity for this bot.
*/
RandomJumpingBot::RandomJumpingBot(	unsigned int initMin, 
										unsigned int initMax, 
										unsigned int initMaxVelocity)
{
	// INIT THE BASIC STUFF
	initBot(initMin, initMax, initMaxVelocity);

	cyclesRemainingBeforeThinking = 30;
	pp.setVelocity(0.0f, 0.0f);

	pickRandomCyclesInRange();
}
コード例 #4
0
/*
	This is the public constructor used by other classes for 
	creating these types of bots.
*/
RandomFloatingBot::RandomFloatingBot(	Physics *physics,
										unsigned int initMin, 
										unsigned int initMax, 
										unsigned int initMaxVelocity)
{
	// INIT THE BASIC STUFF
	initBot(initMin, initMax, initMaxVelocity);

	// AND START THE BOT OFF IN A RANDOM DIRECTION AND VELOCITY
	// AND WITH RANDOM INTERVAL UNTIL IT THINKS AGAIN
	pickRandomVelocity(physics);
	pickRandomCyclesInRange();
}
コード例 #5
0
/*
	think - called once per frame, this is where the bot performs its
	decision-making. Note that we might not actually do any thinking each
	frame, depending on the value of cyclesRemainingBeforeThinking.
*/
void RandomFloatingBot::think(Game *game)
{
	// EACH FRAME WE'LL TEST THIS BOT TO SEE IF WE NEED
	// TO PICK A DIFFERENT DIRECTION TO FLOAT IN

	if (cyclesRemainingBeforeThinking == 0)
	{
		GameStateManager *gsm = game->getGSM();
		pickRandomVelocity(gsm->getPhysics());
		pickRandomCyclesInRange();
	}
	else
		cyclesRemainingBeforeThinking--;
}
コード例 #6
0
/*
	think - called once per frame, this is where the bot performs its
	decision-making. Note that we might not actually do any thinking each
	frame, depending on the value of cyclesRemainingBeforeThinking.
*/
void RandomWanderingBot::think(Game *game)
{
	// EACH FRAME WE'LL TEST THIS BOT TO SEE IF WE NEED
	// TO PICK A DIFFERENT DIRECTION TO FLOAT IN
	if (cyclesRemainingBeforeThinking == 0)
	{
		GameStateManager *gsm = game->getGSM();
		pickRandomCyclesInRange();
		if (currentState != L"STANDING"){	pickRandomVelocity(); }
	}
	else{
		cyclesRemainingBeforeThinking--;
	}
	body->ApplyForceToCenter(velocity, true);
}
コード例 #7
0
/*
	This is the public constructor used by other classes for 
	creating these types of bots.
*/
RandomJumpingBot::RandomJumpingBot(	Physics *physics,
										unsigned int initMin, 
										unsigned int initMax, 
										unsigned int initMaxVelocity)
{
	// INIT THE BASIC STUFF
	initBot(initMin, initMax, initMaxVelocity);

	// AND START THE BOT OFF IN A RANDOM DIRECTION AND VELOCITY
	// AND WITH RANDOM INTERVAL UNTIL IT THINKS AGAIN
	body->SetTransform(*new b2Vec2(0,0),0);

	//pickRandomJump(physics);
	pickRandomCyclesInRange();


}
コード例 #8
0
/*
	think - called once per frame, this is where the bot performs its
	decision-making. Note that we might not actually do any thinking each
	frame, depending on the value of cyclesRemainingBeforeThinking.
*/
void RandomJumpingBot::think(Game *game)
{
	// EACH FRAME WE'LL TEST THIS BOT TO SEE IF WE NEED
	// TO PICK A DIFFERENT DIRECTION TO FLOAT IN

	if (cyclesRemainingBeforeThinking == 0)
	{
		if (this->wasOnTileLastFrame())
		{
			GameStateManager *gsm = game->getGSM();
			pickRandomJump(gsm->getPhysics());
			pickRandomCyclesInRange();
		}
	}
	else
		cyclesRemainingBeforeThinking--;

	animationRandomizer--;
	if (animationRandomizer == 0)
	{
		animationCounter++;
		animationRandomizer = (rand() % 45) + 5;
	}
}