private void ChangeScene(Structs.GameScene to) { currentScene = to; //Debug.Log("Change scene to: " + currentScene); switch (currentScene) { case Structs.GameScene.Initialization: SwitchToMenu(); break; case Structs.GameScene.Menu: managerInput.SetEvents(); managerUI.SetPanels(); break; case Structs.GameScene.LoadingGame: gameManager.ResetGame(); gameManager.StartGame(); managerUI.SetPanels(); managerCamera.SwitchToCamera(ManagerCamera.Cameras.Static); // And go! SwitchToIngame(); break; case Structs.GameScene.Ingame: gameManager.OnEndGame += GameEnd; managerInput.SetEvents(); managerUI.SetPanels(); break; case Structs.GameScene.GameEnd: gameManager.OnEndGame -= GameEnd; managerCamera.SwitchToCamera(ManagerCamera.Cameras.Motion); //gameManager.ResetGame(); // not necessary managerUI.SetCurrentPlayer(GameManager.Players.None.ToString()); //managerUI.SetWinner( gameManager.GetCurrentPlayer().ToString() ); SwitchToScore(); break; case Structs.GameScene.Score: managerInput.SetEvents(); managerUI.SetPanels(); break; case Structs.GameScene.Exit: Application.Quit(); break; } }
private void ChangeScene(Structs.GameScene to) { currentScene = to; //Debug.Log("Change scene to: " + currentScene); switch (currentScene) { case Structs.GameScene.Initialization: SwitchToMenu(); break; case Structs.GameScene.Menu: managerInput.SetEvents(); managerUI.SetPanels(); break; case Structs.GameScene.LoadingGame: //InitMap(); //entityManager.Init(); //GameInitialize(); //InitPlayer(); //InitCamera(); //SetCameraOnPlayer(); //GameStart(); // If we are in 2 player modes, or 3 player mode, change settings if (currentGameMode == Structs.GameMode.Multi3players) { remainingPlayers = 3; } else { remainingPlayers = 2; } managerUI.SetPanels(); SwitchToIngame(); break; case Structs.GameScene.Ingame: //inputManager.SetEvents(); //uiManager.UpdateUI(); Unpause(); managerMap.Reset(); managerMap.SummonMap(); managerEntity.Reset(); managerEntity.SummonPlayers(); ResetCamera(); if (managerEntity.playersScript[0] != null) { managerEntity.playersScript[0].OnDie += EndGameConditionChecker; managerEntity.playersScript[0].OnCollision += managerEntity.SummonHole; managerUI.SetPlayerSprite(0, managerEntity.playersScript[0].sprite.sprite); } if (managerEntity.playersScript[1] != null) { managerEntity.playersScript[1].OnDie += EndGameConditionChecker; managerEntity.playersScript[1].OnCollision += managerEntity.SummonHole; managerUI.SetPlayerSprite(1, managerEntity.playersScript[1].sprite.sprite); } if (currentGameMode == Structs.GameMode.Multi3players) { if (managerEntity.playersScript[2] != null) { managerEntity.playersScript[2].OnDie += EndGameConditionChecker; managerEntity.playersScript[2].OnCollision += managerEntity.SummonHole; managerUI.SetPlayerSprite(2, managerEntity.playersScript[2].sprite.sprite); } } managerInput.SetEvents(); managerUI.SetPanels(); break; case Structs.GameScene.Score: managerEntity.playersScript[0].OnCollision = null; managerEntity.playersScript[0].OnDie = null; managerEntity.playersScript[1].OnCollision = null; managerEntity.playersScript[1].OnDie = null; if (currentGameMode == Structs.GameMode.Multi3players) { managerEntity.playersScript[2].OnCollision = null; managerEntity.playersScript[2].OnDie = null; } managerInput.SetEvents(); managerUI.SetPanels(); break; case Structs.GameScene.GameEnd: managerEntity.Reset(); managerMap.Reset(); managerInput.SetEvents(); managerUI.SetPanels(); SwitchToMenu(); break; case Structs.GameScene.Exit: Application.Quit(); break; } }
private void ChangeScene(Structs.GameScene to) { currentScene = to; //Debug.Log("Change scene to: " + currentScene); switch (currentScene) { case Structs.GameScene.Initialization: SwitchToMenu(); break; case Structs.GameScene.Menu: managerUI.SetPanels(); //managerInput.SetEvents(); // using rewired managerCamera.UpdateCameras(); // This will be called from the update with input //GameBegin(); // Reset game. Only set score to 0 for now managerGame.Initialize(); break; case Structs.GameScene.LoadingGame: managerUI.SetPanels(); SwitchToIngame(); break; case Structs.GameScene.Ingame: // This loads the map, sets the player and the camera // Using the number of the level //LoadLevel(); // Load the 2 players bool playerSummoningFailed = managerEntity.SummonPlayers(); if (!playerSummoningFailed) { Debug.LogError("Failed instantiating players "); GameEnd(); return; } // And subscribe to endgame conditions if (managerEntity.playersScript[0] != null) { PabloTools.Bind(ref managerEntity.playersScript[0].OnDie, GameReset); } if (managerEntity.playersScript[1] != null) { PabloTools.Bind(ref managerEntity.playersScript[1].OnDie, GameReset); } // Set managers //managerInput.SetEvents(); // using rewired managerUI.SetPanels(); managerCamera.UpdateCameras(); // Play start sfx managerAudio.PlaySfx(ManagerAudio.Sfx.Start); break; case Structs.GameScene.GameReset: // Update score if (managerEntity.playersScript[0].state == EntityPlayer.PlayerState.Alive) { Director.Instance.managerGame.ScoreIncrease(0); } else if (managerEntity.playersScript[1].state == EntityPlayer.PlayerState.Alive) { Director.Instance.managerGame.ScoreIncrease(1); } // Unsubscribe from endgame conditions and remove players if (managerEntity.playersScript[0] != null) { PabloTools.Unbind(ref managerEntity.playersScript[0].OnDie); } if (managerEntity.playersScript[1] != null) { PabloTools.Unbind(ref managerEntity.playersScript[1].OnDie); } managerEntity.Reset(); //managerMap.Reset(); GameBegin(); break; case Structs.GameScene.GameEnd: // Unsubscribe from endgame conditions and remove players if (managerEntity.playersScript[0] != null) { PabloTools.Unbind(ref managerEntity.playersScript[0].OnDie); } if (managerEntity.playersScript[1] != null) { PabloTools.Unbind(ref managerEntity.playersScript[1].OnDie); } managerEntity.Reset(); //managerMap.Reset(); //managerInput.SetEvents(); // using rewired managerUI.SetPanels(); SwitchToMenu(); break; case Structs.GameScene.Exit: Application.Quit(); break; } }