Esempio n. 1
0
 public void Update()
 {
     foreach (IBuilding building in BuildingList)
     {
         Henhouse item = building as Henhouse;
         item?.Update(); // "?" = check for null
     }
 }
Esempio n. 2
0
        public static void UpgradeHenhouseRack <TRackType>(Henhouse henhouse) where TRackType : IRack
        {
            IRack upgradedRack = henhouse?.Racks.Find(rack => rack is TRackType) ??
                                 throw new ArgumentNullException("Rack is null", nameof(upgradedRack));

            if (CtxFarm.Money >= upgradedRack.UpgrageCost)
            {
                CtxFarm.Money -= upgradedRack.UpgrageCost;
                henhouse.UpgradeRack <TRackType>();
            }
        }
Esempio n. 3
0
 public static void BuyRack <TRackType>(Henhouse henhouse) where TRackType : IRack
 {
     if (typeof(VegetableRack).IsAssignableFrom(typeof(TRackType)) &&
         CtxFarm.Money > FarmOptions.DefaultVegetableRackPrice)
     {
         henhouse.Racks.Add(new VegetableRack(henhouse));
     }
     else if (typeof(MeatRack).IsAssignableFrom(typeof(TRackType)) &&
              CtxFarm.Money > FarmOptions.DefaultMeatRackPrice)
     {
         henhouse.Racks.Add(new MeatRack(henhouse));
     }
 }
Esempio n. 4
0
 internal void Die()
 {
     CtxHenhouse = null;
 }
Esempio n. 5
0
 public Chicken(Henhouse ctxHenhouse, Breed chikenBreed)
 {
     CtxHenhouse = ctxHenhouse ?? throw new ArgumentNullException(nameof(ctxHenhouse));
     ChikenBreed = chikenBreed;
     Hunger      = 100;
 }