示例#1
0
void NewGameState::onBeginGameButtonClick(std::shared_ptr<MouseEvent> event)
{
    auto player = _characters.at(_selectedCharacter);
    player->setHitPoints(player->hitPointsMax());
    Game::getInstance()->setPlayer(player);
    Game::getInstance()->setState(new LocationState());
}
示例#2
0
 worldContainer::worldContainer(coord Location, coord Goal, double Charge, double Base, double HitPoints)
 {
    setLocation(Location);
    setGoal(Goal);
    setCharge(Charge);
    setBase(Base);
    setHitPoints(HitPoints);
 }
示例#3
0
 worldContainer::worldContainer()
 {
    coord temp;
    temp.x = 0;
    temp.y = 0;
    temp.z = 0;
    setLocation(temp);
    setGoal(temp);
    
    setHitPoints(0);
    setCharge(0);
    setBase(0);
 }
示例#4
0
void Character::modifyHitPoints(int modifier)
{
  int toSet = getHitPoints() + modifier;
  if ( toSet > getMaxHitPoints() )
  {
    toSet = getMaxHitPoints();
  }
  else if ( toSet < 0 )
  {
    toSet = 0;
  }

  setHitPoints( toSet );
}
示例#5
0
void Vine::init(float px, float py, AnimatedSpriteType *sprite){
	setHitPoints(1);
	setDamage(VINE_DAMAGE);
	setSpriteType(sprite);
	setAlpha(255);
	setCurrentState(IDLE_LEFT);
	pp.setX(px);
	pp.setY(py);
	pp.setVelocity(0.0f, 0.0f);
	pp.setAccelerationX(0);
	pp.setAccelerationY(0);
	setOnTileThisFrame(false);
	setOnTileLastFrame(false);
	affixTightAABBBoundingVolume();
}
示例#6
0
void Bubble::init(float px, float py, AnimatedSpriteType *sprite){
	setHitPoints(1);
	setDamage(SEED_DAMAGE);
	setSpriteType(sprite);
	setAlpha(255);
	setCurrentState(IDLE_LEFT);
	PhysicalProperties *fireballProps = getPhysicalProperties();
	pp.setX(px);
	pp.setY(py);
	pp.setVelocity(0.0f, 0.0f);
	pp.setAccelerationX(0);
	pp.setAccelerationY(0);
	setOnTileThisFrame(false);
	setOnTileLastFrame(false);
	affixTightAABBBoundingVolume();
}
示例#7
0
void Player::doSomething()
{
	if (!(getKeepable())) return; //dead, so return
	int ch;
	bool shoot = false;
	if (getWorld()->getKey(ch)) // key pressed
	{
		switch (ch)
		{
		case KEY_PRESS_ESCAPE:
		{
			setHitPoints(0);
			return;
			break;
		}
		case KEY_PRESS_SPACE:
		{
			shoot = true;
			break;
		}
		//move keys determine player's direction
		case KEY_PRESS_LEFT:
		{
			setDirection(GraphObject::left);
			break;
		}
		case KEY_PRESS_RIGHT:
		{
			setDirection(GraphObject::right);
			break;
		}
		case KEY_PRESS_DOWN:
		{
			setDirection(GraphObject::down);
			break;
		}
		case KEY_PRESS_UP:
		{
			setDirection(GraphObject::up);
			break;
		}
		}

		
		int newLocX = getX(), newLocY = getY();
		getWorld()->determineNext(newLocX, newLocY, getDirection()); //find next location in that direction

		if (shoot) //place bullet in that location
		{
			if (ammo <= 0) return;
			getWorld()->addActor(new Bullet(IID_BULLET, newLocX, newLocY, getWorld(), getDirection()));
			getWorld()->playSound(SOUND_PLAYER_FIRE);
			ammo--;
			return;
		}

		//otherwise is players next location
		int adjLocX = newLocX, adjLocY = newLocY;
		getWorld()->determineNext(adjLocX, adjLocY, getDirection()); //find location adjacent to next location, in current direction

		std::list<Actor*> occs = getWorld()->getOccupants(newLocX, newLocY);
		std::list<Actor*>::iterator it = occs.begin();
		Actor* actp;
		while (it != occs.end()) //loop through actors in pending spot
		{
			actp = *it; //derefence iterator
			if (actp != nullptr) //can cast if not null
			{
				Boulder* bp = dynamic_cast<Boulder*>(actp); //check for Boulder
				if (bp != nullptr) //is a boulder
				{
					bp->getsPushedTo(adjLocX, adjLocY); //have boulder determine if movable
				}
			}
			it++; //go to next actor
		}
		if (getWorld()->isWalkableLoc(newLocX, newLocY)) moveTo(newLocX, newLocY);
	}
}
示例#8
0
	/**
	 * Add (or subtract) object's hit points.
	 *
	 * @param change Hit points change.
	 */
	void addHitPoints(int change) {
		setHitPoints(getHitPoints() + change);
	}
示例#9
0
文件: Enemy.cpp 项目: Faianca/hikari
 void Enemy::takeDamage(float amount) {
     setHitPoints(getHitPoints() - amount);
     damageTickCounter = 1;
 }
示例#10
0
void PlayerCreateState::onDoneButtonClick(MouseEvent* event)
{
    auto player = Game::getInstance()->player();
    player->setHitPoints(player->hitPointsMax());
    Game::getInstance()->setState(new LocationState());
}