Ejemplo n.º 1
0
    private void ShowScoreChange(bool show, bool animated)
    {
        if (animated)
        {
            AnimationOperation showFadeOperation = new AnimationOperation(scoreChange, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 0.5f)
            {
                fadeSettings = new AnimationOperation.FadeSettings {
                    startAlpha  = 0,
                    targetAlpha = 1
                }
            };
            AnimationSequence fadeAnimation = new AnimationSequence(e => StartCoroutine(e));
            fadeAnimation.AddOperation(showFadeOperation);
            fadeAnimation.AddOperation(new AnimationOperation {
                targetObject = scoreChange, type = UIAnimationType.Activate, activate = true
            });

            if (show)
            {
                fadeAnimation.Play();
            }
            else
            {
                AnimationSequence reversedAnimation = new AnimationSequence(fadeAnimation.Reversed(), e => StartCoroutine(e));
                reversedAnimation.AddOperation(new AnimationOperation {
                    targetObject = scoreChange, type = UIAnimationType.Activate, activate = false, delay = 0.5f
                });
                reversedAnimation.Play();
            }
        }
        else
        {
            scoreChange.SetActive(show);
        }
    }
Ejemplo n.º 2
0
    private void InitAnimations()
    {
        AnimationOperation fadeOperation = new AnimationOperation(panel, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 0.5f)
        {
            fadeSettings = new AnimationOperation.FadeSettings {
                startAlpha  = 0,
                targetAlpha = 1
            }
        };

        showAnimation = new AnimationSequence(e => StartCoroutine(e));
        showAnimation.AddOperation(fadeOperation, new AnimationOperation {
            targetObject = panel, type = UIAnimationType.Activate, activate = true
        });
        resumeButton.SelectOnShow = true;
        showAnimation.OnFinished(() => {
            resumeButton.Show(true, false);
            quitButton.Show(true, false);
        });

        hideAnimation = new AnimationSequence(e => StartCoroutine(e));
        hideAnimation.AddOperation(fadeOperation.Reversed(), new AnimationOperation {
            targetObject = panel, type = UIAnimationType.Activate, activate = false, delay = 0.5f
        });
    }
Ejemplo n.º 3
0
    private void SetShotSelectionBackgroundImageColour(ShotType shotType, bool animated)
    {
        Color targetColour = shotType switch {
            ShotType.Flat => flatShotColour,
            ShotType.TopSpin => topSpinShotColour,
            ShotType.Slice => sliceShotColour,
            ShotType.DropOrLob => dropOrLobShotColour,
            _ => Color.white
        };

        if (animated)
        {
            AnimationOperation colourOperation = new AnimationOperation(shotSelectionBackgroundImage.gameObject, UIAnimationType.Colour, EaseType.SmoothStepSmoother, 0, 0.5f)
            {
                colourSettings = new AnimationOperation.ColourSettings {
                    startColour  = shotSelectionBackgroundImage.color,
                    targetColour = targetColour
                }
            };
            AnimationSequence colourAnimation = new AnimationSequence(e => StartCoroutine(e));
            colourAnimation.AddOperation(colourOperation);

            colourAnimation.Play();
        }
        else
        {
            shotSelectionBackgroundImage.color = targetColour;
        }
    }
    private void ShowMessage(string message)
    {
        trainerMessageText.text = message;

        AnimationOperation scaleOperation = new AnimationOperation(messagePanel, UIAnimationType.Scale, EaseType.SmoothStepSmoother, 0, 1f)
        {
            scaleSettings = new AnimationOperation.ScaleSettings {
                startScale  = Vector3.zero,
                targetScale = Vector3.one
            }
        };

        AnimationOperation fadeOperation = new AnimationOperation(messagePanel, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 1f)
        {
            fadeSettings = new AnimationOperation.FadeSettings {
                startAlpha  = 0,
                targetAlpha = 1
            }
        };

        AnimationOperation flipOperation = new AnimationOperation(messagePanel, UIAnimationType.Rotate, EaseType.SmoothStepSmoother, 0, 0.5f)
        {
            rotateSettings = new AnimationOperation.RotateSettings {
                startEuler  = Vector3.zero,
                targetEuler = new Vector3(90, 0, 0)
            }
        };

        AnimationSequence showMessageAnimation = new AnimationSequence(e => StartCoroutine(e));

        showMessageAnimation.AddOperation(scaleOperation, fadeOperation, new AnimationOperation {
            targetObject = messagePanel, type = UIAnimationType.Activate, activate = true
        });
        showMessageAnimation.AddDelay(2f);
        showMessageAnimation.AddOperation(new AnimationOperation(fadeOperation.Reversed())
        {
            duration = 0.5f
        }, flipOperation, new AnimationOperation {
            targetObject = messagePanel, type = UIAnimationType.Activate, activate = false, delay = 0.5f
        }, new AnimationOperation {
            targetObject = messagePanel, type = UIAnimationType.Rotate, rotateSettings = new AnimationOperation.RotateSettings {
                targetEuler = Vector3.zero
            }, delay = 0.5f
        });

        showMessageAnimation.Play();
    }
    private void SetMultiplier(int combo, bool animated)
    {
        int multiplier = GetScoreMultiplier(combo);

        if (animated)
        {
            if (multiplierAnimation == null && multiplier == 2)
            {
                scaleOperation = new AnimationOperation(multiplierText.gameObject, UIAnimationType.Scale, EaseType.SmoothStepSmoother, 0, 0.5f)
                {
                    scaleSettings = new AnimationOperation.ScaleSettings {
                        startScale  = Vector3.one,
                        targetScale = Vector3.one * 1.25f
                    }
                };
                reversedScaleOperation       = scaleOperation.Reversed();
                reversedScaleOperation.delay = 0.5f;

                multiplierAnimation = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);
                multiplierAnimation.AddOperation(scaleOperation);
                multiplierAnimation.AddOperation(reversedScaleOperation);
                multiplierAnimation.Loop();

                multiplierAnimation.Play();

                Show();
            }

            if (multiplier < currentMultiplier)
            {
                Hide();
            }

            multiplierText.text = $"x {multiplier}";
            currentCombo        = combo;
            currentMultiplier   = multiplier;
        }
        else
        {
            multiplierText.text = $"x {multiplier}";
            currentCombo        = combo;
            currentMultiplier   = multiplier;

            ShowHudElement(multiplier > 1, false);
        }
    }
    private void ShowHudElement(bool show, bool animated)
    {
        if (animated)
        {
            AnimationOperation fadeOperation = new AnimationOperation(panel, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 0.5f)
            {
                fadeSettings = new AnimationOperation.FadeSettings {
                    startAlpha  = 0,
                    targetAlpha = 1
                }
            };
            AnimationOperation anchorPositionOperation = new AnimationOperation(panel, UIAnimationType.AnchoredPosition, EaseType.BackInOut, 0, 0.5f)
            {
                anchoredPositionSettings = new AnimationOperation.AnchoredPositionSettings {
                    startMin  = new Vector2(-0.12f, 0.84f),
                    startMax  = new Vector2(0.08f, 1f),
                    targetMin = new Vector2(0f, 0.84f),
                    targetMax = new Vector2(0.2f, 1f)
                }
            };
            AnimationSequence showAnimation = new AnimationSequence(e => StartCoroutine(e));
            showAnimation.AddOperation(anchorPositionOperation);
            showAnimation.AddOperation(fadeOperation);
            showAnimation.AddOperation(new AnimationOperation {
                targetObject = panel, type = UIAnimationType.Activate, activate = true
            });

            if (show)
            {
                showAnimation.Play();
            }
            else
            {
                AnimationSequence reversedShowAnimation = new AnimationSequence(showAnimation.Reversed(), e => StartCoroutine(e));
                reversedShowAnimation.AddOperation(new AnimationOperation {
                    targetObject = panel, type = UIAnimationType.Activate, activate = false, delay = 0.5f
                });
                reversedShowAnimation.Play();
            }
        }
        else
        {
            panel.SetActive(show);
        }
    }
Ejemplo n.º 7
0
 private void InitAnimations() {
     AnimationOperation scaleContentOperation = new AnimationOperation(content, UIAnimationType.Scale, EaseType.SmoothStepSmoother, 0, 0.5f) {
         scaleSettings = new AnimationOperation.ScaleSettings {
             startScale = Vector3.zero,
             targetScale = Vector3.one
         }
     };
     AnimationOperation fadeContentOperation = new AnimationOperation(content, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 0.5f) {
         fadeSettings = new AnimationOperation.FadeSettings {
             startAlpha = 0,
             targetAlpha = 1
         }
     };
     AnimationOperation fadeBackgroundOperation = new AnimationOperation(fadeContentOperation) {targetObject = background};
         
     showAnimation = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);
     showAnimation.AddOperation(scaleContentOperation, fadeContentOperation, fadeBackgroundOperation, new AnimationOperation {targetObject = panel, type = UIAnimationType.Activate, activate = true});
     showAnimation.OnFinished(() => confirmButton.Select());
     
     hideAnimation = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);
     hideAnimation.AddOperation(scaleContentOperation.Reversed(), fadeContentOperation.Reversed(), fadeBackgroundOperation.Reversed(), new AnimationOperation{targetObject = panel, type = UIAnimationType.Activate, activate = false, delay = 0.5f});
 }
Ejemplo n.º 8
0
    private void Awake()
    {
        ShowOverview(false, false);

        backButton.onPress.AddListener(Back);

        backgroundShowAnimation = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);
        backgroundHideAnimation = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);

        AnimationOperation fadeOperation = new AnimationOperation(background, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 0.5f)
        {
            fadeSettings = new AnimationOperation.FadeSettings {
                startAlpha = 0, targetAlpha = 1
            }
        };

        backgroundShowAnimation.AddOperation(fadeOperation, new AnimationOperation {
            targetObject = background, type = UIAnimationType.Activate, activate = true
        });
        backgroundHideAnimation.AddOperation(fadeOperation.Reversed(), new AnimationOperation {
            targetObject = background, type = UIAnimationType.Activate, activate = false, delay = fadeOperation.duration
        });
    }
Ejemplo n.º 9
0
    private void ShowResults(TrainingProgramData programData)
    {
        sessionNameText.text = $"{programData.programName} - Results";

        int programTotalScore   = programData.GetTotalScore();
        int programMaximumScore = programData.GetMaximumScore();

        totalScoreText.text = $"{programTotalScore}/{programMaximumScore}";

        float ratingValue    = (float)programTotalScore / programMaximumScore * 100f;
        float f              = 100f / ratingScaleImageNumber;
        float colourDuration = (float)ratingScaleImages.Count / (ratingScaleImages.Count * ratingScaleImages.Count);
        float delay          = colourDuration * 1.5f;

        AnimationSequence ratingAnimation = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);

        ratingAnimation.AddDelay(1f);

        spinningAnimations.Clear();
        AnimationOperation spinningOperation1 = new AnimationOperation(null, UIAnimationType.Rotate, EaseType.Linear, 0, 4f)
        {
            rotateSettings = new AnimationOperation.RotateSettings {
                startEuler  = new Vector3(0, 0, 0),
                targetEuler = new Vector3(0, 0, 180)
            }
        };
        AnimationOperation spinningOperation2 = new AnimationOperation(null, UIAnimationType.Rotate, EaseType.Linear, 3.95f, 4f)
        {
            rotateSettings = new AnimationOperation.RotateSettings {
                startEuler  = new Vector3(0, 0, 180),
                targetEuler = new Vector3(0, 0, 360)
            }
        };

        for (int i = 0; i < ratingScaleImages.Count; i++)
        {
            if (i * f >= ratingValue)
            {
                break;
            }

            AnimationOperation colourOperation = new AnimationOperation(ratingScaleImages[i].gameObject, UIAnimationType.Colour, EaseType.CubicIn, delay, colourDuration)
            {
                colourSettings = new AnimationOperation.ColourSettings {
                    startColour  = ratingScaleImages[i].color,
                    targetColour = Color.white
                }
            };

            ratingAnimation.AddOperation(colourOperation);

            AnimationSequence spinningAnim = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);

            spinningAnim.AddOperation(
                new AnimationOperation(spinningOperation1)
            {
                targetObject = ratingScaleImages[i].gameObject
            },
                new AnimationOperation(spinningOperation2)
            {
                targetObject = ratingScaleImages[i].gameObject
            });
            spinningAnim.Loop();

            spinningAnimations.Add(spinningAnim);
        }

        foreach (TrainingSessionData session in programData.trainingSessions)
        {
            GameObject sessionResultRow = Instantiate(sessionResultRowPrefab, sessionScrollRect.content);
            if (!sessionResultRow.TryGetComponent(out SessionResultRow sessionResult))
            {
                continue;
            }

            sessionResult.Setup(session.sessionName, $"{session.Score}/{session.MaximumScore}", null);
            // TODO hook session row buttons to show respective session results => set action
        }

        ShowWindow(true, true);
        ratingAnimation.Play();

        foreach (AnimationSequence animationSequence in spinningAnimations)
        {
            animationSequence.Play();
        }
    }
Ejemplo n.º 10
0
    private void InitAnims()
    {
        showAnim = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);

        AnimationOperation activateOperation = new AnimationOperation(panel, UIAnimationType.Activate, EaseType.None, fadeScreenDuration, 0)
        {
            activate = true
        };
        AnimationOperation fadeOperation = new AnimationOperation(panel, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 1f)
        {
            fadeSettings = new AnimationOperation.FadeSettings {
                startAlpha  = 0,
                targetAlpha = 1
            }
        };

        showAnim.AddOperation(activateOperation, fadeOperation);

        hideAnim = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);
        AnimationOperation deactivateOperation = new AnimationOperation(panel, UIAnimationType.Activate, EaseType.None, 1, 0)
        {
            activate = false
        };

        hideAnim.AddOperation(new AnimationOperation(fadeOperation.Reversed()), deactivateOperation);
        hideAnim.OnFinished(() => {
            progressBarFill.fillAmount = 0;
            if (progressRoutine != null)
            {
                applicationEventRelay.RequestStoppingCoroutine(progressRoutine);
            }
            barCurrentTargetValue = 0;
        });

        textBlinkAnim = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);
        AnimationOperation blinkOperation = new AnimationOperation(fadeOperation)
        {
            targetObject = loadingText.gameObject
        };

        textBlinkAnim.AddOperation(blinkOperation);
        textBlinkAnim.PingPong();
        textBlinkAnim.Loop();

        AnimationOperation spinningOperation1 = new AnimationOperation(tennisBallImage, UIAnimationType.Rotate, EaseType.Linear, 0, 4f)
        {
            rotateSettings = new AnimationOperation.RotateSettings {
                startEuler  = new Vector3(0, 0, 0),
                targetEuler = new Vector3(0, 0, 180)
            }
        };
        AnimationOperation spinningOperation2 = new AnimationOperation(tennisBallImage, UIAnimationType.Rotate, EaseType.Linear, 3.95f, 4f)
        {
            rotateSettings = new AnimationOperation.RotateSettings {
                startEuler  = new Vector3(0, 0, 180),
                targetEuler = new Vector3(0, 0, 360)
            }
        };

        spinningBallAnim = new AnimationSequence(applicationEventRelay.RequestStartingCoroutine);
        spinningBallAnim.AddOperation(spinningOperation1, spinningOperation2);
        spinningBallAnim.Loop();
    }
Ejemplo n.º 11
0
    private void Show(float duration, bool show)
    {
        inverseMaskImage.rectTransform.sizeDelta = rootCanvasRectTransform.rect.size;

        if (show)
        {
            AnimationSequence sequence = new AnimationSequence(e => {
                if (applicationEventRelay)
                {
                    applicationEventRelay.RequestStartingCoroutine(e);
                }
            });

            AnimationOperation activateOperation = new AnimationOperation(screenFaderPanel, UIAnimationType.Activate, EaseType.None, 0, 0)
            {
                activate = true
            };

            AnimationOperation showOperation = new AnimationOperation(faderMaskImage.gameObject, UIAnimationType.AnchoredPosition, EaseType.QuarticIn, 0, duration)
            {
                anchoredPositionSettings = new AnimationOperation.AnchoredPositionSettings {
                    startMin  = new Vector2(-1, -1),
                    startMax  = new Vector2(2, 2),
                    targetMin = new Vector2(0.5f, 0.5f),
                    targetMax = new Vector2(0.5f, 0.5f)
                }
            };

            sequence.AddOperation(activateOperation);
            sequence.AddOperation(showOperation);

            sequence.Play();
        }
        else
        {
            AnimationSequence sequence = new AnimationSequence(e => {
                if (applicationEventRelay)
                {
                    applicationEventRelay.RequestStartingCoroutine(e);
                }
            });

            AnimationOperation showOperation = new AnimationOperation(faderMaskImage.gameObject, UIAnimationType.AnchoredPosition, EaseType.QuarticIn, 0, duration)
            {
                anchoredPositionSettings = new AnimationOperation.AnchoredPositionSettings {
                    targetMin = new Vector2(-1, -1),
                    targetMax = new Vector2(2, 2),
                    startMin  = new Vector2(0.5f, 0.5f),
                    startMax  = new Vector2(0.5f, 0.5f)
                }
            };

            AnimationOperation activateOperation = new AnimationOperation(screenFaderPanel, UIAnimationType.Activate, EaseType.None, duration, 0)
            {
                activate = false
            };

            sequence.AddOperation(showOperation);
            sequence.AddOperation(activateOperation);


            sequence.Play();
        }
    }
Ejemplo n.º 12
0
    private void SceneLoadedShow()
    {
        // Maybe do this in via the editor...
        GameObject         qMButton        = quickMatchButton.gameObject;
        AnimationOperation qMFadeOperation = new AnimationOperation(qMButton, UIAnimationType.Fade, EaseType.SmoothStepSmoother, 0, 0.5f)
        {
            fadeSettings = new AnimationOperation.FadeSettings {
                startAlpha  = 0f,
                targetAlpha = 1f
            }
        };
        AnimationOperation qMScaleOperation = new AnimationOperation(qMButton, UIAnimationType.Scale, EaseType.SmoothStepSmoother, 0, 0.5f)
        {
            scaleSettings = new AnimationOperation.ScaleSettings {
                startScale  = Vector3.zero,
                targetScale = Vector3.one
            }
        };
        AnimationOperation qMActivateOperation = new AnimationOperation(qMButton, UIAnimationType.Activate, EaseType.None, 0, 0.5f)
        {
            activate = true
        };

        AnimationSequence quickMatchButtonSequence = new AnimationSequence(RelayRoutine);

        quickMatchButtonSequence.AddOperation(qMFadeOperation, qMScaleOperation, qMActivateOperation);

        GameObject         cButton        = careerButton.gameObject;
        AnimationOperation cFadeOperation = new AnimationOperation(qMFadeOperation)
        {
            targetObject = cButton,
            delay        = 0.25f
        };
        AnimationOperation cScaleOperation = new AnimationOperation(qMScaleOperation)
        {
            targetObject = cButton
        };
        AnimationOperation cActivateOperation = new AnimationOperation(qMActivateOperation)
        {
            targetObject = cButton
        };
        AnimationSequence careerButtonSequence = new AnimationSequence(RelayRoutine);

        careerButtonSequence.AddOperation(cFadeOperation, cScaleOperation, cActivateOperation);

        GameObject         oButton        = onlineButton.gameObject;
        AnimationOperation oFadeOperation = new AnimationOperation(qMFadeOperation)
        {
            targetObject = oButton,
            delay        = 0.35f
        };
        AnimationOperation oScaleOperation = new AnimationOperation(qMScaleOperation)
        {
            targetObject = oButton
        };
        AnimationOperation oActivateOperation = new AnimationOperation(qMActivateOperation)
        {
            targetObject = oButton
        };
        AnimationSequence onlineButtonSequence = new AnimationSequence(RelayRoutine);

        onlineButtonSequence.AddOperation(oFadeOperation, oScaleOperation, oActivateOperation);

        GameObject         tButton        = trainingButton.gameObject;
        AnimationOperation tFadeOperation = new AnimationOperation(qMFadeOperation)
        {
            targetObject = tButton,
            delay        = 0.45f
        };
        AnimationOperation tScaleOperation = new AnimationOperation(qMScaleOperation)
        {
            targetObject = tButton
        };
        AnimationOperation tActivateOperation = new AnimationOperation(qMActivateOperation)
        {
            targetObject = tButton
        };
        AnimationSequence trainingButtonSequence = new AnimationSequence(RelayRoutine);

        trainingButtonSequence.AddOperation(tFadeOperation, tScaleOperation, tActivateOperation);

        GameObject         seButton        = settingsButton.gameObject;
        AnimationOperation seFadeOperation = new AnimationOperation(qMFadeOperation)
        {
            targetObject = seButton,
            delay        = 0.6f
        };
        AnimationOperation seScaleOperation = new AnimationOperation(qMScaleOperation)
        {
            targetObject = seButton
        };
        AnimationOperation seActivateOperation = new AnimationOperation(qMActivateOperation)
        {
            targetObject = seButton
        };
        AnimationSequence settingsButtonSequence = new AnimationSequence(RelayRoutine);

        settingsButtonSequence.AddOperation(seFadeOperation, seScaleOperation, seActivateOperation);

        GameObject         stButton        = statisticsButton.gameObject;
        AnimationOperation stFadeOperation = new AnimationOperation(qMFadeOperation)
        {
            targetObject = stButton,
            delay        = 0.75f
        };
        AnimationOperation stScaleOperation = new AnimationOperation(qMScaleOperation)
        {
            targetObject = stButton
        };
        AnimationOperation stActivateOperation = new AnimationOperation(qMActivateOperation)
        {
            targetObject = stButton
        };

        statisticsButtonSequence = new AnimationSequence(RelayRoutine);
        statisticsButtonSequence.AddOperation(stFadeOperation, stScaleOperation, stActivateOperation);
        statisticsButtonSequence.OnFinished(() => trainingButton.Select());

        quickMatchButtonSequence.Play();
        careerButtonSequence.Play();
        onlineButtonSequence.Play();
        trainingButtonSequence.Play();
        settingsButtonSequence.Play();
        statisticsButtonSequence.Play();

        statisticsButton.CanBePressed = true;
        quickMatchButton.CanBePressed = true;
        careerButton.CanBePressed     = true;
        onlineButton.CanBePressed     = true;
        trainingButton.CanBePressed   = true;
        settingsButton.CanBePressed   = true;

        Utility.SetCursor(true, CursorLockMode.None);
    }