少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Events;
 
public class GActorInfo
{
    [System.Serializable]
    public class PropValEx
    {
        // 当前值
        public ulong val;
        // 最大值
        public ulong max;
    }
 
    /// <summary>
    /// 是否本服务端死亡
    /// </summary>
    public bool serverDie = false;
    public bool recordServerDie = false;
    public float moveSpeed;
    public float atkSpeed = 1;
    public float rotateSpeed;
 
    #region 服务端同步信息
    public uint sid;
    public uint ownerSID;// 拥有者的服务端ID,一般为宠物,召唤物会对此值进行赋值
    public byte Job;
    public int face;
    public int facePic;
    public ushort ReincarnationLv;
 
    private string _PlayerName;
    public string PlayerName
    {
        get { return _PlayerName; }
        set
        {
            _PlayerName = UIHelper.ServerStringTrim(value);
 
        }
    }
    public ushort LV;
    public uint realm;//境界
    public uint titleID;// 称号ID
    public uint teamID;// 队伍id, 用来和主角判断是否同个队伍
    public uint familyID;// 仙盟id, 用来和主角判断是否在同个仙盟
    private string _FamilyName;
 
    //预留后续IL开发使用
    public Dictionary<int, ulong> actorDict = new Dictionary<int, ulong>();
    public string familyName// 仙盟名称
    {
        get { return _FamilyName; }
        set
        {
            _FamilyName = UIHelper.ServerStringTrim(value);
 
        }
    }
    public int faction;// 阵营, 用来和主角判断是否在同个阵营
    public uint horseItemID;// 坐骑ID
    public uint ExAttr1; //协助玩家ID
    public uint curProDef; //当前护盾值
    public uint maxProDef; //最大护盾值
    public Vector2 serverBornPos;// 服务端坐标, 目前至对NPC有赋值, 玩家的没有赋值
    public Dictionary<byte, Dictionary<uint, int>> status4012 = new Dictionary<byte, Dictionary<uint, int>>(); // buff给角色增加的状态
    public int GetStatusCount(byte status, uint sid = 0)
    {
        int _count = 0;
        if (status4012.ContainsKey(status))
        {
            if (sid != 0)
            {
                if (status4012[status].ContainsKey(sid))
                {
                    _count = status4012[status][sid];
                }
            }
            else
            {
                foreach (var _c in status4012[status].Values)
                {
                    _count += _c;
                }
            }
        }
        return _count;
    }
    #endregion
 
    #region 血量
 
    /// <summary>
    /// 血量改变事件
    /// </summary>
    public event UnityAction<ulong> OnHpChange;
    /// <summary>
    /// 血量
    /// </summary>
    private PropValEx pveHp = new PropValEx();
 
    private ulong _synchp;
    public ulong SyncServerHp
    {
        get { return _synchp; }
        set
        {
            _synchp = value;
        }
    }// 服务端血量的校准值, 后期检查若没用可去除
 
    public ulong Hp
    {
        get
        {
            return pveHp.val;
        }
 
        set
        {
            pveHp.val = value;
        }
    }
 
    public ulong MaxHp
    {
        get
        {
            return pveHp.max;
        }
 
        set
        {
            pveHp.max = value;
        }
    }
 
    //RealHp 和 RealMaxHp  无特殊含义,历史遗留问题
    public ulong RealHp
    {
        get
        {
            return Hp;
        }
    }
 
    public ulong RealMaxHp
    {
        get
        {
            return MaxHp;
        }
    }
 
    public void ResetHp(long val = -1, long valMax = -1)
    {
        if (val != -1)
        {
            Hp = (ulong)val;
        }
 
        if (valMax != -1)
        {
            MaxHp = (ulong)valMax;
        }
 
        if (sid == PlayerDatas.Instance.PlayerId)
        {
            if (Hp == 0)
            {
                if (Hp != SyncServerHp)
                {
                    //存在服务端和客户端血量不一致的现象
                    Hp = SyncServerHp;
                }
            }
        }
 
 
        if (OnHpChange != null)
        {
            OnHpChange(Hp);
        }
    }
 
    public void ReduceHp(ulong value)
    {
 
        Hp = SyncServerHp;
 
        if (sid == PlayerDatas.Instance.PlayerId)
        {
            if (Hp == 0)
            {
                if (Hp != SyncServerHp)
                {
                    Hp = SyncServerHp;
                }
            }
        }
 
 
        if (OnHpChange != null)
        {
            OnHpChange(Hp);
        }
    }
 
    public void IncreaseHp(ulong value)
    {
 
        Hp = value + Hp;
        if (Hp > SyncServerHp)
        {
            Hp = SyncServerHp;
        }
 
 
        if (OnHpChange != null)
        {
            OnHpChange(Hp);
        }
    }
 
    public void Clear()
    {
        OnHpChange = null;
        status4012.Clear();
    }
 
    #endregion
}