Beispiel #1
0
 /// <summary>
 /// Saves rules to given file location.
 /// </summary>
 /// <param name="fileName">File to save to, not including extension.</param>
 /// <param name="rules">Rules to save.</param>
 public static void Save(string fileName, AltitudeMapRules rules)
 {
     using (StreamWriter file = new StreamWriter(fileName + ".xml", false))
     {
         var ruleType   = rules.GetType();
         var serializer = new XmlSerializer(typeof(AltitudeMapRules));
         serializer.Serialize(file, rules);
     }
 }
        /// <summary>
        /// Generates a height map given an array of points and rules for how to do so.
        /// </summary>
        /// <param name="pointMap">Points to base height map off of.</param>
        /// <param name="inRules">Rules for generating points.</param>
        /// <returns>Height map to generate.</returns>
        public static double[,] Run(PlatePoint[,] pointMap, AltitudeMapRules inRules)
        {
            rules     = inRules;
            heightMap = new double[pointMap.GetLength(0), pointMap.GetLength(1)];
            var randomNumber = new Random();

            for (int x = 0; x < pointMap.GetLength(0); x++)
            {
                for (int y = 0; y < pointMap.GetLength(1); y++)
                {
                    heightMap[x, y] = GetHeight(pointMap[x, y], randomNumber.NextDouble());
                }
            }
            return(heightMap);
        }