private void TryBuyItem(ShopItem.ItemType itemType) { if (shopCustomer.TrySpendGoldAmount(ShopItem.GetCost(itemType))) { //can afforf cost shopCustomer.BouthItem(itemType); } }
public void PopUpShop() { if (shopPopped == false) { CreateItemButton(ShopItem.GetSprite(ShopItem.ItemType.WWRifle), "Rifle", ShopItem.GetCost(ShopItem.ItemType.WWRifle), 0); CreateItemButton(ShopItem.GetSprite(ShopItem.ItemType.RailGun), "Rail Gun", ShopItem.GetCost(ShopItem.ItemType.RailGun), 1); CreateItemButton(ShopItem.GetSprite(ShopItem.ItemType.RocketLauncher), "Rocket Launcher", ShopItem.GetCost(ShopItem.ItemType.RocketLauncher), 2); shopPopped = true; //action handling Cursor.lockState = CursorLockMode.None; //player.GetComponent<WeaponInventory>().enabled = false; } }
private void TryBuyItem(ShopItem.ShopItemType itemType) { ShopItem.ItemCost itemCost = ShopItem.GetCost(itemType); if (_coins.Value >= itemCost.coins && _stars.Value >= itemCost.stars) { BoughtItem(itemType); _coins.Value -= itemCost.coins; _stars.Value -= itemCost.stars; _changeDataGameEvent.Raise(); AudioManager.Instance.PlaySound2D(SoundLibrary.Sound.ClickButton02); } }
public void PurchaseItem(ShopItem item) { string itemName = item.GetName(); int cost = item.GetCost(); if (cost <= PlayerDataController.Instance.Data.Money) { //change and write data PlayerDataController.Instance.AddMoney(-cost); PlayerDataController.Instance.ItemPurchased(item.GetItemId()); PlayerDataController.Instance.WriteData(); //set new money text MoneyText.text = PlayerDataController.Instance.Data.Money.ToString(); //play animation and other do other processing item.BuyItem(); } else { item.AnimateError(); } }
private void Start() { CreateItemButton(ShopItem.ItemType.Hp, ShopItem.GetSprite(ShopItem.ItemType.Hp), "HEALTH", ShopItem.GetCost(ShopItem.ItemType.Hp), 0); CreateItemButton(ShopItem.ItemType.Pistol, ShopItem.GetSprite(ShopItem.ItemType.Pistol), "PISTOL", ShopItem.GetCost(ShopItem.ItemType.Pistol), 1); CreateItemButton(ShopItem.ItemType.Rifle, ShopItem.GetSprite(ShopItem.ItemType.Rifle), "RIFLE", ShopItem.GetCost(ShopItem.ItemType.Rifle), 2); CreateItemButton(ShopItem.ItemType.Shotgun, ShopItem.GetSprite(ShopItem.ItemType.Shotgun), "SHOTGUN", ShopItem.GetCost(ShopItem.ItemType.Shotgun), 3); Hide(); }
private void RefreshUI() { _coinAmountText.text = _coins.Value.ToString(); _starAmountText.text = _stars.Value.ToString(); if (_container == null) { return; } for (int i = 0; i < _container.childCount; i++) { GameObject toRemove = _container.GetChild(i).gameObject; Destroy(toRemove); } switch (GameDataController.GetPlayerHealthLevel()) { case PlayerHealthShield.HealthLevel.Level_1: CreateItemButton(ShopItem.ShopItemType.Health_2, ShopItem.GetSprite(ShopItem.ShopItemType.Health_2), "HEALTH [LEVEL 2]", "Increases player's health by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Health_2)); break; case PlayerHealthShield.HealthLevel.Level_2: CreateItemButton(ShopItem.ShopItemType.Health_3, ShopItem.GetSprite(ShopItem.ShopItemType.Health_3), "HEALTH [LEVEL 3]", "Increases player's health by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Health_3)); break; case PlayerHealthShield.HealthLevel.Level_3: CreateItemButton(ShopItem.ShopItemType.Health_4, ShopItem.GetSprite(ShopItem.ShopItemType.Health_4), "HEALTH [LEVEL 4]", "Increases player's health by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Health_4)); break; } switch (GameDataController.GetPlayerShieldArmor()) { case PlayerHealthShield.ShieldArmor.None: CreateItemButton(ShopItem.ShopItemType.Shield_1, ShopItem.GetSprite(ShopItem.ShopItemType.Shield_1), "SHIELD [LEVEL 1]", "Adds shield to the player.", ShopItem.GetCost(ShopItem.ShopItemType.Shield_1)); break; case PlayerHealthShield.ShieldArmor.Tier_1: CreateItemButton(ShopItem.ShopItemType.Shield_2, ShopItem.GetSprite(ShopItem.ShopItemType.Shield_2), "SHIELD [LEVEL 2]", "Increases player's shield by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Shield_2)); break; case PlayerHealthShield.ShieldArmor.Tier_2: CreateItemButton(ShopItem.ShopItemType.Shield_3, ShopItem.GetSprite(ShopItem.ShopItemType.Shield_3), "SHIELD [LEVEL 3]", "Increases player's shield by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Shield_3)); break; case PlayerHealthShield.ShieldArmor.Tier_3: CreateItemButton(ShopItem.ShopItemType.Shield_4, ShopItem.GetSprite(ShopItem.ShopItemType.Shield_4), "SHIELD [LEVEL 4]", "Increases player's shield by 25 points.", ShopItem.GetCost(ShopItem.ShopItemType.Shield_4)); break; } switch (GameDataController.GetSpeedLevel()) { case 0: CreateItemButton(ShopItem.ShopItemType.Speed_1, ShopItem.GetSprite(ShopItem.ShopItemType.Speed_1), "SPEED [LEVEL 2]", "Increases player's speed by 10%.", ShopItem.GetCost(ShopItem.ShopItemType.Speed_1)); break; case 1: CreateItemButton(ShopItem.ShopItemType.Speed_2, ShopItem.GetSprite(ShopItem.ShopItemType.Speed_2), "SPEED [LEVEL 3]", "Increases player's speed by 10%.", ShopItem.GetCost(ShopItem.ShopItemType.Speed_2)); break; case 2: CreateItemButton(ShopItem.ShopItemType.Speed_3, ShopItem.GetSprite(ShopItem.ShopItemType.Speed_3), "SPEED [LEVEL 4]", "Increases player's speed by 10%.", ShopItem.GetCost(ShopItem.ShopItemType.Speed_3)); break; } switch (GameDataController.GetShotLevel()) { case 0: CreateItemButton(ShopItem.ShopItemType.Shot_1, ShopItem.GetSprite(ShopItem.ShopItemType.Shot_1), "SHOT [LEVEL 2]", "Increases player's shot by 1.", ShopItem.GetCost(ShopItem.ShopItemType.Shot_1)); break; case 1: CreateItemButton(ShopItem.ShopItemType.Shot_2, ShopItem.GetSprite(ShopItem.ShopItemType.Shot_2), "SHOT [LEVEL 3]", "Increases player's shot by 1.", ShopItem.GetCost(ShopItem.ShopItemType.Shot_2)); break; } #if UNITY_ANDROID if (!GameDataController.IsBombAbilityEnable()) { CreateItemButton(ShopItem.ShopItemType.Bomb, ShopItem.GetSprite(ShopItem.ShopItemType.Bomb), "BOMB", "Gives player ability to spawn a bomb to damage close enemies.", ShopItem.GetCost(ShopItem.ShopItemType.Bomb)); } #endif if (!GameDataController.IsTimePickupEnable()) { CreateItemButton(ShopItem.ShopItemType.Time, ShopItem.GetSprite(ShopItem.ShopItemType.Time), "SLOWMO [PICKUP]", "Snipe your enemies one by one in an awesome slowmo sequence.", ShopItem.GetCost(ShopItem.ShopItemType.Time)); } if (!GameDataController.IsVoidPickupEnable()) { CreateItemButton(ShopItem.ShopItemType.Void, ShopItem.GetSprite(ShopItem.ShopItemType.Void), "VOID [PICKUP]", "Gives player ability to spawn a void vortex to attract and damage enemies.", ShopItem.GetCost(ShopItem.ShopItemType.Void)); } if (!GameDataController.IsRepairPickupEnable()) { CreateItemButton(ShopItem.ShopItemType.Repair, ShopItem.GetSprite(ShopItem.ShopItemType.Repair), "REPAIR [PICKUP]", "Repairs player's spaceship to full health and shield.", ShopItem.GetCost(ShopItem.ShopItemType.Repair)); } }