/// <summary> /// This function is used to increase the power level of a talent. This function also checks /// if the taletn can be bought or not. /// </summary> /// <param name="text"></param> public void IncreasePowerLevel(TextMeshProUGUI text) { string name = text.gameObject.transform.parent.name; int coins = info.BuyLevel(name); if (coins > 0) { if (info.GetMaxPowerLevel(name) == info.GetPowerLevel(name)) { text.text = "MAXED"; } else { text.text = info.GetPowerLevel(name) + "/" + info.GetMaxPowerLevel(name) + "\n" + info.GetBuyAmmount(name); } tempCoins.text = info.GetCoinCount().ToString("00000000"); } else if (coins == 0) { print("MAX LEVEL"); text.text = "MAXED"; } else { print("NO ENOUGH COINS"); } }
/// <summary> /// This fucntion is used to update the coins and xp bars on the stats panel. /// </summary> public void UpdateUIStats() { PlayerInfoScript play = PlayerInfoScript.instance; tempCoins.text = play.GetCoinCount().ToString("00000000");//change the innital coin display here tempLevel.transform.parent.transform.Find("Fill").GetChild(0).GetComponent <Image>().fillAmount = play.GetPercentageToNextLevel(); tempLevel.text = "" + play.GetLevel(); }
private PlayerInfoScript info; // A reference to the PlayerInfoScript singleton #endregion private void Start() { //Get all of the references in the game _buttonPanel = GameObject.Find("Buttons"); _allPanels = GameObject.Find("SugarPanels"); _backButton = GameObject.Find("BackButton"); _selectionPanel = GameObject.Find("Selection"); _skillsPanel = GameObject.Find("SkillsPanel"); _mainMenuPanel = GameObject.Find("MainMenu"); _achievementPanel = GameObject.Find("AchievementsPanel"); _leftArrow.SetActive(false); _xpSlider = tempLevel.transform.parent.transform.Find("Fill").GetChild(0).GetComponent <Image>(); _allPanels.SetActive(false); _selectionPanel.SetActive(false); _skillsPanel.SetActive(false); _achievementPanel.SetActive(false); info = PlayerInfoScript.instance; tempCoins.text = info.GetCoinCount().ToString("00000000"); _xpSlider.fillAmount = info.GetPercentageToNextLevel(); tempLevel.text = "" + info.GetLevel(); UpdatePowers(info.GetLevel()); _currentLevels = _mainMenuPanel; int size = _allPanels.transform.childCount; //Loop through the sugar groups panels for (int i = 0; i < size; i++) { SugarButton group = new SugarButton(); Transform panel = _allPanels.transform.GetChild(i).GetChild(0); _allPanels.transform.GetChild(i).GetComponent <ScrollRect>().verticalNormalizedPosition = 1; //Automatically scroll to the top group.init(panel.gameObject, PlayerInfoScript.instance.GetLevelInSugarGroup(i)); //Init the sugar group buttonGroups.Add(group); //Update the titles Transform child = panel.parent.Find("Text"); if (group._currentButton) { group._currentButton.onClick.AddListener(() => PlayLevel(_currentSelection)); //Set the current button to be active group._currentButton.interactable = true; child.GetComponent <Text>().text = buttonGroups[i]._name + " - " + (buttonGroups[i]._currentButtonIndex) + "/" + buttonGroups[i]._buttonCount; } else { child.GetComponent <Text>().text = buttonGroups[i]._name + " - " + (buttonGroups[i]._buttonCount) + "/" + buttonGroups[i]._buttonCount; } //Update the buttons to be at the location last saved (Future: From the save file) UpdateButtons(buttonGroups[i]); panel.parent.gameObject.SetActive(false); } //Settings for the "map" selection animations _selectionOffset = -_selectionPanel.transform.GetChild(0).GetComponent <RectTransform>().sizeDelta.x / buttonGroups.Count; _targetLocation = -_selectionPanel.transform.GetChild(0).GetChild(0).GetComponent <RectTransform>().anchoredPosition.x; }