using System.Collections.Generic;
|
using UnityEngine;
|
using vnxbqy.UI;
|
|
public class GA_NpcFightZZPlayer : GActorPlayerBase, IOtherSelectable
|
{
|
public class DungeonHelpInfo
|
{
|
public uint objID;
|
public uint playerID;
|
public byte job;
|
}
|
|
public static List<uint> s_UnCreateObjIDList = new List<uint>();
|
|
private H0406_tagNPCAppear m_H0406;
|
private CmdManager m_CmdManager;
|
|
public static int cacheMapDataId;
|
|
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;
|
|
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
|
m_CmdManager = new CmdManager();
|
|
// Debug.LogFormat("-------- 关于助战类型的Init: {0}", m_H0406.ObjID);
|
|
if (!s_UnCreateObjIDList.Contains(m_H0406.ObjID))
|
{
|
var _valueInfo = LocalSave.GetString("GA_NpcFightZZPlayer_" + m_H0406.ObjID);
|
if (!string.IsNullOrEmpty(_valueInfo))
|
{
|
string[] _values = _valueInfo.Split('|');
|
int _playerId = int.Parse(_values[0]);
|
|
//Debug.LogFormat("-------- _playerId: " + _playerId);
|
|
SyncHelpBattle(_playerId);
|
}
|
}
|
}
|
|
public void SyncHelpBattle(int playerID)
|
{
|
if (m_ViewPlayerData == null && (playerID > 100))
|
{
|
//Debug.LogFormat("没有: {0} 信息数据, 这里获取", playerID);
|
RoleParticularModel.OnRevPackage += OnRevA705;
|
ModelCenter.Instance.GetModel<RoleParticularModel>().ViewPlayerCacheData(playerID, (int)ViewPlayerType.viewPlayerDataZZ);
|
|
}
|
else
|
{
|
SyncHelpPlayerInfo();
|
}
|
}
|
|
public void SyncHelpPlayerInfo()
|
{
|
var _valueInfo = LocalSave.GetString("GA_NpcFightZZPlayer_" + m_H0406.ObjID);
|
string[] _values = _valueInfo.Split('|');
|
int _playerId = int.Parse(_values[0]);
|
|
int _clothesId = -1;
|
int _weaponId = -1;
|
int _secondaryId = -1;
|
int _wingId = -1;
|
|
// 读取配置表
|
if (_playerId >= 1 && _playerId <= 100)
|
{
|
if (PlayerDatas.Instance.baseData.MapID == 31110)
|
{
|
cacheMapDataId = PlayerDatas.Instance.baseData.MapID * 10 + PlayerDatas.Instance.baseData.realmLevel;
|
}
|
else
|
{
|
if (cacheMapDataId <= 0)
|
{
|
cacheMapDataId = PlayerDatas.Instance.baseData.MapID * 10 + PlayerDatas.Instance.baseData.dungeonLineId;
|
}
|
}
|
var _config = DungeonHelpBattleConfig.Get(cacheMapDataId);
|
|
ActorInfo.LV = (ushort)_config.RobotLV;
|
ActorInfo.Job = byte.Parse(_values[1]);
|
ActorInfo.face = AvatarHelper.GetAvatarDefaultID(ActorInfo.Job);
|
ActorInfo.facePic = AvatarHelper.GetAvatarFrameDefaultID(ActorInfo.Job);
|
ActorInfo.PlayerName = NPCConfig.Get((int)m_H0406.NPCID).charName;
|
ActorInfo.Hp = m_H0406.NPCHP + m_H0406.NPCHPEx * Constants.ExpPointValue;
|
ActorInfo.MaxHp = m_H0406.MaxHP + m_H0406.MaxHPEx * Constants.ExpPointValue;
|
ActorInfo.familyID = 0;
|
ActorInfo.familyName = "";
|
ActorInfo.realm = (uint)_config.RobotRealmLV;
|
JobSetup = JobSetupConfig.Get(ActorInfo.Job);
|
|
var _jsonData = LitJson.JsonMapper.ToObject(_config.RobotCloth);
|
var _jobJson = _jsonData[_values[1]];
|
if (_jobJson.Count > 0)
|
{
|
_clothesId = (int)_jobJson[0];
|
_weaponId = (int)_jobJson[1];
|
_secondaryId = (int)_jobJson[2];
|
_wingId = (int)_jobJson[3];
|
}
|
}
|
else
|
{
|
if (m_ViewPlayerData == null)
|
{
|
Debug.LogError("异常!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!: " + _playerId);
|
}
|
|
ActorInfo.LV = (ushort)m_ViewPlayerData.rolePropData.LV;
|
ActorInfo.Job = (byte)m_ViewPlayerData.rolePropData.Job;
|
ActorInfo.face = (int)m_ViewPlayerData.rolePropData.Face;
|
ActorInfo.facePic = (int)m_ViewPlayerData.rolePropData.FacePic;
|
ActorInfo.PlayerName = m_ViewPlayerData.rolePropData.Name;
|
ActorInfo.familyID = (uint)m_ViewPlayerData.rolePropData.FamilyID;
|
ActorInfo.familyName = m_ViewPlayerData.rolePropData.FamilyName;
|
ActorInfo.Hp = m_H0406.NPCHP + m_H0406.NPCHPEx * Constants.ExpPointValue;
|
ActorInfo.MaxHp = m_H0406.MaxHP + m_H0406.MaxHPEx * Constants.ExpPointValue;
|
ActorInfo.realm = (uint)m_ViewPlayerData.rolePropData.RealmLV;
|
|
JobSetup = JobSetupConfig.Get(ActorInfo.Job);
|
|
_clothesId = m_ViewPlayerData.GetItemId(RoleEquipType.Clothes);
|
_weaponId = m_ViewPlayerData.GetItemId(RoleEquipType.Weapon);
|
_secondaryId = m_ViewPlayerData.GetItemId(RoleEquipType.Weapon2);
|
_wingId = m_ViewPlayerData.GetItemId(RoleEquipType.Wing);
|
}
|
|
//Debug.LogFormat("Name: {0}", ActorInfo.PlayerName);
|
//Debug.LogFormat("_clothesId: {0}, _weaponId: {1}, _secondaryId: {2}, _wingId: {3}", _clothesId, _weaponId, _secondaryId, _wingId);
|
|
if (_clothesId <= 0)
|
{
|
SwitchClothes(0);
|
}
|
else
|
{
|
SwitchClothes((uint)_clothesId);
|
}
|
|
if (_weaponId > 0)
|
{
|
SwitchWeapon((uint)_weaponId);
|
}
|
else
|
{
|
SwitchWeapon(0);
|
}
|
|
if (_secondaryId > 0)
|
{
|
SwitchSecondary((uint)_secondaryId);
|
}
|
else
|
{
|
SwitchSecondary(0);
|
}
|
|
if (_wingId > 0)
|
{
|
SwitchWing((uint)_wingId);
|
}
|
else
|
{
|
SwitchWing(0);
|
}
|
|
RequestName();
|
|
IdleImmediate();
|
}
|
|
private RoleParticularModel.ViewPlayerData m_ViewPlayerData;
|
|
private void OnRevA705(int viewType, int playerID, RoleParticularModel.ViewPlayerData data)
|
{
|
if (viewType != (int)ViewPlayerType.viewPlayerDataZZ)
|
{
|
return;
|
}
|
var _valueInfo = LocalSave.GetString("GA_NpcFightZZPlayer_" + m_H0406.ObjID);
|
if (string.IsNullOrEmpty(_valueInfo))
|
{
|
return;
|
}
|
string[] _values = _valueInfo.Split('|');
|
int _playerId = int.Parse(_values[0]);
|
if (playerID != _playerId)
|
{
|
return;
|
}
|
// Debug.Log("延迟获取了数据: id为 " + package.PlayerID);
|
RoleParticularModel.OnRevPackage -= OnRevA705;
|
|
m_ViewPlayerData = data;
|
|
SyncHelpPlayerInfo();
|
}
|
|
protected sealed override void OnUpdate()
|
{
|
if (m_CmdManager != null)
|
{
|
m_CmdManager.Update();
|
}
|
}
|
|
protected sealed override void OnUnit()
|
{
|
base.OnUnit();
|
|
RoleParticularModel.OnRevPackage -= OnRevA705;
|
m_H0406 = null;
|
m_CmdManager = null;
|
m_ViewPlayerData = null;
|
}
|
|
public override void Destroy()
|
{
|
}
|
|
public override void OnHorse(byte upOrDown)
|
{
|
|
}
|
|
public 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 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 override void OnPutonClothes(uint clothesItemID, GameObject clothed)
|
{
|
clothed.layer = LayerUtility.Player;
|
|
SkinnedMeshRenderer _renderer = clothed.GetComponentInChildren<SkinnedMeshRenderer>();
|
_renderer.gameObject.SetLayer(LayerUtility.Player, false);
|
}
|
|
protected override void OnPutonSecondary(uint secondaryItemID, GameObject secondary)
|
{
|
Renderer _renderer = secondary.GetComponentInChildren<Renderer>();
|
if (_renderer)
|
{
|
_renderer.gameObject.SetLayer(LayerUtility.Player, false);
|
}
|
}
|
|
protected override void OnPutonWeapon(uint weaponItemID, GameObject weapon)
|
{
|
Renderer _renderer = weapon.GetComponentInChildren<Renderer>();
|
_renderer.gameObject.SetLayer(LayerUtility.Player, false);
|
}
|
|
protected override void OnPutonWing(uint wingItemID, GameObject wing)
|
{
|
SkinnedMeshRenderer _renderer = wing.GetComponentInChildren<SkinnedMeshRenderer>();
|
_renderer.gameObject.SetLayer(LayerUtility.Player, false);
|
}
|
|
protected override void OnSwitchHorse(uint horseID, GameObject horse)
|
{
|
}
|
|
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 OnClick()
|
{
|
if (ActorInfo.serverDie)
|
{
|
return;
|
}
|
|
GA_Hero _hero = PlayerDatas.Instance.hero;
|
if (_hero == null)
|
{
|
return;
|
}
|
|
_hero.LockTarget = this;
|
_hero.SelectTarget = this;
|
}
|
|
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 bool CanBeSelected()
|
{
|
if (ActorInfo.serverDie)
|
{
|
return false;
|
}
|
|
return true;
|
}
|
|
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)
|
{
|
}
|
}
|