本文整理汇总了C#中Room.SetProtect方法的典型用法代码示例。如果您正苦于以下问题:C# Room.SetProtect方法的具体用法?C# Room.SetProtect怎么用?C# Room.SetProtect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room.SetProtect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRooms
private void CreateRooms()
{
for (int x = 0; x < this.level.GetWidth(); ++x) {
for (int y = 0; y < this.level.GetHeight(); ++y) {
if (this.level.IsFloor(x, y)) {
if ( !level.ContainsInRooms(x, y) ) {
Room room = new Room();
this.level.AddRoom(room);
this.AddNeighborRoom(room, x, y);
Vector3 center = this.MatrixToPosition(room.GetCenter());
GameObject lightPrefab = (GameObject)Resources.Load ("Prefabs/roomLightPrefab", typeof(GameObject));
GameObject light = (GameObject)Instantiate (lightPrefab, center + Vector3.up * 10, Quaternion.identity);
light.transform.parent = levelObject.transform;
foreach (Vector2 point in room.GetFloors()) {
Vector2[] neighbors = {point + Vector2.up, point + -Vector2.up, point + Vector2.right, point + -Vector2.right,
point + Vector2.one, point - Vector2.one, point + Vector2.up - Vector2.right, -Vector2.up + Vector2.right
};
foreach (Vector2 neighbor in neighbors) {
if (this.level.IsWall((int)neighbor.x, (int)neighbor.y)) {
room.AddWalls(neighbor);
}
}
}
// make start room as protected.
if (this.level.IsStartUnit(room) ){
room.SetProtect(true);
}
}
}
}
}
}
示例2: AddNeighborRoom
private void AddNeighborRoom(Room room, int x, int y)
{
room.AddFloor(x, y);
if (this.level.GetCharMap()[new Vector2((int)x, (int)y)] == '*') {
room.SetProtect(true);
}
int[] xs = {x + 1, x - 1, x, x};
int[] ys = {y, y, y + 1, y - 1};
for (int i = 0; i < 4; ++i) {
if (this.level.IsFloor(xs[i], ys[i]) && !this.level.ContainsInRooms(xs[i], ys[i])) {
this.AddNeighborRoom(room, xs[i], ys[i]);
}
}
}