Skip to content

Commit

Permalink
Addd Winner Takes All Toggle (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
PNone authored Feb 26, 2023
1 parent 142044b commit 60af804
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions HohimBrueh/Assets/Scripts/Controllers/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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}");
Expand Down
24 changes: 22 additions & 2 deletions HohimBrueh/Assets/Scripts/UI/ScoreScreenController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void Update()
if (!haveUpdatedScores)
{
haveUpdatedScores = true;
if (GameController.isTeamMode)
if (GameController.isTeamMode && GameController.winnerTakesAll)
{
foreach (var player in GameController.activePlayers)
{
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 60af804

Please sign in to comment.