| | |
| | |
|
| | | if (AttackHandler.CheckPull(_attacker, _cTarget, 0))
|
| | | {
|
| | | _cTarget.StartBeatBack(0, MathUtility.ForwardXZ(_cTarget.Pos, _attacker.Pos));
|
| | | _cTarget.StartBeatBack(_attacker.ServerInstID, 0, MathUtility.ForwardXZ(_cTarget.Pos, _attacker.Pos));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | if (AttackHandler.CheckPull(_attacker, _cTarget, 0))
|
| | | {
|
| | | _cTarget.StartBeatBack(0, MathUtility.ForwardXZ(_cTarget.Pos, _attacker.Pos));
|
| | | _cTarget.StartBeatBack(_attacker.ServerInstID, 0, MathUtility.ForwardXZ(_cTarget.Pos, _attacker.Pos));
|
| | | }
|
| | |
|
| | | if (_sTarget.HurtHP != 0)
|
| | |
| | |
|
| | | if (AttackHandler.CheckPull(_attacker, _cTarget, 0))
|
| | | {
|
| | | _cTarget.StartBeatBack(0, MathUtility.ForwardXZ(_cTarget.Pos, _attacker.Pos));
|
| | | _cTarget.StartBeatBack(_attacker.ServerInstID, 0, MathUtility.ForwardXZ(_cTarget.Pos, _attacker.Pos));
|
| | | }
|
| | |
|
| | | if (_sTarget.HurtHP != 0)
|
| | |
| | |
|
| | | if (CheckPull(attacker, target, soConfig.bodyControlId))
|
| | | {
|
| | | target.StartBeatBack(soConfig.bodyControlId, MathUtility.ForwardXZ(target.Pos, attacker.Pos));
|
| | | target.StartBeatBack(attacker.ServerInstID, soConfig.bodyControlId, MathUtility.ForwardXZ(target.Pos, attacker.Pos));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | |
| | | [Tooltip("是否对玩家类型生效")] |
| | | public bool useForPlayer = false; |
| | | |
| | | [Tooltip("是推还是拉, 打钩是推,不打钩是拉")] |
| | | public bool pushOrPull = true; |
| | | |
| | | [Tooltip(@"限制位置, 以释放者为中心的偏移 |
| | | 可以为负值")] |
| | | public float limitDistance = 100; |
| | | } |
| | |
| | |
|
| | | 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;
|
| | |
|
| | |
| | | private float m_BeatStartTime;
|
| | | protected bool m_Beating;
|
| | | private Vector3 m_BeatDirection;
|
| | | private bool m_PushOrPull;
|
| | | private uint m_AttackerSID;
|
| | | private float m_LimitDistance;
|
| | |
|
| | | public void StartBeatBack(int configID, Vector3 direction)
|
| | | public void StartBeatBack(uint attacker, int configID, Vector3 direction)
|
| | | {
|
| | | SoBodyControl _config = ScriptableObjectLoader.LoadSoBodyControl(configID);
|
| | |
|
| | | if (_config == null || _config.curve == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | m_AttackerSID = attacker;
|
| | | m_LimitDistance = _config.limitDistance;
|
| | | m_PushOrPull = _config.pushOrPull;
|
| | |
|
| | | if (!m_PushOrPull)
|
| | | {
|
| | | direction = -direction;
|
| | | }
|
| | |
|
| | | m_BeatDirection = direction;
|
| | |
| | | Vector3 _pos = m_StartBeatPos + _h + _v;
|
| | | Vector3 _end = _pos;
|
| | |
|
| | | GActor _attacker = GAMgr.Instance.GetBySID(m_AttackerSID);
|
| | |
|
| | | float _dis = MathUtility.DistanceSqrtXZ(_attacker.Pos, _end);
|
| | |
|
| | | if (m_PushOrPull)
|
| | | {
|
| | | if (MathUtility.DistanceSqrtXZ(_attacker.Pos, _end) > m_LimitDistance * m_LimitDistance)
|
| | | {
|
| | | _end = _attacker.Pos + m_BeatDirection * m_LimitDistance;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | Vector3 _limPos = _attacker.Pos;
|
| | | _limPos.y = 0;
|
| | | _limPos = _limPos - m_BeatDirection * m_LimitDistance;
|
| | | Vector3 _dir2 = (_end - _limPos).normalized;
|
| | |
|
| | | bool _isOp = MathUtility.OppositeDir(-m_BeatDirection, _dir2);
|
| | | bool _isLimDis = MathUtility.DistanceSqrtXZ(_attacker.Pos, _end) < m_LimitDistance * m_LimitDistance;
|
| | |
|
| | | if (_isOp
|
| | | || _isLimDis)
|
| | | {
|
| | | _end = _attacker.Pos - m_BeatDirection * m_LimitDistance;
|
| | | needSyncGroundHeight = true;
|
| | | m_Beating = false;
|
| | | }
|
| | | }
|
| | |
|
| | | Vector3 _position = m_StartBeatPos;
|
| | | _position.y = 0;
|
| | | _end.y = 0;
|
| | |
| | | return (target - self).normalized; |
| | | } |
| | | |
| | | public static bool IsSameDir(Vector3 vec1, Vector3 vec2) |
| | | { |
| | | vec1.y = 0; |
| | | vec2.y = 0; |
| | | |
| | | return Vector3.Dot(vec1, vec2) > 0; |
| | | } |
| | | |
| | | public static bool OppositeDir(Vector3 vec1, Vector3 vec2) |
| | | { |
| | | vec1.y = 0; |
| | | vec2.y = 0; |
| | | |
| | | return Vector3.Dot(vec1, vec2) < 0; |
| | | } |
| | | public static int Power(int a, int e) |
| | | { |
| | | int value = 1; |