Esempio n. 1
0
    private void Update()
    {
        if (isTransltingReverseActive)
        {
            platformLeft.transform.Translate(Vector3.right * Time.deltaTime * 5f);
            platformRight.transform.Translate(Vector3.left * Time.deltaTime * 5f);
            colider.enabled = true;

            if (platformLeft.transform.localPosition.x >= -0.65)
            {
                isTransltingReverseActive = false;
                SetBulbsColor(Color.red);
            }
        }

        if (isTranslatingActive)
        {
            platformLeft.transform.Translate(Vector3.left * Time.deltaTime * 5f);
            platformRight.transform.Translate(Vector3.right * Time.deltaTime * 5f);
            colider.enabled = false;
            if (isJumperOnPlatform)
            {
                jumper.AnimateFalling();
            }

            if (platformLeft.transform.localPosition.x < -1.7)
            {
                isTranslatingActive       = false;
                isTransltingReverseActive = true;
            }
        }

        if (isCountdownActive)
        {
            if (progress > bulbsSR.Count)
            {
                isCountdownActive   = false;
                progress            = 0;
                waitingTime         = 0;
                isTranslatingActive = true;
                SetBulbsColor(Color.green);
            }
            else
            {
                waitingTime += Time.deltaTime;

                if (waitingTime >= timeStep)
                {
                    if (progress < bulbsSR.Count)
                    {
                        bulbsSR[progress].color = Color.yellow;
                    }
                    waitingTime = 0;
                    progress   += 1;
                }
            }
        }
    }