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


C# Maze.Digging方法代码示例

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


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

示例1: GenerateTiles

    private void GenerateTiles()
    {
        for (int i = 0; i< this.tiles.Length; i++) {
            Tile tile = new Tile();
            tile.SetPosition(new Position(i % this.width, i / this.width));
            tiles[i] = tile;
        }

        for(int i=0; i<1000 && rooms.Count <= this.roomCount; i++)
        {
            int x = Random.Range(1, this.width - Room.MAX_SIZE - 1);
            int w = Random.Range(Room.MIN_SIZE, Room.MAX_SIZE);
            int y = Random.Range(1, this.height - Room.MAX_SIZE - 1);
            int h = Random.Range(Room.MIN_SIZE, Room.MAX_SIZE);
            Room room = new Room (this, x, x + w, y, y + h);
            room.Digging ();
        }

        for (int y=1; y<height-1; y++) {
            for (int x=1; x<width-1; x++) {
                if(1 == x%2 && 1 == y%2 && 0 == GetTileGroupID(x, y)) {
                    Maze maze = new Maze (this);
                    maze.Digging (Maze.DirectionType.West, x, y);
                }
            }
        }

        foreach (Room room in rooms) {
            room.Connect();
        }

        bool delete = true;
        while(delete) {
            delete = false;
            for (int y=1; y<height-1; y++) {
                for (int x=1; x<width-1; x++) {
                    if(0 != GetTileGroupID(x, y))
                    {
                        int count = 0;
                        for (int dy = -1; dy <= 1; dy += 2)
                        {
                            if (0 == GetTileGroupID(x, y + dy))
                            {
                                count++;
                            }
                        }
                        for (int dx = -1; dx <= 1; dx += 2)
                        {
                            if (0 == GetTileGroupID(x + dx, y))
                            {
                                count++;
                            }
                        }

                        if(3 <= count)
                        {
                            tiles_[x + y * width] = 0;
                            delete = true;
                        }
                    }
                }
            }
        }

        for (int y=0; y<height; y++) {
            for (int x=0; x<width; x++) {
                if(0 == this.GetTileGroupID(x, y))
                {
                    int count = 0;
                    count += GetTileGroupID(x-1, y-1);
                    count += GetTileGroupID(x, y-1);
                    count += GetTileGroupID(x+1, y-1);
                    count += GetTileGroupID(x+1, y);
                    count += GetTileGroupID(x+1, y+1);
                    count += GetTileGroupID(x, y+1);
                    count += GetTileGroupID(x-1, y+1);
                    count += GetTileGroupID(x-1, y);

                    if(0 != count)
                    {
                        Wall wall = new Wall();
                        wall.SetPosition(new Position(x, y));
                    }
                }
            }
        }

        start = rooms [root ["start_room"].AsInt].GetRandomPosition ();
    }
开发者ID:ChoiIngon,项目名称:Rpg1994,代码行数:89,代码来源:Dungeon.cs


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