Esempio n. 1
0
 Transform PickPrefab(HexFeatureCollection[] collection, int level, float hash, float choice)
 {
     if (level > 0)
     {
         float[] thresholds = HexMetrics.GetFeatureThresholds(level - 1);
         for (int i = 0; i < thresholds.Length; i++)
         {
             if (hash < thresholds[i])
             {
                 return(collection[i].Pick(choice));
             }
         }
     }
     return(null);
 }
Esempio n. 2
0
 public Transform PickFeaturePrefab(HexFeatureCollection[] collections, int level, float hash, float choice)
 {
     if (level > 0)
     {
         float[] chances = HexMetrics.GetFeatureThresholds(level - 1);
         for (int i = 0; i < chances.Length; ++i)
         {
             if (hash < chances[i])
             {
                 return(collections[i].Pick(choice));
             }
         }
     }
     return(null);
 }
        public void featureTresholdsTest()
        {
            float[] expected1 = new float[] { 0.0f, 0.0f, 0.4f };
            float[] expected2 = new float[] { 0.0f, 0.4f, 0.6f };
            float[] expected3 = new float[] { 0.4f, 0.6f, 0.8f };
            int     level     = 0;

            float[] actual1 = HexMetrics.GetFeatureThresholds(level);
            level = 1;
            float[] actual2 = HexMetrics.GetFeatureThresholds(level);
            level = 2;
            float[] actual3 = HexMetrics.GetFeatureThresholds(level);
            Assert.AreEqual(expected1, actual1);
            Assert.AreEqual(expected2, actual2);
            Assert.AreEqual(expected3, actual3);
        }