void Obstacle::onCollision(const float power)
{
	health-=power;

	if(health<=0)
	{
		onCollision();
		createBonus();
	}
}
Esempio n. 2
0
void BrickBonus::animationDestroy()
{
	if (_type == EWALL)
	{
		_sprite->stopActionByTag(BLINK_TAG);
		_sprite->setColor(_oldColor);
		changeTexture(EBACKGROUND);
		_type = EBONUS;
	}
	if (!createBonus())
	{	
		animateDestroyBonus();
	}
}
Esempio n. 3
0
void CArtHandler::giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, std::shared_ptr<IPropagator> propagator /*= nullptr*/, int additionalInfo)
{
	giveArtBonus(aid, createBonus(type, val, subtype, propagator, additionalInfo));
}
Esempio n. 4
0
void CArtHandler::giveArtBonus( ArtifactID aid, Bonus::BonusType type, int val, int subtype, Bonus::ValueType valType, std::shared_ptr<ILimiter> limiter, int additionalInfo)
{
	giveArtBonus(aid, createBonus(type, val, subtype, valType, limiter, additionalInfo));
}
Esempio n. 5
0
void Game::startGame(bool isStartingGame)
{
	gfx.pal.clear();
	
	if(isStartingGame)
	{
		if(settings.regenerateLevel
		|| settings.randomLevel != oldRandomLevel
		|| settings.levelFile != oldLevelFile)
		{
			generateLevel();
		}
	
		
		initGame();
		
		
		
		for(std::size_t i = 0; i < viewports.size(); ++i)
		{
			viewports[i]->x = 0;
			viewports[i]->y = 0;
		}

		selectWeapons();
		
		sfx.play(22, 22);

		cycles = 0;
		
		for(int w = 0; w < 40; ++w)
		{
			weapons[w].computedLoadingTime = (settings.loadingTime * weapons[w].loadingTime) / 100;
			if(weapons[w].computedLoadingTime == 0)
				weapons[w].computedLoadingTime = 1;
		}
	}
	
	int fadeAmount = isStartingGame ? 180 : 0;
	bool shutDown = false;
	
	do
	{
		++cycles;
		
		if(!H[HBonusDisable]
		&& settings.maxBonuses > 0
		&& rand(C[BonusDropChance]) == 0)
		{
			createBonus();
		}
			
		for(std::size_t i = 0; i < worms.size(); ++i)
		{
			worms[i]->process();
		}
		
		for(std::size_t i = 0; i < worms.size(); ++i)
		{
			worms[i]->ninjarope.process(*worms[i]);
		}
		
		switch(game.settings.gameMode)
		{
		case Settings::GMGameOfTag:
		{
			bool someInvisible = false;
			for(std::size_t i = 0; i < worms.size(); ++i)
			{
				if(!worms[i]->visible)
				{
					someInvisible = true;
					break;
				}
			}
			
			if(!someInvisible
			&& lastKilled
			&& (cycles % 70) == 0
			&& lastKilled->timer < settings.timeToLose)
			{
				++lastKilled->timer;
			}
		}
		break;
		}
		
		processViewports();
		drawViewports();
				
		for(BonusList::iterator i = bonuses.begin(); i != bonuses.end(); ++i)
		{
			i->process();
		}
		
		if((cycles & 1) == 0)
		{
			for(std::size_t i = 0; i < viewports.size(); ++i)
			{
				Viewport& v = *viewports[i];
				
				bool down = false;
				
				if(v.worm->killedTimer > 16)
					down = true;
					
				if(down)
				{
					if(v.bannerY < 2)
						++v.bannerY;
				}
				else
				{
					if(v.bannerY > -8)
						--v.bannerY;
				}
			}
		}
		
		for(SObjectList::iterator i = game.sobjects.begin(); i != game.sobjects.end(); ++i)
		{
			i->process();
		}
		
		// TODO: Check processing order of bonuses, wobjects etc.
		
		for(WObjectList::iterator i = wobjects.begin(); i != wobjects.end(); ++i)
		{
			i->process();
		}
		
		for(NObjectList::iterator i = nobjects.begin(); i != nobjects.end(); ++i)
		{
			i->process();
		}
		
		for(BObjectList::iterator i = bobjects.begin(); i != bobjects.end(); ++i)
		{
			i->process();
		}
		
		if((cycles & 3) == 0)
		{
			for(int w = 0; w < 4; ++w)
			{
				gfx.origpal.rotate(gfx.colourAnim[w].from, gfx.colourAnim[w].to);
			}
		}
		
		gfx.pal = gfx.origpal;
		
		if(fadeAmount <= 32)
			gfx.pal.fade(fadeAmount);

		if(gfx.screenFlash > 0)
		{
			gfx.pal.lightUp(gfx.screenFlash);
		}
		
		gfx.flip();
		gfx.process();
		
		if(gfx.screenFlash > 0)
			--gfx.screenFlash;
		
		if(isGameOver())
		{
			gfx.firstMenuItem = 1;
			shutDown = true;
		}
		
		for(std::size_t i = 0; i < viewports.size(); ++i)
		{
			if(viewports[i]->shake > 0)
				viewports[i]->shake -= 4000; // TODO: Read 4000 from exe?
		}

		if(gfx.testSDLKeyOnce(SDLK_ESCAPE)
		&& !shutDown)
		{
			gfx.firstMenuItem = 0;
			fadeAmount = 31;
			shutDown = true;
		}

		if(shutDown)
		{
			fadeAmount -= 1;
		}
		else if(!isStartingGame)
		{
			if(fadeAmount < 33)
			{
				fadeAmount += 1;
				if(fadeAmount >= 33)
					fadeAmount = 180;
			}
		}
	}
	while(fadeAmount > 0);
	
	gfx.clearKeys();
}