コード例 #1
0
        /// <summary>
        /// returns which side of map is closer to point - north, south, etc
        /// </summary>
        public static WorldSide getSideOfWorld(Vector2 point)
        {
            // find to which border it's closer
            WorldSide side        = null;
            float     distToWest  = Math.Abs(0f - point.x);
            float     distToEast  = Math.Abs(1f - point.x);
            float     distToSouth = Math.Abs(0f - point.y);
            float     distToNorth = Math.Abs(1f - point.y);

            if (distToEast == Math.Min(Math.Min(Math.Min(distToWest, distToEast), distToNorth), distToSouth))
            {
                side = WorldSide.East;
            }
            else if (distToWest == Math.Min(Math.Min(Math.Min(distToWest, distToEast), distToNorth), distToSouth))
            {
                side = WorldSide.West;
            }
            else if (distToSouth == Math.Min(Math.Min(Math.Min(distToWest, distToEast), distToNorth), distToSouth))
            {
                side = WorldSide.South;
            }
            else if (distToNorth == Math.Min(Math.Min(Math.Min(distToWest, distToEast), distToNorth), distToSouth))
            {
                side = WorldSide.North;
            }

            return(side);
        }
コード例 #2
0
        public void RemoveOcean(Vector2 point)
        {
            var side = WorldSide.getSideOfWorld(point);

            if (oceans.Contains(side))
            {
                oceans.Remove(side);
                terrainField.ChangeValue(new Vector4(oceanDepth, 0f, 0f, 0f), side.getPartOfMap(oceanWidth));
            }
        }
コード例 #3
0
        public void AddOcean(Vector2 point)
        {
            var side = WorldSide.getSideOfWorld(point);

            if (!oceans.Contains(side))
            {
                oceans.Add(side);
                //// clear ocean bottom
                terrainField.ChangeValue(new Vector4(oceanDepth * -1f, 0f, 0, 0f), side.getPartOfMap(oceanWidth));
            }
        }