// Update is called once per frame void Update() { phase = PhaseHandler.phase; roundCount = PhaseHandler.roundCount; timeLeft = PhaseHandler.timeLeft; leadingTeam = PhaseHandler.leadingTeam; title = $"{phase} Phase"; descriptionTextMesh.text = $"{title}\n{description}"; if (phase == PhaseHandler.Phase.Action) { description = "Fight!\n"; } if (phase == PhaseHandler.Phase.Decision) { description = "Select opponent and weapon!"; descriptionTextMesh.text += $"\nTime left: {timeLeft.ToString("F0")} seconds"; } if (phase == PhaseHandler.Phase.End) { string roundWord = roundCount == 1 ? "round" : "rounds"; descriptionTextMesh.text = $"Total time: {PhaseHandler.passedGameSeconds.ToString("F0")}\nGame ended after {roundCount} {roundWord}.\nTeam {leadingTeam} won!"; } }
// searches for the player of the other team by chosing the other team and the target row public PlayerProperties GetTargetPlayer(PhaseHandler.RowPosition row) { PhaseHandler.Team team = player.team == PhaseHandler.Team.Left ? PhaseHandler.Team.Right : PhaseHandler.Team.Left; List <PlayerProperties> matchingPlayers = players.FindAll(somePlayer => somePlayer.team == team && somePlayer.rowPosition == row); if (matchingPlayers.Count == 1) { print($"Matching target player is: {matchingPlayers[0].playerName}, was called from { new StackFrame(1, true).GetMethod().Name}"); return(matchingPlayers[0]); } else { // more or less than one player found print($"found {matchingPlayers.Count} matching players, but there should be only exactly 1"); if (matchingPlayers.Count > 1) { print("found following players:"); foreach (PlayerProperties player in matchingPlayers) { print(player.playerName); } } throw new InvalidOperationException(); } }
// Update is called once per frame void Update() { phase = PhaseHandler.phase; roundCount = PhaseHandler.roundCount; timeLeft = PhaseHandler.timeLeft; leadingTeam = PhaseHandler.leadingTeam; title = $"{phase} Phase"; // TODO time left should be set via interconnections group instead of here descriptionTextMesh.text = $"Time left: {(PhaseHandler.maxGameSeconds - PhaseHandler.passedGameSeconds).ToString("F0")} \nRound {roundCount}\n{leadingTeam} is leading.\n{description}"; if (phase == PhaseHandler.Phase.End) { string roundWord = roundCount == 1 ? "round" : "rounds"; descriptionTextMesh.text = $"Total time: {PhaseHandler.passedGameSeconds.ToString("F0")}\nGame ended after {roundCount} {roundWord}.\nTeam {leadingTeam} won!"; } }
public void GetWinners() { if (phase == PhaseHandler.Phase.End) { print("end phase!"); PhaseHandler.Team leadingTeam = PhaseHandler.leadingTeam; int[] firstPlaceIndices = players.Select((v, i) => new { v, i }) .Where(x => x.v.team == leadingTeam) .Select(x => x.i).ToArray(); int[] secondPlaceIndices = players.Select((v, i) => new { v, i }) .Where(x => x.v.team != leadingTeam) .Select(x => x.i).ToArray(); // since this is a teamVsTeam game, there are no 3rd/4th places MiniGameFinished(firstPlace: firstPlaceIndices, secondPlace: secondPlaceIndices, thirdPlace: new int[] { }, fourthPlace: new int[] { }); } }