using System; using UnityEngine; using System.Collections; using System.Collections.Generic; using Debug = System.Diagnostics.Debug; public class Shake : MoveRoot { #region 变量 public override bool InDestination { get { if (Target.position.Equal(Origin)) { InDestination_ = true; } else { InDestination_ = false; } return InDestination_; } set { InDestination_ = value; InPause = false; if (InDestination_) { Target.position = Origin; } } } public int Repeat; public float Z; public float Timer; public float Duration; public Vector3 Origin; public Vector3 Strength; public Transform Target; public ShakeFunctionV Func; #endregion public Shake(Transform transform) { Target = transform; } public override bool DoForward() { Timer += Time.deltaTime; if (Timer > Duration) { Timer = 0; InDestination = true; if (OnForwardFinish != null) { OnForwardFinish.Invoke(); } return true; } else { Target.position = Func(Timer, Duration, Repeat, Origin, Strength); Target.SetZ(Z); return false; } } public override bool DoBackward() { throw new Exception(); } public void StartShake(int repeat, float duration, Vector3 strength, Curve curve) { Timer = 0; InDestination = false; Repeat = repeat; Z = Target.position.z; Origin = Target.position; Strength = strength; Duration = duration; Func = AnimManager.ShakeFuncDicV[curve]; OnForwardStart.SafeInvoke(); AnimManager.MoveForList.Remove(this); AnimManager.MoveForList.Add(this); } }