Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        maxScore = _repeatedMove.rythmData.Length * (_repeatAmount + 1);
        manager  = RythmManager.Instance;
        PlayerAnimator.SetTrigger(_repeatedMove.moveAnimation);
        _audio.clip = _repeatedMove.moveAudioClip;
        _audio.Play();
        manager.PlayTrainingMove(_repeatedMove);

        backgroundBack.sprite = backgrounds[Random.Range(0, backgrounds.Count)];
        do
        {
            backgroundFront.sprite = backgrounds[Random.Range(0, backgrounds.Count)];
        } while (backgroundFront.sprite == backgroundBack.sprite);
        bufferColor = backgroundFront.color;
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        float amount = Mathf.Lerp(1, 0, currentTime / backgroundLerpTime);

        currentTime          += Time.deltaTime;
        bufferColor.a         = amount;
        backgroundFront.color = bufferColor;

        if (currentTime > backgroundLerpTime)
        {
            currentTime            = 0;
            backgroundFront.sprite = backgroundBack.sprite;
            do
            {
                backgroundBack.sprite = backgrounds[Random.Range(0, backgrounds.Count)];
            } while (backgroundFront.sprite == backgroundBack.sprite);
            bufferColor.a         = 1.0f;
            backgroundFront.color = bufferColor;
        }

        if (manager.MoveDone)
        {
            currentScore += manager.CurrentMoveRight;
            currentIteration++;
            if (currentIteration > _repeatAmount)
            {
                performance = currentScore / maxScore;
                ApplyGains();
            }
            else
            {
                manager.MoveDone = false;
                manager.PlayTrainingMove(_repeatedMove);
            }
        }
    }