using UnityEngine; using System.Collections; using System.Collections.Generic; using Debug = System.Diagnostics.Debug; public class Shake : Move { #region 变量 public override bool InDestination { get { if (Target.position.Equal(Origin)) { _InDestination = true; } else { _InDestination = false; } return _InDestination; } set { _InDestination = value; 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 Do() { Timer += Time.fixedDeltaTime; 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 void StartShake(int repeat, float duration, Vector3 strength, Curve curve) { InDestination = false; Repeat = repeat; Z = Target.position.z; Origin = Target.position; Strength = strength; Duration = duration; Func = ManaAnim.ShakeFuncDicV[curve]; OnForwardStart.SafeInvoke(); ManaAnim.MoveList.Remove(this); ManaAnim.MoveList.Add(this); } }