public void PlayerClearedBlocks(PlayerSupervisor supervisor) { if (trainingMode) { supervisor.WinGame(); RestartGame(supervisor); return; } // Single player games avoid rules if (playerSupervisors.Length < 2) { gameData.gameResult = $"Game Over!"; AudioManager.Instance.PlaySoundBetweenScenes(winSound); TransitionToEndScreen(); return; } // Multiplayer game rules switch (gameData.gameEndCondition) { case GameEndCondition.OnePlayerClearsAllBlocks: case GameEndCondition.AllPlayersLoseBall: case GameEndCondition.OnePlayerLosesBall: default: SetWinner(supervisor); TransitionToEndScreen(); break; } }
private void SetWinnerToHighestPointEarner() { // If all of the PlayerSupervisors have equal points, report a tie. if (Array.TrueForAll(playerSupervisors, ps => ps.GetPoints() == playerSupervisors[0].GetPoints())) { gameData.gameResult = $"It's a tie!"; } // Otherwise, report the highest scoring player's name. else { PlayerSupervisor winner = playerSupervisors[0]; for (int i = 1; i < playerSupervisors.Length; i++) { if (playerSupervisors[i].GetPoints() > winner.GetPoints()) { winner = playerSupervisors[i]; } } if (winner.GetPlayerType() == PlayerType.Human) { gameData.gameResult = $"You Win!"; } else { gameData.gameResult = $"{winner.GetName()} Wins!"; } } }
private void Start() { if (!playerSupervisor) { playerSupervisor = FindObjectOfType <PlayerSupervisor>(); } }
private void SetWinner(PlayerSupervisor winner) { if (winner.GetPlayerType() == PlayerType.Human) { gameData.gameResult = $"You Win!"; } else { gameData.gameResult = $"{winner.GetName()} Wins!"; } }
// Start is called before the first frame update void Awake() { playerSupervisors = FindObjectsOfType <PlayerSupervisor>(); // Still need this for training_0 agent performance tracking playerSupervisor = FindObjectOfType <PlayerSupervisor>(); // Clear the GameData of past games' player data // and create a new list to store this game's player data. gameData.PlayerList = new List <PlayerData>(); sceneLoader = FindObjectOfType <SceneLoader>(); }
public void PlayerLostBall(PlayerSupervisor supervisor) { if (trainingMode) { supervisor.LoseGame(); RestartGame(supervisor); return; } // Single player games avoid rules if (playerSupervisors.Length < 2) { gameData.gameResult = $"Game Over!"; AudioManager.Instance.PlaySoundBetweenScenes(loseSound); TransitionToEndScreen(); return; } // Multiplayer game rules switch (gameData.gameEndCondition) { case GameEndCondition.OnePlayerClearsAllBlocks: supervisor.ResetPlayState(); break; case GameEndCondition.AllPlayersLoseBall: // If all players have lost their ball, transition to the End Screen. int activeBalls = 0; foreach (Ball ball in GameObject.FindObjectsOfType <Ball>()) { if (ball.gameObject.activeSelf) { ++activeBalls; } } if (activeBalls == 0) { SetWinnerToHighestPointEarner(); TransitionToEndScreen(); } break; case GameEndCondition.OnePlayerLosesBall: // Should the winner in this case be the one who broke the most blocks? // Or the one who kept the ball in play longer? SetWinnerToHighestPointEarner(); TransitionToEndScreen(); break; } }
public void SupervisorThreadFactoryTest() { var player = new Arbiter.ConfigurationSvc.PlayerData(); var supervisor = new PlayerSupervisor(player); var client = new GameProvider(membershipManager.Object, timingManager.Object, statusMessageLogger.Object); var threads = client.SupervisorThreadFactory(new List <PlayerSupervisor> { supervisor }); Assert.That(threads, Is.Not.Null, "Collection of returned threads is null"); Assert.That(threads, Is.Not.Empty, "Collection of returned threads is empty"); Assert.That(threads.Count(), Is.EqualTo(1), "Collection of threads contains more than 1 supervisor"); }
// Start is called before the first frame update void Start() { gameManager = FindObjectOfType <GameManager>(); if (!playerSupervisor) { playerSupervisor = FindObjectOfType <PlayerSupervisor>(); } if (materials.Length > 0) { Material mat = Instantiate(materials[UnityEngine.Random.Range(0, materials.Length)]); GetComponent <SpriteRenderer>().material = mat; } }
void Start() { if (trackingPerformanceTF) { // Used as a unique ID for each run, likely this will come in handy runTime = System.DateTime.Now; // SET TIME SCALE to 20 for performance tracking to speed it up Time.timeScale = gameplayTimeScale; SetDataDirectory(); nnModelName = FindObjectOfType <PlayerAgent>().GetComponent <BehaviorParameters>().Model.name; fileNames = new List <string>(); playerSupervisor = FindObjectOfType <PlayerSupervisor>(); } }
private void Start() { if (!playerSupervisor) { playerSupervisor = FindObjectOfType <PlayerSupervisor>(); } if (!ball) { ball = FindObjectOfType <Ball>(); } if (!paddle) { paddle = FindObjectOfType <Paddle>(); } }
public void StartGame(PlayerSupervisor supervisor) { supervisor.StartGame(); }
public void RestartGame(PlayerSupervisor supervisor) { // Reset any game state then let the player start again startTime = DateTime.Now; supervisor.ResetEnvironmentState(); }