Beispiel #1
0
    public void BallShieldCollision(GameObject shield, Ball ball)
    {
        PlayerController playerController;

        // check if the player is cached / cache it
        if (!playerDictionary.TryGetValue(shield, out playerController))
        {
            playerController = shield.GetComponent <Shield>().GetPlayer();
            if (playerController == null)
            {
                return;
            }

            playerDictionary.Add(shield, playerController);
        }

        playerController.Rumble();

        EPowerUp currentPowerUp = playerController.GetCurrentPowerUp();

        if (currentPowerUp != EPowerUp.None)
        {
            switch (currentPowerUp)
            {
            case EPowerUp.Multiball:
                if (!ball.GetTempStatus() && balls.Count <= powerUpManager.GetMaxBalls() - powerUpManager.GetBallSpawnCount())
                {
                    playerController.PlayPowerupUsedSound();
                    playerController.RemovePowerUp();
                    SpawnMultipleBalls(ball);
                    multiBallInPlay = false;
                }
                break;

            case EPowerUp.CatchNThrow:
                playerController.PlayPowerupUsedSound();
                playerController.RemovePowerUp();
                playerController.SetBallHeld(ball);
                ball.SetHeld(true);
                ball.transform.SetParent(playerController.GetShieldTransform());
                StartCoroutine(DropBallCoroutine(playerController, ball));
                break;
            }
        }

        // The last player to touch the ball
        ball.SetLastTouchedBy(playerController);
    }