예제 #1
0
 /// <summary>
 /// Returns an int based on a comparison between creatures
 /// </summary>
 /// <param name="c1">The first creature to compare</param>
 /// <param name="c2">The second creature to compare</param>
 /// <returns>An int, 1 if the first creature is better and -1 if the second is better</returns>
 public static int judgeCreatures(Creature c1, Creature c2)
 {
     int ret;
     int c1Health = (int)c1.getHealth() * Simulation.getHealthWeight();
     int c1Energy = (int)c1.getEnergy() * Simulation.getEnergyWeight();
     int c2Health = (int)c2.getHealth() * Simulation.getHealthWeight();
     int c2Energy = (int)c2.getEnergy() * Simulation.getEnergyWeight(); ;
     if (c1Health + c1Energy > c2Health + c2Energy)
     {
         ret = -1;
     }
     else if (c1Health + c1Energy == c2Health + c2Energy)
     {
         int c1Stats = c1.getStatValue();
         int c2Stats = c2.getStatValue();
         if (c1Stats > c2Stats)
         {
             ret = -1;
         }
         else if (c2Stats < c1Stats)
         {
             ret = 1;
         }
         else
         {
             ret = 0; //in this case they are equal
         }
     }
     else //if c1stuff < c2stuff
     {
         ret = -1;
     }
     return ret;
 }
예제 #2
0
 /// <summary>
 /// Gets an array of strings that contain information about the creature
 /// </summary>
 /// <param name="c">The creature to get information about</param>
 /// <returns>An array of strings containing a set of information about the creature</returns>
 public string[] getCreatureInfo(Creature c)
 {
     string[] status = new string[1];
     switch (DataViewed)
     {
         case 0: status = new string[] { "Health: " + c.getHealth(), "Energy :" + c.getEnergy(), "Current Scenario: " + c.CurrentScenario, "Response: " + c.CurrentResponse, "Stamina: " + c.getStamina() + "/" + c.getMaxStamina(), "Location: (" + c.getLocationXY()[0] + "," + c.getLocationXY()[1] + ")" }; break;
         case 1: int[] colours = c.getDna().getColourCount();
             status = new string[] { "Number of...", "0s: " + colours[0], "1s: " + colours[1], "2s: " + colours[2], "3s: " + colours[3], "4s: " + colours[4], "5s: " + colours[5], "6s: " + colours[6] };
             break;
         case 2: Color[] cols = Simulation.getColours();
             status = new string[cols.Length];
             for (int i = 0; i < cols.Length; i++ )
             {
                 status[i] = i + ": " + cols[i].ToString();
             }
             break;
         case 3: string dietString = "Diet: " + c.getDiet();
             if (c.getDiet() < 0.5)
             {
                 dietString += " (HERBIVORE)";
             }
             else
             {
                 dietString += " (CARNIVORE)";
             }
             status = new string[] { "Stats:", "STR: " + c.getStrength(), "SPD: " + c.getSpeed(), "STL: " + c.getStealthVal(), "AWA: " + c.getAwareness(), "DEF: " + c.getDefence(), dietString };
             break;
     }
     return status;
 }