using System.Collections; using System.Collections.Generic; using UnityEngine; using GCGame.Table; public class TitlePropPanelCtr : MonoBehaviour { public static TitlePropPanelCtr Instance; public UIContainerBase _PropContainer; public UIContainerBase _ActiveItemContainer; public UIImgText _TotalCombat; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } private Dictionary _PropDic; private void OnEnable() { StartCoroutine(GetAllPropDic()); } public void RefreshTitlePropView() { StartCoroutine(GetAllPropDic()); } IEnumerator GetAllPropDic() { yield return new WaitForEndOfFrame(); _PropDic = new Dictionary(); foreach (var info in TableManager.GetTitleData().Values) { for (int index = 0; index < info.getAttrIdCount(); index++) { if (info.GetAttrIdbyIndex(index) != -1 && !_PropDic.ContainsKey(info.GetAttrIdbyIndex(index))) _PropDic.Add(info.GetAttrIdbyIndex(index), 0); } } List _ActiviteTileIdList = new List(); var _TotalCombatVal = 0; for(int index = 0; index < GameManager.gameManager.PlayerDataPool.TitleInvestitive.AllTitleList.Count; index++) { var titleId = GameManager.gameManager.PlayerDataPool.TitleInvestitive.AllTitleList[index].TitleID; var titleData = TableManager.GetTitleDataByID(titleId, 0); _TotalCombatVal += titleData.CombatPower; _ActiviteTileIdList.Add(titleId); for (int attrIndex = 0; attrIndex < titleData.getAttrIdCount(); attrIndex ++) { if(titleData.GetAttrIdbyIndex(attrIndex) != -1 && _PropDic.ContainsKey(titleData.GetAttrIdbyIndex(attrIndex))) { _PropDic[titleData.GetAttrIdbyIndex(attrIndex)] += titleData.GetAttrValbyIndex(attrIndex); } else if(titleData.GetAttrIdbyIndex(attrIndex) != -1) { _PropDic.Add(titleData.GetAttrIdbyIndex(attrIndex), titleData.GetAttrValbyIndex(attrIndex)); } } } _TotalCombat.text = _TotalCombatVal.ToString(); _ActiveItemContainer.InitContentItem(_ActiviteTileIdList); List infoList = new List(); foreach (var info in _PropDic) { TitleViewPropItemStruct prop = new TitleViewPropItemStruct(info.Key, info.Value); infoList.Add(prop); } _PropContainer.InitContentItem(infoList); yield break; } }