Commit e84c22d8 authored by Gerstrong's avatar Gerstrong

Added dive suit + cleanups

parent 47b019cc
......@@ -18,8 +18,9 @@
namespace galaxy {
CLevelPlay::CLevelPlay(CExeFile &ExeFile,
CInventory &Inventory) :
CMapPlayGalaxy(ExeFile, Inventory)
CInventory &Inventory,
stCheat &Cheatmode) :
CMapPlayGalaxy(ExeFile, Inventory, Cheatmode)
{ }
......@@ -52,7 +53,9 @@ bool CLevelPlay::loadLevel(const Uint16 level)
// Add the load message
const std::string level_text = "LEVEL" + itoa(level) + "_LOAD_TEXT";
const std::string loading_text = g_pBehaviorEngine->getString(level_text);
m_MessageBoxes.push_back(new CMessageBoxBitmapGalaxy( loading_text, 106 ) );
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
EventContainer.add( new EventSendBitmapDialogMsg(106, loading_text, LEFT) );
m_Map.drawAll();
return true;
......
......@@ -16,7 +16,7 @@ namespace galaxy {
class CLevelPlay : public CMapPlayGalaxy {
public:
CLevelPlay(CExeFile &ExeFile, CInventory &Inventory);
CLevelPlay(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode);
void loadMap(const int level);
void reloadLevel();
......
......@@ -28,6 +28,7 @@
#include "engine/galaxy/ai/ep4/CPoisonSlug.h"
#include "engine/galaxy/ai/ep4/CCouncilMember.h"
#include "engine/galaxy/ai/ep4/CMiragia.h"
#include "engine/galaxy/ai/ep4/CDiveSuit.h"
#include "engine/galaxy/ai/CSpriteItem.h"
#include "engine/galaxy/ai/platforms.h"
......@@ -331,6 +332,8 @@ const int PLATFORM_VERT = 29;
const int PLATFORM_HORIZ = 30;
// 31 does not count, because it's a blocker.
const int PLATFORM_DROP = 32;
const int DIVE_SUIT = 35;
/**
* @brief Loads a foe given by the coordiantes
*/
......@@ -406,6 +409,11 @@ void CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, size_t y)
p_newfoe = new galaxy::CMiragia(&Map, Location);
break;
case DIVE_SUIT:
// Place Miragia in Episode 4 on the Map
p_newfoe = new galaxy::CDiveSuit(&Map, x, y);
break;
case 42:
// This is Keen in the swimming suit
p_newfoe = new galaxy::CPlayerDive(&Map, x, y, m_ObjectPtr,
......
......@@ -9,11 +9,12 @@
#include "engine/galaxy/ai/CPlayerBase.h"
#include "common/CBehaviorEngine.h"
CMapPlayGalaxy::CMapPlayGalaxy(CExeFile &ExeFile, CInventory &Inventory) :
CMapPlayGalaxy::CMapPlayGalaxy(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode) :
m_active(false),
m_ExeFile(ExeFile),
m_Inventory(Inventory),
mp_option(g_pBehaviorEngine->m_option)
mp_option(g_pBehaviorEngine->m_option),
m_Cheatmode(Cheatmode)
{}
......@@ -52,20 +53,12 @@ std::string CMapPlayGalaxy::getLevelName()
std::list<CMessageBoxGalaxy*>& CMapPlayGalaxy::getMessageBoxQueue()
{
std::list<CMessageBoxGalaxy*>& queue = m_MessageBoxes;
return queue;
}
void CMapPlayGalaxy::process()
void CMapPlayGalaxy::process(const bool msgboxactive)
{
// Check if the engine need to be paused
const bool pause = m_Inventory.showStatus() || !m_MessageBoxes.empty();
const bool pause = m_Inventory.showStatus() || msgboxactive;
// Animate the tiles of the map
m_Map.m_animation_enabled = !pause;
......@@ -142,54 +135,6 @@ void CMapPlayGalaxy::process()
if(mp_option[OPT_HUD].value )
m_Inventory.drawHUD();
// Draw some Textboxes with Messages only if one of those is open and needs to be drawn
if(!m_MessageBoxes.empty())
{
CMessageBoxGalaxy *pMB = m_MessageBoxes.front();
pMB->process();
if(pMB->isFinished())
{
delete(pMB);
pMB = NULL;
m_MessageBoxes.pop_front();
}
return;
}
//// Special Keyboard Input
/// Cheat Codes
if( g_pInput->getHoldedKey(KF10) )
{
if(g_pInput->getHoldedKey(KJ))
{
m_Cheatmode.jump = !m_Cheatmode.jump;
std::string jumpstring = "Jump-Cheat has been ";
jumpstring += ((m_Cheatmode.jump) ? "enabled" : "disabled");
m_MessageBoxes.push_back(new CMessageBoxGalaxy(jumpstring));
}
else if(g_pInput->getHoldedKey(KG))
{
m_Cheatmode.god = !m_Cheatmode.god;
std::string godstring = "God-Mode has been ";
godstring += ((m_Cheatmode.god) ? "enabled" : "disabled");
m_MessageBoxes.push_back(new CMessageBoxGalaxy(godstring));
}
else if(g_pInput->getHoldedKey(KI))
{
m_Cheatmode.items = true;
m_MessageBoxes.push_back(new CMessageBoxGalaxy("Get all Items!"));
m_Inventory.Item.triggerAllItemsCheat();
m_Cheatmode.items = true;
}
else if(g_pInput->getHoldedKey(KN))
{
m_Cheatmode.noclipping = true;
m_MessageBoxes.push_back(new CMessageBoxGalaxy("No clipping toggle!"));
}
}
CEventContainer &EventContainer = g_pBehaviorEngine->m_EventList;
if( EventSpawnObject *ev = EventContainer.occurredEvent<EventSpawnObject>() )
......
......@@ -28,7 +28,7 @@
class CMapPlayGalaxy {
public:
CMapPlayGalaxy(CExeFile &ExeFile, CInventory &Inventory);
CMapPlayGalaxy(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode);
~CMapPlayGalaxy();
bool isActive();
......@@ -39,23 +39,17 @@ public:
*/
std::string getLevelName();
/**
* \brief Returns the instance of that MessageBox Queue
*/
std::list<CMessageBoxGalaxy*>& getMessageBoxQueue();
void process();
void process(const bool msgboxactive);
protected:
std::vector<CObject*> m_ObjectPtr;
std::list<CMessageBoxGalaxy*> m_MessageBoxes;
bool m_active;
CMap m_Map;
CExeFile &m_ExeFile;
CInventory &m_Inventory;
stOption *mp_option;
stCheat m_Cheatmode;
stCheat &m_Cheatmode;
};
#endif /* CMAPPLAYGALAXY_H_ */
......@@ -25,8 +25,8 @@ CPlayGameGalaxy::CPlayGameGalaxy(CExeFile &ExeFile, char level,
CSavedGame &SavedGame) :
CPlayGame(ExeFile, level, numplayers, difficulty ),
m_Inventory(difficulty, m_LevelName),
m_WorldMap(ExeFile, m_Inventory),
m_LevelPlay(ExeFile, m_Inventory),
m_WorldMap(ExeFile, m_Inventory, m_Cheatmode),
m_LevelPlay(ExeFile, m_Inventory, m_Cheatmode),
mp_Menu(NULL),
m_SavedGame(SavedGame)
{
......@@ -110,6 +110,8 @@ void CPlayGameGalaxy::process()
m_Inventory.toggleStatusScreen();
}
const bool msgboxactive = !m_MessageBoxes.empty();
// process Page if one is open. Could be one of the finale scenes
//if(m_Page.isActive())
//m_Page.process();
......@@ -117,13 +119,13 @@ void CPlayGameGalaxy::process()
// process World Map if active. At the start it's enabled
if(m_WorldMap.isActive())
{
m_WorldMap.process();
m_WorldMap.process(msgboxactive);
}
// process World Map if active. At the start it's enabled
if(m_LevelPlay.isActive())
{
m_LevelPlay.process();
m_LevelPlay.process(msgboxactive);
}
// We have to show the status screen, do so...
......@@ -131,13 +133,61 @@ void CPlayGameGalaxy::process()
{
m_Inventory.drawStatus();
}
// Draw some Textboxes with Messages only if one of those is open and needs to be drawn
if(msgboxactive)
{
CMessageBoxGalaxy *pMB = m_MessageBoxes.front();
pMB->process();
if(pMB->isFinished())
{
delete(pMB);
pMB = NULL;
m_MessageBoxes.pop_front();
}
return;
}
//// Special Keyboard Input
/// Cheat Codes
if( g_pInput->getHoldedKey(KF10) )
{
if(g_pInput->getHoldedKey(KJ))
{
m_Cheatmode.jump = !m_Cheatmode.jump;
std::string jumpstring = "Jump-Cheat has been ";
jumpstring += ((m_Cheatmode.jump) ? "enabled" : "disabled");
m_MessageBoxes.push_back(new CMessageBoxGalaxy(jumpstring));
}
else if(g_pInput->getHoldedKey(KG))
{
m_Cheatmode.god = !m_Cheatmode.god;
std::string godstring = "God-Mode has been ";
godstring += ((m_Cheatmode.god) ? "enabled" : "disabled");
m_MessageBoxes.push_back(new CMessageBoxGalaxy(godstring));
}
else if(g_pInput->getHoldedKey(KI))
{
m_Cheatmode.items = true;
m_MessageBoxes.push_back(new CMessageBoxGalaxy("Get all Items!"));
m_Inventory.Item.triggerAllItemsCheat();
m_Cheatmode.items = true;
}
else if(g_pInput->getHoldedKey(KN))
{
m_Cheatmode.noclipping = true;
m_MessageBoxes.push_back(new CMessageBoxGalaxy("No clipping toggle!"));
}
}
}
// In this part we will poll all the relevant Events that are important for the
// Galaxy Main Engine itself. For example, load map, setup world map, show Highscore
// are some of those events.
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
std::list<CMessageBoxGalaxy*>& MessageBoxQueue = m_LevelPlay.getMessageBoxQueue();
std::list<CMessageBoxGalaxy*>& MessageBoxQueue = m_MessageBoxes;
if( EventSendBitmapDialogMsg* ev = EventContainer.occurredEvent<EventSendBitmapDialogMsg>() )
{
......
......@@ -50,6 +50,8 @@ private:
CMenuGalaxy *mp_Menu;
CSavedGame &m_SavedGame;
CBitmap m_BackgroundBitmap;
std::list<CMessageBoxGalaxy*> m_MessageBoxes;
stCheat m_Cheatmode;
};
}
......
......@@ -11,8 +11,9 @@
namespace galaxy {
CWorldMap::CWorldMap(CExeFile &ExeFile,
CInventory &Inventory):
CMapPlayGalaxy(ExeFile, Inventory)
CInventory &Inventory,
stCheat &Cheatmode):
CMapPlayGalaxy(ExeFile, Inventory, Cheatmode)
{}
void CWorldMap::init()
......@@ -22,7 +23,9 @@ void CWorldMap::init()
MapLoader.loadMap(m_Map, 0); // Is it a Map Level?
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
m_MessageBoxes.push_back(new CMessageBoxBitmapGalaxy( loading_text, 106 ) );
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
EventContainer.add( new EventSendBitmapDialogMsg(106, loading_text, LEFT) );
m_Map.drawAll();
}
......
......@@ -16,7 +16,7 @@ namespace galaxy {
class CWorldMap : public CMapPlayGalaxy {
public:
CWorldMap(CExeFile &ExeFile, CInventory &Inventory);
CWorldMap(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode);
void init();
void loadAndPlayMusic();
......
......@@ -222,6 +222,10 @@ void CPlayerBase::makeWalkSound()
void CPlayerBase::processDead()
{
// must be processed only once!
if(dead)
return;
m_Inventory.Item.m_lifes--;
setActionForce(A_KEEN_DIE);
......@@ -235,6 +239,7 @@ void CPlayerBase::processDead()
EventContainer.add( pdialogevent );
m_dying = false;
dead = true;
}
......
......@@ -34,7 +34,8 @@ m_basesprite(WALKBASEFRAME),
m_looking_dir(LEFT),
m_animation(0),
m_animation_time(1),
m_animation_ticker(0)
m_animation_ticker(0),
m_cantswim(false)
{
sprite = m_basesprite;
performCollisions();
......@@ -86,8 +87,13 @@ void CPlayerWM::processMoving()
bool walking=false;
bool bleft, bright, bup, bdown;
// This will trigger between swim and walkmode
checkforSwimming(bleft, bright, bup, bdown);
// Normal walking
if(g_pInput->getHoldedCommand(IC_LEFT))
if(g_pInput->getHoldedCommand(IC_LEFT) && !bleft)
{
if(!g_pInput->getHoldedCommand(IC_UP) && !g_pInput->getHoldedCommand(IC_DOWN))
m_vDir = NONE;
......@@ -96,7 +102,7 @@ void CPlayerWM::processMoving()
walking = true;
m_hDir = LEFT;
}
else if(g_pInput->getHoldedCommand(IC_RIGHT))
else if(g_pInput->getHoldedCommand(IC_RIGHT) && !bright)
{
if(!g_pInput->getHoldedCommand(IC_UP) && !g_pInput->getHoldedCommand(IC_DOWN))
m_vDir = NONE;
......@@ -106,7 +112,7 @@ void CPlayerWM::processMoving()
m_hDir = RIGHT;
}
if(g_pInput->getHoldedCommand(IC_UP))
if(g_pInput->getHoldedCommand(IC_UP) && !bup)
{
if(!g_pInput->getHoldedCommand(IC_LEFT) && !g_pInput->getHoldedCommand(IC_RIGHT))
m_hDir = NONE;
......@@ -115,7 +121,7 @@ void CPlayerWM::processMoving()
walking = true;
m_vDir = UP;
}
else if(g_pInput->getHoldedCommand(IC_DOWN))
else if(g_pInput->getHoldedCommand(IC_DOWN) && !bdown)
{
if(!g_pInput->getHoldedCommand(IC_LEFT) && !g_pInput->getHoldedCommand(IC_RIGHT))
m_hDir = NONE;
......@@ -147,12 +153,31 @@ void CPlayerWM::processMoving()
// If keen is just walking on the map or swimming in the sea. Do the proper animation for it.
if(m_basesprite == WALKBASEFRAME)
{
performWalkingAnimation(walking);
m_cantswim = false;
}
else if(m_basesprite == SWIMBASEFRAME)
performSwimmingAnimation();
{
if(m_Inventory.Item.m_special.ep4.swimsuit)
{
performSwimmingAnimation();
}
else
{
if( !m_cantswim )
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
// This will trigger between swim and walkmode
checkforSwimming();
g_pSound->playSound( SOUND_CANT_SWIM, PLAY_PAUSEALL );
EventContainer.add( new EventSendBitmapDialogMsg(106,
g_pBehaviorEngine->getString("CANT_SWIM_TEXT"), LEFT) );
m_cantswim = true;
}
}
}
}
/**
......@@ -204,11 +229,13 @@ void CPlayerWM::finishLevel(Uint16 object)
* 13 Enter water from bottom Keen 4
* 14 Enter water from left Keen 4
*/
void CPlayerWM::checkforSwimming()
void CPlayerWM::checkforSwimming(bool &bleft, bool &bright, bool &bup, bool &bdown)
{
Uint16 left, right, up, down;
std::vector<CTileProperties> &Tile = g_pBehaviorEngine->getTileProperties(1);
bleft = bright = bup = bdown = false;
left = Tile[mp_Map->at( getXLeftPos()>>CSF, getYMidPos()>>CSF, 1)].behaviour;
right = Tile[mp_Map->at( getXRightPos()>>CSF, getYMidPos()>>CSF, 1)].behaviour;
up = Tile[mp_Map->at( getXMidPos()>>CSF, getYUpPos()>>CSF, 1)].behaviour;
......@@ -216,27 +243,42 @@ void CPlayerWM::checkforSwimming()
// from top
if(up == 11)
{
bdown = true;
m_basesprite = SWIMBASEFRAME;
}
else if(down == 11)
m_basesprite = WALKBASEFRAME;
// from right
if(right == 12)
{
bleft = true;
m_basesprite = SWIMBASEFRAME;
}
else if(left == 12)
m_basesprite = WALKBASEFRAME;
// from bottom
if(down == 13)
{
bup = true;
m_basesprite = SWIMBASEFRAME;
}
else if(up == 13)
m_basesprite = WALKBASEFRAME;
// from left
if(left == 14)
{
bright = true;
m_basesprite = SWIMBASEFRAME;
}
else if(right == 14)
m_basesprite = WALKBASEFRAME;
if(m_Inventory.Item.m_special.ep4.swimsuit)
bleft = bright = bup = bdown = false;
}
/**
......
......@@ -26,7 +26,7 @@ public:
void startLevel(Uint16 object);
void finishLevel(Uint16 object);
void checkforSwimming();
void checkforSwimming(bool &bleft, bool &bright, bool &bup, bool &bdown);
void performWalkingAnimation(bool walking);
void performSwimmingAnimation();
......@@ -38,6 +38,7 @@ private:
Uint8 m_animation;
Uint8 m_animation_time;
Uint8 m_animation_ticker;
bool m_cantswim;
};
}
......
/*
* CDiveSuit.cpp
*
* Created on: 25.06.2011
* Author: gerstrong
*/
#include "CDiveSuit.h"
#include "engine/galaxy/ai/CPlayerLevel.h"
namespace galaxy {
CDiveSuit::CDiveSuit(CMap *pmap, Uint32 x, Uint32 y) :
CObject(pmap, x, y, OBJ_NONE),
taken(false)
{
sprite = 306;
calcBouncingBoxes();
}
void CDiveSuit::process()
{}
void CDiveSuit::getTouchedBy(CObject &theObject)
{
if(taken)
return;
// When Keen touches the Council Member exit the level and add one to the council list
if(theObject.m_type == OBJ_PLAYER)
{
CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject);
bool &swimsuit = Player.m_Inventory.Item.m_special.ep4.swimsuit;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
g_pSound->playSound( SOUND_GET_WETSUIT, PLAY_PAUSEALL );
taken = swimsuit = true;
EventContainer.add( new EventSendBitmapDialogMsg(106,
g_pBehaviorEngine->getString("SWIM_SUIT_TEXT"), LEFT) );
EventContainer.add( new EventExitLevel(mp_Map->getLevel(), true) );
}
}
} /* namespace galaxy */
/*
* CDiveSuit.h
*
* Created on: 25.06.2011
* Author: gerstrong
*/
#ifndef CDIVESUIT_H_
#define CDIVESUIT_H_
#include "common/CObject.h"
namespace galaxy {
class CDiveSuit: public CObject {
public:
CDiveSuit(CMap *pmap, Uint32 x, Uint32 y);
private:
void process();
void getTouchedBy(CObject &theObject);
bool taken;
};
} /* namespace galaxy */
#endif /* CDIVESUIT_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment