using Common.Utility.CombatEvent; using Core.Utility; using Fort23.Core; using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical; using UnityEngine; using Utility.CTween; namespace GameLogic.Combat.Skill.MagicSkill { public class StraightLineShow : MagicAttShowBasic { private BesselPath _besselPath; private float allTime; private float speed = 15; private float addTime; protected override void ProSetInfo() { _besselPath = CObjectPool.Instance.Fetch(); _skillBasic.CombatHeroEntity.GameObject.transform.eulerAngles = Vector3.zero; Vector3 p1 = _skillBasic.CombatHeroEntity.GameObject.transform.TransformPoint(new Vector3(-5f, 5f, 5f)); Vector3 p2 = SetTargetPos2(); _besselPath.controlPoints.Add(_skillBasic.CombatHeroEntity.GameObject.transform.position); _besselPath.controlPoints.Add(p1); _besselPath.controlPoints.Add(p2); _besselPath.controlPoints.Add(target.dotPos); float d = _besselPath.GetLengthAtT(allTime); addTime = 1.0f / (d / speed); allTime = 0; } protected Vector3 SetTargetPos2() { Vector3 p2 = target.GameObject.transform.TransformPoint(new Vector3(-5f, 1f, 5f)); return p2; } protected override void ProUpdate(float t) { Vector3 p2 = SetTargetPos2(); _besselPath.controlPoints[2] = p2; _besselPath.controlPoints[3] = target.dotPos; allTime += t * addTime; float v = CustomTweenManager.AnimationCurveLibrary.fabaoAtt.Evaluate(allTime); Vector3 lasetPos = _besselPath.CalculatePoint(v - 0.01f); Vector3 p = _besselPath.CalculatePoint(v); _skillBasic.CombatHeroEntity.combatHeroGameObject.SetPosition(p); Quaternion quaternion = Quaternion.LookRotation((p - lasetPos).normalized); _skillBasic.CombatHeroEntity.GameObject.transform.rotation = Quaternion.Lerp(_skillBasic.CombatHeroEntity.GameObject.transform.rotation, quaternion, 0.5f); if (allTime >= 1) { isUpdate = false; callBack?.Invoke(); } } } }