public void SetElapsedTime(float time) { if (timeElapsed == 0f) { GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.8f); isAnimating = true; AnimationStarted?.Invoke(new AnimationStartedArgs(duration, frames.Length)); } timeElapsed = time; CheckFrame(); }
public override void Start() { _repeatCounter = 0; _frameCount = NumberOfFrames; _finished = false; base.OneShot = RepeatCount == 1; base.Start(); _isRunning = true; AnimationStarted?.Invoke(this, null); }
// starts rotation sequence, called with direction from playerinput public void StartRotation(Vector3 direction) { if (rotationDirection == Vector3.zero && MenuOpen == true) { // sends action to coordinate cursor AnimationStarted?.Invoke(); rotationDirection = direction; timer = rotationTime; if (openAudio.isPlaying == false) { rotateAudio.Play(); } } }
public override void Start() { _repeatCounter = 0; _frameCount = NumberOfFrames; _finished = false; base.OneShot = RepeatCount == 1; base.Start(); if (!System.Maui.Maui.IsLollipopOrNewer) { base.SetVisible(true, true); } _isRunning = true; AnimationStarted?.Invoke(this, null); }
/// <summary> /// Sets current animation and starts it. /// </summary> /// <param name="name">Name of animation</param> /// <param name="playReversed">Plays the animation backwards.</param> public void SetAnimation(string name, bool playReversed = false) { if (_currentAnimationName == name && CurrentAnimation != null) { if (CurrentAnimation.PlayReversed == playReversed) { return; } CurrentAnimation.Start(playReversed); } else { _currentAnimationName = name; CurrentAnimation = _animations[name]; CurrentAnimation.Start(playReversed); AnimationStarted?.Invoke(name); } }
// activates subscreens on open and starts their closing animation on close void MenuControl() { if (MenuOpen == false) { // opens menu and plays audio MenuOpen = true; OpenAnimationStarted?.Invoke(); openAudio.Play(); // sets new starting position and rotates to the right on open startPosition = transform.eulerAngles.y - 90; transform.Rotate(0, -90, 0); StartRotation(Vector3.up); // sets each subscreen to active and enables scripts to play flip animation foreach (GameObject screen in subscreens) { screen.SetActive(true); SubscreenAnimation animationScript = screen.GetComponent <SubscreenAnimation>(); animationScript.enabled = true; } } else if (MenuOpen == true) { // sends action for closing, but there's no close loop CloseAnimationStarted?.Invoke(); AnimationStarted?.Invoke(); closeAudio.Play(); // activates close menu function in each subscreen foreach (GameObject screen in subscreens) { SubscreenAnimation animationScript = screen.GetComponent <SubscreenAnimation>(); animationScript?.CloseMenuFlip(); } // sets bool to false after to coordinate some rotation actions MenuOpen = false; } }
protected virtual void OnAnimationStarted() { AnimationStarted?.Invoke(this, new AnimationStartedEventArgs(AnimationSource)); }
/// <summary> /// Called when animation started. /// </summary> void _viewFieldAnimator_Started(ViewFieldAnimator viewFieldAnimator) { AnimationStarted.Trigger(); }
/// <summary> /// Starts the animation. /// </summary> public override void StartAnimation() { this.ForEachChild <ViewAnimation>(x => x.StartAnimation(), false); AnimationStarted.Trigger(); }