// Takes the current inventory, so already purchased rides can be hidden public List <Shop> GetBuyableShops(ParkInventory currentInventory) { List <Shop> buyableShops = new List <Shop>(); foreach (BuildableObject item in purchasableObjects) { if (!(item is Shop)) { continue; } // If the player already has the item if (currentInventory.Contains(item)) { continue; } // If the item has already been purchased if (purchasedObjects.Contains(item)) { continue; } buyableShops.Add(item as Shop); } return(buyableShops); }
public void Buy(BuildableObject rideOrShop, Wallet fromWallet, ParkInventory toInventory) { if (fromWallet.Balance < rideOrShop.Cost) { throw new ArgumentException("Wallet does not have enough money! Check balance in the UI before calling this method."); } if (toInventory.Contains(rideOrShop)) { throw new ArgumentException("Inventory already contains this item! Check if player owns the item before calling this method."); } if (rideOrShop is Ride) { Ride ride = rideOrShop as Ride; toInventory.Rides.Add(ride); purchasedRides.Add(ride); } else if (rideOrShop is Shop) { Shop shop = rideOrShop as Shop; toInventory.Shops.Add(shop); purchasedShops.Add(shop); } // Always deduct the money fromWallet.SubtractFromBalance(rideOrShop.Cost, "Bought " + rideOrShop.Name); }
public Park() { Guests = new GuestList(); Guests.GuestAdded += Guests_GuestAdded; ParkWallet = new Wallet(); ParkInventory = new ParkInventory(); ParkInventory.InventoryChanged += ParkInventory_InventoryChanged; EntryFee = 15; desirables = new List <Desire>(); Employees = new ObservableCollection <Employee>(); EmployeeController = new EmployeeController(this); GuestController = new GuestController(desirables, ref Guests); GuestController.MinimumCash = EntryFee; // TODO: when entryfee changes, this MinimumCash needs to as well. this.WeatherChanged += Park_WeatherChanged; // Start with 20k ParkWallet.SubtractFromBalance(-20000, "Starting cash for running the park"); // Start with random weather DoChangeWeather(); }
// Takes the current inventory, so already purchased rides can be hidden public List <Ride> GetBuyableRides(ParkInventory currentInventory) { List <Ride> buyableRides = new List <Ride>(); foreach (Ride item in purchasableRides) { // If the player already has the item if (currentInventory.Contains(item)) { continue; } // If the item has already been purchased if (purchasedRides.Contains(item)) { continue; } buyableRides.Add(item); } return(buyableRides); }
public void AddToInventory(ParkInventory toInventory) { toInventory.Add(this); }