123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System;
- using System.Collections.Generic;
- using Fort23.Core;
- using Fort23.UTool;
- using GameLogic.Combat.CombatTool.SceneTool;
- using UnityEngine;
- namespace GameLogic.Combat.CombatTool
- {
- [Serializable]
- public class CombatSencePath : CObject
- {
- public Vector3 a;
- public Vector3 b;
- private Vector3 Centre;
- public bool isCentre;
- public float reclaimTime;
- public List<SceneDecoration> allPool = new List<SceneDecoration>();
- public float len;
- public void SetPos(Vector3 startPos, Vector3 target)
- {
- a = startPos;
- b = target;
- isCentre = false;
- SetLen();
- }
- public void SetPos(Vector3 startPos, Vector3 centre, Vector3 target)
- {
- a = startPos;
- Centre = centre;
- b = target;
- isCentre = true;
- SetLen();
- }
- private void SetLen()
- {
- float a = 1 / 100f;
- len = 0;
- for (int i = 0; i < 100; i++)
- {
- Vector3 p = GetValue(i * a);
- Vector3 p2 = GetValue((i + 1) * a);
- len += Vector3.Distance(p, p2);
- }
- }
- 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);
- }
- }
- public void Update(float t)
- {
- for (int i = 0; i < allPool.Count; i++)
- {
- allPool[i].Update(t);
- }
- }
- public override void ActiveObj()
- {
- }
- public override void DormancyObj()
- {
- for (int i = 0; i < allPool.Count; i++)
- {
- CObjectPool.Instance.Recycle(allPool[i]);
- // GObjectPool.Instance.Recycle(allPool[i]);
- }
- allPool.Clear();
- }
- }
- }
|