当前位置: 首页>>代码示例>>C#>>正文


C# Room.SetProtect方法代码示例

本文整理汇总了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);
                     }
                 }
             }
         }
     }
 }
开发者ID:giginet,项目名称:PanicColony,代码行数:32,代码来源:LevelManager.cs

示例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]);
         }
     }
 }
开发者ID:giginet,项目名称:PanicColony,代码行数:14,代码来源:LevelManager.cs


注:本文中的Room.SetProtect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。