using System; using UnityEngine; namespace GameLogic.Combat.CombatTool { [Serializable] public class CombatSencePath { public Vector3 a; public Vector3 b; private Vector3 Centre; private bool isCentre; public void SetPos(Vector3 startPos, Vector3 target) { a = startPos; b = target; isCentre = false; } public void SetPos(Vector3 startPos, Vector3 centre, Vector3 target) { a = startPos; Centre = centre; b = target; isCentre = true; } // private float GetPathCount(Vector3 p1, Vector3 p2, Vector3 p3, int count) // { // float step = 1f / count; // Vector3 startPos = p1; // float d = 0; // for (int i = 1; i < count; i++) // { // float t = i * count; // Vector3 a = Vector3.Lerp(p1, p2, t); // Vector3 b = Vector3.Lerp(a, p3, t); // d += Vector3.Distance(startPos, b); // startPos = b; // } // // // return d; // } // public float GetPathCount(int count) // { // float step = 1f / count; // Vector3 startPos = GetValue(0); // float d = 0; // for (int i = 1; i < count; i++) // { // Vector3 currPos = GetValue(step * i); // d += Vector3.Distance(startPos, currPos); // } // // return d; // } public Vector3 GetValue(float t) { float t1 = t; if (t1 > 1) { t1 = 1; } if (t1 < 0) { t1 = 0; } if (isCentre) { Vector3 p1 = Vector3.Lerp(a, Centre, t1); Vector3 p2 = Vector3.Lerp(p1, b, t1); return p2; } else { return Vector3.Lerp(a, b, t1); } } } }