private void GameOver(bool victory) { var method = MethodBase.GetCurrentMethod(); var attr = (ServerAccess)method.GetCustomAttributes(typeof(ServerAccess), true)[0]; if (!attr.HasAccess) { return; } //PSL_LRSManager.Instance.GameCompleted(_level.SecondsTaken); _gameWon = victory; if (SP_Manager.Instance.IsSinglePlayer()) { SP_Manager.Instance.Get <SP_Menus>().ShowGameOver(victory, _level.SecondsTaken); _curriculum.ResetLevel(); RestartGame(); } else { _menu.ShowGameOver(victory, _level.SecondsTaken, false); RestartGame(); } if (ControlledByOrchestrator) { #if PSL_ENABLED PlatformSelection.UpdateSeverState(GameState.Stopped); #endif } }
public void EditorStart() { PlatformSelection.UpdateSeverState(GameState.Started); }
void Update() { //if (Input.GetKeyDown(KeyCode.A)) //{ // if (SP_Manager.Instance.IsSinglePlayer()) // { // SP_Manager.Instance.Get<SP_GameManager>().NextRound(); // } // else if (isServer) // { // _players[0].ServerNextRound(); // } //} if (isServer || SP_Manager.Instance.IsSinglePlayer()) { NetworkServer.RegisterHandler(MsgType.Connect, OnConnected); NetworkServer.RegisterHandler(MsgType.Disconnect, OnDisconnected); if (_level == null) { _level = GameObject.Find("LevelManager").GetComponent <LevelManager>(); if (_level != null) { _level.MathsVersion = !_generateRocks; } } if (_menu == null) { _menu = GameObject.Find("MenuManager").GetComponent <MenuManager>(); } if (_curriculum == null) { _curriculum = GameObject.Find("CurriculumManager").GetComponent <Curriculum>(); } if (_playerActionManager == null) { _playerActionManager = GameObject.Find("InteractionManager").GetComponent <PlayerActionManager>(); } if (_level.RoundStarted && _level.IsGameOver) { PauseGame(); GameOver(_gameComplete); } //// Check if the game should be started //if (!_level.RoundStarted) //{ // Set the sync var variable AllPlayersReady = AreAllPlayersReady(); if (SP_Manager.Instance != null && SP_Manager.Instance.IsSinglePlayer()) { if (AllPlayersReady) { StartGameTimer(); ResumeGame(); } else { PauseGame(); } } #if PSL_ENABLED if (!ControlledByOrchestrator || PlatformSelection.ConnectionType == ConnectionType.Testing) { if (AllPlayersReady) { PlatformSelection.UpdateSeverState(GameState.Started); StartGameTimer(); ResumeGame(); } else { PlatformSelection.UpdateSeverState(GameState.WaitingForPlayers); PauseGame(); } //} // //AllPlayersReady = _players.Count >= 3; if (!AllPlayersReady) { PauseGame(); PlatformSelection.UpdateSeverState(GameState.Paused); } else { ResumeGame(); PlatformSelection.UpdateSeverState(GameState.Started); } } if (ControlledByOrchestrator && (PlatformSelection.GetGameState() == GameState.Started || PlatformSelection.GetGameState() == GameState.WaitingForPlayers) && !SP_Manager.Instance.IsSinglePlayer()) { if (!AllPlayersReady) { PauseGame(); } else if (AllPlayersReady) { StartGameTimer(); ResumeGame(); } } #endif // end game when no players after a certain time if (_players.Count == 0) { _noPlayerTimer += Time.deltaTime; if (_noPlayerTimer > _maxInactiveTime) { Application.Quit(); } } else { _noPlayerTimer = 0f; } } //if (Input.GetKeyDown(KeyCode.F1)) //{ // ready = true; //} //if (Input.GetKeyDown(KeyCode.R)) //{ // ResetRound(); //} #if PSL_ENABLED PauseScreen.SetActive(!_gamePlaying); LessonSelectRequired = PSL_GameConfig.LessonSelectionRequired; #else #endif }
public void EditorPause() { PlatformSelection.UpdateSeverState(GameState.Paused); }