示例#1
0
 public Hexagon(IEnumerable<Hexagon> neighbours)
 {
     if (neighbours == null)
         Neighbours = new List<Hexagon>();
     else
         Neighbours = new List<Hexagon>(neighbours);
     Settlements = new Settlement[6];
     Roads = new Road[6];
 }
示例#2
0
 /// <summary>
 /// Egy települést várossá alakít. Ha nincs elég nyersanyag, akkor kivételt dob. Ha
 /// a paraméter már város akkor is. :)
 /// </summary>
 /// <param name="Settlement"></param>
 public void UpgradeSettlement(Settlement settlement)
 {
     if (settlement.GetType().ToString() != "Town") {
         if (Materials[Material.Iron] >= 3 && Materials[Material.Wheat] >= 2) {
             Materials[Material.Wheat] -= 3;
             Materials[Material.Iron] -= 2;
             Town town = new Town(settlement.getFields(), this);
             Settlements.Remove(settlement);
             Settlements.Add(town);
         }
         else {
             throw new Exception("Nincs elég nyersanyag!");
         }
     }
     else {
         throw new Exception("Ez a település már város");
     }
 }
示例#3
0
 /// <summary>
 /// Készít egy új települést. Hozzáadja a listájához, levonja a nyersanyagot, majd
 /// visszatér vele. Ha nincs elég nyersanyag akkor kivételt dob.
 /// </summary>
 public Settlement BuildSettlement(bool isFree)
 {
     Settlement set = new Settlement(null, this);
     if (Materials[Material.Wood] > 0 && Materials[Material.Clay] > 0 && Materials[Material.Wheat] > 0 && Materials[Material.Wool] > 0) {
         if (!isFree) {
             Materials[Material.Wood]--;
             Materials[Material.Clay]--;
             Materials[Material.Wheat]--;
             Materials[Material.Wool]--;
         }
         Settlements.Add(set);
     }
     else {
         throw new Exception("Nincs elég nyersanyag!");
     }
     return set;
 }
示例#4
0
 /// <summary>
 /// Hozzáad egy új települést vagy várost.
 /// </summary>
 /// <param name="Settlement"></param>
 public void AddSettlement(Settlement Settlement)
 {
     Settlements.Add(Settlement);
 }
示例#5
0
 /// <summary>
 /// Beállítja az adott sarokra a megadott települést.
 /// </summary>
 /// <param name="settlement"></param>
 /// <param name="position"></param>
 public void SetTown(Settlement settlement, int position)
 {
     if (position >= 0 && position <= 5) {
         Settlements[position] = settlement;
         if (Neighbours[position] != null) {
             Neighbours[position].Settlements[(position + 2) % 6] = settlement;
         }
         if (Neighbours[(position + 1) % 6] != null) {
             Neighbours[(position + 1) % 6].Settlements[(position + 4) % 6] = settlement;
         }
     }
 }