public override void Show() { CacheSkillSelectionManager.eventOnSelect.RemoveListener(OnSelectCharacterSkill); CacheSkillSelectionManager.eventOnSelect.AddListener(OnSelectCharacterSkill); CacheItemSelectionManager.eventOnSelect.RemoveListener(OnSelectCharacterItem); CacheItemSelectionManager.eventOnSelect.AddListener(OnSelectCharacterItem); var owningCharacter = BasePlayerCharacterController.OwningCharacter; if (owningCharacter == null) { CacheSkillList.HideAll(); CacheItemList.HideAll(); return; } var filterSkills = new List <CharacterSkill>(); var filterItems = new List <CharacterItem>(); var characterSkills = owningCharacter.Skills; var characterItems = owningCharacter.NonEquipItems; foreach (var characterSkill in characterSkills) { var skill = characterSkill.GetSkill(); if (skill != null && characterSkill.level > 0 && (skill.skillType == SkillType.Active || skill.skillType == SkillType.CraftItem)) { filterSkills.Add(characterSkill); } } foreach (var characterItem in characterItems) { var item = characterItem.GetItem(); if (item != null && characterItem.level > 0 && characterItem.amount > 0 && (item.IsPotion() || item.IsBuilding() || item.IsPet())) { filterItems.Add(characterItem); } } CacheSkillList.Generate(filterSkills, (index, characterSkill, ui) => { var uiCharacterSkill = ui.GetComponent <UICharacterSkill>(); uiCharacterSkill.Setup(new SkillTuple(characterSkill.GetSkill(), characterSkill.level), null, -1); uiCharacterSkill.Show(); CacheSkillSelectionManager.Add(uiCharacterSkill); }); CacheItemList.Generate(filterItems, (index, characterItem, ui) => { var uiCharacterItem = ui.GetComponent <UICharacterItem>(); uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, string.Empty), null, -1); uiCharacterItem.Show(); CacheItemSelectionManager.Add(uiCharacterItem); }); base.Show(); }
public override void Show() { CacheSkillSelectionManager.eventOnSelect.RemoveListener(OnSelectCharacterSkill); CacheSkillSelectionManager.eventOnSelect.AddListener(OnSelectCharacterSkill); CacheItemSelectionManager.eventOnSelect.RemoveListener(OnSelectCharacterItem); CacheItemSelectionManager.eventOnSelect.AddListener(OnSelectCharacterItem); BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter; if (owningCharacter == null) { CacheSkillList.HideAll(); CacheItemList.HideAll(); return; } // Skills List <CharacterSkill> filterSkills = new List <CharacterSkill>(); List <int> filterSkillsIndexes = new List <int>(); // Items List <CharacterItem> filterItems = new List <CharacterItem>(); List <int> filterItemsIndexes = new List <int>(); CharacterSkill tempCharacterSkill; foreach (KeyValuePair <Skill, short> characterSkill in owningCharacter.CacheSkills) { tempCharacterSkill = CharacterSkill.Create(characterSkill.Key, characterSkill.Value); if (uiCharacterHotkey.CanAssignCharacterSkill(tempCharacterSkill)) { filterSkills.Add(tempCharacterSkill); filterSkillsIndexes.Add(owningCharacter.IndexOfSkill(tempCharacterSkill.dataId)); } } int counter = 0; foreach (CharacterItem characterItem in owningCharacter.NonEquipItems) { if (uiCharacterHotkey.CanAssignCharacterItem(characterItem)) { filterItems.Add(characterItem); filterItemsIndexes.Add(counter); } ++counter; } CacheSkillList.Generate(filterSkills, (index, characterSkill, ui) => { UICharacterSkill uiCharacterSkill = ui.GetComponent <UICharacterSkill>(); uiCharacterSkill.Setup(new CharacterSkillTuple(characterSkill, characterSkill.level), null, filterSkillsIndexes[index]); uiCharacterSkill.Show(); CacheSkillSelectionManager.Add(uiCharacterSkill); }); CacheItemList.Generate(filterItems, (index, characterItem, ui) => { UICharacterItem uiCharacterItem = ui.GetComponent <UICharacterItem>(); uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), null, filterItemsIndexes[index]); uiCharacterItem.Show(); CacheItemSelectionManager.Add(uiCharacterItem); }); base.Show(); }