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
|
}
|