public void GetNewGameWindow() { NewGameWindow = new NewGameWindow(); this.NewGameOptions = new NewGameOptions(); VM_NewGame = new VM_NewGame(NewGameOptions, this); NewGameWindow.DataContext = VM_NewGame; NewGameWindow.Show(); }
private NewGameOptionsArgs GetPlayerArgs() { INewGameOptions newGameOptions = new NewGameOptions(); newGameOptions.PrintMessage(); return(newGameOptions.GetGameOptionsArgs()); }
public VM_NewGame(NewGameOptions ngo, MainController controller) { Controller = controller; Settings = ngo; Cmd_RefreshView = new RelayCommand(RefreshView); Cmd_NewGame = new RelayCommand(NewGame); }
public GameState CreateNewGame() { int id = _games.Count + 1; var options = new NewGameOptions(1, 2, 1); var game = _simulator.BuildNewGameState(id, options); _games[id] = game; return(game); }
public GameState BuildNewGameState(int id, NewGameOptions options) { var state = new GameState(id); state.Time = new GameTime(8, 4, 2422, 3, 20); state.GenerateCrewMembers(options.StartingCrewMembers) .GenerateSystems(options.StartingSystems) .GenerateWorkItems(options.StartingWorkItems); return(state); }
// Update is called once per frame void Update() { //Handle 'esc' button for quit if (Input.GetKey("escape")) { gameState = GameState.Closing; } // Ensure sound keeps looping - Sometimes it stops randomly if (!audio.isPlaying) { audio.Play(); Debug.Log("Sound was restarted!!"); } if (gameState == GameState.Starting) { // Show Title if (!showTitleScreen || guiController.ShowTitleScreen(3.0f) == GUIResult.Finished) { gameState = GameState.MainMenu; } } if (gameState == GameState.MainMenu) { var result = guiController.ShowMainMenu(); if (result.isFinished) { switch (result.mainMenuAction) { case MainMenuAction.NewGame: gameState = GameState.LoadingNewGame; newGameOptions = result.newGameOptions; break; case MainMenuAction.Close: default: gameState = GameState.Closing; break; } } } if (gameState == GameState.LoadingNewGame) { // TEMP: Refactor this guiController.ShowNone(); var options = newGameOptions; var humans = new List<int>(); for (int i = 0; i < options.humanPlayerCount; i++) { humans.Add(i); } PerformanceController.PausePerformance(); NewGame(options.humanPlayerCount + options.computerPlayerCount, humans); PerformanceController.ResetPerformance(0.5f); gameState = GameState.Editor; } if (gameState == GameState.Editor) { HandleCameraInputs(); // Handle when editor is finished if (editorController.editorState == EditorState.Finished || !newGameOptions.shouldShowEditor) { editorController.FinishedIsHandled(); PerformanceController.PausePerformance(); // Disable editor for performance Destroy(editorController); CreateBasesIfEmpty(); RemoveAllAligners(); EnableBases(); PerformanceController.ResetPerformance(1.0f); // Start Game Mode gameState = GameState.Playing; } } if (gameState == GameState.Playing) { SetRadarCameraVisible(true); var hasMoved = HandleCameraInputs(); if (hasMoved) { hasCameraMovedForTurnState = true; } if (turnState == TurnState.Starting) { // Move camera var pos = players[playerTurnIndex].baseObject.transform.position; mouseHelper.MoveCameraToLookAtGroundPoint(pos.x, pos.z); // Move the ActiveBaseMarker activeBaseMarker.transform.position = pos; // TODO: Display Player Info Debug.Log("Turn = PlayerIndex " + playerTurnIndex); turnState = TurnState.Aiming; hitBaseIndex = -1; } if (turnState == TurnState.Aiming) { GameAction gameAction; if (players[playerTurnIndex].isHuman) { // TODO: Allow player to shoot blocks only near base gameAction = HandleGameInputs(); } else { // Computer Aiming gameAction = ComputerAim(); } if (gameAction == GameAction.PlayerShotBlock) { turnState = TurnState.Shooting; } else if (gameAction == GameAction.None) { // Do Nothing } else { throw new System.Exception("Unknown GameAction: " + gameAction); } } if (turnState == TurnState.Shooting) { // Detect shooting block stop movement + Timeout var sController = shootingBlock.GetComponent<ShootingBlockController>(); var isTurnFinished = sController.shootingBlockState == ShootingBlockState.Finished && Time.time - sController.finishedTime > endOfTurnTimeSpan; // Detect if has hit enemy base var pos = shootingBlock.transform.position; for (var iPlayer = 0; iPlayer < players.Count; iPlayer++) { if (iPlayer == playerTurnIndex) { continue; } var player = players[iPlayer]; var pBase = player.baseObject; if (!player.isAlive) { continue; } var bPos = pBase.transform.position; var distance = Vector3.Distance(bPos, pos); if (distance < blockHitBaseDistance) { hitBaseIndex = iPlayer; } } if (sController.shootingBlockState != ShootingBlockState.Finished && !hasCameraMovedForTurnState) { if (hitBaseIndex < 0) { // Follow the shooting block with the camera (while it is still moving) mouseHelper.MoveCameraToLookAtGroundPoint(pos.x, pos.z); } else { // Move camera to base var pBasePos = players[hitBaseIndex].baseObject.transform.position; mouseHelper.MoveCameraToLookAtGroundPoint(pBasePos.x, pBasePos.z); } } if (isTurnFinished) { sController.FinishedIsHandled(); turnState = TurnState.Ended; } } if (turnState == TurnState.Ended) { // Detect End of Game (if only one human player is still active or all human players are inactive) // Or if no human players - then only one computer left var humanPlayerCount = 0; var humansAliveCount = 0; var computersAliveCount = 0; foreach (var p in players) { if (p.isHuman) { humanPlayerCount++; if (p.isAlive) { humansAliveCount++; } } else { if (p.isAlive) { computersAliveCount++; } } } var playersAliveCount = humansAliveCount + computersAliveCount; if ((humansAliveCount == 0 && humanPlayerCount > 0) || playersAliveCount <= 1) { Debug.Log("Players -> GameOver"); gameState = GameState.EndOfGameReport; } // Go to next alive player var origPlayer = playerTurnIndex; do { playerTurnIndex++; if (playerTurnIndex >= players.Count) { playerTurnIndex = 0; } if (playerTurnIndex == origPlayer) { // Game Over (only one player alive (or maybe none alive)) - This should be handled by above check break; } } while (!players[playerTurnIndex].isAlive); turnState = TurnState.Starting; } } if (gameState == GameState.EndOfGameReport) { SetRadarCameraVisible(false); var winnerName = "Nobody"; var isWinnerHuman = false; var loserHumans = new List<string>(); foreach (var p in players) { if (p.isAlive) { winnerName = p.name; isWinnerHuman = p.isHuman; } else { if (p.isHuman) { loserHumans.Add(p.name); } } } var reportInfo = new EndOfGameInfo(winnerName, isWinnerHuman, loserHumans.ToArray()); if (guiController.ShowEndOfGameReport(reportInfo, 5.0f) == GUIResult.Finished) { gameState = GameState.MainMenu; } } if (gameState == GameState.Closing) { Application.Quit(); } }
public MainMenuResult(GUIResult guiResult, MainMenuAction action, NewGameOptions newGameOptions) { this.guiResult = guiResult; this.mainMenuAction = action; this.newGameOptions = newGameOptions; }