Пример #1
0
    private void RpcUseAbility(PowerUp.Abilities ability)
    {
        // Use the ability and set its end time.
        var delay = Ability.Begin(ability, this, isServer);

        // Set the active ability to our ability.
        ActiveAbility = ability;

        // Reset the ability of this paddle.
        ResetAbility();

        AbilityEnd = Time.time + delay;

        // If we're using a one time use ability, don't try to end it.
        if (delay == 0f)
        {
            ResetActiveAbility();
        }

        // If this is our paddle using the ability:
        if (isLocalPlayer)
        {
            // Tell our UI to reset our ability.
            PowerUpUI.Instance.Reset();
        }
    }
Пример #2
0
    public void EndAbility(PowerUp.Abilities ability)
    {
        // End the ability.
        Ability.End(ability, this, isServer);

        // Reset the active ability of this paddle.
        ResetActiveAbility();
    }
Пример #3
0
    private static float Use(PowerUp.Abilities ability, Paddle paddle, bool begin, bool isServer)
    {
        // Switch of ability:
        switch (ability)
        {
        // If we are using the grow power up, call its respective function.
        case PowerUp.Abilities.Grow:
            if (begin)
            {
                Grow.Begin(paddle);
            }
            else
            {
                Grow.End(paddle);
            }

            return(Grow.Duration);

        // If we are using the shrink power up, call its respective function.
        case PowerUp.Abilities.Shrink:
            if (begin)
            {
                Shrink.Begin(paddle);
            }
            else
            {
                Shrink.End(paddle);
            }

            return(Shrink.Duration);

        // If we are using the confusion power up, call its respective function.
        case PowerUp.Abilities.Confusion:
            if (begin)
            {
                Confusion.Begin(paddle);
            }
            else
            {
                Confusion.End(paddle);
            }

            return(Confusion.Duration);

        // As ricochet is one time use, return zero as the duration and only use on begin.
        case PowerUp.Abilities.Ricochet:
            // Only run on server as this is change to the ball's velocity which the server controls.
            if (isServer && begin)
            {
                Ricochet.Use();
            }

            return(0f);
        }

        return(0f);
    }
Пример #4
0
    public static float Begin(PowerUp.Abilities ability, Paddle paddle, bool isServer)
    {
        // If they already currently have an active ability, end it.
        if (paddle.HasActiveAbility())
        {
            paddle.EndAbility(paddle.ActiveAbility);
        }

        return(Use(ability, paddle, true, isServer));
    }
Пример #5
0
    public void GetPowerUp(PowerUp.Abilities ability)
    {
        switch (ability)
        {
        case PowerUp.Abilities.Mashroom:
            status = 2;
            SoundManager.instance.PlaySingle(mushroomSound);
            break;

        case PowerUp.Abilities.Fire:
            SoundManager.instance.PlaySingle(mushroomSound);
            status = 3;
            break;

        case PowerUp.Abilities.Invincible:
            SoundManager.instance.PlaySingle(mushroomSound);
            status = 4;
            break;

        default:
            break;
        }
    }
Пример #6
0
 public void ResetActiveAbility()
 {
     // Set our ability to none.
     ActiveAbility = PowerUp.Abilities.None;
 }
Пример #7
0
 public void ResetAbility()
 {
     // Set our ability to none.
     AbilitySlot = PowerUp.Abilities.None;
 }
Пример #8
0
 private void RpcEndAbility(PowerUp.Abilities ability)
 {
     // Call the non-RPC end ability.
     EndAbility(ability);
 }
Пример #9
0
    public void Set(PowerUp.Abilities powerUp)
    {
        var ability = Enum.GetName(typeof(PowerUp.Abilities), powerUp);

        Current = ability.ToLower();
    }
Пример #10
0
 public static void End(PowerUp.Abilities ability, Paddle paddle, bool isServer)
 {
     Use(ability, paddle, false, isServer);
 }