Esempio n. 1
0
    protected override void UpdateAction()
    {
        //If the player presses the action button
        if (actionInput)
        {
            //If the player is in cooldown, just return
            if (cooldownCounter > 0)
            {
                return;
            }

            if (dischargeCounter < dischargeTime)
            {
                //Tried to activate the shield too soon, caused a discharge
                cooldownCounter = dischargeCooldown;

                //No matter what the shield is doing, it will turn off
                shield.Discharge();

                //Revert things
                shielding = false;
                moveSpeed = baseSpeed;

                return;
            }

            //If the player pressed the action button, it will always reset the counter to 0
            dischargeCounter = 0;

            if (!shielding)
            {
                shield.DeployShield(shieldDeploySpeed);
                shielding = true;

                //Slow the player when shield is held
                moveSpeed *= shieldSpeedMult;
            }
            else if (shielding)
            {
                shield.EndShield(shieldDeploySpeed);
                shielding = false;

                //Revert speed
                moveSpeed = baseSpeed;
            }
        }
    }