Exemplo n.º 1
0
 public void Update()
 {
     foreach (IBuilding building in BuildingList)
     {
         Henhouse item = building as Henhouse;
         item?.Update(); // "?" = check for null
     }
 }
Exemplo 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>();
            }
        }
Exemplo 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));
     }
 }
Exemplo n.º 4
0
 internal void Die()
 {
     CtxHenhouse = null;
 }
Exemplo n.º 5
0
 public Chicken(Henhouse ctxHenhouse, Breed chikenBreed)
 {
     CtxHenhouse = ctxHenhouse ?? throw new ArgumentNullException(nameof(ctxHenhouse));
     ChikenBreed = chikenBreed;
     Hunger      = 100;
 }