|
@@ -1,9 +1,11 @@
|
|
|
using System.Collections.Generic;
|
|
|
using Core.Audio;
|
|
|
using Core.Triiger;
|
|
|
+using Core.Utility;
|
|
|
using GameLogic.Combat.CombatTool;
|
|
|
using GameLogic.Combat.Hero;
|
|
|
using GameLogic.Combat.Skill;
|
|
|
+using UnityEditor;
|
|
|
using UnityEngine;
|
|
|
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
|
|
|
|
|
@@ -25,6 +27,9 @@ namespace Common.Combat.FxAILogic
|
|
|
[Header("曲线类型")] public CurveType parabolaCurveType;
|
|
|
[Header("释放碰撞到地面时结束")] public bool isTriggerGroundEnd;
|
|
|
[Header("碰撞到地面时的特效")] public string GroundHitFxName;
|
|
|
+ [Header("是否使用X曲线跟随角色")] public bool isUseX;
|
|
|
+ [Header("自定义曲线")] public BesselPath BesselPath;
|
|
|
+
|
|
|
|
|
|
private Vector3 endPos;
|
|
|
private Vector3 dir;
|
|
@@ -34,6 +39,7 @@ namespace Common.Combat.FxAILogic
|
|
|
|
|
|
// private BesselPath _besselPath;
|
|
|
|
|
|
+ protected BesselPath moveBezierPath;
|
|
|
|
|
|
private float _addTime;
|
|
|
protected Vector3 startDir;
|
|
@@ -57,22 +63,60 @@ namespace Common.Combat.FxAILogic
|
|
|
if (parabolaCurveType == CurveType.DynamicCurve)
|
|
|
{
|
|
|
Vector3 off = _currPos - CombatHeroEntity.GameObject.transform.position;
|
|
|
+ float x = Mathf.Sign(Random.Range(-1, 1));
|
|
|
+ if (isUseX)
|
|
|
+ {
|
|
|
+ Vector3 pos =
|
|
|
+ CombatHeroEntity.GameObject.transform.InverseTransformPoint(gameObject.transform.position);
|
|
|
+ x = Mathf.Sign(pos.x);
|
|
|
+ }
|
|
|
+
|
|
|
startDir = CombatHeroEntity.GameObject.transform.TransformPoint(off +
|
|
|
new Vector3(
|
|
|
- Mathf.Sign(Random.Range(-1, 1)),
|
|
|
+ x,
|
|
|
Random.Range(0.1f, 1f),
|
|
|
Random.Range(0.1f, 5f)));
|
|
|
|
|
|
startDir = (startDir - _currPos).normalized;
|
|
|
dirLerpTime = 0;
|
|
|
dir = (endPos - CurrPos).normalized;
|
|
|
+ gameObject.transform.rotation = Quaternion.LookRotation(dir);
|
|
|
}
|
|
|
- else
|
|
|
+ else if (parabolaCurveType == CurveType.Beeline)
|
|
|
{
|
|
|
dir = (endPos - _currPos).normalized;
|
|
|
+ gameObject.transform.rotation = Quaternion.LookRotation(dir);
|
|
|
}
|
|
|
+ else if (parabolaCurveType == CurveType.CustomizeCurve)
|
|
|
+ {
|
|
|
+ gameObject.transform.rotation = CombatHeroEntity.GameObject.transform.rotation;
|
|
|
+ Vector3 pos =
|
|
|
+ CombatHeroEntity.GameObject.transform.InverseTransformPoint(gameObject.transform.position);
|
|
|
+ if (moveBezierPath == null)
|
|
|
+ {
|
|
|
+ moveBezierPath = new BesselPath();
|
|
|
+ }
|
|
|
|
|
|
- gameObject.transform.rotation = Quaternion.LookRotation(dir);
|
|
|
+ moveBezierPath.controlPoints.Clear();
|
|
|
+ for (int i = 0; i < BesselPath.controlPoints.Count; i++)
|
|
|
+ {
|
|
|
+ Vector3 p = BesselPath.controlPoints[i];
|
|
|
+ if (isUseX)
|
|
|
+ {
|
|
|
+ if (i == 1)
|
|
|
+ {
|
|
|
+ p.x = pos.x > 0 ? p.x * -1 : p.x;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ moveBezierPath.controlPoints.Add(gameObject.transform.TransformPoint(p));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ _addTime = 1.0f / (moveBezierPath.GetLengthAtT(0) / speed);
|
|
|
+ currTime = 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void TriggerGround()
|
|
@@ -257,6 +301,14 @@ namespace Common.Combat.FxAILogic
|
|
|
|
|
|
private void CustomizeCurve(float time)
|
|
|
{
|
|
|
+ currTime += _addTime * time;
|
|
|
+ GetTargetPos();
|
|
|
+ moveBezierPath.controlPoints[3] = endPos;
|
|
|
+ // moveBezierPath.controlPoints[0] = (gameObject.transform.TransformPoint(BesselPath.controlPoints[0]));
|
|
|
+ Vector3 p = moveBezierPath.CalculatePoint(currTime);
|
|
|
+ Vector3 p2 = moveBezierPath.CalculatePoint(currTime - 0.01f);
|
|
|
+ gameObject.transform.position = p;
|
|
|
+ gameObject.transform.rotation = Quaternion.LookRotation((p - p2).normalized);
|
|
|
}
|
|
|
|
|
|
private void DynamicCurve(float time)
|
|
@@ -288,5 +340,77 @@ namespace Common.Combat.FxAILogic
|
|
|
|
|
|
UnRegister = null;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private void OnDrawGizmos()
|
|
|
+ {
|
|
|
+ if (parabolaCurveType != CurveType.CustomizeCurve)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (BesselPath.controlPoints.Count < 4)
|
|
|
+ {
|
|
|
+ BesselPath.controlPoints.Add(Vector3.zero);
|
|
|
+ BesselPath.controlPoints.Add(new Vector3(-1, 1, -1));
|
|
|
+ BesselPath.controlPoints.Add(new Vector3(0, 0, 2));
|
|
|
+ BesselPath.controlPoints.Add(new Vector3(0, 0, 5));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Gizmos.color = Color.blue;
|
|
|
+
|
|
|
+ // 绘制控制点
|
|
|
+
|
|
|
+
|
|
|
+ // 绘制曲线
|
|
|
+ Vector3 previousPoint = BesselPath.CalculatePoint(0) + transform.position;
|
|
|
+ int segments = 50;
|
|
|
+
|
|
|
+ for (int i = 1; i <= segments; i++)
|
|
|
+ {
|
|
|
+ float t = i / (float)segments;
|
|
|
+ Vector3 currentPoint = BesselPath.CalculatePoint(t) + transform.position;
|
|
|
+ // Gizmos.DrawSphere(currentPoint, 0.03f);
|
|
|
+ Gizmos.DrawLine(previousPoint, currentPoint);
|
|
|
+ previousPoint = currentPoint;
|
|
|
+ }
|
|
|
+ }
|
|
|
+#if UNITY_EDITOR
|
|
|
+ [CustomEditor(typeof(FxParabolaBulletLogic))]
|
|
|
+ public class MovableCoordinateEditor : Editor
|
|
|
+ {
|
|
|
+ void OnSceneGUI()
|
|
|
+ {
|
|
|
+ FxParabolaBulletLogic fxParabolaBulletLogic = target as FxParabolaBulletLogic;
|
|
|
+ if (fxParabolaBulletLogic.parabolaCurveType != CurveType.CustomizeCurve)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fxParabolaBulletLogic.BesselPath.controlPoints.Count < 4)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用 Handles.PositionHandle 提供一个可拖动的控制柄
|
|
|
+
|
|
|
+ for (int i = 0; i < fxParabolaBulletLogic.BesselPath.controlPoints.Count; i++)
|
|
|
+ {
|
|
|
+ EditorGUI.BeginChangeCheck();
|
|
|
+ Vector3 newPosition = Handles.PositionHandle(
|
|
|
+ fxParabolaBulletLogic.BesselPath.controlPoints[i] +
|
|
|
+ fxParabolaBulletLogic.gameObject.transform.position,
|
|
|
+ Quaternion.identity);
|
|
|
+ if (EditorGUI.EndChangeCheck())
|
|
|
+ {
|
|
|
+ Undo.RecordObject(fxParabolaBulletLogic, "Move Coordinate");
|
|
|
+ fxParabolaBulletLogic.BesselPath.controlPoints[i] =
|
|
|
+ newPosition - fxParabolaBulletLogic.gameObject.transform.position;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif
|
|
|
}
|
|
|
}
|