示例#1
0
        public void BuildRiver(IList<IRegion> regions)
        {
            IRegion firstRegion = regions.First();

            int firstTile = new Random().Next(0, 9);

            Position position = new Position(0, firstTile);

            this.ConvertToWaterTile(firstRegion, 0, firstTile);

            // "east", "north", "south"

            ITile[,] tiles = this.ConvertRegions(regions);

            foreach(River river in this._rivers)
            {
                foreach (Direction direction in river.Directions)
                {
                    if (direction == Direction.North)
                    {
                        position.Y = position.Y - 1;
                    }

                    if (direction == Direction.South)
                    {
                        position.Y = position.Y + 1;
                    }

                    if (direction == Direction.East)
                    {
                        position.X = position.X + 1;
                    }

                    if (direction == Direction.West)
                    {
                        position.X = position.X - 1;
                    }

                    //if (position.X >= 0 && position.X < tiles.Length && position.Y >= 0 && position.Y < tiles.Length)
                    //{
                        IRegion region = this.GetRegion(regions, position.X, position.Y);
                        ITile tile = tiles[position.X, position.Y];

                        this.ConvertToWaterTile(region, tile.Position.X, tile.Position.Y);
                    //}
                }
            }
        }
示例#2
0
        public IList<IRegion> GetRegions(int topLeftX, int topLeftY, int topRightX, int topRightY, int bottomLeftX, int bottomLeftY, int bottomRightX, int bottomRightY, IList<int> exclude)
        {
            IPosition topLeft = new Position(topLeftX, topLeftY);
            IPosition topRight = new Position(topRightX, topRightY);
            IPosition bottomLeft = new Position(bottomLeftX, bottomLeftY);
            IPosition bottomRight = new Position(bottomRightX, bottomRightY);

            return this._regionRepository.GetRegions(topLeft, topRight, bottomLeft, bottomRight, exclude);
        }