| Main/System/HeroFates/HeroFatesAttrCell.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/HeroFates/HeroFatesAttrCell.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/HeroFates/HeroFatesAttrItem.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/HeroFates/HeroFatesAttrItem.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/HeroFates/HeroFatesManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/HeroFates/HeroFatesWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Main/System/HeroFates/HeroFatesAttrCell.cs
New file @@ -0,0 +1,43 @@ using System.Collections.Generic; using UnityEngine; public class HeroFatesAttrCell : MonoBehaviour { [SerializeField] HeroFatesAttrItem[] items; HeroFatesManager manager { get { return HeroFatesManager.Instance; } } public void Display(int rowIndex, List<int> totalAttrIdList, Dictionary<int, long> totalAttrDict) { if (totalAttrIdList.IsNullOrEmpty() || totalAttrDict.IsNullOrEmpty()) { return; } for (int i = 0; i < items.Length; i++) { int index = rowIndex * manager.attrRowCountMax + i; if (index < totalAttrIdList.Count) { if (index >= totalAttrIdList.Count || index < 0) { continue; } int attrId = totalAttrIdList[index]; if (!totalAttrDict.ContainsKey(attrId)) { continue; } long attrValue = totalAttrDict[attrId]; items[i].SetActive(true); items[i].Display(attrId, attrValue); } else { items[i].SetActive(false); } } } } Main/System/HeroFates/HeroFatesAttrCell.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: bfad3efe8ed965a468b3d10078e23014 MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/System/HeroFates/HeroFatesAttrItem.cs
New file @@ -0,0 +1,11 @@ using System.Collections.Generic; using UnityEngine; public class HeroFatesAttrItem : MonoBehaviour { [SerializeField] TextEx txtAttr; public void Display(int attrID, long attrValue) { txtAttr.text = PlayerPropertyConfig.GetFullDescription(attrID, attrValue); } } Main/System/HeroFates/HeroFatesAttrItem.cs.meta
New file @@ -0,0 +1,11 @@ fileFormatVersion: 2 guid: 0c43efa49cf2f564a8acdc3ec0e57eea MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Main/System/HeroFates/HeroFatesManager.cs
@@ -6,7 +6,7 @@ public class HeroFatesManager : GameSystemManager<HeroFatesManager> { public readonly int rowCountMax = 5; public readonly int attrRowCountMax = 3; public override void Init() { DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitializeEventOnRelogin; Main/System/HeroFates/HeroFatesWin.cs
@@ -1,3 +1,4 @@ using System; using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -5,7 +6,7 @@ public class HeroFatesWin : UIBase { [SerializeField] ScrollerController scroller; [SerializeField] List<TextEx> attrs; [SerializeField] ScrollerController attrScroller; HeroFatesManager manager { get { return HeroFatesManager.Instance; } } protected override void InitComponent() { @@ -15,6 +16,7 @@ protected override void OnPreOpen() { scroller.OnRefreshCell += OnRefreshCell; attrScroller.OnRefreshCell += OnRefreshAttrCell; manager.OnUpdateHeroFatesInfoEvent += OnUpdateHeroFatesInfo; CreateScoller(); @@ -22,19 +24,26 @@ manager.HasShowRedDotFates(out firstIndex); scroller.JumpIndex(firstIndex); DisplayAttrs(); CreateAttrScoller(); } protected override void OnPreClose() { scroller.OnRefreshCell -= OnRefreshCell; attrScroller.OnRefreshCell -= OnRefreshAttrCell; manager.OnUpdateHeroFatesInfoEvent -= OnUpdateHeroFatesInfo; } private void OnRefreshAttrCell(ScrollerDataType type, CellView cell) { var _cell = cell.GetComponent<HeroFatesAttrCell>(); _cell?.Display(cell.index, totalAttrIdList, totalAttrDict); } private void OnUpdateHeroFatesInfo() { RefeshScoller(); DisplayAttrs(); CreateAttrScoller(); } List<int> fatesIDList = new List<int>(); private void OnRefreshCell(ScrollerDataType type, CellView cell) @@ -62,29 +71,28 @@ scroller.m_Scorller.RefreshActiveCellViews(); } void DisplayAttrs() List<int> totalAttrIdList = new List<int>(); Dictionary<int, long> totalAttrDict = new Dictionary<int, long>(); void CreateAttrScoller() { Dictionary<int, long> totalAttrDict = manager.GetTotalAttr(); if (attrs.IsNullOrEmpty() || totalAttrDict.IsNullOrEmpty()) totalAttrDict = manager.GetTotalAttr(); if (totalAttrDict.IsNullOrEmpty()) return; List<int> totalAttrIdList = totalAttrDict.Keys .OrderByDescending(attrID => totalAttrDict[attrID] > 0) // 属性值>0的排前面 .ThenBy(attrID => attrID) // 然后按attrID升序 .ToList(); for (int i = 0; i < attrs.Count; i++) totalAttrIdList = totalAttrDict.Keys .OrderByDescending(attrID => totalAttrDict[attrID] > 0) // 属性值>0的排前面 .ThenBy(attrID => attrID) // 然后按attrID升序 .ToList(); attrScroller.Refresh(); if (!totalAttrIdList.IsNullOrEmpty()) { if (i < totalAttrDict.Count) int rowCount = Mathf.CeilToInt((float)totalAttrIdList.Count / manager.attrRowCountMax); for (int i = 0; i < rowCount; i++) { int attrID = totalAttrIdList[i]; long attrValue = totalAttrDict[attrID]; attrs[i].text = PlayerPropertyConfig.GetFullDescription(attrID, attrValue); attrs[i].SetActive(true); } else { attrs[i].SetActive(false); attrScroller.AddCell(ScrollerDataType.Header, i); } } attrScroller.Restart(); } }