Example #1
0
    private void RpcBackWallHit(int backWallHitPosition)
    {
        backWallHits[(PlayerPosition)backWallHitPosition]++;
        WallHit?.Invoke((PlayerPosition)backWallHitPosition);

        if (backWallHits[(PlayerPosition)backWallHitPosition] >= backWallMaxHits)
        {
            backWallHits[PlayerPosition.Top]    = 0;
            backWallHits[PlayerPosition.Bottom] = 0;
            currentScore[(PlayerPosition)backWallHitPosition] += scoreIncrease;

            ScoreIncreased?.Invoke(currentScore, (PlayerPosition)backWallHitPosition);


            if (currentScore.Values.ToList().TrueForAll(x => x == killerPointScore))
            {
                //Handle Killer Point
            }
            if (currentScore[(PlayerPosition)backWallHitPosition] >= winningScore)
            {
                StartCoroutine(HandleGameOver((PlayerPosition)backWallHitPosition));
            }
            ballSpawner.DestroyCurrentBall();

            //TODO: Handle ball spawning
            if (!gameOver)
            {
                scoreAnimator.UpdateScores(EvaluateScore(currentScore[PlayerPosition.Bottom]),
                                           EvaluateScore(currentScore[PlayerPosition.Top]),
                                           (PlayerPosition)backWallHitPosition == PlayerPosition.Bottom,
                                           (PlayerPosition)backWallHitPosition == PlayerPosition.Bottom,
                                           (PlayerPosition)backWallHitPosition == PlayerPosition.Top,
                                           (PlayerPosition)backWallHitPosition == PlayerPosition.Top);
                StartCoroutine(scoreTransition.Animate(Camera.main.GetComponent <AnalogGlitch>()));
                scoreAnimator.MoveScores();
                StartCoroutine(ballSpawner.WaitBeforeBallSpawn(ballSpawner.longSpawnTime));
            }
        }
    }