//CHANGE SKILL LEVEL public void skillLevelUp(GameObject _skill) { if (HeroController.mainHero.freeSkillPoints > 0) { string _sName = _skill.name; A_Skill _s = skillTree.Find(x => x.skillName == _sName); // skills are default level 1 if ((_s.skillLevel + 1 <= _s.skillMaxLevel) || (!_s.isLearned && _s.skillMaxLevel == 1)) { string _availability = HeroSkillsController.getSkillAvailability(_s); if (_availability.Equals("Available")) { HeroSkillsController.setSkillAsLearned(_s); HeroSkillsController.getNewAvailableSKills(skillTree, _sName); --HeroController.mainHero.freeSkillPoints; visualValuesUpdated = false; } else if (_availability.Equals("Learned")) { ++_s.skillLevel; refreshSkill(_skill, _sName, _s); --HeroController.mainHero.freeSkillPoints; visualValuesUpdated = false; } } } }
//Update skillPoints UI value and skillAvailability UI value private void updateTextValues(GameObject _skill) { heroSkillPoints.text = HeroController.mainHero.freeSkillPoints.ToString(); A_Skill skill = skillTree.Find(x => x.skillName.Equals(_skill.name)); skillAvailability.text = HeroSkillsController.getSkillAvailability(skill); }
//LOAD LEVEL DATA void loadSkillData(GameObject _skill) { this.skillLevelDescription.text = ""; skillDuration.text = ""; skillAvailability.text = ""; SkillDataStorage _data = data.Find(x => x.skillName == _skill.name); //concrette skill storage skillName.text = _data.skillLocalisedName; skillDescription.text = _data.skillMainDescription; string skillLevelDescription = _data.skillLocalisedLevelDescription[_data.skillCurentLevel - 1]; List <string> skillValues = new List <string>(); //every value is separated by $$ //then divide values count by 2 to get actual values count int _valCount = 0; for (int i = 0; i < skillLevelDescription.Length; ++i) { if (skillLevelDescription.Substring(i, 1).Equals("$")) { ++_valCount; } } _valCount /= 2; string _substr = skillLevelDescription; // temp full string for (int i = 0; i < _substr.Length; ++i) { string _subChar = _substr.Substring(i, 1); //next char if (_subChar.Equals("$")) { string _val = _substr.Substring(i + 1, _substr.Length - i - 1); // from $val to the end of curr string for (int j = 0; j < _val.Length; ++j) { string _subJ = _val.Substring(j, 1); if (_subJ.Equals("$")) { string newVal = _val.Substring(0, j); // get value name _substr = _val.Substring(j + 1, _val.Length - j - 1); // set new main string from $val$ to the end of current string skillValues.Add(newVal); // add value name to list i = -1; // for i++ break; // end of $val$ go to next $val$ } } } } _substr = skillLevelDescription; foreach (string _val in skillValues) { if (_data.skillValues[_data.skillCurentLevel - 1].ContainsKey(_val)) { _substr = _substr.Replace("$" + _val + "$", _data.skillValues[_data.skillCurentLevel - 1][_val]); } else { Debug.Log("not a key " + _val); } } this.skillLevelDescription.text += _substr + "\n"; //get APCost EnergyCost and Targets int _intkey = _data.skillCurentLevel; if (_data.skillAPCost.ContainsKey(_intkey)) { skillAPCost.text = _data.skillAPCost[_data.skillCurentLevel]; skillEnergyCost.text = _data.skillEneCost[_data.skillCurentLevel]; skillTargets.text = _data.skillTargetsDescription[_data.skillCurentLevel - 1]; //list } // get skill duration "Time" if exist if (_data.skillValues[_data.skillCurentLevel - 1].ContainsKey("Time")) { skillDuration.text = _data.skillValues[_data.skillCurentLevel - 1]["Time"]; } //get skillAvailability skillAvailability.text = HeroSkillsController.getSkillAvailability(skillTree.Find(x => x.skillName.Equals(_data.skillName))); }