Пример #1
0
 protected void OnSelectCharacterSkill(UICharacterSkill ui)
 {
     if (uiSkillDialog != null)
     {
         uiSkillDialog.selectionManager = CacheSkillSelectionManager;
         uiSkillDialog.Setup(ui.Data, character, ui.IndexOfData);
         uiSkillDialog.Show();
     }
 }
Пример #2
0
        protected override void UpdateData()
        {
            var characterHotkey = Data;
            var skill           = characterHotkey.GetSkill();
            var item            = characterHotkey.GetItem();

            var owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (uiCharacterSkill != null)
            {
                if (skill == null)
                {
                    uiCharacterSkill.Hide();
                }
                else
                {
                    var index = owningCharacter.IndexOfSkill(characterHotkey.dataId);
                    if (index >= 0 && index < owningCharacter.Skills.Count)
                    {
                        var characterSkill = owningCharacter.Skills[index];
                        uiCharacterSkill.Setup(new SkillTuple(characterSkill.GetSkill(), characterSkill.level), owningCharacter, index);
                        uiCharacterSkill.Show();
                    }
                    else
                    {
                        uiCharacterSkill.Hide();
                    }
                }
            }

            if (uiCharacterItem != null)
            {
                if (item == null)
                {
                    uiCharacterItem.Hide();
                }
                else
                {
                    var index = owningCharacter.IndexOfNonEquipItem(characterHotkey.dataId);
                    if (index >= 0 && index < owningCharacter.NonEquipItems.Count)
                    {
                        var characterItem = owningCharacter.NonEquipItems[index];
                        uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, string.Empty), owningCharacter, index);
                        uiCharacterItem.Show();
                    }
                    else
                    {
                        uiCharacterItem.Hide();
                    }
                }
            }
        }
Пример #3
0
        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();
                    }
                });
            }
        }
Пример #4
0
        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();
        }
Пример #6
0
        protected override void UpdateData()
        {
            if (Level <= 0)
            {
                onSetLevelZeroData.Invoke();
            }
            else
            {
                onSetNonLevelZeroData.Invoke();
            }

            if (uiTextTitle != null)
            {
                uiTextTitle.text = string.Format(
                    LanguageManager.GetText(formatKeyTitle),
                    Skill == null ? LanguageManager.GetUnknowTitle() : Skill.Title);
            }

            if (uiTextDescription != null)
            {
                uiTextDescription.text = string.Format(
                    LanguageManager.GetText(formatKeyDescription),
                    Skill == null ? LanguageManager.GetUnknowDescription() : Skill.Description);
            }

            if (uiTextLevel != null)
            {
                uiTextLevel.text = string.Format(
                    LanguageManager.GetText(formatKeyLevel),
                    Level.ToString("N0"));
            }

            if (imageIcon != null)
            {
                Sprite iconSprite = Skill == null ? null : Skill.icon;
                imageIcon.gameObject.SetActive(iconSprite != null);
                imageIcon.sprite = iconSprite;
            }

            if (uiTextSkillType != null)
            {
                switch (Skill.skillType)
                {
                case SkillType.Active:
                    uiTextSkillType.text = string.Format(
                        LanguageManager.GetText(formatKeySkillType),
                        LanguageManager.GetText(UILocaleKeys.UI_SKILL_TYPE_ACTIVE.ToString()));
                    break;

                case SkillType.Passive:
                    uiTextSkillType.text = string.Format(
                        LanguageManager.GetText(formatKeySkillType),
                        LanguageManager.GetText(UILocaleKeys.UI_SKILL_TYPE_PASSIVE.ToString()));
                    break;

                case SkillType.CraftItem:
                    uiTextSkillType.text = string.Format(
                        LanguageManager.GetText(formatKeySkillType),
                        LanguageManager.GetText(UILocaleKeys.UI_SKILL_TYPE_CRAFT_ITEM.ToString()));
                    break;
                }
            }

            if (uiTextAvailableWeapons != null)
            {
                if (Skill.availableWeapons == null || Skill.availableWeapons.Length == 0)
                {
                    uiTextAvailableWeapons.gameObject.SetActive(false);
                }
                else
                {
                    string str = string.Empty;
                    foreach (WeaponType availableWeapon in Skill.availableWeapons)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            str += "/";
                        }
                        str += availableWeapon.Title;
                    }
                    uiTextAvailableWeapons.text = string.Format(
                        LanguageManager.GetText(formatKeyAvailableWeapons),
                        str);
                    uiTextAvailableWeapons.gameObject.SetActive(true);
                }
            }

            if (uiTextConsumeMp != null)
            {
                uiTextConsumeMp.text = string.Format(
                    LanguageManager.GetText(formatKeyConsumeMp),
                    (Skill == null || Level <= 0) ?
                    LanguageManager.GetUnknowDescription() :
                    Skill.GetConsumeMp(Level).ToString("N0"));
            }

            if (uiRequirement != null)
            {
                if (Skill == null || (Skill.GetRequireCharacterLevel(Level) == 0 && Skill.CacheRequireSkillLevels.Count == 0))
                {
                    uiRequirement.Hide();
                }
                else
                {
                    uiRequirement.Show();
                    uiRequirement.Data = new CharacterSkillTuple(CharacterSkill, Level);
                }
            }

            if (uiCraftItem != null)
            {
                if (Skill == null || Skill.skillType != SkillType.CraftItem)
                {
                    uiCraftItem.Hide();
                }
                else
                {
                    uiCraftItem.SetupForCharacter(Skill.itemCraft);
                    uiCraftItem.Show();
                }
            }

            bool isAttack = Skill != null && Skill.IsAttack();
            bool isOverrideWeaponDamage = isAttack && Skill.skillAttackType == SkillAttackType.Normal;

            if (uiDamageAmount != null)
            {
                if (!isOverrideWeaponDamage)
                {
                    uiDamageAmount.Hide();
                }
                else
                {
                    uiDamageAmount.Show();
                    KeyValuePair <DamageElement, MinMaxFloat> keyValuePair = Skill.GetDamageAmount(Level, null);
                    uiDamageAmount.Data = new DamageElementAmountTuple(keyValuePair.Key, keyValuePair.Value);
                }
            }

            if (uiDamageInflictions != null)
            {
                Dictionary <DamageElement, float> damageInflictionRates = Skill.GetWeaponDamageInflictions(Level);
                if (!isAttack || damageInflictionRates == null || damageInflictionRates.Count == 0)
                {
                    uiDamageInflictions.Hide();
                }
                else
                {
                    uiDamageInflictions.Show();
                    uiDamageInflictions.Data = damageInflictionRates;
                }
            }

            if (uiAdditionalDamageAmounts != null)
            {
                Dictionary <DamageElement, MinMaxFloat> additionalDamageAmounts = Skill.GetAdditionalDamageAmounts(Level);
                if (!isAttack || additionalDamageAmounts == null || additionalDamageAmounts.Count == 0)
                {
                    uiAdditionalDamageAmounts.Hide();
                }
                else
                {
                    uiAdditionalDamageAmounts.Show();
                    uiAdditionalDamageAmounts.Data = additionalDamageAmounts;
                }
            }

            if (uiSkillBuff != null)
            {
                if (!Skill.IsBuff())
                {
                    uiSkillBuff.Hide();
                }
                else
                {
                    uiSkillBuff.Show();
                    uiSkillBuff.Data = new BuffTuple(Skill.buff, Level);
                }
            }

            if (uiSkillDebuff != null)
            {
                if (!Skill.IsDebuff())
                {
                    uiSkillDebuff.Hide();
                }
                else
                {
                    uiSkillDebuff.Show();
                    uiSkillDebuff.Data = new BuffTuple(Skill.debuff, Level);
                }
            }

            if (clones != null && clones.Length > 0)
            {
                for (int i = 0; i < clones.Length; ++i)
                {
                    if (clones[i] == null)
                    {
                        continue;
                    }
                    clones[i].Data = Data;
                }
            }

            if (uiNextLevelSkill != null)
            {
                if (Level + 1 > Skill.maxLevel)
                {
                    uiNextLevelSkill.Hide();
                }
                else
                {
                    uiNextLevelSkill.Setup(new CharacterSkillTuple(CharacterSkill, (short)(Level + 1)), Character, IndexOfData);
                    uiNextLevelSkill.Show();
                }
            }
        }
Пример #7
0
        protected override void UpdateData()
        {
            if (Level <= 0)
            {
                onSetLevelZeroData.Invoke();
            }
            else
            {
                onSetNonLevelZeroData.Invoke();
            }

            if (uiTextTitle != null)
            {
                uiTextTitle.text = string.Format(titleFormat, Skill == null ? "Unknow" : Skill.title);
            }

            if (uiTextDescription != null)
            {
                uiTextDescription.text = string.Format(descriptionFormat, Skill == null ? "N/A" : Skill.description);
            }

            if (uiTextLevel != null)
            {
                uiTextLevel.text = string.Format(levelFormat, Level.ToString("N0"));
            }

            if (imageIcon != null)
            {
                var iconSprite = Skill == null ? null : Skill.icon;
                imageIcon.gameObject.SetActive(iconSprite != null);
                imageIcon.sprite = iconSprite;
            }

            if (uiTextSkillType != null)
            {
                switch (Skill.skillType)
                {
                case SkillType.Active:
                    uiTextSkillType.text = string.Format(skillTypeFormat, activeSkillType);
                    break;

                case SkillType.Passive:
                    uiTextSkillType.text = string.Format(skillTypeFormat, passiveSkillType);
                    break;

                case SkillType.CraftItem:
                    uiTextSkillType.text = string.Format(skillTypeFormat, craftItemSkillType);
                    break;
                }
            }

            if (uiTextAvailableWeapons != null)
            {
                if (Skill.availableWeapons == null || Skill.availableWeapons.Length == 0)
                {
                    uiTextAvailableWeapons.gameObject.SetActive(false);
                }
                else
                {
                    var str = string.Empty;
                    foreach (var availableWeapon in Skill.availableWeapons)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            str += "/";
                        }
                        str += availableWeapon.title;
                    }
                    uiTextAvailableWeapons.text = string.Format(availableWeaponsFormat, str);
                    uiTextAvailableWeapons.gameObject.SetActive(true);
                }
            }

            if (uiTextConsumeMp != null)
            {
                uiTextConsumeMp.text = string.Format(consumeMpFormat, Skill == null || Level <= 0 ? "N/A" : Skill.GetConsumeMp(Level).ToString("N0"));
            }

            if (uiRequirement != null)
            {
                if (Skill == null || (Skill.GetRequireCharacterLevel(Level) == 0 && Skill.CacheRequireSkillLevels.Count == 0))
                {
                    uiRequirement.Hide();
                }
                else
                {
                    uiRequirement.Show();
                    uiRequirement.Data = new SkillTuple(Skill, Level);
                }
            }

            if (uiCraftItem != null)
            {
                if (Skill == null || Skill.skillType != SkillType.CraftItem)
                {
                    uiCraftItem.Hide();
                }
                else
                {
                    uiCraftItem.Show();
                    uiCraftItem.Data = Skill.itemCraft;
                }
            }

            var isAttack = Skill != null && Skill.IsAttack();
            var isOverrideWeaponDamage = isAttack && Skill.skillAttackType == SkillAttackType.Normal;

            if (uiDamageAmount != null)
            {
                if (!isOverrideWeaponDamage)
                {
                    uiDamageAmount.Hide();
                }
                else
                {
                    uiDamageAmount.Show();
                    var keyValuePair = Skill.GetDamageAmount(Level, null);
                    uiDamageAmount.Data = new DamageElementAmountTuple(keyValuePair.Key, keyValuePair.Value);
                }
            }

            if (uiDamageInflictions != null)
            {
                var damageInflictionRates = Skill.GetWeaponDamageInflictions(Level);
                if (!isAttack || damageInflictionRates == null || damageInflictionRates.Count == 0)
                {
                    uiDamageInflictions.Hide();
                }
                else
                {
                    uiDamageInflictions.Show();
                    uiDamageInflictions.Data = damageInflictionRates;
                }
            }

            if (uiAdditionalDamageAmounts != null)
            {
                var additionalDamageAmounts = Skill.GetAdditionalDamageAmounts(Level);
                if (!isAttack || additionalDamageAmounts == null || additionalDamageAmounts.Count == 0)
                {
                    uiAdditionalDamageAmounts.Hide();
                }
                else
                {
                    uiAdditionalDamageAmounts.Show();
                    uiAdditionalDamageAmounts.Data = additionalDamageAmounts;
                }
            }

            if (uiSkillBuff != null)
            {
                if (!Skill.IsBuff())
                {
                    uiSkillBuff.Hide();
                }
                else
                {
                    uiSkillBuff.Show();
                    uiSkillBuff.Data = new BuffTuple(Skill.buff, Level);
                }
            }

            if (uiSkillDebuff != null)
            {
                if (!Skill.IsDebuff())
                {
                    uiSkillDebuff.Hide();
                }
                else
                {
                    uiSkillDebuff.Show();
                    uiSkillDebuff.Data = new BuffTuple(Skill.debuff, Level);
                }
            }

            if (uiNextLevelSkill != null)
            {
                if (Level + 1 > Skill.maxLevel)
                {
                    uiNextLevelSkill.Hide();
                }
                else
                {
                    uiNextLevelSkill.Setup(new SkillTuple(Skill, (short)(Level + 1)), character, indexOfData);
                    uiNextLevelSkill.Show();
                }
            }
        }