using UnityEngine; using UnityEngine.Events; using System; using System.Collections; public class Move : Anim { #region 变量 protected override bool InDestination { get { if (Target.position == Destination) { _InDestination = true; } else { _InDestination = false; } return _InDestination; } set { _InDestination = value; if (_InDestination) { Target.position = Destination; } } } protected float Timer; protected float Duration; protected Vector3 Delta; protected Vector3 Origin; protected Vector3 Destination; protected Transform Target; protected CurveFunctionV Func; #endregion public Move(Transform target) { Target = target; } public override bool Do() { Timer += Time.fixedDeltaTime; if (Timer > Duration) { Timer = 0; Target.position = Destination; ManaAnim.AnimList.Remove(this); if (OnFinish != null) { OnFinish.Invoke(); } return true; } else { Target.position = Func(Timer, Duration, Origin, Delta); return false; } } public void StartMove(Vector3 destination, float duration, Curve curve) { InDestination = false; destination.z = Target.position.z; Delta = destination - Target.position; Origin = Target.position; Duration = duration; Destination = destination; Func = ManaAnim.CurveFunctionDicV[curve]; if (OnStart != null) { OnStart.Invoke(); } ManaAnim.AnimList.Remove(this); ManaAnim.AnimList.Add(this); } }