D'angband  0.0.0
Deeangband
 全て クラス 名前空間 ファイル 関数 変数 型定義 列挙型 列挙値 フレンド マクロ定義 ページ
Field.cpp
[詳解]
1 
9 #include "stdafx.h"
10 #include "Field.h"
11 
12 namespace Deeangband
13 {
14 
15  Field::Field(std::map<TAG, boost::shared_ptr<Dungeon>>::iterator dungeonIt, DEPTH depth) : GameInstance()
16  {
17  Dungeon *dungeonPtr = &(*dungeonIt->second);
18  int x, y;
19  this->dungeonTag = dungeonIt->first;
20  this->width = dungeonPtr->GetBaseSize().GetX();
21  this->height = dungeonPtr->GetBaseSize().GetY();
22  this->generated = false;
23 
24  if(depth > dungeonPtr->GetMaxDepth() || depth > dungeonPtr->GetMinDepth()) return;
25 
26  squares.resize(this->height);
27  for(y = 0; y < height; y++)
28  {
29  for(x = 0; x < width; x++)
30  {
31  squares[y].push_back(boost::shared_ptr<Square>(new Square()));
32  if(Dice::Cast(1, 2) == 2) squares[y][x]->SetFloorTag(dungeonPtr->GetInnerWallFloorTag());
33  else squares[y][x]->SetFloorTag(dungeonPtr->GetFloorFloorTag());
34  }
35  }
36 
37  creatures.resize(0);
38  doors.resize(0);
39  traps.resize(0);
40  items.resize(0);
41 
42  this->generated = true;
43  }
44 
45  Field::Field()
46  {
47  WipeData();
48  }
49 
50  Field::‾Field()
51  {
52  WipeData();
53  }
54 
55  void Field::WipeData(void)
56  {
57  this->width = 0;
58  this->height = 0;
59  this->dungeonTag = "";
60  creatures.resize(0);
61  doors.resize(0);
62  traps.resize(0);
63  items.resize(0);
64  }
65 
66  MAP_LENGTH Field::GetWidth(void)
67  {
68  return width;
69  }
70 
71  MAP_LENGTH Field::GetHeight(void)
72  {
73  return height;
74  }
75 
76  bool Field::SetSize(MAP_LENGTH width, MAP_LENGTH height)
77  {
78  this->width = width;
79  this->height = height;
80  return true;
81  }
82 
83  Square *Field::GetSquare(MAP_LENGTH x, MAP_LENGTH y)
84  {
85  return &(*(squares[x][y]));
86  }
87 
88  bool Field::GenerateTrap(std::map<TAG, boost::shared_ptr<TrapBase>>::iterator trapBaseIt, Coordinates *position)
89  {
90  traps.emplace(traps.end(), boost::make_shared<Trap>(trapBaseIt, position));
91  return true;
92  }
93 
94 }
TAG dungeonTag
生成元ダンジョンタグ
Definition: Field.h:41
std::string TAG
ゲーム要素文字列ID
Definition: Deeangband.h:144
std::vector< boost::shared_ptr< Door > > doors
ドアインスタンスの配列
Definition: Field.h:35
std::vector< boost::shared_ptr< Creature > > creatures
クリーチャーインスタンスの配列
Definition: Field.h:34
MAP_LENGTH width
フロアの横サイズ
Definition: Field.h:38
int DEPTH
階層深度
Definition: Deeangband.h:150
標準のシステム インクルード ファイルのインクルード ファイル、または 参照回数が多く、かつあまり変更さ...
std::vector< std::vector< boost::shared_ptr< Square > > > squares
フロアマスの配列
Definition: Field.h:33
int MAP_LENGTH
マップ距離
Definition: Deeangband.h:154
ゲーム中のダンジョンと付随要素のプロトタイプ
MAP_LENGTH height
フロアの縦サイズ
Definition: Field.h:39
std::vector< boost::shared_ptr< Item > > items
アイテムインスタンスの配列
Definition: Field.h:37
std::vector< boost::shared_ptr< Trap > > traps
トラップインスタンスの配列
Definition: Field.h:36