| New file |
| | |
| | | using Snxxz.UI; |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | |
| | | public class GA_NpcFightSgzcZZ : GActorPlayerBase, IOtherSelectable |
| | | { |
| | | public class EquipRandomInfo |
| | | { |
| | | public int[] randClothesItemIDs; |
| | | public int[] randWeaponItemIDs; |
| | | public int[] randSecondaryItemIDs; |
| | | public int[] randWingItemIDs; |
| | | public int[] godWeaponIDs; |
| | | } |
| | | |
| | | public static LitJson.JsonData objIdToJson; |
| | | |
| | | private H0406_tagNPCAppear m_H0406; |
| | | private CmdManager m_CmdManager; |
| | | |
| | | public static int cacheMapDataId; |
| | | |
| | | protected override void OnInit(GameNetPackBasic package) |
| | | { |
| | | base.OnInit(package); |
| | | ActorType = GameObjType.gotNPC; |
| | | |
| | | 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; |
| | | ActorInfo.LV = (ushort)m_H0406.CurLV; |
| | | ActorInfo.PlayerName = ModelCenter.Instance.GetModel<ActivityModel>().GetAncientRobotName((int)m_H0406.ObjID, (int)m_H0406.NPCID); |
| | | ActorInfo.Hp = m_H0406.NPCHP; |
| | | ActorInfo.MaxHp = m_H0406.MaxHP; |
| | | ActorInfo.familyID = 0; |
| | | ActorInfo.familyName = ""; |
| | | ActorInfo.realm = (uint)Random.Range(3, 9); |
| | | // ------------------------------------------------------------------------- |
| | | // ------------------------------------------------------------------------- |
| | | // ------------------------------------------------------------------------- |
| | | // ------------------------------------------------------------------------- |
| | | |
| | | if (objIdToJson == null) |
| | | { |
| | | Debug.Log("看到机器人的时候, 还没有收到id与职业对应的关系.....!!!"); |
| | | } |
| | | else |
| | | { |
| | | var _key = m_H0406.ObjID.ToString(); |
| | | if ((objIdToJson as IDictionary).Contains(_key)) |
| | | { |
| | | var _job = (int)objIdToJson[_key]; |
| | | Debug.Log("机器人职业为: " + _job); |
| | | JobSetup = Config.Instance.Get<TableConfig.JobSetupConfig>(_job); |
| | | ActorInfo.Job = (byte)_job; |
| | | } |
| | | else |
| | | { |
| | | Debug.LogFormat("机器人信息中不包含ID: {0} 对应的职业.....!!!", m_H0406.ObjID); |
| | | } |
| | | } |
| | | |
| | | m_CmdManager = new CmdManager(); |
| | | |
| | | SyncHelpPlayerInfo(); |
| | | } |
| | | |
| | | public sealed override void ChangeEquip(EquipInfo equipInfo) { } |
| | | |
| | | public void SyncHelpPlayerInfo() |
| | | { |
| | | int _clothesId = -1; |
| | | int _weaponId = -1; |
| | | int _secondaryId = -1; |
| | | int _wingId = -1; |
| | | |
| | | if (JobSetup == null) |
| | | { |
| | | JobSetup = Config.Instance.Get<TableConfig.JobSetupConfig>(1); |
| | | ActorInfo.Job = 1; |
| | | } |
| | | |
| | | var _dict = GeneralDefine.SgzzRobotEquipDict[JobSetup.Job]; |
| | | EquipRandomInfo _info = null; |
| | | foreach (var _key in _dict.Keys) |
| | | { |
| | | if (m_H0406.CurLV <= _key) |
| | | { |
| | | _info = _dict[_key]; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (_info == null) |
| | | { |
| | | Debug.Log("无法确定装备信息.........."); |
| | | } |
| | | else |
| | | { |
| | | _clothesId = _info.randClothesItemIDs[Random.Range(0, _info.randClothesItemIDs.Length)]; |
| | | _weaponId = _info.randWeaponItemIDs[Random.Range(0, _info.randWeaponItemIDs.Length)]; |
| | | _secondaryId = _info.randSecondaryItemIDs[Random.Range(0, _info.randSecondaryItemIDs.Length)]; |
| | | _wingId = _info.randWingItemIDs[Random.Range(0, _info.randWingItemIDs.Length)]; |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | |
| | | 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 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); |
| | | } |
| | | |
| | | protected override void OnPutonSecondary(uint secondaryItemID, GameObject secondary) |
| | | { |
| | | Renderer _renderer = secondary.GetComponentInChildren<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(); |
| | | } |
| | | } |