CSpecialItem.cpp 1.47 KB
Newer Older
1
#include "CSpecialItem.h"
Gerhard Stein's avatar
Gerhard Stein committed
2
#include "../../common/ai/CPlayerBase.h"
Gerhard Stein's avatar
Gerhard Stein committed
3
#include "../../common/dialog/CMessageBoxBitmapGalaxy.h"
4 5 6 7 8

namespace galaxy 
{
    
CSpecialItem::CSpecialItem(CMap* pmap, const Uint16 foeID, Uint32 x, Uint32 y, const int actionoffset) : 
Gerhard Stein's avatar
Gerhard Stein committed
9
CGalaxySpriteObject(pmap, foeID, x, y, 0),
10
mTaken(false)
11 12
{
	setupGalaxyObjectOnMap(actionoffset, 0);
13 14 15
		
	answermap[0] = "KEEN_GOT_GRAPPLING_HOOK";	
	answermap[1] = "KEEN_GOT_SANDWICH";
16 17 18 19 20
	answermap[2] = "KEEN_GOT_SHIPCARD";	
}

void CSpecialItem::getTouchedBy(CSpriteObject& theObject)
{
21
    if(mTaken)
Gerhard Stein's avatar
Gerhard Stein committed
22 23 24
    {
        return;
    }
25 26 27
    
	if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
	{
28
	    mTaken = true;
Gerhard Stein's avatar
Gerhard Stein committed
29
		auto &item = player->m_Inventory.Item.m_special;
30

31
		// Sound play
32
		gSound.playSound(SOUND_GET_SPECIAL_ITEM, SoundPlayMode::PLAY_PAUSEALL);
33 34 35 36 37 38 39 40

		switch(mFoeID)
		{
		    case 0x63: item.hook++; break;
		    case 0x64: item.sandwich++; break;
		    case 0x65: item.rocketKeycard++; break;
		    default: break;
		}
Gerhard Stein's avatar
Gerhard Stein committed
41

42
        auto exitEvent = new EventExitLevel(mpMap->getLevel(), true, false, player->getSpecialIdx());
Gerhard Stein's avatar
Gerhard Stein committed
43 44

        // Play it but afterwards
45 46 47
        exitEvent->playSound = true;                

        // Show got item message
48
        showMsgWithBmp( player->getSpriteVariantIdx(), gBehaviorEngine.getString(answermap[mFoeID-0x63]), 30, LEFT, exitEvent );
49

50
        player->m_Inventory.Item.m_gem.clear();
51 52 53 54 55 56 57 58 59 60
	}    
}

void CSpecialItem::process()
{
    if(!processActionRoutine())
	exists = false;    
}

    
Gerhard Stein's avatar
Gerhard Stein committed
61
};