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 gameSurface->SetField(gameWorld->GetField(0));
28 gameSurface->SetSideStatusCreature(gameWorld->GetCreature(0));
29 this->gameLogger->PutLog("GameEngine
\8aJ
\8en");
30 Direction::Initialize();
33 PLAY_EXIT_CODE GameEngine::PlayLoop(void)
35 GAME_COMMAND commandID;
36 PLAY_EXIT_CODE code = PLAY_EXIT_NONE;
38 gameSurface->Draw(gameWorld->GetPlayerCreature());
40 while(code == PLAY_EXIT_NONE)
42 this->gameSurface->UpdateTimeStatus(this->gameWorld->GetGameTime());
43 //actionIt = this->toNextProcess();
44 commandID = gameSurface->GetCommand(gameWorld->GetPlayerCreature());
45 code = DoGameCommand(commandID);
46 this->gameSurface->FocusField(gameWorld->GetPlayerCreature()->second->GetPosition());
48 this->gameSurface->UpdateSideCreatureStatus(gameWorld->GetPlayerCreature()->second.get());
49 ProcessDeadCreatures();
50 if(!gameWorld->GetPlayerCreature()->second->IsAlive())
52 code = PLAY_EXIT_DEAD;
53 gameSurface->SystemMessage("
\82 \82È
\82½
\82Í
\8e\80\82É
\82Ü
\82µ
\82½
\81B");
57 return PLAY_EXIT_QUIT;
60 PLAY_EXIT_CODE GameEngine::DoGameCommand(GAME_COMMAND command)
62 CREATURE_IT playerIt = gameWorld->GetPlayerCreature();
66 case GAME_COMMAND_VIEW_PLAYER_STATUS:
67 gameSurface->ViewCreatureStatus(gameWorld->GetPlayerCreature()->second.get());
69 case GAME_COMMAND_REDRAW:
70 gameSurface->Draw(playerIt);
72 case GAME_COMMAND_DEBUG_XML_SAVE:
74 gameSurface->SystemMessage("XML
\82É
\95Û
\91¶
\82µ
\82Ü
\82µ
\82½
\81B");
76 case GAME_COMMAND_DEBUG_XML_LOAD:
77 gameSurface->Draw(playerIt);
79 gameSurface->SystemMessage("XML
\82©
\82ç
\8cÄ
\82Ñ
\8fo
\82µ
\82Ü
\82µ
\82½
\81B");
81 case GAME_COMMAND_EXIT:
82 return PLAY_EXIT_QUIT;
84 case GAME_COMMAND_NORTH:
85 playerIt->second.get()->Walk(DIRECTION_NORTH);
87 case GAME_COMMAND_NORTH_EAST:
88 playerIt->second.get()->Walk(DIRECTION_NORTH_EAST);
90 case GAME_COMMAND_EAST:
91 playerIt->second.get()->Walk(DIRECTION_EAST);
93 case GAME_COMMAND_SOUTH_EAST:
94 playerIt->second.get()->Walk(DIRECTION_SOUTH_EAST);
96 case GAME_COMMAND_SOUTH:
97 playerIt->second.get()->Walk(DIRECTION_SOUTH);
99 case GAME_COMMAND_SOUTH_WEST:
100 playerIt->second.get()->Walk(DIRECTION_SOUTH_WEST);
102 case GAME_COMMAND_WEST:
103 playerIt->second.get()->Walk(DIRECTION_WEST);
105 case GAME_COMMAND_NORTH_WEST:
106 playerIt->second.get()->Walk(DIRECTION_NORTH_WEST);
109 return PLAY_EXIT_NONE;
113 bool GameEngine::CombatCreatures(Creature *attackerPtr, Creature *targetPtr)
115 attackerPtr->Melee(targetPtr);
119 int GameEngine::ProcessDeadCreatures()
122 CREATURE_IT creatureIt, creatureItCurrent;
123 CREATURE_LIST *creatureList = gameWorld->GetCreatureList();
125 creatureIt = creatureList->begin();
127 while(creatureIt != creatureList->end())
129 creatureItCurrent = creatureIt;
131 if(!creatureItCurrent->second->IsAlive())
133 //!< @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
134 if(gameWorld->GetPlayerCreature() != creatureItCurrent)
136 gameSurface->GameMessage(creatureItCurrent->second->GetName() + "
\82Í
\8e\80\82ñ
\82¾
\81B");
137 creatureList->erase(creatureItCurrent);
146 ACTION_IT GameEngine::toNextProcess(void)
148 return this->gameWorld->GetActionList()->begin()++;