コード例 #1
0
    void Update()
    {
        if (shieldActive)
        {
            if (shieldDuration > 0)
            {
                shieldDuration -= Time.deltaTime;
            }
            else
            {
                shieldActive = false;
                if (!speedActive)
                {
                    playerControls.SetShield(false);
                }
                EventManager.TriggerEvent(PowerupEvents.PLAYER_SHIELD_ENDED);
            }
        }

        if (speedActive)
        {
            if (speedDuruation > 0)
            {
                speedDuruation -= Time.deltaTime;
            }
            else
            {
                speedActive = false;
                dayNightCycle.DecreasePlayerLightRange();
                if (!shieldActive)
                {
                    playerControls.SetShield(false);
                }
                EventManager.TriggerEvent(PowerupEvents.PLAYER_SPEED_ENDED);
                audioSource.loop = false;
                audioSource.Stop();
            }
        }

        if (lightActive)
        {
            if (lightDuration > 0)
            {
                lightDuration -= Time.deltaTime;
            }
            else
            {
                lightActive = false;
                dayNightCycle.setNightTime();
                EventManager.TriggerEvent(PowerupEvents.PLAYER_LIGHT_ENDED);
            }
        }
    }