using System; using System.Collections.Generic; // 属性计算相关 public partial class PhantasmPavilionManager : GameSystemManager { public Dictionary attrDic = new Dictionary(); public Dictionary GetTotalAttr() { return attrDic; } public long GetAttrValue(int attrID) { attrDic.TryGetValue(attrID, out long value); return value; } public int GetAttrPer(int attrID) { if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrID)) { var pertype = PlayerPropertyConfig.baseAttr2perDict[attrID]; attrDic.TryGetValue(pertype, out long value); return (int)(value); } return 0; } public void RefreshAttr() { attrDic.Clear(); foreach (string name in Enum.GetNames(typeof(PhantasmPavilionType))) { PhantasmPavilionType type = (PhantasmPavilionType)Enum.Parse(typeof(PhantasmPavilionType), name); if (!TryGetHandlerValue(type, out var handler)) continue; var list = handler.GetKeyList(); if (list.IsNullOrEmpty()) continue; foreach (var id in list) { bool hasInitAttr = HasInitAttr(type, id); bool hasStarAddAttr = HasStarAddAttr(type, id); // 有初始属性 if (hasInitAttr && !hasStarAddAttr) { int[] attrIDList = GetAttrIDList(type, id); // 不支持升星 if (!hasStarAddAttr) { int[] initAttrValueList = GetInitAttrValueList(type, id); for (int i = 0; i < attrIDList.Length; i++) { if (!attrDic.ContainsKey(attrIDList[i])) { attrDic[attrIDList[i]] = 0; } // 解锁的才累加计算属性 bool isUnlock = IsUnlock(type, id); if (!isUnlock) continue; attrDic[attrIDList[i]] += initAttrValueList[i]; } } // 支持升星 else { for (int i = 0; i < attrIDList.Length; i++) { if (!attrDic.ContainsKey(attrIDList[i])) { attrDic[attrIDList[i]] = 0; } // 解锁的才累加计算属性 bool isUnlock = IsUnlock(type, id); if (!isUnlock) continue; int addValue = GetEndAttrValue(type, id, i); attrDic[attrIDList[i]] += addValue; } } } } } } //最终属性 = 初始属性 + 星级*升星加成值 public int GetEndAttrValue(PhantasmPavilionType type, int id, int AttrIndex) { bool isCanStarAdd = HasStarAddAttr(type, id); // 是否可升星 if (!isCanStarAdd || !TryGetInfo(type, id, out PhantasmPavilionData info)) return 0; int[] attrIDList = GetAttrIDList(type, id); int[] initAttrValueList = GetInitAttrValueList(type, id); int[] attrPerStarAddList = GetAttrPerStarAddList(type, id); if (attrIDList.IsNullOrEmpty() || initAttrValueList.IsNullOrEmpty() || attrPerStarAddList.IsNullOrEmpty() || attrIDList.Length != initAttrValueList.Length || attrIDList.Length != attrPerStarAddList.Length || attrIDList.Length <= AttrIndex) return 0; int initAttrValue = initAttrValueList[AttrIndex]; int attrPerStarAdd = attrPerStarAddList[AttrIndex]; return initAttrValue + info.Star * attrPerStarAdd; } }