private void skillSelected(CharacterSkill skill, int selectedIndex) { CharacterAttribute attribute = NeverdawnDatabase.GetAttribute(skill.baseAttribute); UIQuickMenuSkillUp skillUp = Instantiate(skillUpPrefab); int level = avatarController.character.GetSkillLevel(skill.type); skillUp.label = skill.label; skillUp.description = skill.description; skillUp.baseValue = level; skillUp.attributeValue = avatarController.character.GetAttributeLevel(attribute.type); skillUp.equipmentValue = avatarController.character.mannequin ? avatarController.character.mannequin.GetSkillBonus(skill.type) : 0; skillUp.foodValue = avatarController.character.GetFoodBonus(skill.type); skillUp.cost = NeverdawnDatabase.GetUpgradeCost(skill.type, level); skillUp.learningPoints = avatarController.character.skillable.learningPoints; skillUp.showAttributes = true; skillUp.attributeColor = attribute.color; skillUp.attributeLabel = attribute.label; skillUp.confirm.interactable = avatarController.character.skillable.learningPoints >= NeverdawnDatabase.GetUpgradeCost(skill.type, level); skillUp.confirm.onClick.AddListener(() => skillUpSkill(skillUp, skill.type)); this.selectedIndex = selectedIndex; menu.NavigateInto(skillUp); }
// Use this for initialization void Start() { buttons = new List <UIButton>(); attributeViewMap = new Dictionary <AttributeType, UISkillView>(); skillViewMap = new Dictionary <SkillType, UISkillView>(); Character character = avatarController.character; listController.inputModule = avatarController.inputModule; int k = 0; foreach (CharacterAttribute attribute in NeverdawnDatabase.attributes) { if (attribute != null) { UISkillView attributeView = Instantiate(skillViewPrefab); int i = k++; attributeView.transform.SetParent(skillViewParent); attributeView.totalValue = string.Empty; attributeView.label = attribute.label; attributeView.value = character.GetAttributeLevel(attribute.type, true).ToString(); attributeView.labelColor = attribute.color; attributeView.button.onClick.AddListener(() => attributeSelected(attribute, i)); attributeViewMap.Add(attribute.type, attributeView); buttons.Add(attributeView.button); } } GameObject go = new GameObject("gap"); go.AddComponent <RectTransform>(); LayoutElement layout = go.AddComponent <LayoutElement>(); layout.preferredHeight = 10; go.transform.SetParent(skillViewParent); foreach (CharacterSkill skill in NeverdawnDatabase.skills) { if (skill != null) { int i = k++; CharacterAttribute baseAttribute = NeverdawnDatabase.GetAttribute(skill.baseAttribute); UISkillView skillView = Instantiate(skillViewPrefab); skillView.transform.SetParent(skillViewParent); skillView.label = skill.label; skillView.totalValue = string.Empty; skillView.value = character.GetSkillLevel(skill.type, true).ToString(); skillView.totalValueColor = baseAttribute.color; skillView.button.onClick.AddListener(() => skillSelected(skill, i)); skillViewMap.Add(skill.type, skillView); buttons.Add(skillView.button); } } selectedIndex = 0; }