3 * @brief
\83Q
\81[
\83\80\83G
\83\93\83W
\83\93\82Ì
\8eÀ
\91\95
12 #include "GameEngine.h"
14 #include "HaveGameTime.h"
16 #include "GameCampaign.h"
17 #include "GameLogger.h"
21 GameEngine::GameEngine()
23 gameWorld = new GameWorld();
24 gameSurface = new GameSurfaceSDL(gameWorld);
25 gameLogger = new GameLogger();
27 GameElement::GameWorldPtr = gameWorld;
28 GameElement::GameSurfacePtr = gameSurface;
29 GameElement::GameLoggerPtr = gameLogger;
32 gameWorld->Initialize();
34 gameSurface->SetField(gameWorld->GetField(0));
35 gameSurface->SetSideStatusCreature(gameWorld->GetCreature(0));
36 this->gameLogger->PutLog("GameEngine
\8aJ
\8en");
37 Direction::Initialize();
40 GameEngine::~GameEngine()
47 PLAY_EXIT_CODE GameEngine::PlayLoop(void)
49 GAME_COMMAND commandID;
50 PLAY_EXIT_CODE code = PLAY_EXIT_NONE;
52 gameSurface->Draw(gameWorld->GetPlayerCreature());
54 while(code == PLAY_EXIT_NONE)
56 this->gameSurface->UpdateTimeStatus(this->gameWorld->GetGameTime());
57 //actionIt = this->toNextProcess();
58 commandID = gameSurface->GetCommand(gameWorld->GetPlayerCreature());
59 code = DoGameCommand(commandID);
60 this->gameSurface->FocusField(gameWorld->GetPlayerCreature()->second->GetPosition());
62 this->gameSurface->UpdateSideCreatureStatus(gameWorld->GetPlayerCreature()->second.get());
63 ProcessDeadCreatures();
64 if(!gameWorld->GetPlayerCreature()->second->IsAlive())
66 code = PLAY_EXIT_DEAD;
67 gameSurface->SystemMessage("
\82 \82È
\82½
\82Í
\8e\80\82É
\82Ü
\82µ
\82½
\81B");
71 return PLAY_EXIT_QUIT;
74 PLAY_EXIT_CODE GameEngine::DoGameCommand(GAME_COMMAND command)
76 CREATURE_IT playerIt = gameWorld->GetPlayerCreature();
80 case GAME_COMMAND_VIEW_PLAYER_STATUS:
81 gameSurface->ViewCreatureStatus(gameWorld->GetPlayerCreature()->second.get());
83 case GAME_COMMAND_REDRAW:
84 gameSurface->Draw(playerIt);
86 case GAME_COMMAND_DEBUG_XML_SAVE:
88 gameSurface->SystemMessage("XML
\82É
\95Û
\91¶
\82µ
\82Ü
\82µ
\82½
\81B");
90 case GAME_COMMAND_DEBUG_XML_LOAD:
91 gameSurface->Draw(playerIt);
93 gameSurface->SystemMessage("XML
\82©
\82ç
\8cÄ
\82Ñ
\8fo
\82µ
\82Ü
\82µ
\82½
\81B");
95 case GAME_COMMAND_EXIT:
96 return PLAY_EXIT_QUIT;
98 case GAME_COMMAND_NORTH:
99 playerIt->second.get()->Walk(DIRECTION_NORTH);
101 case GAME_COMMAND_NORTH_EAST:
102 playerIt->second.get()->Walk(DIRECTION_NORTH_EAST);
104 case GAME_COMMAND_EAST:
105 playerIt->second.get()->Walk(DIRECTION_EAST);
107 case GAME_COMMAND_SOUTH_EAST:
108 playerIt->second.get()->Walk(DIRECTION_SOUTH_EAST);
110 case GAME_COMMAND_SOUTH:
111 playerIt->second.get()->Walk(DIRECTION_SOUTH);
113 case GAME_COMMAND_SOUTH_WEST:
114 playerIt->second.get()->Walk(DIRECTION_SOUTH_WEST);
116 case GAME_COMMAND_WEST:
117 playerIt->second.get()->Walk(DIRECTION_WEST);
119 case GAME_COMMAND_NORTH_WEST:
120 playerIt->second.get()->Walk(DIRECTION_NORTH_WEST);
123 return PLAY_EXIT_NONE;
127 bool GameEngine::CombatCreatures(Creature *attackerPtr, Creature *targetPtr)
129 attackerPtr->Melee(targetPtr);
133 int GameEngine::ProcessDeadCreatures()
136 CREATURE_IT creatureIt, creatureItCurrent;
137 CREATURE_LIST *creatureList = gameWorld->GetCreatureList();
139 creatureIt = creatureList->begin();
141 while(creatureIt != creatureList->end())
143 creatureItCurrent = creatureIt;
145 if(!creatureItCurrent->second->IsAlive())
147 //!< @note
\83v
\83\8c\83C
\83\84\81[
\82Ì
\8e\80\96S
\82È
\82ç
\82Î
\95Ê
\93r
\8f\88\97\9d\82·
\82é
\82Ì
\82Å
\83X
\83L
\83b
\83v
\81A
\82³
\82à
\82È
\82
\82Î
\83N
\83\8a\81[
\83`
\83\83\81[
\82Ì
\8fÁ
\96Å
\81B
148 if(gameWorld->GetPlayerCreature() != creatureItCurrent)
150 gameSurface->GameMessage(creatureItCurrent->second->GetName() + "
\82Í
\8e\80\82ñ
\82¾
\81B");
151 creatureList->erase(creatureItCurrent);
160 ACTION_IT GameEngine::toNextProcess(void)
162 return this->gameWorld->GetActionList()->begin()++;