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"
23 GameEngine::GameEngine()
25 gameWorld = new GameWorld();
26 gameSurface = new GameSurfaceSDL(gameWorld);
27 gameLogger = new GameLogger();
29 GameElement::GameWorldPtr = gameWorld;
30 GameElement::GameSurfacePtr = gameSurface;
31 GameElement::GameLoggerPtr = gameLogger;
34 gameWorld->Initialize();
36 this->gameSurface->SetField(gameWorld->GetField(0));
37 this->gameSurface->SetSideStatusCreature(gameWorld->GetCreature(0));
38 this->gameLogger->PutLog("GameEngine
\8aJ
\8en");
39 Direction::Initialize();
42 GameEngine::~GameEngine()
49 void GameEngine::DrawingLoop(void)
54 this->gameSurface->UpdateTimeStatus(this->gameWorld->GetGameTime());
55 this->gameSurface->UpdateSideCreatureStatus(gameWorld->GetPlayerCreature()->second.get());
56 this->gameSurface->Draw(gameWorld->GetPlayerCreature());
62 PLAY_EXIT_CODE GameEngine::PlayLoop(void)
64 boost::asio::io_service io;
65 boost::thread drawing(&GameEngine::DrawingLoop, this);
68 GAME_COMMAND commandID;
69 PLAY_EXIT_CODE code = PLAY_EXIT_NONE;
71 HaveGameTime *currentHaveGameTimeObject;
72 while(code == PLAY_EXIT_NONE)
75 currentHaveGameTimeObject = this->gameWorld->GetNextActionObject();
77 code = currentHaveGameTimeObject->TurnProcess();
79 ProcessDeadCreatures();
80 this->gameSurface->FocusField(gameWorld->GetPlayerCreature()->second->GetPosition());
81 if(!gameWorld->GetPlayerCreature()->second->IsAlive())
83 code = PLAY_EXIT_DEAD;
84 gameSurface->SystemMessage("
\82 \82È
\82½
\82Í
\8e\80\82É
\82Ü
\82µ
\82½
\81B");
89 return PLAY_EXIT_QUIT;
92 bool GameEngine::CombatCreatures(Creature *attackerPtr, Creature *targetPtr)
94 attackerPtr->Melee(targetPtr);
98 int GameEngine::ProcessDeadCreatures()
101 CREATURE_IT creatureIt, creatureItCurrent;
102 CREATURE_LIST *creatureList = gameWorld->GetCreatureList();
104 creatureIt = creatureList->begin();
106 while(creatureIt != creatureList->end())
108 creatureItCurrent = creatureIt;
110 if(!creatureItCurrent->second->IsAlive())
112 //!< @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
113 if(gameWorld->GetPlayerCreature() != creatureItCurrent)
115 gameSurface->GameMessage(creatureItCurrent->second->GetName() + "
\82Í
\8e\80\82ñ
\82¾
\81B");
116 creatureList->erase(creatureItCurrent);