本文整理汇总了C++中Section::GetRoom方法的典型用法代码示例。如果您正苦于以下问题:C++ Section::GetRoom方法的具体用法?C++ Section::GetRoom怎么用?C++ Section::GetRoom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::GetRoom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Section::operator=(Section const& section)
{
delete myComponent;
delete room;
myComponent = new Component;
room = new Rect;
*myComponent = section.GetComponent();
*room = section.GetRoom();
roomConnected = section.GetConnectedRooms();
groupId = section.groupId;
hasRoom = section.hasRoom;
hasPath = section.hasPath;
}
示例2: MakePath
void MysteryDungeonMaker::MakePath()
{
//ステップ1(部屋のあるセクションの上下左右をチェック)
int sectionRowNum=dungeonSize->DungeonRowNum();
int sectionColumnNum=dungeonSize->DungeonColumnNum();
for (int i = 0; i < sectionRowNum; i++)
{
for (int j = 0; j < sectionColumnNum; j++)
{
if (sections[i][j].HasRoom())
{
for (int k = 0; k < 4; ++k)
{
int i_rota=i+up_down[k];
int j_rota=j+right_left[k];
if ((0 <= i_rota && i_rota < sectionRowNum) && (0 <= j_rota && j_rota < sectionColumnNum))
{
if (sections[i_rota][j_rota].HasRoom())
{
ConnectAdjacentRoom(§ions[i][j], §ions[i_rota][j_rota]);
}
}
}
}
}
}
//ステップ2(部屋のないセクションの上下左右をチェック)
for (int i = 0; i < sectionRowNum; i++)
{
for (int j = 0; j < sectionColumnNum; j++)
{
if ( ! sections[i][j].HasRoom())
{
std::vector<Section*> aroundSections;
for (int k = 0; k < 4; ++k)
{
int i_rota = i + up_down[k];
int j_rota = j + right_left[k];
if ((0 <= i_rota && i_rota < sectionRowNum) && (0 <= j_rota && j_rota < sectionColumnNum))
{
if (sections[i_rota][j_rota].HasRoom())
aroundSections.push_back(§ions[i_rota][j_rota]);
}
}
if (aroundSections.size() == 2)
{
if( ! aroundSections[0]->isConnectedTo(*aroundSections[1]))
{
MakeRoom(Component(i, j), 1, 1);
ConnectAdjacentRoom(§ions[i][j], aroundSections[0]);
ConnectAdjacentRoom(§ions[i][j], aroundSections[1]);
RemoveRoom(sections[i][j].GetRoom());
sections[i][j].SetHasPath(true);
}
}
}
}
}
//ステップ3
std::vector<std::vector<Section*>> groups = ClassifyGroups();
std::vector<Component>route;
while (groups.size() > 1)
{
DungeonMakerHelper::SortByGroupSize(&groups);
for (size_t i = 0; i < groups[0].size(); i++)
{
route = SearchShortestRoute(*groups[0][i]);
if ( ! route.empty())
break;
}
if (!route.empty())
{
Component goal = route[route.size() - 1];
for (size_t i = 0; i < route.size() - 1; i++)
{
if (route[i+1] != goal)
MakeRoom(route[i + 1], 1, 1);
Section* sectionMadeRoom = §ions[route[i + 1].i][route[i + 1].j];
ConnectAdjacentRoom(§ions[route[i].i][route[i].j], sectionMadeRoom);
}
for (size_t i = 1; i < route.size() - 1; i++)
{
Section* roomRemoved = §ions[route[i].i][route[i].j];
RemoveRoom(roomRemoved->GetRoom());
roomRemoved->SetHasPath(true);
}
}
ResetGroupId();
groups = ClassifyGroups();
}
}