Esempio n. 1
0
/*!\func
 *
 * \param
 * \return
 */
INode* GraphBody::getParentNode()
{
	LOG(LOG_DEBUG, QString(__FUNCTION__) + " <" + QString::number(__LINE__) + ">");
	while(node->getParent())
		levelUp();
	return node;
}
Esempio n. 2
0
void Champion::update(int64 diff) {
   Unit::update(diff);
   
   if(respawnTimer > 0) {
      respawnTimer -= diff;
      if(respawnTimer <= 0) {
         setPosition(map->getRespawnLoc(side).getX(), map->getRespawnLoc(side).getY());
         map->getGame()->notifyChampionRespawn(this);
         getStats().setCurrentHealth(getStats().getMaxHealth());
         getStats().setCurrentMana(getStats().getMaxMana());
         deathFlag = false;
      }
   }
   
   bool levelup = false;
   
   while(getStats().getLevel() < map->getExpToLevelUp().size() && getStats().getExp() >= map->getExpToLevelUp()[getStats().getLevel()]) {
      levelUp();
      levelup = true;
   }
   
   if(levelup) {
      map->getGame()->notifyLevelUp(this);
   }
   
   for(Spell* s : spells) {
      s->update(diff);
   }

   
}
Esempio n. 3
0
void Enemy::addExp(int exp){
	this->exp += exp;
	if (this->exp >= ((level * 10) + 10)){
		levelUp();
		this->exp = 0;
	}
}
Esempio n. 4
0
void Hero::addExp(int x)
{
	experience += x;

	if (experience >= requiredXp)
		levelUp();
}
Esempio n. 5
0
void findFoes(const PUnit* a, PCommand &cmd) //单位a寻找对手
{
    if ((*a)["Exp"]->val[3]) //优先升级技能
    {
        levelUp(a, cmd);
    } else
    {
        if (fixPos[a->id] == EMPTYPOS)
        {
            vector<Pos> atk_tar;
            atk_tar.clear();
            getFoes(atk_tar, a->level > HIGHLEVEL ? HIGHLEVEL : 0, a->level); //策略:达到一定强度开始攻击防御塔
            if (atk_tar.size()) //寻找固定点的弱小对手
            {
                fixPos[a->id] = atk_tar[rand()%atk_tar.size()]; //锁定目标
            } else
            {
                fixPos[a->id] = DEFAULFPOS;
            }
        }
        Operation op;
        op.id = a->id;
        op.type = "Move";
        findShortestPath(*MAP, a->pos, fixPos[a->id], blocks, op.targets); //向弱小对手移动
        cmd.cmds.push_back(op);
    }
}
Esempio n. 6
0
void Player::addExp(float exp)
{
	m_exp += exp;
	while (m_exp >= m_levelThreshold)
	{
		levelUp();
	}
}
void AManaJourneyCharacter::gainExp(float gainedExp)
{
	currentExp = currentExp + gainedExp;
	if (currentExp >= nextExp)
	{
		currentExp = 0.0f;
		levelUp();
	}
}
Esempio n. 8
0
void Player::setExp(float exp)
{
	m_exp = exp;
	//TODO: Fix: If Threshold 0 or not set yet, while will never end
	while (m_exp >= m_levelThreshold)
	{
		levelUp();
	}
}
Esempio n. 9
0
void
Player::gainExp(int amount) {
    m_exp += amount;
    if(m_hd<20) {
        while(m_exp >= m_expForNextLevel) {
            levelUp();
        }
    }
}
void player::setExperience(int input)
{
    experience=input;
    if (experience > xpToLevel)
    {
        levelUp();
    }
    return;
}
Esempio n. 11
0
/***********************************************************************
     * Character
     * gainXP

***********************************************************************/
void fired::Character::gainXP(long xp) {
	char exp[64];
	xp *= (stats.xpfactor + 1.0f);
	snprintf(exp, sizeof(exp), "+%lu XP", xp);

	XP += xp;
	world->addText(phys.pos, sf::Color(0, 255, 0, 255), 16, exp);
	if (XP >= needXP) levelUp();
}
Esempio n. 12
0
void House::timeStep(const unsigned long time)
{
   // _goodStockList[G_WHEAT]._currentQty -= _d->currentHabitants;  // to do once every month!
   if( time % 16 == 0 )
   {
      // consume services
      for (int i = 0; i < S_MAX; ++i)
      {
         ServiceType service = (ServiceType) i;
         _d->serviceAccessMap[service] = std::max(_d->serviceAccessMap[service] - 1, 0);
      }

      cancelService( S_WORKERS_HUNTER );

      // consume goods
      for (int i = 0; i < G_MAX; ++i)
      {
         GoodType goodType = (GoodType) i;
         int qty = std::max(_d->goodStore.getCurrentQty(goodType) - 1, 0);
         _d->goodStore.setCurrentQty(goodType, qty);
      }
   }

   if( time % 64 == 0 )
   {
     bool validate = _d->houseLevelSpec.checkHouse(*this);
     if (!validate)
     {
       levelDown();
     }
     else
     {
       validate = _d->nextHouseLevelSpec.checkHouse(*this);
       if( validate && _d->currentHabitants > 0 )
       {
          levelUp();
       }
     }

     int homeless = math::clamp( _d->currentHabitants - _d->maxHabitants, 0, 0xff );

     if( homeless > 0 )
     {
       _d->currentHabitants = math::clamp( _d->currentHabitants, 0, _d->maxHabitants );

       CityPtr city = Scenario::instance().getCity();
       ImmigrantPtr im = Immigrant::create( city );
       im->setCapacity( homeless );
       im->send2City( getTile() );
     }
   }

   if( _d->currentHabitants > 0 )
   {
     Building::timeStep( time );
   }
}
Esempio n. 13
0
void House::timeStep(const unsigned long time)
{
   if( _d->currentHabitants > 0 )
   {
     if( time % 16 == 0 )
     {
        // consume services
        for (int i = 0; i < Service::S_MAX; ++i)
        {
           Service::Type service = (Service::Type) i;
           _d->serviceAccess[service] = std::max(_d->serviceAccess[service] - 1, 0);
        }

        cancelService( Service::S_WORKERS_HUNTER );
        _d->updateHealthLevel();

        // consume goods
        for (int i = 0; i < Good::goodCount; ++i)
        {
           Good::Type goodType = (Good::Type) i;
           _d->goodStore.setCurrentQty( goodType, std::max( _d->goodStore.getCurrentQty(goodType) - 1, 0) );
        }
     }

     if( time % 64 == 0 )
     {
       bool validate = _d->houseLevelSpec.checkHouse( this );
       if (!validate)
       {
         levelDown();
       }
       else
       {
         _d->condition4Up = "";
         validate = _d->nextHouseLevelSpec.checkHouse( this, &_d->condition4Up );
         if( validate && _d->currentHabitants > 0 )
         {
            levelUp();
         }
       }

       int homeless = math::clamp( _d->currentHabitants - _d->maxHabitants, 0, 0xff );

       if( homeless > 0 )
       {
         _d->currentHabitants = math::clamp( _d->currentHabitants, 0, _d->maxHabitants );

         ImmigrantPtr im = Immigrant::create( _getCity() );
         im->setCapacity( homeless );
         im->send2City( getTile() );
       }
     }

     Building::timeStep( time );
   }
}
Esempio n. 14
0
void CPlayer::addXP(unsigned int xp)
{
	m_xp += xp;
	while(m_xpMax < m_xp)	//取得經驗後 可升級
	{		
		m_xp -= m_xpMax;
		//升級function
		levelUp();
	}
   notifyPlayerAttrUpdate(xp, 0);
}
Esempio n. 15
0
void Hero::calculateLevel()
{
	int l{ level };

	const double CONSTANT{ 0.11 };
	level = static_cast<int>(floor(CONSTANT * sqrt(experience)));

	if (l < level)
	{
		levelUp();
	}
}
void CharacterAssistant::addXP(int xpNew, int xpTotal, int level, Character* current)
{
    xpTotal=xpTotal+xpNew;
    cout<<"xp: "<<xpTotal<<endl;
    if((xpTotal>300 && level==1)||(xpTotal>900 && level==2)||(xpTotal>2700 && level==3)||(xpTotal>6500 && level==4)||(xpTotal>14000 && level==5)
       ||(xpTotal>23000 && level==6)||(xpTotal>34000 && level==7)||(xpTotal>48000 && level==8)||(xpTotal>64000 && level==9)||(xpTotal>85000 && level==10)
       ||(xpTotal>100000 && level==11)||(xpTotal>120000 && level==12)||(xpTotal>140000 && level==13)||(xpTotal>165000 && level==14)||(xpTotal>195000 && level==15)
       ||(xpTotal>225000 && level==16)||(xpTotal>265000 && level==17)||(xpTotal>305000 && level==18)||(xpTotal>355000 && level==19))
    {
        levelUp(current);
    }
}
Esempio n. 17
0
	int ICharacter::checkLevelUp(int exp) 		//Checks to see if a character's exp passed the level up threshold
	{			
		int currentExp = this -> exp,
			level = this -> level, 
			nextLevelEXP;

		if(currentExp >= (nextLevelEXP = (level * (level + 1) * 500)))
		{				
			levelUp();

			return checkLevelUp(currentExp - nextLevelEXP);
		}

		return currentExp;
	}
Esempio n. 18
0
void Game::update(double aDelta)
{
	//If the game is over, paused, or the title screen is showing
	if(m_Pause || m_GameOver || m_ShowTitle)
	{
		// Stops updating the game.
		return;
	}

	// Use an integer to keep track of the number of active Brick objects
	int bricksLeft = 0;

	//Cycle through all the game objects
	for(int i = 0; i < m_GameObjects.size(); i++)
	{
		//Make sure the GameObject is active
		if(m_GameObjects.at(i)->getIsActive() == true)
		{
			//Update the GameObject
			m_GameObjects.at(i)->update(aDelta);

			Ball* ball = (Ball*)getGameObjectByType(GAME_BALL_TYPE);
			if(ball->getIsActive())
			{
				ball->checkCollision(m_GameObjects.at(i));
			}

			// Increment the brick counter
			if(m_GameObjects.at(i)->getType() == GAME_BRICK_TYPE)	
			{
				bricksLeft++;
			}
		}
	}
	

	// Once no bricks are left (all inactive)
	if(bricksLeft == 0)
	{
		// Call the levelUp function
		levelUp();
	}
}
Esempio n. 19
0
void CGHeroInstance::levelUpAutomatically()
{
	while(gainsLevel())
	{
		const auto primarySkill = nextPrimarySkill();
		setPrimarySkill(primarySkill, 1, false);

		auto proposedSecondarySkills = getLevelUpProposedSecondarySkills();

		const auto secondarySkill = nextSecondarySkill();
		if(secondarySkill)
		{
			setSecSkillLevel(*secondarySkill, 1, false);
		}

		//TODO why has the secondary skills to be passed to the method?
		levelUp(proposedSecondarySkills);
	}
}
void Monster::killedEnemy(const Monster *enemy) {

    hpEv = enemy->baseHpEv;
    atkEv = enemy->baseAtkEv;
    defEv = enemy->baseDefEv;
    satkEv = enemy->baseSatkEv;
    sdefEv = enemy->baseSdefEv;
    speEv = enemy->baseSpeEv;
    int expShare = 1;
    int expPointPower = 1;
    int gainedExp = ( ( enemy->wild * enemy->speciesExp * enemy->level ) / ( expShare * 5 ) * pow(2 * enemy->level + 10,2.5) / pow(enemy->level + level + 10, 2.5) + 1 ) * trainer * enemy->luckyEgg * expPointPower;
    if ( gainedExp + exp < pow(level+1,3)) {
        exp += gainedExp;
    } else {
        exp += gainedExp;
        levelUp();
    }

}
Esempio n. 21
0
void Game::update(void)
{
	if(dots > 0) {
		pacman->update(gameboard);
		int x = pacman->getX();
		int y = pacman->getY();
		switch (gameboard[y][x]) {
			case 'u':
				superPacman();
				score++;
			case 'd':
				score++;
				dots--;
				gameboard[y][x] = '0';
				break;
		}
		boolean hit = false;
		switch (level)
		{
			case 4:
				hit = ambusher->update(x, y, gameboard) || hit;
			case 3:
				hit = chaser->update(x, y, gameboard) || hit;
			case 2:
				hit = fickle->update(x, y, gameboard) || hit;
			case 1:
				hit = stupid->update(x, y, gameboard) || hit;
		}
		if(hit) {
			score -= 30;
			pacman->die();
		}
	} else {
		levelUp();
	}
}
Esempio n. 22
0
 bool Entity::checkForNewLevel(void)
 {
     if (xp >= max_xp)
         levelUp();
 }
Esempio n. 23
0
 void Entity::gainXp(void)
 {
     xp++;
     if (checkForNewLevel()) levelUp();
 }
void AdvancedCharacter::increaseXp(int xp){
	this->xp += xp;
	if (this->xp >= (((((level + 1)*((level + 1) + 1)) / 2)*14.4) + ((level + 1)*57.6)) - 72)
		levelUp();
}
Esempio n. 25
0
void doBattle() {
    int round = 1;
    int nme_idx;
    int gold_amt = 0;
    int expGiven = 0;
    int key;
    int damage = 0;
    int canFlee = 0;
    bool didFlee = FALSE;
    ENEMY the_enemy;

    /* Pick an enemy randomly from the list */
    nme_idx = rollDie(0,MAX_ENEMIES);
    if (nme_idx == MAX_ENEMIES) nme_idx = MAX_ENEMIES - 1;

    /*
        Keep a temporary copy so we can kill
        it without hurting the prototypes
    */
    the_enemy = enemies[nme_idx];

    /*
        If the enemy has an e_weapon of -1
        we give them one randomly
    */
    if (the_enemy.e_weapon == -1) {
        nme_idx = rollDie(0,MAX_WEAPONS);
        if (nme_idx == MAX_WEAPONS) nme_idx = MAX_WEAPONS - 1;
        the_enemy.e_weapon = nme_idx;
    }

    /* Calculate victory condition values */
    expGiven = rollDie(1,the_enemy.exp);
    if (the_enemy.max_gold != 0) gold_amt = rollDie(1,the_enemy.max_gold);

    while (the_enemy.hp > 0 && player.is_dead == FALSE && player.hp > 0 && didFlee == FALSE) {
        flushinp();
        battleStats(the_enemy,round);

        wattrset(win,A_BOLD);
        mvwprintw(win,7,12,"[A]ttack");
        mvwprintw(win,8,12,"[F]lee");
        wattrset(win,A_NORMAL);

        noecho();
        keypad(win, TRUE);
        raw();

        key = wgetch(win);
        flushinp();

        switch(key) {
            case 'F':
            case 'f':
                canFlee = rollDie(1,6) + rollDie(1,6) + rollDie(1,6);
                if (player.agi > canFlee) {
                    battleStats(the_enemy,round);
                    mvwprintw(win,10,3,"%s flees from the battle!",player.player_name);
                    wrefresh(win);
                    napms(500);
                    didFlee = TRUE;
                    walk_counter = 0;
                } else {
                    battleStats(the_enemy,round);
                    mvwprintw(win,10,3,"%s attempts to flee but fails!",player.player_name);
                    wrefresh(win);
                    napms(1000);
                    enemyAttack(the_enemy,round);
                    round++;
                }
                break;
            case 'A':
            case 'a':
                //keypad(win,FALSE);
                battleStats(the_enemy,round);
                mvwprintw(win,10,3,"%s attacks the %s...",player.player_name,the_enemy.enemy_name,weapons[player.weapon].weapon_name);
                //napms(750);
                if (playerDidHit(the_enemy) == TRUE) {
                    damage = (player.str + weapons[player.weapon].basehit + player.attack_bonus + rollDie(1,weapons[player.weapon].base_str)) - (the_enemy.def + the_enemy.armor);
                    if (damage <= 0) {
                        mvwprintw(win,11,5,"...%s's strike glances off the %s!",player.player_name,the_enemy.enemy_name);
                    } else {
                        mvwprintw(win,11,5,"...%s hits the %s for %i damage!",player.player_name,the_enemy.enemy_name,damage);
                        the_enemy.hp -= damage;
                    }
                } else {
                    mvwprintw(win,11,5,"...%s misses!",player.player_name);
                }
                wrefresh(win);
                napms(750);
                if (the_enemy.hp > 0) {
                    enemyAttack(the_enemy,round);
                    round++;
                }
                break;
            default:
                wattrset(win,A_REVERSE);
                mvwprintw(win,10,10,"Invalid Option. Try again.");
                wattrset(win,A_NORMAL);
                wrefresh(win);
                napms(500);
                break;
        }
        if (player.hp < 0) player.hp = 0;
        if (player.hp == 0) player.is_dead = TRUE;
        drawStatsArea();
    }

    flushinp();
    if (player.is_dead == TRUE) {
        wbkgd(win,COLOR_PAIR(4) | A_DIM);
        wclear(win);
        box(win,ACS_VLINE,ACS_HLINE);
        mvwprintw(win,10,20,"Thou art dead!");
        mvwprintw(win,12,20,"Press any key...");
        wrefresh(win);
        wgetch(win);
        game_state = GAME_DONE;
    } else if (didFlee == FALSE) {
        //wclear(encounterwin);
        if (player.gold + gold_amt >= INT_MAX) player.gold = INT_MAX; else player.gold += gold_amt;
        player.slain++;
        walk_counter = 0;
        wbkgd(win,COLOR_PAIR(1) | A_DIM);
        wclear(win);
        box(win,ACS_VLINE,ACS_HLINE);

        mvwprintw(win,3,10,"Victory!");
        mvwprintw(win,5,5,"%s hast slain the %s!",player.player_name,the_enemy.enemy_name);
        mvwprintw(win,6,5,"%s found %i gold on the %s",player.player_name,gold_amt,the_enemy.enemy_name);
        if (expGiven > 0)
            mvwprintw(win,7,5,"%s gained %i XP from the battle",player.player_name,expGiven);

        if (levelUp(expGiven) == 1) {
            wattrset(win,A_BOLD);
            mvwprintw(win, 9, 5,"%s has gained a level!",player.player_name);
            wattrset(win,A_NORMAL);
        }
        wattrset(win,A_REVERSE);
        mvwprintw(win,13,10,"Press any key to continue thine journey...");
        wattrset(win,A_NORMAL);
        wrefresh(win);
        drawStatsArea();
        wgetch(win);
    }
}
Esempio n. 26
0
void Knight::EXP(int aEXP) {
    this->experience += aEXP;
    if (this->experience >= this->needExperienceToNextLevel) {
        levelUp();
    }
}
void battle(){
  int roomXp = DRoom -> roomXp;
  if(Enemy->hp <= 0){
    printf("There is no monster in this room\n");
    sleep(1);
  }
  else{
    int dmg;
    if(Player->spd >= Enemy->spd){
      dmg = rand_lim(Player->atk) + Player->atk - Enemy->def;
      if(dmg < 0)
	dmg = 0;
      printf("You dealt %d damage to the %s\n", dmg,Enemy->name);
      Enemy->hp = Enemy->hp - dmg;
      sleep(1);
      if(Enemy->hp > 0){
	dmg = rand_lim(Enemy->atk) + Enemy->atk - Player->def;
	if(dmg < 0)
	  dmg = 0;
	printf("The %s dealt %d damage to you\n", Enemy->name, dmg);
	sleep(1);
	Player->hp = Player->hp - dmg;
      }
      else{
	printf("The %s died!\n", Enemy->name);
	sleep(1);
	DRoom -> roomClear = 1;
	pickUpLoot();
	Player->xp = Player->xp + roomXp;
	while(Player->xp >= Player->xpOffset){
	  levelUp();
	}
      }
    }
    else{
      dmg = rand_lim(Enemy->atk) + Enemy->atk - Player->def;
      if(dmg < 0)
	dmg = 0;
      printf("The %s dealt %d damage to you\n", Enemy->name, dmg);
      Player->hp = Player->hp - dmg;
      sleep(1);
      if(Player->hp > 0){
	dmg = rand_lim(Player->atk) + Player->atk - Enemy->def;
	if(dmg < 0)
	  dmg = 0;
	printf("You dealt %d damage to the %s\n", dmg, Enemy->name);
	sleep(1);
	Enemy->hp = Enemy->hp - dmg;
	if(Enemy->hp <= 0){
	  printf("The %s  died!\n", Enemy->name);
	  sleep(1);
	  DRoom -> roomClear = 1;
	  pickUpLoot();
	  Player->xp = Player->xp + roomXp;
	  while(Player->xp >= Player->xpOffset){
	    levelUp();
	  }
	}
      }
    }
  }
}
Esempio n. 28
0
bool UserCharacter::handleMessage(const Telegram& msg)
{
	int damage = 0;
	//first see if the current goal accepts the message
	if (getBrain()->handleMessage(msg)) return true;

	//handle any messages not handles by the goals
	switch (msg.msg)
	{
	case MSG_GET_DAMAGED:

		if(isAlive())
		{
			damage = dereferenceToType<int>(msg.extra_info);

			//the extra info field of the telegram carries the amount of damage
		
			// 아직 유저가 죽는것 안함.
			reduceHealth(dereferenceToType<int>(msg.extra_info));

			AbstCharacter* attacker =
				(AbstCharacter*)EntityMgr.getEntityFromID(msg.sender);
			getSensoryMemory()->updateWithDamageSource(attacker, damage);

			//if this bot is now dead let the shooter know
			if (!isAlive())
			{
				int gold_worth = getGoldWorth();
				Dispatcher.dispatchMsg(
					SEND_MSG_IMMEDIATELY,
					getId(),
					msg.sender,
					MSG_GIVE_GOLD,
					(void*)&gold_worth);  // 내 가치를 죽인애한테 gold로 준다.

				Dispatcher.dispatchMsg(
					SEND_MSG_IMMEDIATELY,
					getId(),
					msg.sender,
					MSG_YOU_GOT_ME,
					NULL);  // 내 가치를 죽인애한테 gold로 준다.

				for (auto iter = std::begin(_game_world->getUserCharacters());
					iter != std::end(_game_world->getUserCharacters());
					iter++)
				{
					if (getTeam() != iter->second->getTeam())
					{
						//int damage = _owner_skill->getDamage() + _shooter->getMDamage();
						int exp = getExpWorth();
						//send a message to the bot to let it know it's been hit, and who the
						//shot came from.
						Dispatcher.dispatchMsg(
							SEND_MSG_IMMEDIATELY,
							getId(),
							iter->second->getId(),
							MSG_GIVE_EXP,
							(void*)&exp);
					}
				}
			}
			// hit animation
			float noise_x = util::genRand(0, 30) - 15;
			float noise_y = util::genRand(0, 30) - 15;
			_game_world->getAnimationQ()
				.push(std::make_tuple("damage", _pos.x + noise_x, _pos.y + noise_y));
		}

		return true;

	case MSG_GIVE_GOLD:

		setGold(getGold() + dereferenceToType<int>(msg.extra_info));

		return true;

	case MSG_GIVE_EXP:

		setExp(getExp() + dereferenceToType<int>(msg.extra_info));
		if (getExp() >= _level_up_need_exp)  // level up
		{
			setLevel(getLevel() + 1);
			setExp(getExp() - _level_up_need_exp);
			levelUp();
		}

		return true;

	case MSG_YOU_GOT_ME:  // 내가 누굴 죽였다고 메시지를 받음

		setScore(getScore() + 1);

		//the bot this bot has just killed should be removed as the target
		_target_system->clearTarget();

		return true;

	case MSG_GUN_SHOT_SOUND:

		//add the source of this sound to the bot's percepts
		getSensoryMemory()->updateWithSoundSource((AbstCharacter*)msg.extra_info);

		return true;

	case MSG_USER_HAS_REMOVED_BOT:
	{

		AbstCharacter* pRemovedBot = (AbstCharacter*)msg.extra_info;

		getSensoryMemory()->removeBotFromMemory(pRemovedBot);

		//if the removed bot is the target, make sure the target is cleared
		if (pRemovedBot == getTargetSys()->getTarget())
		{
			getTargetSys()->clearTarget();
		}

		return true;
	}
	case MSG_GAME_OVER:
		GameServerManager::getInstance().sendAll(
			PacketFactory::getInstance().createPacketGameOver(_client_name, _team));
		return true;


	default: return false;
	}
}
Esempio n. 29
0
int main()
{
    srand (time (0));
    sf::RenderWindow window (sf::VideoMode(480*0.5, 800*0.5), "Fighters");
    window.setFramerateLimit(60);

    PASS = 1;

    Things::load ();
    Sound::load ();
    Text::load ();

    Sky sky;
    Hero hero;
    Sound::GAME_MUSIC.play ();

    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear( sf::Color::Black );

        int test = 0;
        if ( hero.getRed() < -1 )
            test = 1;
        switch ( test )
        {
            case 1:
                sky.gameover ( window );
                Sound::GAME_MUSIC.play ();
                break;
            case 0:
                if ( hero.getRed() > 0 )
                {
                    Game ( hero );
                    if ( timeNow > TIME-PASS*10 )
                    {
                        timeNow = 0;
                        sky.addEnemy ( enemy, PASS);
                    }
                    timeNow++;
                    gapNow++;
                    sky.heroGunRunInto ( hero, enemy );
                }
                hero.gunMove ();
                sky.draw ( window, hero );
                drawEnemy ( window );
                break;
        }
        levelUp ();
        Text::outText ( window, hero.getRed(), PASS );

        // end the current frame
        window.display();
    }

    return 0;
}
Esempio n. 30
0
void Unit::redeemEXP()
{
	auto restEXP = levelUp();

	if(restEXP < getEXP()) setEXP(restEXP);
}