Commit b5266b96 authored by Gerhard Stein's avatar Gerhard Stein

HUD Displays now for all players in the galaxy engine

parent 396df9f2
......@@ -37,7 +37,7 @@ timer(0)
{
mpHUDBox = g_pGfxEngine->getSprite("HUDBACKGROUND");
m_Rect.h = mpHUDBox->getHeight()+2;
m_Rect.w = mpHUDBox->getWidth()+2;
m_Rect.w = (mpHUDBox->getWidth()+2)*4;
mpHUDBlit.reset( CG_CreateRGBSurface( m_Rect ), &SDL_FreeSurface );
#if SDL_VERSION_ATLEAST(2, 0, 0)
......@@ -161,25 +161,36 @@ void CHUD::DrawCircle(int x, int y, int width)
/**
* \brief This part of the code will render the entire HUD. Galaxy Version
*/
void CHUD::renderGalaxy()
void CHUD::renderGalaxy(const int place, const int players)
{
m_Rect.x = 4; m_Rect.y = 2;
m_Rect.w = 80; m_Rect.h = 29;
// Compute the score that really will be seen
int score, lives, charges;
score = (m_oldScore<999999999) ? m_oldScore : 999999999;
lives = (m_lives<99) ? m_lives : 99;
charges = (m_oldCharges<99) ? m_oldCharges : 99;
auto rect = m_Rect;
// Draw the HUD with all the digits
SDL_Surface* blitsfc = mpHUDBlit.get();
mpHUDBox->drawSprite( blitsfc, m_Rect.x, m_Rect.y );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(score),9), m_Rect.x+8, m_Rect.y+4, blitsfc );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(charges),2), m_Rect.x+64, m_Rect.y+20, blitsfc );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(lives),2), m_Rect.x+24, m_Rect.y+20, blitsfc );
SDL_BlitSurface( mpHUDBlit.get(), NULL, g_pVideoDriver->getBlitSurface(), &m_Rect );
rect.w = 40; rect.h = 29;
if(players > 3)
{
rect.x = place*(rect.w-1); rect.y = 0;
}
else
{
rect.x = 4 + place*rect.w; rect.y = 2;
}
// Compute the score that really will be seen
int score, lives, charges;
score = (m_oldScore<999999999) ? m_oldScore : 999999999;
lives = (m_lives<99) ? m_lives : 99;
charges = (m_oldCharges<99) ? m_oldCharges : 99;
// Draw the HUD with all the digits
SDL_Surface* blitsfc = mpHUDBlit.get();
mpHUDBox->drawSprite( blitsfc, rect.x, rect.y );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(score),9), rect.x+8, rect.y+4, blitsfc );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(charges),2), rect.x+64, rect.y+20, blitsfc );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(lives),2), rect.x+24, rect.y+20, blitsfc );
SDL_BlitSurface( blitsfc, NULL, g_pVideoDriver->getBlitSurface(), &rect );
}
/**
* \brief This part of the code will render the entire HUD. Vorticon version
......@@ -220,7 +231,7 @@ void CHUD::renderVorticon()
}
void CHUD::render()
void CHUD::render(const int place, const int players)
{
size_t Episode = g_pBehaviorEngine->getEpisode();
......@@ -257,9 +268,9 @@ void CHUD::render()
}
if( Episode>=1 && Episode<=3 )
renderVorticon();
renderVorticon();
else if( Episode>=4 && Episode<=6 )
renderGalaxy();
renderGalaxy(place, players);
}
......
......@@ -22,7 +22,8 @@
#define CHUD_H_
class CHUD {
class CHUD
{
public:
CHUD(unsigned long &score,
signed char &lives,
......@@ -32,7 +33,7 @@ public:
/**
* \brief This part of the code will render the entire HUD
*/
void render();
void render(const int place, const int players);
/**
* \brief This will sync some data in the HUD, especially the oldScore variable
......@@ -42,7 +43,7 @@ public:
private:
void CreateBackground();
void renderGalaxy();
void renderGalaxy(const int place, const int players);
void renderVorticon();
void DrawCircle(int x, int y, int width);
......
......@@ -21,9 +21,9 @@
namespace galaxy {
CLevelPlay::CLevelPlay(CExeFile &ExeFile,
CInventory &Inventory,
std::vector<CInventory> &inventory,
stCheat &Cheatmode) :
CMapPlayGalaxy(ExeFile, Inventory, Cheatmode)
CMapPlayGalaxy(ExeFile, inventory, Cheatmode)
{ }
......@@ -33,11 +33,11 @@ void CLevelPlay::loadMap(const int level)
std::unique_ptr<CMapLoaderGalaxy> MapLoader;
if(g_pBehaviorEngine->getEpisode() == 4)
MapLoader.reset(new CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventory, mCheatmode));
MapLoader.reset(new CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventoryVec, mCheatmode));
else if(g_pBehaviorEngine->getEpisode() == 5)
MapLoader.reset(new CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventory, mCheatmode));
MapLoader.reset(new CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventoryVec, mCheatmode));
else if(g_pBehaviorEngine->getEpisode() == 6)
MapLoader.reset(new CMapLoaderGalaxyEp6(mExeFile, mObjectPtr, mInventory, mCheatmode));
MapLoader.reset(new CMapLoaderGalaxyEp6(mExeFile, mObjectPtr, mInventoryVec, mCheatmode));
MapLoader->loadMap( mMap, level );
......
......@@ -17,7 +17,7 @@ namespace galaxy {
class CLevelPlay : public CMapPlayGalaxy
{
public:
CLevelPlay(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode);
CLevelPlay(CExeFile &ExeFile, std::vector<CInventory> &inventory, stCheat &Cheatmode);
void loadMap(const int level);
void reloadLevel();
......
......@@ -20,10 +20,10 @@
#include <boost/property_tree/ptree.hpp>
#include "Base64.h"
CMapPlayGalaxy::CMapPlayGalaxy(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode) :
CMapPlayGalaxy::CMapPlayGalaxy(CExeFile &ExeFile, std::vector<CInventory> &inventoryVec, stCheat &Cheatmode) :
mActive(false),
mExeFile(ExeFile),
mInventory(Inventory),
mInventoryVec(inventoryVec),
mpOption(g_pBehaviorEngine->m_option),
mCheatmode(Cheatmode),
mMsgBoxOpen(false)
......@@ -68,8 +68,11 @@ void CMapPlayGalaxy::ponder()
{
const bool msgboxactive = mMsgBoxOpen;
bool pause = msgboxactive;
// Check if the engine need to be paused
const bool pause = mInventory.showStatus() || msgboxactive;
for( auto &inv : mInventoryVec)
pause |= inv.showStatus();
// Animate the tiles of the map
mMap.m_animation_enabled = !pause;
......@@ -214,7 +217,12 @@ void CMapPlayGalaxy::render()
}
if(mpOption[OPT_HUD].value )
mInventory.drawHUD();
{
for( int pId = mInventoryVec.size()-1 ; pId>=0 ; pId-- )
{
mInventoryVec[pId].drawHUD(pId, mInventoryVec.size());
}
}
}
......@@ -295,15 +303,15 @@ bool CMapPlayGalaxy::operator<<(CSaveGameController &savedGame)
if(episode == 4)
{
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventory, mCheatmode) );
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
}
else if(episode == 5)
{
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventory, mCheatmode) );
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
}
else if(episode == 6)
{
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp6(mExeFile, mObjectPtr, mInventory, mCheatmode) );
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp6(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
}
else
{
......@@ -479,15 +487,15 @@ void CMapPlayGalaxy::operator<<(boost::property_tree::ptree &levelNode)
if(episode == 4)
{
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventory, mCheatmode) );
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
}
else if(episode == 5)
{
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventory, mCheatmode) );
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
}
else if(episode == 6)
{
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp6(mExeFile, mObjectPtr, mInventory, mCheatmode) );
mapLoader.reset( new galaxy::CMapLoaderGalaxyEp6(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
}
else
{
......
......@@ -32,7 +32,7 @@
class CMapPlayGalaxy : public GameState
{
public:
CMapPlayGalaxy(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode);
CMapPlayGalaxy(CExeFile &ExeFile, std::vector<CInventory> &inventoryVec, stCheat &Cheatmode);
bool isActive();
void setActive(const bool value);
......@@ -72,7 +72,7 @@ protected:
CMap mMap;
CExeFile &mExeFile;
CInventory &mInventory;
std::vector<CInventory> &mInventoryVec;
stOption *mpOption;
stCheat &mCheatmode;
......
......@@ -30,11 +30,11 @@ namespace galaxy
CPlayGameGalaxy::CPlayGameGalaxy(CExeFile &ExeFile, char level,
char numplayers, CSaveGameController &SavedGame) :
CPlayGame(ExeFile, level, numplayers ),
m_Inventory(m_LevelName),
m_WorldMap(ExeFile, m_Inventory, m_Cheatmode),
m_LevelPlay(ExeFile, m_Inventory, m_Cheatmode),
m_WorldMap(ExeFile, mInventoryVec, m_Cheatmode),
m_LevelPlay(ExeFile, mInventoryVec, m_Cheatmode),
m_SavedGame(SavedGame)
{
mInventoryVec.resize(numplayers);
m_WorldMap.init();
}
......@@ -61,8 +61,7 @@ bool CPlayGameGalaxy::loadGameState()
savedGame.decodeData(m_NumPlayers);
// We need to load both Levels first, before we do the writing from the saved state.
m_Inventory << savedGame;
mInventoryVec[0] << savedGame;
bool active;
savedGame.decodeData( active );
......@@ -135,7 +134,7 @@ bool CPlayGameGalaxy::loadXMLGameState()
ptree &playerNode = pt.get_child("Player");
//id = playerNode.get<int>("<xmlattr>.id", );
auto &invNode = playerNode.get_child("inventory");
m_Inventory << invNode;
mInventoryVec[id] << invNode;
}
......@@ -155,10 +154,10 @@ bool CPlayGameGalaxy::loadXMLGameState()
}
void CPlayGameGalaxy::operator<<(boost::property_tree::ptree &invNode)
/*void CPlayGameGalaxy::operator<<(boost::property_tree::ptree &invNode)
{
m_Inventory<<invNode;
}
}*/
bool CPlayGameGalaxy::saveXMLGameState()
......@@ -187,7 +186,7 @@ bool CPlayGameGalaxy::saveXMLGameState()
ptree &playerNode = pt.add("Player", "");
playerNode.put("<xmlattr>.id", id);
auto &invNode = playerNode.put("inventory", "");
m_Inventory >> invNode;
mInventoryVec[id] >> invNode;
}
bool active = m_WorldMap.isActive();
......@@ -219,14 +218,12 @@ bool CPlayGameGalaxy::init()
{
m_WorldMap.setActive(true);
m_WorldMap.loadAndPlayMusic();
m_LevelName = m_WorldMap.getLevelName();
}
else
{
// manually a level has been loaded
m_LevelPlay.loadLevel(m_Level);
m_LevelPlay.setActive(true);
m_LevelName = m_LevelPlay.getLevelName();
}
return true;
......@@ -246,27 +243,34 @@ void CPlayGameGalaxy::ponder()
if( !gpMenuController->active() )
{
processInput();
processInput();
const bool msgboxactive = !mMessageBoxes.empty();
const bool msgboxactive = !mMessageBoxes.empty();
int playerCount = 0;
for( auto &inv : mInventoryVec )
{
// Trigger the Status screen here
if(inv.showStatus())
{
if( g_pInput->getPressedAnyButtonCommand(playerCount) )
{
g_pSound->playSound(SOUND_STATUS_SLIDE_OUT);
inv.toggleStatusScreen();
}
}
else
{
if(!msgboxactive && g_pInput->getPressedCommand(playerCount, IC_STATUS))
{
g_pSound->playSound(SOUND_STATUS_SLIDE_IN);
inv.toggleStatusScreen();
}
}
playerCount++;
}
// Trigger the Status screen here
if(m_Inventory.showStatus())
{
if( g_pInput->getPressedAnyButtonCommand(0) )
{
g_pSound->playSound(SOUND_STATUS_SLIDE_OUT);
m_Inventory.toggleStatusScreen();
}
}
else
{
if(!msgboxactive && g_pInput->getPressedCommand(IC_STATUS))
{
g_pSound->playSound(SOUND_STATUS_SLIDE_IN);
m_Inventory.toggleStatusScreen();
}
}
// process World Map if active. At the start it's enabled
if(m_WorldMap.isActive())
......@@ -315,7 +319,10 @@ void CPlayGameGalaxy::ponder()
else if(g_pInput->getHoldedKey(KI))
{
eventContainer.add( new EventSendDialog("Get all Items!") );
m_Inventory.Item.triggerAllItemsCheat();
for( auto &inv : mInventoryVec )
inv.Item.triggerAllItemsCheat();
m_Cheatmode.items = true;
}
else if(g_pInput->getHoldedKey(KN))
......@@ -325,7 +332,9 @@ void CPlayGameGalaxy::ponder()
}
else if(g_pInput->getHoldedKey(KS))
{
m_Inventory.Item.triggerAllItemsCheat();
for( auto &inv : mInventoryVec )
inv.Item.triggerAllItemsCheat();
m_Cheatmode.items = true;
m_Cheatmode.god = true;
m_Cheatmode.jump = true;
......@@ -416,7 +425,6 @@ void CPlayGameGalaxy::ponder()
g_pMusicPlayer->stop();
m_WorldMap.setActive(false);
m_LevelPlay.loadLevel(NewLevel);
m_LevelName = m_LevelPlay.getLevelName();
g_pSound->playSound( SOUND_ENTER_LEVEL );
m_LevelPlay.setActive(true);
}
......@@ -433,7 +441,6 @@ void CPlayGameGalaxy::ponder()
{
m_LevelPlay.setActive(false);
m_WorldMap.setActive(true);
m_LevelName = m_WorldMap.getLevelName();
m_WorldMap.loadAndPlayMusic();
const EventExitLevel &evCopy = *ev;
......@@ -453,7 +460,6 @@ void CPlayGameGalaxy::ponder()
g_pMusicPlayer->stop();
m_LevelPlay.setActive(false);
m_WorldMap.setActive(true);
m_LevelName = m_WorldMap.getLevelName();
m_WorldMap.loadAndPlayMusic();
eventContainer.add( new EventPlayerRideFoot(*ev) );
eventContainer.pop_Event();
......@@ -491,9 +497,10 @@ void CPlayGameGalaxy::render()
}
// We have to show the status screen, do so...
if( m_Inventory.showStatus() )
for( auto &inv : mInventoryVec )
{
m_Inventory.drawStatus();
if( inv.showStatus() )
inv.drawStatus();
}
const bool msgboxactive = !mMessageBoxes.empty();
......
......@@ -27,11 +27,11 @@ namespace galaxy
class CPlayGameGalaxy : public CPlayGame
{
public:
CPlayGameGalaxy(CExeFile &ExeFile, char level,
CPlayGameGalaxy(CExeFile &ExeFile, char level,
char numplayers,
CSaveGameController &SavedGame);
bool loadGameState();
bool loadGameState();
//bool saveGameState();
bool loadXMLGameState();
bool saveXMLGameState();
......@@ -40,22 +40,21 @@ public:
void ponder();
void render();
void processInput();
void processRendering();
void processInput();
void processRendering();
void operator<<(boost::property_tree::ptree &invNode);
void cleanup() {};
private:
std::string m_LevelName;
CInventory m_Inventory;
CWorldMap m_WorldMap;
CLevelPlay m_LevelPlay;
CSaveGameController &m_SavedGame;
CBitmap m_BackgroundBitmap;
std::list< std::shared_ptr<CMessageBoxGalaxy> > mMessageBoxes;
stCheat m_Cheatmode;
std::vector<CInventory> mInventoryVec;
CWorldMap m_WorldMap;
CLevelPlay m_LevelPlay;
CSaveGameController &m_SavedGame;
CBitmap m_BackgroundBitmap;
std::list< std::shared_ptr<CMessageBoxGalaxy> > mMessageBoxes;
stCheat m_Cheatmode;
};
}
......
......@@ -18,10 +18,9 @@
#include "engine/galaxy/ep6/CStatusScreenGalaxyEp6.h"
CInventory::CInventory(const std::string& levelname) :
CInventory::CInventory() :
m_HUD(Item.m_points, Item.m_lifes, Item.m_bullets),
mp_StatusBgrnd(NULL),
m_LevelName(levelname)
mp_StatusBgrnd(NULL)
{
reset();
......@@ -37,15 +36,15 @@ m_LevelName(levelname)
if(Episode == 4)
{
mp_StatusScreen.reset(new CStatusScreenGalaxyEp4(Item, m_LevelName));
mp_StatusScreen.reset(new CStatusScreenGalaxyEp4(Item));
}
else if(Episode == 5)
{
mp_StatusScreen.reset(new CStatusScreenGalaxyEp5(Item, m_LevelName));
mp_StatusScreen.reset(new CStatusScreenGalaxyEp5(Item));
}
else if(Episode == 6)
{
mp_StatusScreen.reset(new CStatusScreenGalaxyEp6(Item, m_LevelName));
mp_StatusScreen.reset(new CStatusScreenGalaxyEp6(Item));
}
}
......@@ -101,9 +100,9 @@ void CInventory::toggleStatusScreen()
}
void CInventory::drawHUD()
void CInventory::drawHUD(const int place, const int players)
{
m_HUD.render();
m_HUD.render(place, players);
}
void CInventory::drawStatus()
......
......@@ -23,11 +23,11 @@
class CInventory
{
public:
CInventory(const std::string& levelname);
CInventory();
void reset();
// This function draws the HUD on the Screen
void drawHUD();
void drawHUD(const int place, const int players);
// This one draw the Status screen whenever it's called
void drawStatus();
......@@ -52,7 +52,6 @@ public:
CHUD m_HUD;
std::unique_ptr<CStatusScreenGalaxy> mp_StatusScreen;
SDL_Surface *mp_StatusBgrnd;
const std::string &m_LevelName;
};
......
......@@ -35,10 +35,10 @@ namespace galaxy
CMapLoaderGalaxy::CMapLoaderGalaxy(CExeFile &ExeFile,
std::vector< std::shared_ptr<CGalaxySpriteObject> > &ObjectPtr,
CInventory &Inventory, stCheat &Cheatmode):
std::vector<CInventory> &inventoryVec, stCheat &Cheatmode):
m_ExeFile(ExeFile),
m_ObjectPtr(ObjectPtr),
m_Inventory(Inventory),
mInventoryVec(inventoryVec),
m_Cheatmode(Cheatmode),
mPlayerID(0)
{}
......@@ -360,7 +360,7 @@ void CMapLoaderGalaxy::spawnFoes(CMap &Map)
const int foeID = *data_ptr;
// Check if it is the player, because in multiplayer we spawn multiple keens
if(foeID > 2 && foeID <= 3) // World Map only
if(foeID > 0 && foeID <= 3) // World Map only
{
for(int i = 0 ; i < numPlayers ; i++)
{
......
......@@ -28,7 +28,7 @@ class CMapLoaderGalaxy
public:
CMapLoaderGalaxy(CExeFile &ExeFile,
std::vector< std::shared_ptr<CGalaxySpriteObject> > &ObjectPtr,
CInventory &Inventory, stCheat &Cheatmode);
std::vector<CInventory> &inventoryVec, stCheat &Cheatmode);
size_t getMapheadOffset();
bool gotoNextSignature(std::ifstream &MapFile);
......@@ -50,7 +50,7 @@ protected:
CExeFile &m_ExeFile;
std::vector< std::shared_ptr<CGalaxySpriteObject> > &m_ObjectPtr;
CInventory &m_Inventory;
std::vector<CInventory> &mInventoryVec;
stCheat &m_Cheatmode;
std::string mLevelName;
int mPlayerID;
......
......@@ -11,10 +11,9 @@
#include "common/CBehaviorEngine.h"
#include "sdl/extensions.h"
CStatusScreenGalaxy::CStatusScreenGalaxy(const stItemGalaxy& Item, const std::string &LevelName) :
CStatusScreenGalaxy::CStatusScreenGalaxy(const stItemGalaxy& Item) :
m_showstatus(false),
m_Item(Item),
m_LevelName(LevelName)
m_Item(Item)
{}
void CStatusScreenGalaxy::drawBase(SDL_Rect &EditRect)
......
......@@ -18,7 +18,7 @@
class CStatusScreenGalaxy
{
public:
CStatusScreenGalaxy(const stItemGalaxy& Item, const std::string &LevelName);
CStatusScreenGalaxy(const stItemGalaxy& Item);
// This will generate the status screen. It must be derived by other classes, depending on the Episode
virtual void GenerateStatus() = 0;
......@@ -37,7 +37,6 @@ public:
bool m_showstatus;
std::shared_ptr<SDL_Surface> mpStatusSurface;
const stItemGalaxy& m_Item;
const std::string &m_LevelName;
};
......
......@@ -12,9 +12,9 @@
namespace galaxy {
CWorldMap::CWorldMap(CExeFile &ExeFile,
CInventory &Inventory,
std::vector<CInventory> &inventoryVec,
stCheat &Cheatmode):
CMapPlayGalaxy(ExeFile, Inventory, Cheatmode)
CMapPlayGalaxy(ExeFile, inventoryVec, Cheatmode)
{}
void CWorldMap::init()
......@@ -23,11 +23,11 @@ void CWorldMap::init()
std::unique_ptr<CMapLoaderGalaxy> MapLoader;
if(g_pBehaviorEngine->getEpisode() == 4)
MapLoader.reset( new CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventory, mCheatmode) );
MapLoader.reset( new CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
else if(g_pBehaviorEngine->getEpisode() == 5)
MapLoader.reset( new CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventory, mCheatmode) );
MapLoader.reset( new CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
else if(g_pBehaviorEngine->getEpisode() == 6)
MapLoader.reset( new CMapLoaderGalaxyEp6(mExeFile, mObjectPtr, mInventory, mCheatmode) );
MapLoader.reset( new CMapLoaderGalaxyEp6(mExeFile, mObjectPtr, mInventoryVec, mCheatmode) );
MapLoader->loadMap( mMap, 0 );
g_pBehaviorEngine->mapLevelName = MapLoader->getLevelName();
......
......@@ -18,7 +18,7 @@ namespace galaxy {
class CWorldMap : public CMapPlayGalaxy
{
public:
CWorldMap(CExeFile &ExeFile, CInventory &Inventory, stCheat &Cheatmode);
CWorldMap(CExeFile &ExeFile, std::vector<CInventory> &inventoryVec, stCheat &Cheatmode);
void init();
void loadAndPlayMusic();
......
......@@ -45,8 +45,8 @@ namespace galaxy
CMapLoaderGalaxyEp4::CMapLoaderGalaxyEp4(CExeFile &ExeFile,
std::vector< std::shared_ptr<CGalaxySpriteObject> > &ObjectPtr,
CInventory &Inventory, stCheat &Cheatmode) :
CMapLoaderGalaxy( ExeFile, ObjectPtr, Inventory, Cheatmode)
std::vector<CInventory> &inventoryVec, stCheat &Cheatmode) :
CMapLoaderGalaxy( ExeFile, ObjectPtr, inventoryVec, Cheatmode)
{}
......@@ -106,21 +106,24 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x,
// otherwise look for special foe.
VectorD2<Uint32> loc(x,y);
auto &inventory = mInventoryVec[mPlayerID];
switch(foe)
{
case 0x01:
case 0x02:
// This is the player on the map in one level
inventory.Item.mLevelName = Map.getLevelName();
p_newfoe = new galaxy::CPlayerLevel(&Map, foe, x, y, m_ObjectPtr,
(foe==0x01) ? RIGHT : LEFT, m_Inventory, m_Cheatmode, 0x98C, mPlayerID);
(foe==0x01) ? RIGHT : LEFT, inventory, m_Cheatmode, 0x98C, mPlayerID);
mPlayerID++;
break;
case 0x03:
// This is the player on the world map
// Add the Camera into the game scene and attach it to this player
p_newfoe = new galaxy::CPlayerWM(&Map, foe, x, y, m_Inventory, m_Cheatmode, 0x15C2, mPlayerID);
inventory.Item.mLevelName = Map.getLevelName();
p_newfoe = new galaxy::CPlayerWM(&Map, foe, x, y, inventory, m_Cheatmode, 0x15C2, mPlayerID);
mPlayerID++;
break;
......@@ -253,10 +256,14 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x,
case 0x22:
// Place a gun in case Keen is missing bullets
if(m_Inventory.Item.m_bullets < 5)
{
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, 127);
}
for( auto &inventory : mInventoryVec)
{
if(inventory.Item.m_bullets < 5)
{
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, 127);
break;
}