public void UpdateGraphic() { float mod = 1f; if (lvl == startlvl) { mod = refund; } else { mod = Discount; } lvlbar.value = lvl; if (lvl != 5) { UpCost.text = ((int)(UIMasterScript.passiveBaseCostList[gradeID] * (lvl + 1) * Discount)).ToString(); } else { UpCost.text = "Max"; } if (lvl > 0) { DownCost.text = ((int)((UIMasterScript.passiveBaseCostList[gradeID] * lvl) * mod)).ToString(); } else { DownCost.text = 0.ToString(); } //update costs UIMasterScript.UpdateGraphic(); }
//Output the new state of the Toggle into Text when the user uses the Toggle public void ToggleValueChanged(Toggle change) { if (!ignorenextchange) { if (change.isOn) { //check cash if (UIMasterScript.FreeCash() - UIMasterScript.activeBAseCostList[gradeID] >= 0) { UIMasterScript.currentCosts += (int)(UIMasterScript.activeBAseCostList[gradeID] * Discount); UIMasterScript.activeList[index] = true; UIMasterScript.UpdateGraphic(); } else { Debug.Log("Insufficient funds"); ignorenextchange = true; m_Toggle.isOn = !m_Toggle.isOn; } } else { //remove cash/ //unless already baught then change back to true if (UIMasterScript.activeList[gradeID]) { ignorenextchange = true; m_Toggle.isOn = !m_Toggle.isOn; } else { UIMasterScript.currentCosts -= (int)(UIMasterScript.activeBAseCostList[gradeID] * Discount); UIMasterScript.activeList[index] = false; UIMasterScript.UpdateGraphic(); } } } else { ignorenextchange = false; } }
public void PosRequest() { if (lvl >= 5) { Debug.Log("max level"); } else { //ask if there is enough money to support cost if (UIMasterScript.FreeCash() - (UIMasterScript.passiveBaseCostList[gradeID] * (lvl + 1) * Discount) >= 0) { UIMasterScript.currentCosts += (int)(UIMasterScript.passiveBaseCostList[gradeID] * (lvl + 1) * Discount); lvl++; UIMasterScript.passiveList[gradeID] = lvl; } else { Debug.Log("Insufficient funds"); } //if yes increase lvl UpdateGraphic(); } }