void GeneticAlgorithmProfile1::RestoreState(cocos2d::Layer& _sc) { GameScene* gs = (GameScene*) & _sc; /////////////////////////////////////////////////////// //restore the gamestate gs->gameState = this->gamestateBK; gs->playerHandler->SetCurrency(this->currencyBK); gs->playerHandler->SetLifePoints(this->lifePointsBK); gs->playerHandler->SetPlayerName(this->playerNameBK); gs->creepDeploymentDelay = this->creepSpawnDelayBK; gs->nextWaveStartingDelay = this->nextWaveStartingDelayBK; /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// //restore the wave state this->speedMultiplier = this->speedMultiplierBK; this->hpMultiplier = this->hpMultiplierBK; this->numOfStartingCreeps = this->numOfStartingCreepsBK; this->numOfCreepsMultiplier = this->numOfCreepsMultiplierBK; this->numOfCreepsAddedPerWave = this->numOfCreepsAddedPerWaveBK; this->specialCreepSet = this->specialCreepSetBK; this->specialCreepSpeedMultiplier = this->specialCreepSpeedMultiplierBK; this->specialCreepHPMultiplier = this->specialCreepHPMultiplierBK; this->specialCreepSpawnFrequency = this->specialCreepSpawnFrequencyBK; this->roundsAfterSpawn = this->roundsAfterSpawnBK; this->multiplyCreepNumbersPerRound = this->multiplyCreepNumbersPerRoundBK; this->round = this->roundBK; /////////////////////////////////////////////////////// //remove speed boost of tower for ( std::list<Tower*>::iterator tower = gs->towerslist.begin(); tower != gs->towerslist.end(); ++tower ) { Tower* t = *tower; t->SetInbetweenAttacksPeriod(t->GetInbetweenAttacksPeriod() * speedBoost); } }
void GeneticAlgorithmProfile1::BackUpState(cocos2d::Layer& _sc) { GameScene* gs = (GameScene*) & _sc; /////////////////////////////////////////////////////// //backup everything related to the game state this->gamestateBK = gs->gameState; this->lifePointsBK = gs->playerHandler->GetLifePoints(); this->currencyBK = gs->playerHandler->GetCurrency(); this->playerNameBK = gs->playerHandler->GetPlayerName(); this->creepSpawnDelayBK = gs->creepDeploymentDelay; this->nextWaveStartingDelayBK = gs->nextWaveStartingDelay; /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// //backup everything related to the wave state this->speedMultiplierBK = this->speedMultiplier; this->hpMultiplierBK = this->hpMultiplier; this->numOfStartingCreepsBK = this->numOfStartingCreeps; this->numOfCreepsMultiplierBK = this->numOfCreepsMultiplier; this->numOfCreepsAddedPerWaveBK = this->numOfCreepsAddedPerWave; this->specialCreepSetBK = this->specialCreepSet; this->specialCreepSpeedMultiplierBK = this->specialCreepSpeedMultiplier; this->specialCreepHPMultiplierBK = this->specialCreepHPMultiplier; this->specialCreepSpawnFrequencyBK = this->specialCreepSpawnFrequency; this->roundsAfterSpawnBK = this->roundsAfterSpawn; this->multiplyCreepNumbersPerRoundBK = this->multiplyCreepNumbersPerRound; this->roundBK = this->round; /////////////////////////////////////////////////////// //apply speed boost to creeps spawn delay timer gs->creepDeploymentDelay = gs->creepDeploymentDelay / speedBoost; //apply speed boost to next wave starting delay timer gs->nextWaveStartingDelay = gs->nextWaveStartingDelay / speedBoost; //apply speed boost to tower for ( std::list<Tower*>::iterator tower = gs->towerslist.begin(); tower != gs->towerslist.end(); ++tower ) { Tower* t = *tower; t->SetInbetweenAttacksPeriod(t->GetInbetweenAttacksPeriod() / speedBoost); } }