void UnequipConsumable() { if (equippedConsumable.GetName() != "Snake Oil") { SwapConsumable(); } else { StartCoroutine(SwapConsumableDelayed()); } }
void Awake() { if (Instance == this) { DontDestroyOnLoad(gameObject); activeGuns = new List <Gun>(); activeConsumables = new List <Consumable>(); currency = PlayerPrefs.GetInt("Currency", 0); hasGun[1] = (PlayerPrefs.GetInt("Has Winchester", 0) == 1); int i = 0; foreach (Transform gunObject in weaponHolderPrefab.GetComponent <WeaponHolder>().GunHolder) { if (hasGun[i]) { gunObject.gameObject.SetActive(true); Gun gun = gunObject.GetComponent <Gun>(); if (gun) { activeGuns.Add(gun); } } i++; } i = 0; foreach (Transform consumableObject in weaponHolderPrefab.GetComponent <WeaponHolder>().ConsumableHolder) { Consumable consumable = consumableObject.GetComponent <Consumable>(); if (consumable) { string consName = consumable.GetName(); activeConsumables.Add(consumable); consumablesAmount[i] = PlayerPrefs.GetInt(consName + " Amount", 0); consumable.IncreaseAmount(consumablesAmount[i]); } i++; } } else { Destroy(gameObject); } }
public void StopDeadEyeEffect() { Consumable consumable = weaponHolder.EquippedConsumable; if (consumable && consumable.IsInUse) { consumable.CancelUse(); if (consumable.GetName() == "Snake Oil") { SnakeOil snakeOil = (SnakeOil)consumable; if (snakeOil.IsApplyingEffect) { snakeOil.StopEffect(); } } } }
public void DecreaseConsumableAmount(Consumable cons) { foreach (Consumable consumable in activeConsumables) { if (consumable.GetName() == cons.GetName()) { consumable.ReduceAmount(); int amountToSave = consumable.GetAmount(); switch (consumable.GetName()) { case "Snake Oil": PlayerPrefs.SetInt("Snake Oil Amount", amountToSave); break; case "Bait": PlayerPrefs.SetInt("Bait Amount", amountToSave); break; } } } }