protected void UpdateData(IList <ItemCraft> itemCrafts) { int selectedIdx = CacheItemSelectionManager.SelectedUI != null?CacheItemSelectionManager.IndexOf(CacheItemSelectionManager.SelectedUI) : -1; CacheItemSelectionManager.DeselectSelectedUI(); CacheItemSelectionManager.Clear(); CacheItemList.Generate(itemCrafts, (index, craftItem, ui) => { UICraftItem uiCraftItem = ui.GetComponent <UICraftItem>(); switch (CrafterType) { case CrafterType.Character: uiCraftItem.SetupForCharacter(craftItem); break; case CrafterType.Npc: uiCraftItem.SetupForNpc(craftItem); break; case CrafterType.Workbench: uiCraftItem.SetupForWorkbench(BuildingObjectId, craftItem); break; } uiCraftItem.Show(); CacheItemSelectionManager.Add(uiCraftItem); if (selectedIdx == index) { uiCraftItem.OnClickSelect(); } }); }
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(); } } }