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 } }
void Awake() { if (_instance) { Destroy(gameObject); return; } _instance = this; DontDestroyOnLoad(this); }
public void PlayerShowedSkill(string playerId, LRSSkillVerb verb, int increment) { var method = MethodBase.GetCurrentMethod(); var attr = (ServerAccess)method.GetCustomAttributes(typeof(ServerAccess), true)[0]; if (!attr.HasAccess) { return; } PlatformSelection.AddSkill(playerId, verb, increment); }
public void OnDisconnected(NetworkConnection netMsg) { var method = MethodBase.GetCurrentMethod(); var attr = (ServerAccess)method.GetCustomAttributes(typeof(ServerAccess), true)[0]; if (!attr.HasAccess) { return; } Debug.Log("Disconnected: " + netMsg.connectionId); var player = _players.Find(p => p.ConnectionId == netMsg.connectionId); if (player == null) { return; } // Remove player from the list _players.Remove(player); Debug.Log("(D} Current Players: " + _players.Count); if (player.HoldingPlatform) { var platform = GameObject.FindGameObjectWithTag("Platform"); player.DropPlatform(platform); } if (player.OnPlatform) { GameObject.FindGameObjectWithTag("Platform").GetComponent <FloatingPlatform>().Respawn(); player.FellInWater(); player.Respawn(); player.OnPlatform = false; } // Destroy player game object DestroyImmediate(player.gameObject); netMsg.Disconnect(); ChangeRoles(); // TODO check if needs a delay for player disconnection, may break otherwise #if PSL_ENABLED PlatformSelection.UpdatePlayers(_players.Select(p => p.PlayerID).ToList()); #endif }
public void SendSkillData(bool finalResult, int timeTaken) { var method = MethodBase.GetCurrentMethod(); var attr = (ServerAccess)method.GetCustomAttributes(typeof(ServerAccess), true)[0]; if (!attr.HasAccess) { return; } // Send to LRS PlatformSelection.SendSkillData(); SendTrackedData(timeTaken); // Output to file var individualData = PlatformSelection.OutputSkillData(); OutputTrackedData(individualData, finalResult, timeTaken); }
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 EditorStart() { PlatformSelection.UpdateSeverState(GameState.Started); }
public void EditorPause() { PlatformSelection.UpdateSeverState(GameState.Paused); }