Beispiel #1
0
void Blob::update(){
	updatePassives();
	if(m_Health <= 0 && !ContainsFlags(m_UnitStatus,Dead)){
		die();
	}
	else if(!ContainsFlags(m_UnitStatus,Dead)){
		if(getTarget() && !ContainsFlags(m_UnitStatus,Consume)){
			if(m_Target->getHealth() <= 0){
				m_Target = NULL;
				stop();
			}
			else if(getTarget()->getCurrentTile() != getDestinationTile()){
				setDestinationTile(getTarget()->getCurrentTile());
			}
		}
		moveLerp();
		Enemy* enemy;
		if((enemy = BlobGame::instance()->enemyOnTile(getCurrentTile())) &&
			!ContainsFlags(m_UnitStatus,Consume) && 
			!ContainsFlags(enemy->getStatus(),Consumed)){
			m_Target = enemy;
			enemy->idle();
			enemy->fullStop();
			enemy->addStatus(Consumed);
			addPassive(&consume);
			addStatus(Consume);
			//MessageHandler::Instance()->createMessage
			//	(7,this,BlobGame::instance(),enemy,0);
		}
		updateAbilities();
	}
}
Beispiel #2
0
void Enemy::update(double delta)
{
    Player::update(delta);
    
    //Set the destination tile based on the player's current tile
    setDestinationTile(m_Level->getTileForPlayer(m_Level->getHero()));
}
Beispiel #3
0
void Enemy::reset()
{
    Player::reset();
    
    //Set the destination tile
    setDestinationTile(m_Level->getTileForPlayer(m_Level->getHero()));

}
Beispiel #4
0
void Hero::mouseLeftClickUpEvent(float positionX, float positionY)
{
    Tile* tile = m_Level->getTileForPosition(positionX, positionY);
    if(tile != NULL && tile->isWalkableTile() == true)
    {
        //set the destination tile
         setDestinationTile(tile);
        m_Level->setSelectedTileIndex(m_Level->getTileIndexForTile(tile));
    }
}
void Creep::update(double delta)
{
	//Update the player
	Player::update(delta);

	//Tell the creeps to attack the tower
	setDestinationTile(m_Level->getTileForPlayer(m_Level->getCastle()));

	//Update the animated texture
    m_BabyCreep->update(delta);
    
	//Get the pointer to tiles
    Tile* castleTile = m_Level->getTileForIndex(95);

	//Get the tile for the creep
    Tile* creepTile = m_Level->getTileForPlayer(this);
	
	//If a creep is on the castle tile
    if(castleTile == creepTile)
    {
		//Add a dead Creep
		m_CreepsDead += 1;

		//Subtract one from the castle health
		m_CastleHealth -= m_Damage *= m_CreepsDead;

		//Kill the creep
		setIsActive(false);
        
		//If the castle health reaches zero,
		if(m_CastleHealth == 0)
		{
			//take away one life
			m_RemainingLives -= 1;

			//If player has 3, 2, or 1 lives
			if(m_RemainingLives == 3 || 2 || 1)
			{
				//Reset the level
				m_Level->reset();
			}
			else
			{
				//You lose
				ScreenManager::getInstance()->switchScreen(YOU_LOSE_SCREEN_NAME);
			}
		}
	}
}
Beispiel #6
0
void PsiBlob::update(){
	if(m_Health <= 0 && !ContainsFlags(m_UnitStatus,Dead)){
		die();
	}
	else if(!ContainsFlags(m_UnitStatus,Dead)){
		if(getTarget()){
			if(m_Target->getHealth() <= 0){
				m_Target = NULL;
				stop();
			}
			else if(getTarget()->getCurrentTile() != getDestinationTile()){
				setDestinationTile(getTarget()->getCurrentTile());
			}
		}
		moveLerp();
		Enemy* enemy;
		if((enemy = BlobGame::instance()->enemyOnTile(getCurrentTile()))){
			enemy->hit(enemy->getHealth());
		}
		updateAbilities();
	}
}
void Creep::reset()
{
	Player::reset();
	setDestinationTile(m_Level->getTileForPlayer(m_Level->getCastle()));
}