123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 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 CombatHeroEntity target;
- private BesselPath _besselPath;
- private float allTime;
- private float speed = 15;
- private float addTime;
- private System.Action callBack;
- public void SetTarget(CombatHeroEntity target, System.Action callBack)
- {
- this.callBack = callBack;
- this.target = target;
- _besselPath = CObjectPool.Instance.Fetch<BesselPath>();
- _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();
- }
- }
- }
- }
|