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