예제 #1
0
        public void RemoveRoad(IsometricMapComponent map, Point location)
        {
            if (Built.ContainsKey(location))
            {
                Built.Remove(location);
            }

            //UpdateNeighbors(map, location);
        }
예제 #2
0
        private string GetRoadValue(IsometricMapComponent map, Point location)
        {
            // set the value of the location to index of the type of road at this location
            bool NW = false;
            bool NE = false;
            bool SE = false;
            bool SW = false;

            if (map.IsValidIndex(location.X - 1, location.Y))
            {
                NW = Built.ContainsKey(new Point(location.X - 1, location.Y));
            }

            if (map.IsValidIndex(location.X, location.Y - 1))
            {
                NE = Built.ContainsKey(new Point(location.X, location.Y - 1));
            }

            if (map.IsValidIndex(location.X + 1, location.Y))
            {
                SE = Built.ContainsKey(new Point(location.X + 1, location.Y));
            }

            if (map.IsValidIndex(location.X, location.Y + 1))
            {
                SW = Built.ContainsKey(new Point(location.X, location.Y + 1));
            }

            // 1 combo of 4
            if (NW && NE && SE && SW)
            {
                return("fourway");
            }

            // four different combos of 3
            else if (NW && NE && SE)
            {
                return("ne-threeway");
            }
            else if (NW && NE && SW)
            {
                return("nw-threeway");
            }
            else if (NW && SE && SW)
            {
                return("sw-threeway");
            }
            else if (NE && SE && SW)
            {
                return("se-threeway");
            }

            // 6 combos of 2
            else if (SW && SE)
            {
                return("bottom-corner");
            }
            else if (NW && SW)
            {
                return("left-corner");
            }
            else if (NW && NE)
            {
                return("top-corner");
            }
            else if (NE && SE)
            {
                return("right-corner");
            }
            else if (SW && NE)
            {
                return("diagonal-up");
            }
            else if (NW && SE)
            {
                return("diagonal-down");
            }

            // 4 combos of 1
            else if (SW)
            {
                return("sw-endpoint");
            }
            else if (NW)
            {
                return("nw-endpoint");
            }
            else if (NE)
            {
                return("ne-endpoint");
            }
            else if (SE)
            {
                return("se-endpoint");
            }

            // 1 cobmo of 0
            else
            {
                return("single");
            }
        }