Beispiel #1
0
 /// <summary>
 /// Checks all rules in the rule list.
 /// </summary>
 /// <param name="hex">Hex to compare the rules upon</param>
 /// <param name="rule">Rules to check</param>
 /// <param name="tileManager">The scene tile manager</param>
 /// <returns>If the hex passed the tests</returns>
 public static bool Test(Hex hex, HexRule rule, TileManager tileManager)
 {
     //check tile rules
     for (int i = 0; i < rule.possibleTiles.Length; i++)
     {
         //if the hex's tile type is in the list of possible tiles, break out of the loop and check features
         if (TestRule(hex, tileManager.tiles[rule.possibleTiles[i]]) == true)
         {
             break;
         }
         //the hex's tile type was not in the list of possible tiles, return false
         if (i == (rule.possibleTiles.Length - 1))
         {
             return(false);
         }
     }
     //check feature rules
     for (int i = 0; i < rule.possibleFeatures.Length; i++)
     {
         //if hex's feature type is in the list of possible features, return true since both rules have been passed
         if (TestRule(hex, rule.possibleFeatures[i]) == true)
         {
             return(true);
         }
         //the hex's feature type was not in the list of possible features, return false
         if (i == (rule.possibleFeatures.Length - 1))
         {
             return(false);
         }
     }
     //unreachable mandatory code because c# is funky
     return(false);
 }
 /// <summary>
 /// Constructor for this class.
 /// </summary>
 /// <param name="name">Name of the improvement</param>
 /// <param name="meshToSpawn">The improvement mesh to spawn</param>
 /// <param name="meshTexture">The texture for the spawned mesh</param>
 /// <param name="replaceGroundTexture">Decides if the ground texture is replaced with the improvement specific one in the texture atlas</param>
 /// <param name="rule">The rules of where the improvement can spawn</param>
 public Improvement(string name, Mesh meshToSpawn, Texture2D meshTexture, bool replaceGroundTexture, HexRule rule)
 {
     this.name                 = name;
     this.meshTexture          = meshTexture;
     this.meshToSpawn          = meshToSpawn;
     this.replaceGroundTexture = replaceGroundTexture;
     this.rule                 = rule;
 }
 /// <summary>
 /// Constructor of this class.
 /// </summary>
 /// <param name="name">Name of the resource</param>
 /// <param name="rarity">This is a calculated probabilty of 1/<see cref="rarity"/>.</param>
 /// <param name="meshSpawnAmount">Amount of mesh to spawn</param>
 /// <param name="meshToSpawn">The resource mesh to spawn</param>
 /// <param name="meshTexture">The texture for the spawned mesh</param>
 /// <param name="replaceGroundTexture">Decides if the ground texture is replaced with the resource specific one in the texture atlas</param>
 /// <param name="rule">The rules of where the resource can spawn</param>
 public Resource(string name, float rarity, int meshSpawnAmount, Mesh meshToSpawn, Texture2D meshTexture, bool replaceGroundTexture, HexRule rule)
 {
     this.name                 = name;
     this.rarity               = rarity;
     this.meshToSpawn          = meshToSpawn;
     this.meshTexture          = meshTexture;
     this.replaceGroundTexture = replaceGroundTexture;
     this.rule                 = rule;
 }
Beispiel #4
0
 /// <summary>
 /// Checks all rules in the rule list.
 /// </summary>
 /// <param name="hex">Hex to compare the rules upon</param>
 /// <param name="rule">Rules to check</param>
 /// <param name="tileManager">The scene tile manager</param>
 /// <returns>If the hex passed the tests</returns>
 public static bool Test(Hex hex, HexRule rule, TileManager tileManager)
 {
     //check tile rules
     for (int i = 0; i < rule.possibleTiles.Length; i++)
     {
         //if the hex's tile type is in the list of possible tiles, break out of the loop and check features
         if (TestRule(hex, tileManager.tiles[rule.possibleTiles[i]]) == true) { break; }
         //the hex's tile type was not in the list of possible tiles, return false 
         if (i == (rule.possibleTiles.Length - 1)) { return false; }
     }
     //check feature rules
     for (int i = 0; i < rule.possibleFeatures.Length; i++)
     {
         //if hex's feature type is in the list of possible features, return true since both rules have been passed
         if (TestRule(hex, rule.possibleFeatures[i]) == true) { return true; }
         //the hex's feature type was not in the list of possible features, return false 
         if (i == (rule.possibleFeatures.Length - 1)) { return false; }
     }
     //unreachable mandatory code because c# is funky
     return false;
 }
 /// <summary>
 /// Constructor for this class.
 /// </summary>
 /// <param name="name">Name of the improvement</param>
 /// <param name="meshToSpawn">The improvement mesh to spawn</param>
 /// <param name="meshTexture">The texture for the spawned mesh</param>
 /// <param name="replaceGroundTexture">Decides if the ground texture is replaced with the improvement specific one in the texture atlas</param>
 /// <param name="rule">The rules of where the improvement can spawn</param>
 public Improvement(string name, Mesh meshToSpawn, Texture2D meshTexture, bool replaceGroundTexture, HexRule rule)
 {
     this.name = name;
     this.meshTexture = meshTexture;
     this.meshToSpawn = meshToSpawn;
     this.replaceGroundTexture = replaceGroundTexture;
     this.rule = rule;
 }
Beispiel #6
0
 /// <summary>
 /// Constructor of this class.
 /// </summary>
 /// <param name="name">Name of the resource</param>
 /// <param name="rarity">This is a calculated probabilty of 1/<see cref="rarity"/>.</param>
 /// <param name="meshSpawnAmount">Amount of mesh to spawn</param>
 /// <param name="meshToSpawn">The resource mesh to spawn</param>
 /// <param name="meshTexture">The texture for the spawned mesh</param>
 /// <param name="replaceGroundTexture">Decides if the ground texture is replaced with the resource specific one in the texture atlas</param>
 /// <param name="rule">The rules of where the resource can spawn</param>
 public Resource(string name, float rarity, int meshSpawnAmount, Mesh meshToSpawn, Texture2D meshTexture, bool replaceGroundTexture, HexRule rule)
 {
     this.name = name;
     this.rarity = rarity;
     this.meshToSpawn = meshToSpawn;
     this.meshTexture = meshTexture;
     this.replaceGroundTexture = replaceGroundTexture;
     this.rule = rule;
 }