Ejemplo n.º 1
0
    void Update()
    {
        // Waiting to be told by GameManager to start running
        if (isWaitingToStart)
        {
            return;
        }

        // Reduce invulnerability frames until none remain.
        invulnerabilityTime = (int)Mathf.Max(invulnerabilityTime - Time.deltaTime, 0.0f);

        bool isAlive = !IsDead;

        if (isAlive)
        {
            CheckBoostingFinish();

            // Update boosting speed
            if (isBoosting)
            {
                SetRunspeed(15.0f, treadmill.scrollspeed);
            }
            else
            {
                // When not boosting, match with treadmill.
                if (isUsingSlowdown)
                {
                    SetRunspeed(slowDownMovespeed, treadmill.scrollspeed);
                }
                else
                {
                    MatchSpeedToTreadmill();
                }
            }

            TryMove();
            TryActivateAbilities();

            CheckShieldTimeout();
            CheckSlowDownTimeout();

            UpdateYZPosition();

            // If no colors are active, go neutral
            if (!bluePower.IsPowerActive() && !redPower.IsPowerActive() && !greenPower.IsPowerActive())
            {
                ChangeColors(ColorWheel.neutral);
            }
            RenderCurrentColor();
            PullNearbyPickups();
        }
        else if (isReviving)
        {
            // Check if we need to force restore from ragdoll due to timeout
            if (reviveTimeout.IsTimeUp())
            {
                OnBodyRevived();
            }
        }
    }