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


C# QuadTree.HasChildren方法代码示例

本文整理汇总了C#中QuadTree.HasChildren方法的典型用法代码示例。如果您正苦于以下问题:C# QuadTree.HasChildren方法的具体用法?C# QuadTree.HasChildren怎么用?C# QuadTree.HasChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QuadTree的用法示例。


在下文中一共展示了QuadTree.HasChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateGridOnTreeQuad

    private void GenerateGridOnTreeQuad(QuadTree _quadtree)
    {
        if (_quadtree.HasChildren() == false) {

            for (int y = _quadtree.boundary.BottomTile(); y <= _quadtree.boundary.TopTile() - 1; y++) {
                for (int x = _quadtree.boundary.LeftTile(); x <= _quadtree.boundary.RightTile() - 1; x++) {
                    // get dungeon tile on the quadtree zone
                    DungeonTile dtile = generator.tiles[y, x];

                    // set render color
                    Color color = _quadtree.color;

                    // create floors
                    if (dtile.id == DungeonTileType.ROOM || dtile.id == DungeonTileType.CORRIDOR ||
                        dtile.id == DungeonTileType.DOORH || dtile.id == DungeonTileType.DOORV) {
                        grid.CreateTile(x, y, TileTypes.Floor, color);
                    }

                    // create walls
                    if (dtile.id == DungeonTileType.WALL || dtile.id == DungeonTileType.WALLCORNER) {
                        float d = 0.9f;
                        Color wallColor = new Color(color.r * d, color.g * d, color.b * d, 1f);
                        grid.CreateTile(x, y, TileTypes.Floor, wallColor);
                        grid.CreateObstacle(x, y, ObstacleTypes.Wall, wallColor);
                    }

                    // create doors
                    if (dtile.id == DungeonTileType.DOORH) {
                        grid.CreateDoor(x, y, DoorTypes.Wood, DoorStates.Closed, DoorDirections.Horizontal);
                    }

                    if (dtile.id == DungeonTileType.DOORV) {
                        grid.CreateDoor(x, y, DoorTypes.Wood, DoorStates.Closed, DoorDirections.Vertical);
                    }
                }
            }
        } else {
            // Keep iterating on the quadtree
            GenerateGridOnTreeQuad(_quadtree.northWest);
            GenerateGridOnTreeQuad(_quadtree.northEast);
            GenerateGridOnTreeQuad(_quadtree.southWest);
            GenerateGridOnTreeQuad(_quadtree.southEast);
        }
    }
开发者ID:snaptothegrid,项目名称:Tilebase,代码行数:44,代码来源:DungeonRenderer.cs

示例2: GenerateQuadTree

    public void GenerateQuadTree(QuadTree quadtree)
    {
        if (quadtree.HasChildren() == false) {

            for (int y = quadtree.boundary.BottomTile(); y <= quadtree.boundary.TopTile() - 1; y++) {
                for (int x = quadtree.boundary.LeftTile(); x <= quadtree.boundary.RightTile() - 1; x++) {
                    // get dungeon tile on the quadtree zone
                    DungeonTile dtile = dungeonGenerator.tiles[y, x];

                    // In case we want to use different color in each quadtree zone...
                    //Color color = quadtree.color;

                    // create floors
                    if (dtile.id == DungeonTileType.ROOM || dtile.id == DungeonTileType.CORRIDOR ||
                        dtile.id == DungeonTileType.DOORH || dtile.id == DungeonTileType.DOORV) {

                        Sprite asset = floorAsset;;
                        if (floorAsset == null) {
                            asset = Resources.Load<Sprite>("Tilesets/Dungeon/Floor/floor-" + Random.Range(1, 5));
                        }

                        Floor floor = (Floor)grid.CreateTile(typeof(Floor), x, y, 1, asset) as Floor;
                        floor.SetColor(floorColor, true);
                        //floor.SetColor(quadtree.color, true);

                        // set room info in floor tile
                        if (dtile.room != null) {
                            floor.roomId = dtile.room.id;
                        }
                    }

                    // create walls
                    if (dtile.id == DungeonTileType.WALL || dtile.id == DungeonTileType.WALLCORNER) {
                        grid.CreateTile(typeof(Tile), x, y, 1, null);

                        Sprite asset = wallAsset;;
                        if (wallAsset == null) {
                            asset = Resources.Load<Sprite>("Tilesets/Dungeon/Wall/stone-" + Random.Range(1, 5));
                        }

                        Wall wall = (Wall)grid.CreateEntity(typeof(Wall), x, y, 1, asset) as Wall;
                        wall.SetColor(wallColor, true);
                    }

                    // create doors
                    if (dtile.id == DungeonTileType.DOORH || dtile.id == DungeonTileType.DOORV) {
                        Door door = (Door)grid.CreateEntity(typeof(Door), x, y, 1, null) as Door;
                        EntityStates[] states = new EntityStates[] {
                            EntityStates.Open, EntityStates.Closed, EntityStates.Locked
                        };
                        door.SetState(states[Random.Range(0, states.Length)]);
                    }
                }
            }
        } else {
            // Keep iterating on the quadtree
            GenerateQuadTree(quadtree.northWest);
            GenerateQuadTree(quadtree.northEast);
            GenerateQuadTree(quadtree.southWest);
            GenerateQuadTree(quadtree.southEast);
        }
    }
开发者ID:snaptothegrid,项目名称:Tiler,代码行数:62,代码来源:ArchitectureGenerator.cs


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