3 * @brief
\83Q
\81[
\83\80\92\86\82Ì
\83t
\83\8d\83A
\82ð
\92è
\8b`
\82·
\82é
15 Field::Field(std::map<TAG, boost::shared_ptr<Dungeon>>::iterator dungeonIt, DEPTH depth) : GameInstance()
17 Dungeon *dungeonPtr = &(*dungeonIt->second);
19 this->dungeonTag = dungeonIt->first;
20 this->width = dungeonPtr->GetBaseSize().GetX();
21 this->height = dungeonPtr->GetBaseSize().GetY();
22 this->generated = false;
24 if(depth > dungeonPtr->GetMaxDepth() || depth > dungeonPtr->GetMinDepth()) return;
26 squares.resize(this->height);
27 for(y = 0; y < height; y++)
29 for(x = 0; x < width; x++)
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());
42 this->generated = true;
55 void Field::WipeData(void)
59 this->dungeonTag = "";
66 MAP_LENGTH Field::GetWidth(void)
71 MAP_LENGTH Field::GetHeight(void)
76 bool Field::SetSize(MAP_LENGTH width, MAP_LENGTH height)
79 this->height = height;
83 Square *Field::GetSquare(MAP_LENGTH x, MAP_LENGTH y)
85 //! @note
\83t
\83B
\81[
\83\8b\83h
\82Ì
\94Í
\88Í
\8aO
\82Ì
\8dÀ
\95W
\82Ì
\8fê
\8d\87false
\82ð
\95Ô
\82·
\81B
86 if(x < 0 || y < 0 || x >= this->width || y >= this->height) return NULL;
87 return &(*(squares[x][y]));
90 bool Field::GenerateTrap(std::map<TAG, boost::shared_ptr<TrapBase>>::iterator trapBaseIt, Coordinates *position)
92 traps.emplace(traps.end(), boost::make_shared<Trap>(trapBaseIt, position));
96 bool Field::HaveSight(int bx, int by, int tx, int ty)
98 std::vector<Coordinates> coordVec;
99 std::vector<Coordinates>::iterator coordIt;
101 if(bx < 0 || by < 0 || tx < 0 || ty < 0) return false;
102 if(bx >= this->GetWidth() || by >= this->GetHeight() || tx >= this->GetWidth() || ty >= this->GetHeight()) return false;
104 Coordinates::LineOfSight(coordVec, bx, by, tx, ty);
105 for(coordIt = coordVec.begin(); coordIt != coordVec.end(); coordIt++)
107 if(bx == coordIt->GetX() && by == coordIt->GetY()) continue;
108 if(tx == coordIt->GetX() && ty == coordIt->GetY()) continue;
109 if(this->GetSquare(coordIt->GetX(), coordIt->GetY())->GetFloorTag() == "VANILLA_PERMANENT_WALL") return false;