/// <summary> /// Use this for initialization /// </summary> private void Start() { Switch_Button_Text.text = Buy_Amount_Mode.ToString(); Switch_Buy_Amount.onClick.AddListener(() => { BuyAmountMode current = Buy_Amount_Mode; if (current == Enum.GetValues(typeof(BuyAmountMode)).Cast <BuyAmountMode>().Max()) { Buy_Amount_Mode = BuyAmountMode.Single; } else { Buy_Amount_Mode = current + 1; } int amount = 0; switch (Buy_Amount_Mode) { case BuyAmountMode.Single: amount = 1; break; case BuyAmountMode.Fifty: amount = 50; break; case BuyAmountMode.OneHundred: amount = 100; break; } //loop through all purchasables and change buy amount for (int i = 0; i < SaveLoad.Instance.Fish_Item.Count; i++) { Purchasable purchasable = SaveLoad.Instance.Fish_Item[i].GetComponent <PurchasableData>().Purchasable; purchasable.Cost_To_Purchase_Amount = amount; } Switch_Button_Text.text = Buy_Amount_Mode.ToString(); }); }
/// <summary> /// /// </summary> public void SwitchBuyMode() { GUI_Text_SwitchButtonText.text = BuyAmountMode.ToString(); GUI_Button_SwitchBuyAmount.onClick.AddListener(() => { BuyAmountMode current = BuyAmountMode; if (current == Enum.GetValues(typeof(BuyAmountMode)).Cast <BuyAmountMode>().Max()) { BuyAmountMode = BuyAmountMode.Single; } else { BuyAmountMode = current + 1; } switch (BuyAmountMode) { case BuyAmountMode.Single: amount = 1; break; case BuyAmountMode.Fifty: amount = 50; break; case BuyAmountMode.OneHundred: amount = 100; break; } for (int i = 0; i < SaveLoad.Instance.Recipe_Item.Count; i++) { RecipeData r = SaveLoad.Instance.Recipe_Item[i].GetComponent <RecipeData>(); r.AmountSellMuiltplyer = amount; r.UpdateText(); } GUI_Text_SwitchButtonText.text = BuyAmountMode.ToString(); }); }