コード例 #1
0
ファイル: RulesIO.cs プロジェクト: Mathig/Resource_Generator
 /// <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, GenerateRules rules)
 {
     using (StreamWriter file = new StreamWriter(fileName + ".xml", false))
     {
         var ruleType   = rules.GetType();
         var serializer = new XmlSerializer(typeof(GenerateRules));
         serializer.Serialize(file, rules);
     }
 }
コード例 #2
0
 /// <summary>
 /// Sets up Dendritic Point class's static variables using <see cref="GenerateRules"/>.
 /// </summary>
 /// <param name="rules">Rules to set up with.</param>
 public static void Setup(GenerateRules rules)
 {
     _stepCount = rules.xHalfSize > rules.ySize
         ? _stepMultiplier * 2 * rules.xHalfSize
         : _stepMultiplier * 2 * rules.ySize;
     _stepSize      = _stepMultiplier * Math.PI / _stepCount;
     _pointCount    = rules.DendritePointCount;
     _stepThreshold = rules.DendriticStepThreshold;
     DendriticShape.MapSetup(rules.xHalfSize, rules.ySize, rules.DendriteDirectionCount);
 }
コード例 #3
0
 /// <summary>
 /// Starts up and allocates data arrays.
 /// </summary>
 /// <param name="inRules">Rules to use for constructing data.</param>
 private static void ConstructData(GenerateRules inRules)
 {
     rules = inRules;
     BasePoint.MapSetup(rules.xHalfSize, rules.ySize);
     pointMap        = new BasePoint[2 * rules.xHalfSize, rules.ySize];
     pointMagnitudes = new double[2 * rules.xHalfSize, rules.ySize];
     pointActives    = new bool[2 * rules.xHalfSize, rules.ySize];
     platePoints     = new List <KeyPoint> [rules.plateCount];
     for (int i = 0; i < rules.plateCount; i++)
     {
         platePoints[i] = new List <KeyPoint>();
     }
     Parallel.For(0, (2 * rules.xHalfSize), (x) =>
     {
         for (int y = 0; y < rules.ySize; y++)
         {
             pointMap[x, y] = new BasePoint(x, y);
         }
     });
 }
コード例 #4
0
 /// <summary>
 /// Finally deallocate data.
 /// </summary>
 private static void DeconstructData()
 {
     rules       = null;
     platePoints = null;
 }