/// <summary> /// Use this constructor if your show/hide parameters are identical. /// </summary> /// <param name="form"> The form to be animated. </param> /// <param name="animationParams"> Parameters used for both show and hide animations. </param> public FormAnimator(Form form, AnimationParams animationParams) : this(form) { ShowParams = animationParams; HideParams = animationParams; }
/// <summary> /// Use this constructor if you want to specify different parameters /// for the show and hide animations. /// </summary> /// <param name="form"> The form to be animated. </param> /// <param name="showParams"> Parameters used for the show animation. </param> /// <param name="hideParams"> Parameters used for the hide animation. </param> public FormAnimator(Form form, AnimationParams showParams, AnimationParams hideParams) : this(form) { ShowParams = showParams; HideParams = hideParams; }
public void SetLayerData(int layer, AnimationParams primaryAnim, params AnimationParams[] backgroundAnims) { LayerGroup layerGroup = GetLayerGroup(layer); if (layerGroup == null) { layerGroup = new LayerGroup(layer); _layers.Add(layerGroup); } if (primaryAnim._animation == null) { StopLayer(layerGroup); return; } if (AddClipIfDoesntExist(primaryAnim._animation) || !IsLayerChannelPlaying(layerGroup._primaryLayer, primaryAnim._animation.name)) { StopLayerChannel(layerGroup._primaryLayer); layerGroup._primaryLayer._animation = StartAnimationInLayer(layerGroup._primaryLayer._layer, primaryAnim._animation.name, WrapMode.Default); } layerGroup._state = LayerGroup.State.Playing; layerGroup._primaryLayer._animation.time = primaryAnim._time; layerGroup._primaryLayer._animation.speed = primaryAnim._speed; layerGroup._primaryLayer._animation.weight = primaryAnim._weight; for (int i = 0; i < MaxBackgroundLayers; i++) { if (i < backgroundAnims.Length) { if (AddClipIfDoesntExist(backgroundAnims[i]._animation) || !IsLayerChannelPlaying(layerGroup._backgroundLayers[i], backgroundAnims[i]._animation.name)) { StopLayerChannel(layerGroup._backgroundLayers[i]); layerGroup._backgroundLayers[i]._animation = StartAnimationInLayer(layerGroup._backgroundLayers[i]._layer, backgroundAnims[i]._animation.name, WrapMode.Default); } layerGroup._backgroundLayers[i]._animation.time = backgroundAnims[i]._time; layerGroup._backgroundLayers[i]._animation.speed = backgroundAnims[i]._speed; layerGroup._backgroundLayers[i]._animation.weight = backgroundAnims[i]._weight; } else { StopLayerChannel(layerGroup._backgroundLayers[i]); } } }
void setToThisAnimation(AnimationParams type) { Array values = Enum.GetValues(typeof(AnimationParams)); foreach (AnimationParams val in values) { string name = Enum.GetName(typeof(AnimationParams), val); if (val.Equals(type)) { animator.SetBool(name, true); } else { animator.SetBool(name, false); } } }
void SetEnemyAnimation(AnimationParams type) { string targetAnimation = Enum.GetName(typeof(AnimationParams), type); Array values = Enum.GetValues(typeof(AnimationParams)); foreach (AnimationParams val in values) { string name = Enum.GetName(typeof(AnimationParams), val); if (val.Equals(type)) { animator.SetBool(name, true); } else { animator.SetBool(name, false); } } Vector2 pos = GetPlayerDirection(player, transform); if (targetAnimation.Equals("PlayerKicking")) { lastHitTime = Time.time; attacking = true; animator.SetFloat("LastMoveX", pos.x); animator.SetFloat("LastMoveY", pos.y); } else { if (enemyHP <= runAwayHP) { animator.SetFloat("MoveX", -1 * pos.x); animator.SetFloat("MoveY", -1 * pos.y); } else { animator.SetFloat("MoveX", pos.x); animator.SetFloat("MoveY", pos.y); } } }
protected static async UniTask animate(Action <float, float> anim, AnimationParams animParams = null, CancellationToken token = default) { if (animParams == null) { animParams = new AnimationParams(); } AnimationCurve curve = animParams.curve; float t = animParams.startingT; while (t <= 1) { // Evaluate stopPredicate if any if (animParams.stopPredicate?.Invoke() ?? false) { return; } float y = curve.Evaluate(t); anim.Invoke(y, t); if (animParams.duration.HasValue) { t += Time.deltaTime * (1f / animParams.duration.Value); } else { t += Time.deltaTime * animParams.speed; } await UniTask.NextFrame(token); } // Last step (when t == 1f) anim.Invoke(curve.Evaluate(1f), 1f); }
void AnimateBrokenness(AnimationParams animParams) { Bounce(animParams.bounceFreq, animParams.bounceAmp, animParams.swayAmp); SpinChildren(animParams.spinFreq, animParams.spinProb); }
protected static async UniTask animate(Action <float> anim, AnimationParams animParams = null, CancellationToken token = default) => await animate((y, t) => anim(y), animParams, token);