using asap.core; using cfg; // using com.fpnn; using GameCore; using System.Collections.Generic; using TMPro; using UnityEngine; public class item_perk : MonoBehaviour { public Perk perk; public TMP_Text text_name; public TMP_Text text_type; public GameObject text_actived; public GameObject text_current; public GameObject text_notactived; public GameObject info_notactived; List _list = new List(); public void Show(int rodID, int index, int addLevel) { for (int i = 0; i < _list.Count; i++) { Destroy(_list[i]); } _list.Clear(); Tables _tables = GContext.container.Resolve(); RodData rodData = _tables.TbRodData.GetOrDefault(rodID); RodAscend rodAscend = _tables.TbRodAscend.GetOrDefault(rodData.AscendID); var unlockstars = rodAscend.PerkUnlockOrder; int star = GContext.container.Resolve().GetRodPiece(rodData.ID); int perkID = rodAscend.PerkIDList[index]; RodAscendPerk rodEngancePerk = _tables.TbRodAscendPerk.GetOrDefault(perkID); text_name.text = LocalizationMgr.GetText(rodEngancePerk.Title_l10n_key); text_type.gameObject.SetActive(rodEngancePerk.DuelPerk); int curLv = 0; List starList = new List(); for (int i = 0; i < rodAscend.DefaultPerk.Count; i++) { if (rodAscend.DefaultPerk[i] == index + 1) { curLv++; starList.Add(0); } } for (int i = 0; i < unlockstars.Count; i++) { if (unlockstars[i] == index + 1) { starList.Add(i + 1); if (i < star) { curLv++; } } } if (addLevel >= 0) { curLv += addLevel; List PerkDataList = rodAscend.PerkDataList[index]; string perkValue = PerkDataList[curLv - 1]; string text_level = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePopupPanel_1", curLv); string text_info = PlayerFishData.GetPerkDesc(rodEngancePerk.PerkType, rodEngancePerk.Desc_l10n_key, perkValue); GameObject text_go = Instantiate(text_current, transform); text_go.SetActive(true); text_go.GetComponent().text = $"{text_level}: {text_info}"; _list.Add(text_go); } else { ShowList(curLv, index, starList, rodData, rodAscend, rodEngancePerk); } perk.SetData(perkID, curLv, rodData.Quality); } void ShowList(int curLv, int index, List starList, RodData rodData, RodAscend rodAscend, RodAscendPerk rodEngancePerk) { if (curLv == 0) { string perkValue = rodAscend.PerkDataList[index][0]; string text_level = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePopupPanel_1", 1); string text_info = PlayerFishData.GetPerkDesc(rodEngancePerk.PerkType, rodEngancePerk.Desc_l10n_key, perkValue); GameObject text_go = Instantiate(text_notactived, transform); GameObject info_go = Instantiate(info_notactived, transform); info_go.SetActive(true); StarItemRoot starItemRoot = info_go.transform.Find("conditions/text_info/star").GetComponent(); starItemRoot.SetStar(starList[0], rodAscend.MaxAscent); _list.Add(info_go); text_go.SetActive(true); text_go.GetComponent().text = $"{text_level}:{text_info}"; _list.Add(text_go); } else { for (int i = curLv - 1; i < starList.Count && i < curLv + 1; i++) { List PerkDataList = rodAscend.PerkDataList[index]; if (i >= PerkDataList.Count) { Debug.LogError($"钓竿ID:{rodData.ID}的{rodEngancePerk.ID}第{i + 1}阶提升属性不存在"); break; } string perkValue = PerkDataList[i]; string text_level = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePopupPanel_1", i + 1); string text_info = PlayerFishData.GetPerkDesc(rodEngancePerk.PerkType, rodEngancePerk.Desc_l10n_key, perkValue); GameObject text_go = null; if (i == curLv - 1) { //当前 text_go = Instantiate(text_current, transform); } else { //未拥有 text_go = Instantiate(text_notactived, transform); GameObject info_go = Instantiate(info_notactived, transform); info_go.SetActive(true); StarItemRoot starItemRoot = info_go.transform.Find("conditions/text_info/star").GetComponent(); starItemRoot.SetStar(starList[i], rodAscend.MaxAscent); _list.Add(info_go); } text_go.SetActive(true); text_go.GetComponent().text = $"{text_level}: {text_info}"; _list.Add(text_go); } } } }