From 60af804f7d3e4c0e01b51ee7652c8640a320e622 Mon Sep 17 00:00:00 2001 From: PNone <62551530+PNone@users.noreply.github.com> Date: Sun, 26 Feb 2023 20:55:00 +0200 Subject: [PATCH] Addd Winner Takes All Toggle (#14) --- .../Scripts/Controllers/GameController.cs | 2 ++ .../Scripts/UI/ScoreScreenController.cs | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/HohimBrueh/Assets/Scripts/Controllers/GameController.cs b/HohimBrueh/Assets/Scripts/Controllers/GameController.cs index b4dbf41f..9de64d48 100644 --- a/HohimBrueh/Assets/Scripts/Controllers/GameController.cs +++ b/HohimBrueh/Assets/Scripts/Controllers/GameController.cs @@ -22,6 +22,7 @@ public class GameController : MonoBehaviour public static bool onlyBounceBeforeRecover = true; public static bool allowTeamMode = true; public static bool randomizeMaps = false; + public static bool winnerTakesAll = true; public static bool allowCustomScoreToWin = false; public static float customScoreToWin = 10f; @@ -714,6 +715,7 @@ public void OnGUI() onlyBounceBeforeRecover = GUILayout.Toggle(onlyBounceBeforeRecover, "Only Bounce Before Recover"); allowTeamMode = GUILayout.Toggle(allowTeamMode, "Allow Team Deathmatch (F5/back to toggle mode)"); randomizeMaps = GUILayout.Toggle(randomizeMaps, "Randomize Map Order"); + winnerTakesAll = GUILayout.Toggle(winnerTakesAll, "Only Winners Get Points"); allowCustomScoreToWin = GUILayout.Toggle(allowCustomScoreToWin, "Use Custom Score To Win"); customScoreToWin = GUILayout.HorizontalScrollbar(customScoreToWin, 1.0f, 1.0f, 100.0f); GUILayout.Label($"Custom score to win is {(int)customScoreToWin}"); diff --git a/HohimBrueh/Assets/Scripts/UI/ScoreScreenController.cs b/HohimBrueh/Assets/Scripts/UI/ScoreScreenController.cs index c80a186d..06c1026e 100644 --- a/HohimBrueh/Assets/Scripts/UI/ScoreScreenController.cs +++ b/HohimBrueh/Assets/Scripts/UI/ScoreScreenController.cs @@ -102,7 +102,7 @@ void Update() if (!haveUpdatedScores) { haveUpdatedScores = true; - if (GameController.isTeamMode) + if (GameController.isTeamMode && GameController.winnerTakesAll) { foreach (var player in GameController.activePlayers) { @@ -114,6 +114,23 @@ void Update() } foreach (var psd in playerScoreDisplays) { + if (!GameController.winnerTakesAll) + { + if (GameController.isTeamMode) + { + foreach (var activePlayer in GameController.activePlayers) + { + if (activePlayer.team == psd.player.team) + { + psd.player.roundWins += activePlayer.score; + } + } + } + else + { + psd.player.roundWins += psd.player.score; + } + } if (GameController.isTeamMode) { if (psd.player.team == GameController.lastWinningPlayer.team) @@ -128,7 +145,10 @@ void Update() { if (psd.player == GameController.lastWinningPlayer) { - psd.player.roundWins++; + if (GameController.winnerTakesAll) + { + psd.player.roundWins++; + } if (GameController.isShowDown) psd.TemorarilyDisplay("WINNER!", 10f); else