少年修仙传客户端代码仓库
client_Hale
2018-08-20 9317560c31f00383062cd0a97526b040a9c42b61
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
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() == false)
        {
            return;
        }
 
        if (AttackHandler.CheckPull(attacker, target, bodyControlId) == false)
        {
            return;
        }
 
        SoBodyControl _bodyControl = ScriptableObjectLoader.LoadSoBodyControl(bodyControlId);
 
        float _distance = _bodyControl.curve.keys[_bodyControl.curve.length - 1].time;
 
        Vector3 _checkPos = target.Pos;
        Vector3 _pullPosition = _checkPos + direction * _distance;
 
        _checkPos.y = 0;
        _pullPosition.y = 0;
 
        UnityEngine.AI.NavMeshHit _hit;
        if (UnityEngine.AI.NavMesh.Raycast(_checkPos, _pullPosition, out _hit, -1))
        {
            _pullPosition = _hit.position;
        }
 
        if (GActor.TryGetValidPos(_pullPosition, ref _checkPos))
        {
            if (target.ActorType == GameObjType.gotPlayer)
            {
                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.x);
                    GameNetSystem.Instance.SendInfo(_beatBack);
                }
                //else
                //{
                //    Debug.Log("--------------------------- 10");
                //}
            }
            else if (target.ActorType == GameObjType.gotNPC)
            {
                NPCPos _npcPos = new NPCPos
                {
                    objId = (int)target.ServerInstID,
                    posX = (int)(_checkPos.x * 2f),
                    posY = (int)(_checkPos.z * 2f)
                };
                npcPosList.Add(_npcPos);
            }
        }
        //else
        //{
        //    Debug.Log("--------------------------- 111111111111111111: " + _pullPosition);
        //}
 
    }
}