using UnityEngine;
|
using System.Collections.Generic;
|
|
using vnxbqy.UI;
|
|
public class GA_PlayerXMZZ : GActorPlayerBase, IOtherSelectable
|
{
|
public struct XmzzItemInfo
|
{
|
public int id;
|
public int place;
|
}
|
|
public class XmzzTargetInfo
|
{
|
public byte job;
|
public uint playerID;
|
public string FamilyName;
|
public uint FamilyID;
|
public string name;
|
public ushort level;
|
public ulong hp;
|
public ulong maxHp;
|
public XmzzItemInfo[] itemDatas;
|
}
|
|
public static Dictionary<uint, XmzzTargetInfo> xmzzDict = new Dictionary<uint, XmzzTargetInfo>();
|
|
private H0406_tagNPCAppear m_H0406;
|
private CmdManager m_CmdManager;
|
|
protected override void OnInit(GameNetPackBasic package)
|
{
|
base.OnInit(package);
|
|
m_H0406 = package as H0406_tagNPCAppear;
|
|
if (m_H0406 == null)
|
{
|
return;
|
}
|
|
CapsuleCollider _capCollider = Root.AddMissingComponent<CapsuleCollider>();
|
_capCollider.height = 1.2f;
|
_capCollider.center = new Vector3(0, .6f, 0);
|
_capCollider.radius = .4f;
|
|
Evt_PlayerClick _evtClick = Root.AddMissingComponent<Evt_PlayerClick>();
|
_evtClick.ownerSID = ServerInstID;
|
|
// 初始化坐标
|
AdjustPos(m_H0406.PosX, m_H0406.PosY);
|
|
ActorInfo.moveSpeed = 500f / m_H0406.Speed;
|
ActorInfo.atkSpeed = 1;
|
|
XmzzTargetInfo _info = xmzzDict[m_H0406.NPCID];
|
|
JobSetup = JobSetupConfig.Get(_info.job);
|
|
XmzzItemInfo _itemInfo;
|
|
if (_info.itemDatas != null)
|
{
|
// 因为衣服是所有装备的父节点, 需要预先处理衣服
|
for (int i = 0; i < _info.itemDatas.Length; ++i)
|
{
|
_itemInfo = _info.itemDatas[i];
|
|
if (_itemInfo.place == (int)RoleEquipType.Clothes)
|
{
|
//m_SuitLevel = 0;
|
//if (_itemInfo.isSuit == 1)
|
//{
|
// m_SuitLevel = (byte)_itemInfo.suitLevel;
|
//}
|
SwitchClothes((uint)_itemInfo.id);
|
//ChangeEquip(_itemInfo.place, (uint)_itemInfo.id, m_SuitLevel);
|
break;
|
}
|
}
|
}
|
|
// 如果没有任何衣服, 则穿上默认装备
|
if (ClothesItemID == 0 || ClothesItemID == uint.MaxValue)
|
{
|
SwitchClothes(0);
|
}
|
|
if (_info.itemDatas != null)
|
{
|
for (int i = 0; i < _info.itemDatas.Length; ++i)
|
{
|
_itemInfo = _info.itemDatas[i];
|
|
if (_itemInfo.place == (int)RoleEquipType.Weapon)
|
{
|
SwitchWeapon((uint)_itemInfo.id);
|
}
|
else if (_itemInfo.place == (int)RoleEquipType.Weapon2)
|
{
|
SwitchSecondary((uint)_itemInfo.id);
|
}
|
else if (_itemInfo.place == (int)RoleEquipType.Wing)
|
{
|
SwitchWing((uint)_itemInfo.id);
|
}
|
else if (_itemInfo.place == (int)RoleEquipType.Guard)
|
{
|
SwitchGuard((uint)_itemInfo.id);
|
}
|
else if (_itemInfo.place == (int)RoleEquipType.Mount)
|
{
|
ActorInfo.horseItemID = (uint)_itemInfo.id;
|
}
|
|
//m_SuitLevel = 0;
|
//if (_itemInfo.isSuit == 1)
|
//{
|
// m_SuitLevel = (byte)_itemInfo.suitLevel;
|
//}
|
|
//ChangeEquip(_itemInfo.place, (uint)_itemInfo.id, m_SuitLevel);
|
}
|
}
|
|
if (WeaponItemID == 0 || WeaponItemID == uint.MaxValue)
|
{
|
SwitchWeapon(0);
|
}
|
|
ActorInfo.LV = _info.level;
|
ActorInfo.Job = _info.job;
|
ActorInfo.PlayerName = _info.name;
|
if (m_H0406.NPCID == 30403001)
|
{
|
ActorInfo.Hp = _info.hp;
|
ActorInfo.MaxHp = _info.maxHp;
|
}
|
else
|
{
|
ActorInfo.Hp = m_H0406.NPCHP + m_H0406.NPCHPEx * Constants.ExpPointValue;
|
ActorInfo.MaxHp = m_H0406.MaxHP + m_H0406.MaxHPEx * Constants.ExpPointValue;
|
}
|
|
RequestName();
|
|
m_CmdManager = new CmdManager();
|
|
IdleImmediate();
|
}
|
|
public override void Destroy()
|
{
|
}
|
|
protected sealed override void OnUpdate()
|
{
|
if (m_CmdManager != null)
|
{
|
m_CmdManager.Update();
|
}
|
}
|
protected sealed override void OnUnit()
|
{
|
base.OnUnit();
|
|
m_H0406 = null;
|
m_CmdManager = null;
|
}
|
|
public sealed override void OnHorse(byte upOrDown)
|
{
|
}
|
|
public sealed override void RefreshLifeBar(ulong value)
|
{
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
if (_hero != null && _hero.SelectTarget == this)
|
{
|
if (GA_Player.s_OnRefreshLife != null)
|
{
|
GA_Player.s_OnRefreshLife(ServerInstID, ActorInfo.RealHp, ActorInfo.RealMaxHp);
|
}
|
}
|
}
|
|
public sealed override void RequestName()
|
{
|
ReleaseName();
|
if (MovingState == E_MovingState.Ride)
|
{
|
m_HeadUpName = HeadUpName.RequireHeadUpName(HeadUpName.Pattern.Player, MP_Name1, 0, CameraController.Instance.CameraObject);
|
}
|
else
|
{
|
m_HeadUpName = HeadUpName.RequireHeadUpName(HeadUpName.Pattern.Player, MP_Name, 0, CameraController.Instance.CameraObject);
|
}
|
|
m_HeadUpName.SetPlayerInfo(new HeadUpName.PlayerInfo()
|
{
|
realm = ActorInfo.realm,
|
title = ActorInfo.titleID,
|
name = ActorInfo.PlayerName,
|
alliance = ActorInfo.familyName,
|
});
|
RefreshShediaoEffect(ActorInfo.titleID);
|
}
|
|
protected sealed override void OnPutonClothes(uint clothesItemID, GameObject clothed)
|
{
|
clothed.layer = LayerUtility.Player;
|
|
SkinnedMeshRenderer _renderer = clothed.GetComponentInChildren<SkinnedMeshRenderer>();
|
_renderer.gameObject.SetLayer(LayerUtility.Player, false);
|
}
|
|
protected sealed override void OnPutonSecondary(uint secondaryItemID, GameObject secondary)
|
{
|
Renderer _renderer = secondary.GetComponentInChildren<Renderer>();
|
_renderer.gameObject.SetLayer(LayerUtility.Player, false);
|
}
|
|
protected sealed override void OnPutonWeapon(uint weaponItemID, GameObject weapon)
|
{
|
Renderer _renderer = weapon.GetComponentInChildren<Renderer>();
|
_renderer.gameObject.SetLayer(LayerUtility.Player, false);
|
}
|
|
protected sealed override void OnPutonWing(uint wingItemID, GameObject wing)
|
{
|
SkinnedMeshRenderer _renderer = wing.GetComponentInChildren<SkinnedMeshRenderer>();
|
_renderer.gameObject.SetLayer(LayerUtility.Player, false);
|
}
|
|
protected sealed override void OnSwitchHorse(uint horseID, GameObject horse)
|
{
|
}
|
|
public sealed override bool CanAtked() { return true; }
|
|
public bool CanBeSelected()
|
{
|
if (ActorInfo.serverDie)
|
{
|
return false;
|
}
|
|
return true;
|
}
|
|
public void OnClick()
|
{
|
if (ActorInfo.serverDie)
|
{
|
return;
|
}
|
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
if (_hero == null)
|
{
|
return;
|
}
|
|
_hero.LockTarget = this;
|
_hero.SelectTarget = this;
|
}
|
|
public void OnSelect()
|
{
|
if (CanAtked())
|
{
|
SelectionManager.Request(SelectionManager.E_Type.Red, this);
|
}
|
else
|
{
|
SelectionManager.Request(SelectionManager.E_Type.Green, this);
|
}
|
|
if (GA_Player.s_OnSelected != null)
|
{
|
GA_Player.s_OnSelected(ServerInstID, true);
|
}
|
}
|
|
public void OnUnSelect()
|
{
|
SelectionManager.Release(SelectionManager.E_Type.Green);
|
SelectionManager.Release(SelectionManager.E_Type.Red);
|
|
if (GA_Player.s_OnSelected != null)
|
{
|
GA_Player.s_OnSelected(ServerInstID, false);
|
}
|
}
|
|
public void Cmd_0614(H0614_tagUseSkillPos h0614)
|
{
|
Cmd0614 _cmd = new Cmd0614();
|
_cmd.Init(h0614);
|
m_CmdManager.Enqueue(_cmd);
|
}
|
|
public void ClearAllCMD()
|
{
|
m_CmdManager.Clear();
|
}
|
|
public override void SyncSuitEffect(bool onOrOff = true)
|
{
|
}
|
}
|