protected void OnDeselectCharacterSkill(UICharacterSkill ui) { if (uiSkillDialog != null) { uiSkillDialog.Hide(); } }
protected void OnDeselectCharacterSkill(UICharacterSkill ui) { if (uiSkillDialog != null) { uiSkillDialog.onHide.RemoveListener(OnSkillDialogHide); uiSkillDialog.Hide(); uiSkillDialog.onHide.AddListener(OnSkillDialogHide); } }
protected void OnSelectCharacterSkill(UICharacterSkill ui) { if (uiSkillDialog != null) { uiSkillDialog.selectionManager = CacheSkillSelectionManager; uiSkillDialog.Setup(ui.Data, character, ui.IndexOfData); uiSkillDialog.Show(); } }
protected void OnSelectCharacterSkill(UICharacterSkill ui) { var owningCharacter = BasePlayerCharacterController.OwningCharacter; if (owningCharacter != null) { owningCharacter.RequestAssignHotkey(hotkeyId, HotkeyType.Skill, ui.Skill.DataId); } Hide(); }
public void UpdateData(ICharacterData character) { this.character = character; int selectedSkillId = CacheSkillSelectionManager.SelectedUI != null ? CacheSkillSelectionManager.SelectedUI.Skill.DataId : 0; CacheSkillSelectionManager.DeselectSelectedUI(); CacheSkillSelectionManager.Clear(); if (character == null) { CacheSkillList.HideAll(); return; } // All skills included equipment skill levels displayingSkills = character.GetSkills(); BaseCharacter database = character.GetDatabase(); if (database != null) { CharacterSkill tempCharacterSkill; Skill tempSkill; int tempIndexOfSkill; short tempLevel; // Combine skills from database (skill that can level up) and equipment skills Dictionary <Skill, short> skillLevels = new Dictionary <Skill, short>(); skillLevels = GameDataHelpers.CombineSkills(skillLevels, database.CacheSkillLevels); skillLevels = GameDataHelpers.CombineSkills(skillLevels, character.GetEquipmentSkills()); // Filter skills to show by specific skill types / categories Dictionary <Skill, short> filteredSkillLevels = new Dictionary <Skill, short>(); foreach (KeyValuePair <Skill, short> skillLevel in skillLevels) { if (string.IsNullOrEmpty(skillLevel.Key.category) || filterCategories == null || filterCategories.Count == 0 || filterCategories.Contains(skillLevel.Key.category)) { if (filterSkillTypes == null || filterSkillTypes.Count == 0 || filterSkillTypes.Contains(skillLevel.Key.skillType)) { filteredSkillLevels.Add(skillLevel.Key, skillLevel.Value); } } } skillLevels = filteredSkillLevels; // Generate UIs CacheSkillList.Generate(skillLevels, (index, skillLevel, ui) => { UICharacterSkill uiCharacterSkill = ui.GetComponent <UICharacterSkill>(); tempSkill = skillLevel.Key; tempIndexOfSkill = character.IndexOfSkill(tempSkill.DataId); // Set character skill data if (tempIndexOfSkill >= 0) { tempCharacterSkill = character.Skills[tempIndexOfSkill]; } else { tempCharacterSkill = CharacterSkill.Create(tempSkill, 0); } // Set skill level data tempLevel = 0; if (displayingSkills.ContainsKey(tempSkill)) { tempLevel = displayingSkills[tempSkill]; } // Set UI data uiCharacterSkill.Setup(new CharacterSkillTuple(tempCharacterSkill, tempLevel), character, tempIndexOfSkill); uiCharacterSkill.Show(); UICharacterSkillDragHandler dragHandler = uiCharacterSkill.GetComponentInChildren <UICharacterSkillDragHandler>(); if (dragHandler != null) { dragHandler.SetupForSkills(uiCharacterSkill); } CacheSkillSelectionManager.Add(uiCharacterSkill); if (selectedSkillId == skillLevel.Key.DataId) { uiCharacterSkill.OnClickSelect(); } }); } }
public void SetupForSkills(UICharacterSkill uiCharacterSkill) { sourceLocation = SourceLocation.Skills; this.uiCharacterSkill = uiCharacterSkill; }
protected override void UpdateData() { CharacterHotkey characterHotkey = Data; Skill skill = characterHotkey.GetSkill(); Item item = characterHotkey.GetItem(); BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter; if (uiCharacterSkill == null && uiCharacterHotkeys != null && uiCharacterHotkeys.uiCharacterSkillPrefab != null) { uiCharacterSkill = Instantiate(uiCharacterHotkeys.uiCharacterSkillPrefab, transform); GenericUtils.SetAndStretchToParentSize(uiCharacterSkill.transform as RectTransform, transform as RectTransform); uiCharacterSkill.transform.SetAsFirstSibling(); } if (uiCharacterItem == null && uiCharacterHotkeys != null && uiCharacterHotkeys.uiCharacterItemPrefab != null) { uiCharacterItem = Instantiate(uiCharacterHotkeys.uiCharacterItemPrefab, transform); GenericUtils.SetAndStretchToParentSize(uiCharacterItem.transform as RectTransform, transform as RectTransform); uiCharacterItem.transform.SetAsFirstSibling(); } if (uiCharacterSkill != null) { if (skill == null) { uiCharacterSkill.Hide(); } else { Dictionary <Skill, short> allSkills = owningCharacter.GetSkills(); short skillLevel = 0; if (allSkills.TryGetValue(characterHotkey.GetSkill(), out skillLevel)) { int index = owningCharacter.IndexOfSkill(characterHotkey.dataId); CharacterSkill characterSkill = index >= 0 ? owningCharacter.Skills[index] : CharacterSkill.Create(characterHotkey.GetSkill(), skillLevel); uiCharacterSkill.Setup(new CharacterSkillTuple(characterSkill, skillLevel), owningCharacter, index); uiCharacterSkill.Show(); UICharacterSkillDragHandler dragHandler = uiCharacterSkill.GetComponentInChildren <UICharacterSkillDragHandler>(); if (dragHandler != null) { dragHandler.SetupForHotkey(this); } } else { uiCharacterSkill.Hide(); } } } if (uiCharacterItem != null) { if (item == null) { uiCharacterItem.Hide(); } else { int index = owningCharacter.IndexOfNonEquipItem(characterHotkey.dataId); if (index >= 0 && index < owningCharacter.NonEquipItems.Count) { CharacterItem characterItem = owningCharacter.NonEquipItems[index]; uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), owningCharacter, index); uiCharacterItem.Show(); UICharacterItemDragHandler dragHandler = uiCharacterItem.GetComponentInChildren <UICharacterItemDragHandler>(); if (dragHandler != null) { dragHandler.SetupForHotkey(this); } } else { uiCharacterItem.Hide(); } } } }
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(); }