少年修仙传客户端代码仓库
client_Hale
2019-04-16 2f723e5320ef618985cc9ea8f71deafd3e4bec36
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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<NPCPos> 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);
        //}
 
    }
}