Exemple #1
0
 public void OnRoundEnd(Boolean playerWon, OutcomeReason reason)
 {
     _enforcingBoundary = false;
     if (_paddleTooFarForward)
     {
         _paddleTooFarForward = false;
         HandleEndViolation();
     }
 }
    private void EndRound(bool playerWon, OutcomeReason reason)
    {
        if (GameConstants.DEBUG_MODE)
        {
            string name      = playerWon ? "player" : "opponent";
            string reasonStr = reason.ToReadableString();
            Utils.DebugLog($"Round ended: {name} wins because of {reasonStr}.");
        }

        RoundEndEvent.Invoke(playerWon, reason);
        _playingRound = false;
    }
    public static string ToReadableString(this OutcomeReason or)
    {
        switch (or)
        {
        case OutcomeReason.BOUNCE_LOSS:
            return("Too Many Wall Bounces");

        case OutcomeReason.DOUBLE_HIT:
            return("Double Hit");

        case OutcomeReason.LET_THROUGH:
            return("Let Through");

        default:
            throw new System.Exception("OutcomeReason not recognized.");
        }
    }
Exemple #4
0
    public void OnRoundEnd(bool playerWin, OutcomeReason reason)
    {
        AudioSource announcement;

        if (reason == OutcomeReason.BOUNCE_LOSS)
        {
            announcement = playerWin ? PlayerWinBounces : PlayerLoseBounces;
        }
        else if (reason == OutcomeReason.DOUBLE_HIT)
        {
            announcement = playerWin ? PlayerWinDoubleHit : PlayerLoseDoubleHit;
        }
        else if (reason == OutcomeReason.LET_THROUGH)
        {
            announcement = playerWin ? PlayerWinLetThrough : PlayerLoseLetThrough;
        }
        else
        {
            throw new System.Exception("Outcome reason not recognized.");
        }

        announcement.PlayDelayed(GameConstants.OUTCOME_ANNOUNCEMENT_DELAY);
    }
Exemple #5
0
    public void OnRoundEnd(bool playerWon, OutcomeReason reason)
    {
        Color shatterColor = GameConstants.BALL_SHATTER_COLORS[reason];

        BallShatterEffects.transform.position = ball.transform.position;
        BallShatterEffects.GetComponentInChildren <AudioSource>().Play();

        ParticleSystem particleSys = BallShatterEffects.GetComponentInChildren <ParticleSystem>();

        ParticleSystem.MainModule  mainMod  = particleSys.main;
        ParticleSystem.TrailModule trailMod = particleSys.trails;
        mainMod.startColor      = shatterColor;
        trailMod.colorOverTrail = shatterColor;
        particleSys.Play();

        _shatteredBall = Instantiate(
            ShatteredBallPrefab,
            ball.transform.position,
            Quaternion.identity
            );

        foreach (MeshRenderer renderer in _shatteredBall.GetComponentsInChildren <MeshRenderer>())
        {
            renderer.material.SetColor("_Color", shatterColor);
        }

        Vector3 ballVelocity = ball.GetComponent <Rigidbody>().velocity;

        foreach (Rigidbody r in _shatteredBall.GetComponentsInChildren <Rigidbody>())
        {
            r.velocity = ballVelocity;
            r.AddExplosionForce(2.0f, _shatteredBall.transform.position, 0.2f, 0, ForceMode.Impulse);
        }
        ball.SetActive(false);

        Invoke("CleanUpShatter", GameConstants.RETURN_TO_MENU_DELAY);
    }
 public void OnRoundEnd(bool playerWon, OutcomeReason reason)
 {
     _followingBall = false;
 }
Exemple #7
0
 public void OnRoundEnd(bool playerWon, OutcomeReason reason)
 {
     SetTunnelColor(GameConstants.TUNNEL_START_COLOR);
 }
Exemple #8
0
 public void OnRoundEnd(bool playerWon, OutcomeReason reason)
 {
     _detecting = false;
 }
 public void OnRoundEnd(bool playerWon, OutcomeReason reason)
 {
     StartCoroutine(ShowPlayMenuDelayed(GameConstants.RETURN_TO_MENU_DELAY));
 }
Exemple #10
0
 public void OnRoundEnd(bool playerWon, OutcomeReason reason)
 {
     // If the round somehow ends before the ball is launched
     // (which shouldn't be possible), cancel the upcoming launch.
     CancelInvoke();
 }
 public void OnRoundEnd(bool playerWon, OutcomeReason reason)
 {
     StartCoroutine(SetControllersActiveDelayed(GameConstants.RETURN_TO_MENU_DELAY, true));
 }