Пример #1
0
        public TypeTester(Map map, int row, int column)
        {
            Elevations = new int[9];

            Elevations[0] = map.GetTopLeft(row, column).Elevation;
            Elevations[1] = map.GetTop(row, column).Elevation;
            Elevations[2] = map.GetTopRight(row, column).Elevation;
            Elevations[3] = map.GetLeft(row, column).Elevation;
            Elevations[4] = map.Tiles[row, column].Elevation;
            Elevations[5] = map.GetRight(row, column).Elevation;
            Elevations[6] = map.GetBottomLeft(row, column).Elevation;
            Elevations[7] = map.GetBottom(row, column).Elevation;
            Elevations[8] = map.GetBottomRight(row, column).Elevation;

            this.NullElevation = map.NullHeight;
        }
Пример #2
0
        private bool ProcessVertical(ref Map map)
        {
            var success = true;
            for (int column = 0; column < map.Width; column++)
            {
                for (int row = 0; row < map.Width; row++)
                {
                    var tile = map.Tiles[row, column];

                    var top = map.GetTop(row, column);
                    var bottom = map.GetBottom(row, column);

                    if (top.Elevation < tile.Elevation && bottom.Elevation < tile.Elevation)
                    {
                        // must deal with null heights.

                        if (top.Elevation == map.NullHeight)
                        {
                            tile.Elevation = (bottom.Elevation == map.NullHeight) ? map.NullHeight : bottom.Elevation;
                        }
                        else if (bottom.Elevation == map.NullHeight)
                        {
                            tile.Elevation = top.Elevation;
                        }
                        else
                        {
                            tile.Elevation = Convert.ToInt32(Math.Floor((top.Elevation + bottom.Elevation) / 2.0));
                        }

                        success = false;
                    }

                    if (top.Elevation > tile.Elevation && bottom.Elevation > tile.Elevation)
                    {
                        tile.Elevation = Convert.ToInt32(Math.Ceiling((top.Elevation + bottom.Elevation) / 2.0));
                        success = false;
                    }
                }
            }

            return success;
        }