//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(); } }