using UnityEngine; using System.Collections.Generic; public enum E_FrameEventType { OnSkillEvent, OnPlayEffect, OnSkillComplete, OnAnimationPause, OnTimePause, OnSkillPrepare, OnCreateGhost, OnPlayAudio, } public class SMB_Base : StateMachineBehaviour { public struct NPCPos { public int objId; public int posX; public int posY; } protected GActor owner; public sealed override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateEnter(animator, stateInfo, layerIndex); int _instId = animator.GetInteger(GAStaticDefine.Param_ActorInstID); owner = GAMgr.Instance.GetByCID((uint)_instId); if (owner == null) { return; } OnEnter(owner, animator, stateInfo, layerIndex); owner = null; } public sealed override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateUpdate(animator, stateInfo, layerIndex); int _instId = animator.GetInteger(GAStaticDefine.Param_ActorInstID); owner = GAMgr.Instance.GetByCID((uint)_instId); if (owner == null) { return; } OnUpdate(owner, animator, stateInfo, layerIndex); owner = null; } public sealed override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateExit(animator, stateInfo, layerIndex); //DesignDebug.Log("退出: " + GetType().Name + "状态"); int _instId = animator.GetInteger(GAStaticDefine.Param_ActorInstID); owner = GAMgr.Instance.GetByCID((uint)_instId); if (owner == null) { return; } OnExit(owner, animator, stateInfo, layerIndex); owner = null; } protected virtual void OnEnter(GActor owner, Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { } protected virtual void OnUpdate(GActor owner, Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { } protected virtual void OnExit(GActor owner, Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { } protected void AddToNpcPosList(GActorFight attacker, GActorFight target, int bodyControlId, Vector3 direction, List npcPosList) { // Debug.LogFormat("{0} attack {1} ==================== 0", attacker.GetType().ToString(), target.GetType().ToString()); if (!PreFightMission.Instance.IsFinished() || ClientSceneManager.Instance.IsClientFightMode || AdventureStage.Instance.IsInAdventureStage) { return; } if (ClientDungeonStageUtility.isClientDungeon #if UNITY_EDITOR || RuntimeLogUtility.TEST_CLIENT_PVP #endif ) { return; } if (!AttackHandler.CheckPull(attacker, target, bodyControlId)) { return; } SoBodyControl _bodyControl = ScriptableObjectLoader.LoadSoBodyControl(bodyControlId); if (!_bodyControl.pushOrPull) { direction = -direction; } float _distance = _bodyControl.curve.keys[_bodyControl.curve.length - 1].time; Vector3 _checkPos = target.Pos; Vector3 _pullPosition = _checkPos + direction * _distance; if (!_bodyControl.pushOrPull) { _pullPosition = attacker.Pos + MathUtility.ForwardXZ(target.Pos, attacker.Pos) * 0.5f; } _checkPos.y = 0; _pullPosition.y = 0; UnityEngine.AI.NavMeshHit _hit; if (UnityEngine.AI.NavMesh.Raycast(_checkPos, _pullPosition, out _hit, -1)) { _pullPosition = _hit.position; } // 只认主角导致的推逻辑. 如果是其他人的退不认 if (target is GActorNpcFight) { if (attacker is GA_Player) { return; } } if (GActor.TryGetValidPos(_pullPosition, ref _checkPos)) { if (target.ActorType == GameObjType.gotPlayer) { if (target is GA_Hero) { GActorPlayerBase _player = target as GActorPlayerBase; //Debug.Log("--------------------------- 8"); if (_player.MovingState != E_MovingState.Ride) { // Debug.LogFormat("{0} attack {1} ==================== 9", attacker.GetType().ToString(), target.GetType().ToString()); CB402_tagCMNPCBeatBack _beatBack = new CB402_tagCMNPCBeatBack(); _beatBack.ObjType = (byte)GameObjType.gotPlayer; _beatBack.Count = 1; _beatBack.NPCPosList = new CB402_tagCMNPCBeatBack.tagCMNPCPos[1]; _beatBack.NPCPosList[0] = new CB402_tagCMNPCBeatBack.tagCMNPCPos(); _beatBack.NPCPosList[0].ObjID = (uint)target.ServerInstID; _beatBack.NPCPosList[0].PosX = (ushort)(_checkPos.x * 2f + GA_Hero.MapOffset.x); _beatBack.NPCPosList[0].PosY = (ushort)(_checkPos.z * 2f + GA_Hero.MapOffset.z); if (!CrossServerUtility.IsCrossServer()) { GameNetSystem.Instance.SendInfo(_beatBack); } else { GameNetSystem.Instance.SendToCrossServer(_beatBack); } } } //else //{ // Debug.Log("--------------------------- 10"); //} } else if (target.ActorType == GameObjType.gotNPC) { NPCPos _npcPos = new NPCPos { objId = (int)target.ServerInstID, posX = (int)(_checkPos.x * 2f + GA_Hero.MapOffset.x), posY = (int)(_checkPos.z * 2f + GA_Hero.MapOffset.z) }; npcPosList.Add(_npcPos); } } //else //{ // Debug.Log("--------------------------- 111111111111111111: " + _pullPosition); //} } }