hch
2 天以前 89fa96e505af9fe7baf676591222bfdb23b48262
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using System.Collections.Generic;
// 属性计算相关
public partial class PhantasmPavilionManager : GameSystemManager<PhantasmPavilionManager>
{
    public Dictionary<int, long> attrDic = new Dictionary<int, long>();
 
    public Dictionary<int, long> 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;
    }
}