Deeangbandのフルスクラッチ新ソースコード。
BSD系ライセンスを採用予定。
Revision | 0b416ef6508cf8eb87fb79b9542cc3c697fbf36a (tree) |
---|---|
Time | 2015-01-26 23:38:46 |
Author | Deskull <desull@user...> |
Commiter | Deskull |
Square::SetFloorTag()をSetFloor()に変更して修正。 / Rename Square::SetFloorTag() to SetFloor() and Fix.
GameWorldコンストラクタから、GameWorld::Initialize()を分離。 / Split GameWorld::Initialize() from GameWorld constructor.
@@ -32,11 +32,11 @@ namespace Deeangband | ||
32 | 32 | squares[y].push_back(boost::shared_ptr<Square>(new Square())); |
33 | 33 | if(Dice::Cast(1, 4) == 3) |
34 | 34 | { |
35 | - squares[y][x]->SetFloorTag(dungeonPtr->GetInnerWallFloorTag()); | |
35 | + squares[y][x]->SetFloor(dungeonPtr->GetInnerWallFloorTag()); | |
36 | 36 | } |
37 | 37 | else |
38 | 38 | { |
39 | - squares[y][x]->SetFloorTag(dungeonPtr->GetFloorFloorTag()); | |
39 | + squares[y][x]->SetFloor(dungeonPtr->GetFloorFloorTag()); | |
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -216,7 +216,7 @@ namespace Deeangband | ||
216 | 216 | squarePtr = this->GetSquare(x, y); |
217 | 217 | if(squarePtr) |
218 | 218 | { |
219 | - squarePtr->SetFloorTag(dungeonPtr->GetFloorFloorTag()); | |
219 | + squarePtr->SetFloor(dungeonPtr->GetFloorFloorTag()); | |
220 | 220 | } |
221 | 221 | } |
222 | 222 | } |
@@ -224,9 +224,9 @@ namespace Deeangband | ||
224 | 224 | for(y = sy; y <= ey; y++) |
225 | 225 | { |
226 | 226 | squarePtr = this->GetSquare(sx, y); |
227 | - squarePtr->SetFloorTag(dungeonPtr->GetInnerWallFloorTag()); | |
227 | + squarePtr->SetFloor(dungeonPtr->GetInnerWallFloorTag()); | |
228 | 228 | squarePtr = this->GetSquare(ex, y); |
229 | - squarePtr->SetFloorTag(dungeonPtr->GetInnerWallFloorTag()); | |
229 | + squarePtr->SetFloor(dungeonPtr->GetInnerWallFloorTag()); | |
230 | 230 | wallVec.push_back(boost::make_shared<Coordinates>(sx, y)); |
231 | 231 | wallVec.push_back(boost::make_shared<Coordinates>(ex, y)); |
232 | 232 | } |
@@ -234,14 +234,14 @@ namespace Deeangband | ||
234 | 234 | for(x = sx + 1; x < ex; x++) |
235 | 235 | { |
236 | 236 | squarePtr = this->GetSquare(x, sy); |
237 | - squarePtr->SetFloorTag(dungeonPtr->GetInnerWallFloorTag()); | |
237 | + squarePtr->SetFloor(dungeonPtr->GetInnerWallFloorTag()); | |
238 | 238 | squarePtr = this->GetSquare(x, ey); |
239 | - squarePtr->SetFloorTag(dungeonPtr->GetInnerWallFloorTag()); | |
239 | + squarePtr->SetFloor(dungeonPtr->GetInnerWallFloorTag()); | |
240 | 240 | wallVec.push_back(boost::make_shared<Coordinates>(x, sy)); |
241 | 241 | wallVec.push_back(boost::make_shared<Coordinates>(x, ey)); |
242 | 242 | } |
243 | 243 | |
244 | - this->GetSquare(*wallVec[Dice::Rand0(wallVec.size())].get())->SetFloorTag(dungeonPtr->GetFloorFloorTag()); | |
244 | + this->GetSquare(*wallVec[Dice::Rand0(wallVec.size())].get())->SetFloor(dungeonPtr->GetFloorFloorTag()); | |
245 | 245 | } |
246 | 246 | |
247 | 247 | void Field::createRectRoom(Coordinates& leftTop, Coordinates& rightBottom) |
@@ -28,6 +28,9 @@ namespace Deeangband | ||
28 | 28 | GameElement::GameSurfacePtr = gameSurface; |
29 | 29 | GameElement::GameLoggerPtr = gameLogger; |
30 | 30 | |
31 | + Dice::Initialize(); | |
32 | + gameWorld->Initialize(); | |
33 | + | |
31 | 34 | gameSurface->SetField(gameWorld->GetField(0)); |
32 | 35 | gameSurface->SetSideStatusCreature(gameWorld->GetCreature(0)); |
33 | 36 | this->gameLogger->PutLog("GameEngine開始"); |
@@ -49,11 +49,7 @@ namespace Deeangband | ||
49 | 49 | |
50 | 50 | GameWorld::GameWorld(void) |
51 | 51 | { |
52 | - int i; | |
53 | - Dice::Initialize(); | |
54 | 52 | XMLLoad(); |
55 | - std::map<ID, boost::shared_ptr<Field>>::iterator fieldIt; | |
56 | - std::map<TAG, boost::shared_ptr<Species>>::iterator speciesIt; | |
57 | 53 | |
58 | 54 | this->itemID = 0; |
59 | 55 | this->trapID = 0; |
@@ -61,6 +57,13 @@ namespace Deeangband | ||
61 | 57 | this->fieldID = 0; |
62 | 58 | this->gameTime = 0; |
63 | 59 | |
60 | + } | |
61 | + | |
62 | + void GameWorld::Initialize(void) | |
63 | + { | |
64 | + int i; | |
65 | + std::map<ID, boost::shared_ptr<Field>>::iterator fieldIt; | |
66 | + std::map<TAG, boost::shared_ptr<Species>>::iterator speciesIt; | |
64 | 67 | fieldList.emplace(0, boost::make_shared<Field>(dungeonList.find("VANILLA_WOMB"), 1)); |
65 | 68 | fieldIt = fieldList.find(0); |
66 | 69 |
@@ -70,15 +73,14 @@ namespace Deeangband | ||
70 | 73 | speciesIt = speciesList.find("VANILLA_RAVING_LUNATIC"); |
71 | 74 | GameWorld::GenerateCreature(speciesIt, fieldIt, 5, 5); |
72 | 75 | |
73 | - | |
74 | 76 | for(i = 0; i < MAX_KARMAS; i++) |
75 | 77 | { |
76 | 78 | karmaList.emplace("VANILLA_", boost::make_shared<Karma>()); |
77 | 79 | } |
78 | - | |
79 | 80 | playerIt = creatureList.begin()++; |
80 | 81 | } |
81 | 82 | |
83 | + | |
82 | 84 | GameWorld::~GameWorld(void) |
83 | 85 | { |
84 | 86 | } |
@@ -305,17 +305,23 @@ namespace Deeangband | ||
305 | 305 | public: |
306 | 306 | |
307 | 307 | /*! |
308 | - * @brief GameWorldクラスのコンストラクタ | |
309 | - * @param gSurface ゲームのインターフェイスとなる GameSurface 参照 | |
310 | - */ | |
308 | + * @brief GameWorldクラスのコンストラクタ | |
309 | + * @param gSurface ゲームのインターフェイスとなる GameSurface 参照 | |
310 | + */ | |
311 | 311 | GameWorld::GameWorld(void); |
312 | 312 | |
313 | 313 | /*! |
314 | - * @brief GameWorldクラスのデストラクタ | |
315 | - */ | |
314 | + * @brief GameWorldクラスのデストラクタ | |
315 | + */ | |
316 | 316 | GameWorld::~GameWorld(void); |
317 | 317 | |
318 | 318 | /*! |
319 | + * @brief ゲーム世界の初期生成を行う | |
320 | + */ | |
321 | + void GameWorld::Initialize(void); | |
322 | + | |
323 | + | |
324 | + /*! | |
319 | 325 | * @brief クリーチャーを生成しGameWorld中の諸要素と連携させる |
320 | 326 | * @param creatureTag クリーチャータグ |
321 | 327 | * @return 生成に成功した場合trueを返す |
@@ -52,9 +52,10 @@ namespace Deeangband | ||
52 | 52 | return this->spaceTag; |
53 | 53 | } |
54 | 54 | |
55 | - bool Square::SetFloorTag(TAG tag) | |
55 | + bool Square::SetFloor(TAG tag) | |
56 | 56 | { |
57 | 57 | this->floorTag = tag; |
58 | + this->floorPtr = GameElement::GameWorldPtr->GetFloorList()->operator[](tag).get(); | |
58 | 59 | return true; |
59 | 60 | } |
60 | 61 |
@@ -70,7 +70,7 @@ namespace Deeangband | ||
70 | 70 | * @return タグの変更ができた場合trueを返す。 |
71 | 71 | * @todo 正規のタグかどうか判定する機能を実装する。 |
72 | 72 | */ |
73 | - bool Square::SetFloorTag(TAG tag); | |
73 | + bool Square::SetFloor(TAG tag); | |
74 | 74 | |
75 | 75 | /*! |
76 | 76 | * @brief 対応する床地形のタグを返す。 |