CLindsey.cpp 3.42 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 * CLindsey.cpp
 *
 *  Created on: 14.08.2011
 *      Author: gerstrong
 */

#include "CLindsey.h"
Gerhard Stein's avatar
Gerhard Stein committed
9
#include "../../common/ai/CPlayerLevel.h"
Gerhard Stein's avatar
Gerhard Stein committed
10
#include "../../common/dialog/CMessageBoxBitmapGalaxy.h"
11 12 13 14 15 16

namespace galaxy {

const int LINDSEY_MOVE_SPEED = 20;
const int LINDSEY_MOVE_TIME = 60;

17
CLindsey::CLindsey(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
Gerhard Stein's avatar
Gerhard Stein committed
18
CGalaxySpriteObject(pmap, foeID, x, y, 0),
Gerhard Stein's avatar
Gerhard Stein committed
19 20
m_timer(0),
prepareToVanish(false)
21 22 23 24
{
	setupGalaxyObjectOnMap(0x38EA, 0);

	answermap[0] = "LINDSEY_START_TEXT";
25 26 27 28 29 30

	answermap[1] = "LINDSEY_TEXT1";
	answermap[2] = "LINDSEY_TEXT2";

	answermap[3] = "LINDSEY_END_TEXT1";
	answermap[4] = "LINDSEY_END_TEXT2";
31 32 33 34
}

void CLindsey::process()
{
Gerhard Stein's avatar
Gerhard Stein committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
    if(prepareToVanish)
	exists = false;
    
    if(m_timer <= 0)
    {
	m_timer = LINDSEY_MOVE_SPEED;
	yDirection = (yDirection==UP) ? DOWN : UP;
    }
    
    
    if(yDirection == UP)
	moveUp(LINDSEY_MOVE_SPEED);
    else
	moveDown(LINDSEY_MOVE_SPEED);
    
    m_timer--;
    
    if(!processActionRoutine())
	exists = false;
54 55
}

56
void CLindsey::getTouchedBy(CSpriteObject &theObject)
57
{
Gerhard Stein's avatar
Gerhard Stein committed
58 59
    if(prepareToVanish)
	return;
60 61

    int curLevel = mpMap->getLevel();
Gerhard Stein's avatar
Gerhard Stein committed
62 63
    
    // When Keen touches the pincess give that hint
64
    if( auto *player =  dynamic_cast<CPlayerLevel*>(&theObject) )
Gerhard Stein's avatar
Gerhard Stein committed
65
    {
66
        gSound.playSound(SOUND_GET_WETSUIT, SoundPlayMode::PLAY_PAUSEALL);
Gerhard Stein's avatar
Gerhard Stein committed
67

68
        std::array< std::string, 3> lindsey_text;
Gerhard Stein's avatar
Gerhard Stein committed
69

70
        lindsey_text[0] = gBehaviorEngine.getString(answermap[0]);
Gerhard Stein's avatar
Gerhard Stein committed
71

72
        if(curLevel > 5)
Gerhard Stein's avatar
Gerhard Stein committed
73
        {
74 75
            lindsey_text[1] = gBehaviorEngine.getString(answermap[1]);
            lindsey_text[2] = gBehaviorEngine.getString(answermap[3]);
Gerhard Stein's avatar
Gerhard Stein committed
76 77 78
        }
        else
        {
79 80
            lindsey_text[1] = gBehaviorEngine.getString(answermap[2]);
            lindsey_text[2] = gBehaviorEngine.getString(answermap[4]);
Gerhard Stein's avatar
Gerhard Stein committed
81 82 83
        }


Gerhard Stein's avatar
Gerhard Stein committed
84
        std::vector<CMessageBoxGalaxy*> msgs;
Gerhard Stein's avatar
Gerhard Stein committed
85

86 87 88 89 90 91 92 93 94 95 96 97 98

        // Python3 own dialogs
        bool customDlgs = false;

        #if USE_PYTHON3

        auto pModule = gPython.loadModule( "messageMap", gKeenFiles.gameDir );

        if (pModule != nullptr)
        {
            customDlgs = true;

            bool ok = true;
99 100
            ok &= loadStrFunction(pModule, "getLindseyDialog", lindsey_text[0], curLevel);
            ok &= loadStrFunction(pModule, "getLindseyAnswer", lindsey_text[1], curLevel);
101 102 103 104
        }

        #endif

105
        const int sprVar = player->getSpriteVariantIdx();
106 107 108 109


        if(!customDlgs)
        {
110 111 112 113 114 115
            msgs.push_back( new CMessageBoxBitmapGalaxy(sprVar, lindsey_text[0],
                            gGraphics.getBitmapFromId(sprVar, 108), LEFT, false, nullptr) );
            msgs.push_back( new CMessageBoxBitmapGalaxy(sprVar, lindsey_text[1],
                            gGraphics.getBitmapFromId(sprVar, 108), LEFT, false, nullptr) );
            msgs.push_back( new CMessageBoxBitmapGalaxy(sprVar, lindsey_text[2],
                            *gGraphics.getBitmapFromStr(sprVar, "KEENTHUMBSUP"), RIGHT, false, nullptr) );
116 117 118
        }
        else
        {
119 120 121 122
            msgs.push_back( new CMessageBoxBitmapGalaxy(sprVar, lindsey_text[0],
                            gGraphics.getBitmapFromId(sprVar, 108), LEFT, false, nullptr) );
            msgs.push_back( new CMessageBoxBitmapGalaxy(sprVar, lindsey_text[1],
                            *gGraphics.getBitmapFromStr(sprVar, "KEENTHUMBSUP"), RIGHT, false, nullptr) );
123
        }
Gerhard Stein's avatar
Gerhard Stein committed
124

Gerhard Stein's avatar
Gerhard Stein committed
125
        showMsgVec( msgs );
Gerhard Stein's avatar
Gerhard Stein committed
126 127 128

        prepareToVanish = true;
    }
129 130 131 132
}


} /* namespace galaxy */