| New file |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using Snxxz.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; |
| | | |
| | | 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(); |
| | | |
| | | 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) |
| | | { |
| | | var _model = ModelCenter.Instance.GetModel<RoleParticularModel>(); |
| | | var _playerData = _model.GetViewPlayerData(playerID); |
| | | |
| | | if (_playerData == null && (playerID > 100)) |
| | | { |
| | | Debug.LogFormat("没有: {0} 信息数据, 这里获取", playerID); |
| | | CA212_tagCMViewPlayerInfo pak = new CA212_tagCMViewPlayerInfo(); |
| | | pak.PlayerID = (uint)playerID; |
| | | GameNetSystem.Instance.SendInfo(pak); |
| | | |
| | | DTCA705_tagSCQueryPlayerCacheResult.OnRevPackage += OnRevA705; |
| | | } |
| | | 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) |
| | | { |
| | | var _mapDataId = PlayerDatas.Instance.baseData.MapID * 10 + PlayerDatas.Instance.baseData.dungeonLineId; |
| | | var _config = Config.Instance.Get<TableConfig.DungeonHelpBattleConfig>(_mapDataId); |
| | | |
| | | ActorInfo.LV = (ushort)_config.RobotLV; |
| | | ActorInfo.Job = byte.Parse(_values[1]); |
| | | ActorInfo.PlayerName = "助战NPC"; |
| | | ActorInfo.Hp = m_H0406.NPCHP; |
| | | ActorInfo.MaxHp = m_H0406.MaxHP; |
| | | ActorInfo.realm = (uint)_config.RobotRealmLV; |
| | | JobSetup = Config.Instance.Get<TableConfig.JobSetupConfig>(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.PlayerName = m_ViewPlayerData.rolePropData.Name; |
| | | ActorInfo.familyID =(uint) m_ViewPlayerData.rolePropData.FamilyID; |
| | | ActorInfo.familyName = m_ViewPlayerData.rolePropData.FamilyName; |
| | | ActorInfo.Hp = m_H0406.NPCHP; |
| | | ActorInfo.MaxHp = m_H0406.MaxHP; |
| | | ActorInfo.realm = (uint)m_ViewPlayerData.rolePropData.RealmLV; |
| | | |
| | | JobSetup = Config.Instance.Get<TableConfig.JobSetupConfig>(ActorInfo.Job); |
| | | |
| | | RoleParticularModel.ItemData _item = null; |
| | | |
| | | if (m_ViewPlayerData.roleEquipDataDic.TryGetValue(RoleEquipType.retClothes, out _item)) |
| | | { |
| | | _clothesId = _item.ItemID; |
| | | } |
| | | |
| | | if (m_ViewPlayerData.roleEquipDataDic.TryGetValue(RoleEquipType.retWeapon, out _item)) |
| | | { |
| | | _weaponId = _item.ItemID; |
| | | } |
| | | |
| | | if (m_ViewPlayerData.roleEquipDataDic.TryGetValue(RoleEquipType.retWeapon2, out _item)) |
| | | { |
| | | _secondaryId = _item.ItemID; |
| | | } |
| | | |
| | | if (m_ViewPlayerData.roleEquipDataDic.TryGetValue(RoleEquipType.retWing, out _item)) |
| | | { |
| | | _wingId = _item.ItemID; |
| | | } |
| | | } |
| | | |
| | | //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(HA705_tagSCQueryPlayerCacheResult package) |
| | | { |
| | | Debug.Log("延迟获取了数据: id为 " + package.PlayerID); |
| | | DTCA705_tagSCQueryPlayerCacheResult.OnRevPackage -= OnRevA705; |
| | | |
| | | if (m_ViewPlayerData == null) |
| | | { |
| | | m_ViewPlayerData = new RoleParticularModel.ViewPlayerData(); |
| | | } |
| | | |
| | | m_ViewPlayerData.roleEquipDataDic.Clear(); |
| | | m_ViewPlayerData.itemDatas = LitJson.JsonMapper.ToObject<RoleParticularModel.ItemData[]>(package.ItemData); |
| | | m_ViewPlayerData.rolePropData = LitJson.JsonMapper.ToObject<RoleParticularModel.RolePropData>(package.PropData); |
| | | m_ViewPlayerData.rolePlusData = new RoleParticularModel.RolePlusData(); |
| | | m_ViewPlayerData.rolePlusData.AnalysisRolePlusData(package.PlusData); |
| | | if (m_ViewPlayerData.itemDatas != null) |
| | | { |
| | | for (int i = 0; i < m_ViewPlayerData.itemDatas.Length; i++) |
| | | { |
| | | m_ViewPlayerData.itemDatas[i].AnalysisUserData(); |
| | | m_ViewPlayerData.roleEquipDataDic[(RoleEquipType)m_ViewPlayerData.itemDatas[i].ItemIndex] = m_ViewPlayerData.itemDatas[i]; |
| | | } |
| | | } |
| | | m_ViewPlayerData.AnalysisEquipSuit(); |
| | | |
| | | SyncHelpPlayerInfo(); |
| | | } |
| | | |
| | | protected sealed override void OnUpdate() |
| | | { |
| | | if (m_CmdManager != null) |
| | | { |
| | | m_CmdManager.Update(); |
| | | } |
| | | } |
| | | |
| | | protected sealed override void OnUnit() |
| | | { |
| | | base.OnUnit(); |
| | | |
| | | DTCA705_tagSCQueryPlayerCacheResult.OnRevPackage -= OnRevA705; |
| | | m_H0406 = null; |
| | | m_CmdManager = 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((int)ActorInfo.realm, ActorInfo.titleID, ActorInfo.PlayerName, ActorInfo.familyName, false); |
| | | } |
| | | |
| | | protected override void OnPutonClothes(uint clothesItemID, GameObject clothed) |
| | | { |
| | | clothed.layer = LayerUtility.Player; |
| | | |
| | | SkinnedMeshRenderer _renderer = clothed.GetComponentInChildren<SkinnedMeshRenderer>(); |
| | | _renderer.gameObject.SetLayer(LayerUtility.Player, false); |
| | | |
| | | if(m_ViewPlayerData != null) |
| | | { |
| | | SwitchGodWeapon(1,m_ViewPlayerData.rolePlusData.GetGodWeaponLevel(1)); |
| | | SwitchGodWeapon(4,m_ViewPlayerData.rolePlusData.GetGodWeaponLevel(4)); |
| | | } |
| | | } |
| | | |
| | | protected override void OnPutonSecondary(uint secondaryItemID, GameObject secondary) |
| | | { |
| | | Renderer _renderer = secondary.GetComponentInChildren<Renderer>(); |
| | | _renderer.gameObject.SetLayer(LayerUtility.Player, false); |
| | | |
| | | if(m_ViewPlayerData != null) |
| | | { |
| | | SwitchGodWeapon(2,m_ViewPlayerData.rolePlusData.GetGodWeaponLevel(2)); |
| | | } |
| | | } |
| | | |
| | | protected override void OnPutonWeapon(uint weaponItemID, GameObject weapon) |
| | | { |
| | | Renderer _renderer = weapon.GetComponentInChildren<Renderer>(); |
| | | _renderer.gameObject.SetLayer(LayerUtility.Player, false); |
| | | |
| | | if(m_ViewPlayerData != null) |
| | | { |
| | | SwitchGodWeapon(3,m_ViewPlayerData.rolePlusData.GetGodWeaponLevel(3)); |
| | | } |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |