public void OnSkillSelected(int i, Button b) { //Debug.Log(Enum.GetName(typeof(SkillType), i)); //set selected index, paint detail, enable buttons if valid var skillName = Enum.GetName(typeof(SkillType), i); SelectedSkill = i; DetailPanel.SetActive(true); DetailTitle.text = Sub.Replace(skillName, SubList); DetailDescription.text = Sub.Exists(skillName, DescriptionList) ? Sub.Replace(skillName, DescriptionList) : string.Empty; DetailLevel.text = string.Format("{0}->{1}", NewStats.Skills[(SkillType)i], NewStats.Skills[(SkillType)i] + RpgValues.SkillGainForPoints(1)); LevelUpButton.interactable = (PotentialPoints > 0); }
//on actual level handler public void OnClickLevelUp() { NewStats.Skills[(SkillType)SelectedSkill] = NewStats.Skills[(SkillType)SelectedSkill] + RpgValues.SkillGainForPoints(1); PotentialPoints--; UpdateValues(); }
private void UpdateValues() { //update buttons for (int i = 0; i < SkillButtons.Length; i++) { string name = Enum.GetName(typeof(SkillType), i); Button b = SkillButtons[i]; b.GetComponentInChildren <Text>().text = string.Format("{0} [{1}]", Sub.Replace(name, SubList), NewStats.Skills[(SkillType)i]); } //update details DetailLevel.text = string.Format("{0}->{1}", NewStats.Skills[(SkillType)SelectedSkill], NewStats.Skills[(SkillType)SelectedSkill] + RpgValues.SkillGainForPoints(1)); //if we're out of PP, set buttons LevelUpButton.interactable = (PotentialPoints > 0); ConfirmButton.interactable = (PotentialPoints == 0); PointsText.text = string.Format("Potential Points: {0}", PotentialPoints); }