using System; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class BeautyMMTalentEffectCell : CellView { [SerializeField] Text lvText; [SerializeField] ImageEx lvBGImg; [SerializeField] Text nameText; [SerializeField] Text[] talentTexts; [SerializeField] Image activeImg; public void Display(int rank, int mmID) { lvText.text = (rank*BeautyMMManager.Instance.needLVForTalent).ToString(); var lvValue = BeautyMMManager.Instance.GetMMLV(mmID); var isActive = BeautyMMManager.Instance.isActiveMM(mmID); bool isRankActive = false; if (isActive && lvValue/BeautyMMManager.Instance.needLVForTalent >= rank) { isRankActive = true; } lvBGImg.gray = !isRankActive; ShowTalent(mmID, rank, isRankActive); activeImg.SetActive(isRankActive && lvValue / BeautyMMManager.Instance.needLVForTalent == rank); nameText.text = isRankActive ? Language.Get($"BeautyMMLVName{rank + 1}") : UIHelper.AppendColor(TextColType.NavyGray, Language.Get($"BeautyMMLVName{rank + 1}")); } void ShowTalent(int mmID, int rank, bool isRankActive) { var mmConfig = BeautyConfig.Get(mmID); //先显示天赋属性,再显示天赋特性 var attrs = GetMMTalentAttrForUI(mmConfig, rank); int talentIndex = 0; if (attrs.IsNullOrEmpty()) { talentIndex = 0; } else { foreach (var attr in attrs) { if (talentIndex < talentTexts.Length) { talentTexts[talentIndex].SetActive(true); string format = "{0}" + UIHelper.AppendColor(TextColType.Green, "+{1}"); talentTexts[talentIndex].text = PlayerPropertyConfig.GetFullDescription(attr.Key, attr.Value, format); } else { break; } talentIndex++; } } var talentValue = GetMMTalentEffectForUI(mmConfig, rank); for (int i = talentIndex; i < talentTexts.Length; i++) { if (i == talentIndex && mmConfig.EffType != 0) { //天赋效果约定最多一个 talentTexts[talentIndex].SetActive(true); switch (mmConfig.EffType) { case 1: talentTexts[i].text = Language.Get($"BeautyMMTalent1", talentValue); break; case 2: talentTexts[i].text = Language.Get($"BeautyMMTalent2", talentValue / 100, ItemConfig.Get(mmConfig.EffTypeValue).ItemName); break; case 3: talentTexts[i].text = Language.Get($"BeautyMMTalent3", talentValue); break; case 4: talentTexts[i].text = Language.Get($"BeautyMMTalent4", ItemConfig.Get(mmConfig.EffTypeValue).ItemName, talentValue); break; } } else { talentTexts[i].SetActive(false); } } //置灰 if (!isRankActive) { for (int i = 0; i < talentTexts.Length; i++) { talentTexts[i].text = UIHelper.AppendColor(TextColType.NavyGray, talentTexts[i].text); } } } Dictionary GetMMTalentAttrForUI(BeautyConfig config, int rank) { var _dict = new Dictionary(); //初始天赋属性 for (int i = 0; i < config.TalentAttrIDList.Length; i++) { _dict[config.TalentAttrIDList[i]] = config.TalentAttrValueList[i]; } //按x级好感度提升一级天赋效果 if (rank > 0) { for (int i = 0; i < config.TalentAttrIDList.Length; i++) { _dict[config.TalentAttrIDList[i]] += rank * config.TalentPerLVAddList[i]; } } return _dict; } int GetMMTalentEffectForUI(BeautyConfig config, int rank) { //初始天赋效果 int _effect = config.EffValue; if (rank > 0) { _effect += rank * config.EffPerLVAdd; } return _effect; } }