private bool HasActivePowerupInGroup(EPowerupGroup group)
        {
            for (int i = 0; i < ActivePowerupsCount; i++)
            {
                ActivePowerup powerup = GetActivePowerup(i);
                if (powerup.Powerup.Group == group)
                {
                    return(true);
                }
            }

            return(false);
        }
        public void ActivatePowerup(Powerup powerupToActivate)
        {
            // Deactivates the active powerup that is in the same group as the one we're about to activate.
            if (HasActivePowerupInGroup(powerupToActivate.Group, out ActivePowerup activePowerupFound))
            {
                DeactivatePowerup(activePowerupFound.Powerup);
            }

            // Activate the powerup we want activated.
            ActivePowerup activePowerup = new ActivePowerup(powerupToActivate);

            activePowerups.Add(activePowerup);
            powerupToActivate.Activate(this);
            PowerupActivated?.Invoke(activePowerup);
        }
        private bool HasActivePowerupInGroup(EPowerupGroup group, out ActivePowerup activePowerup)
        {
            for (int i = 0; i < ActivePowerupsCount; i++)
            {
                ActivePowerup powerup = GetActivePowerup(i);
                if (powerup.Powerup.Group != group)
                {
                    continue;
                }

                activePowerup = powerup;
                return(true);
            }

            activePowerup = new ActivePowerup();
            return(false);
        }
        private void DeactivatePowerup(Powerup powerupToDeactivate)
        {
            ActivePowerup activePowerup = new ActivePowerup();

            // Remove the powerup from the active powerups.
            for (int i = 0; i < ActivePowerupsCount; i++)
            {
                activePowerup = GetActivePowerup(i);
                if (activePowerup.Powerup != powerupToDeactivate)
                {
                    continue;
                }

                activePowerups.Remove(activePowerup);
                break;
            }

            // Deactivate the powerup.
            if (activePowerup.Powerup != null)
            {
                powerupToDeactivate.Deactivate(this);
                PowerupDeactivated?.Invoke(activePowerup);
            }
        }