CEgg.cpp 997 Bytes
Newer Older
Gerhard Stein's avatar
Gerhard Stein committed
1 2 3 4 5 6 7 8 9 10 11
/*
 * CEgg.cpp
 *
 *  Created on: 10.07.2012
 *      Author: gerstong
 */

#include "CEgg.h"
#include "engine/galaxy/ai/CPlayerLevel.h"
#include "engine/galaxy/ai/CBullet.h"

12 13 14 15 16 17 18 19
namespace galaxy
{


const int A_EGG_NORMAL = 0;
const int A_EGG_BROKEN = 1;
const int A_EGG_SHELL = 2;

Gerhard Stein's avatar
Gerhard Stein committed
20 21 22

CEgg::CEgg(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y)
23 24 25
{
	setupGalaxyObjectOnMap(0x2120, A_EGG_NORMAL);
}
Gerhard Stein's avatar
Gerhard Stein committed
26 27 28

void CEgg::hatch()
{
29 30
	setAction(A_EGG_BROKEN);
	setActionSprite();
Gerhard Stein's avatar
Gerhard Stein committed
31 32 33
}


34

Gerhard Stein's avatar
Gerhard Stein committed
35 36
void CEgg::getTouchedBy(CSpriteObject &theObject)
{
37
	if( !getActionNumber(A_EGG_NORMAL) || theObject.dead )
Gerhard Stein's avatar
Gerhard Stein committed
38 39 40 41 42 43 44 45 46 47
		return;

	if( CBullet *bullet = dynamic_cast<CBullet*>(&theObject) )
	{
		bullet->setAction(A_KEENSHOT_IMPACT);
		bullet->playSound( SOUND_SHOT_HIT );
		bullet->dead = true;
		hatch();
	}

48
	if( dynamic_cast<CPlayerBase*>(&theObject) )
Gerhard Stein's avatar
Gerhard Stein committed
49 50 51 52 53
	{
		hatch();
	}
}

54 55 56 57 58 59 60 61 62 63 64
void CEgg::process()
{

	processFalling();

	performCollisions();

	//processActionRoutine();

}

Gerhard Stein's avatar
Gerhard Stein committed
65
} /* namespace galaxy */