private void GameManager_OnGameStateChange(EGameStates GameState) { switch (GameState) { case EGameStates.MAIN_MENU: OnMainMenu?.Invoke(); break; case EGameStates.CONNECTING: break; case EGameStates.RELOADING_ROUND: break; case EGameStates.LOADING_NEXTROUND: OnRoundBegin.Invoke(); break; case EGameStates.LOADING_REMATCH: break; case EGameStates.GAMEPLAY: OnGameplayBegin?.Invoke(); break; case EGameStates.ROUND_OVER: OnRoundOver.Invoke(); break; case EGameStates.GAME_OVER: OnGameOver.Invoke(); break; } }
public void CallGameStateEvent(EGameStates _gamestate) { if (OnGameState != null) { OnGameState(_gamestate); } }
public virtual void GameMode_OnGameState(EGameStates _newGameState) { switch (_newGameState) { case EGameStates.MAIN_MENU: break; case EGameStates.CONNECTING: break; case EGameStates.LOADING_REMATCH: break; case EGameStates.LOADING_NEXTROUND: break; case EGameStates.GAMEPLAY: bCanPlay = true; bCanMove = true; break; case EGameStates.ROUND_OVER: bCanPlay = false; break; case EGameStates.GAME_OVER: bCanPlay = false; break; } }
void handleGameState() { switch (currentGameState) { case EGameStates.none: win.Close(); //Argumentendifferenz break; case EGameStates.mainMenu: gameState = new MainMenu(); break; case EGameStates.inGame: gameState = new InGame(); break; case EGameStates.credits: gameState = new Credits(); break; case EGameStates.gameWon: gameState = new gameWon(); break; case EGameStates.controls: gameState = new Controls(); break; } gameState.initialize(); gameState.loadContent(); prevGameState = currentGameState; }
private void GameManager_OnGameStateChange(EGameStates state) { if (state == EGameStates.GAMEPLAY) { BeginTimer(); } }
// Adds the correct component to m_goGameState, based on the requested state. // NOTE: It's assumed that m_goGameState is always an empty gameObject! // private void AddComponentToGameStateObject(EGameStates iState) { if (null == m_goGameState) { return; } switch (iState) { case EGameStates._SPLASHSCREEN_ENTER: m_goGameState.AddComponent <gs_SplashScreenEnter>(); break; case EGameStates._SPLASHSCREEN_IN: m_goGameState.AddComponent <gs_SplashScreenIn>(); break; case EGameStates._SPLASHSCREEN_EXIT: m_goGameState.AddComponent <gs_SplashScreenExit>(); break; case EGameStates._MAINMENU_ENTER: m_goGameState.AddComponent <gs_MainMenuEnter>(); break; case EGameStates._MAINMENU_IN: m_goGameState.AddComponent <gs_MainMenuIn>(); break; case EGameStates._MAINMENU_EXIT: m_goGameState.AddComponent <gs_MainMenuExit>(); break; case EGameStates._GAME_ENTER: m_goGameState.AddComponent <gs_GameEnter>(); break; case EGameStates._GAME_IN: m_goGameState.AddComponent <gs_GameIn>(); break; case EGameStates._GAME_EXIT: m_goGameState.AddComponent <gs_GameExit>(); break; case EGameStates._DEVMODE_ENTER_LEVEL: m_goGameState.AddComponent <gs_DevModeEnterLevel>(); break; } }
// Swaps the old GS object for a new one, with the correct component added. // Note: when this function is called makes a difference as to which scene // it will be in, which is why ChangeState() calls that don't load a new // scene call this function immediately. // protected void FinaliseChangeState(EGameStates iState) { // Cleanout the old state Destroy(m_goGameState); m_goGameState = new GameObject(); m_goGameState.name = m_aGameStateNames[(int)iState]; AddComponentToGameStateObject(iState); }
/* ~~~~~~~~~~~ UPDATE - METHODE ~~~~~~~~~~~~*/ public override void update(GameTime time) { if (currentGameState != prevGameState) { handleGameState(); } currentGameState = gameState.update(time); }
public void ChangeGameState(EGameStates _newGameState, bool bCallEvent = true) { _gameState = _newGameState; if (bCallEvent) { CallGameStateEvent(_gameState); } }
public void QuitToTitle() { if (playerTeam != null) { playerTeam.SetActive(false); } SceneManager.LoadScene("00 Main Menu"); menus.CloseMenuImmediate(); state = EGameStates.Menu; }
public void StartNewGame() { // TODO additional stuff around this SceneManager.LoadScene(startingCutsceneName); state = EGameStates.Cutscene; // block activation until player activates or cutscene ends loadScreen.SelectEffect(loadScreen.cutsceneLoad); SceneLoader.Instance.BlockNextSceneActivation(); StartCoroutine(saveManager.LoadFromText(newGameSaveData)); }
protected override void GameManager_OnGameStateChange(EGameStates NewGameState) { switch (NewGameState) { case EGameStates.ROUND_OVER: ShowContainer(); break; default: HideContainer(); break; } }
public override void Update(GameTime gameTime) { Help.Update(gameTime); MouseControler.Update(); KeyboardControler.Update(); if (currentGameState != prevGameState) { HandleGameState(); } currentGameState = gameState.Update(gameTime); }
public Blocks(int blockType, Vector2f position, Texture blockTex) { switch (blockType) { case 0: //alphaweg { this.blockSprite = new Sprite(new Texture("Texturen/Map/wall-clean.png")); this.blockSprite.Position = position; this.walkable = true; break; } case 1: //alphamauer { this.blockSprite = new Sprite(new Texture("Texturen/Map/way-clean.png")); this.blockSprite.Position = position; this.walkable = false; break; } case 2: //leer { this.blockSprite = new Sprite(); this.blockSprite.Position = position; this.walkable = false; break; } case 3: //start { this.blockSprite = new Sprite(new Texture("Texturen/Map/wall-clean.png")); this.blockSprite.Position = position; this.walkable = true; //insert hier spawn für Player // playerposition = blocksprite.position break; } case 4: //Ziel { this.blockSprite = new Sprite(new Texture("Texturen/Map/way-clean.png")); this.blockSprite.Position = position; this.walkable = false; gameState = EGameStates.inGame; break; //insert hier Ziel: -> Gamestat/Level = +1 } } }
private void GameManager_OnGamestateChange(EGameStates Param1) { if (Param1 != EGameStates.GameOver) { return; } childGameover.SetActive(true); canvasGroup?.DOFade(1, fadeTime).OnComplete(() => { Destroy(canvasGroup); bCanRestart = true; }); }
public void LoadContent() { ReturnState = EGameStates.MainMenu; Selected = ESelectedSprite.None; Background = new Sprite(new Texture("Assets/Textures/MainMenu.png")); Background.Scale = Game.WindowSize / new Vec2f(Background.Texture.Size.X, Background.Texture.Size.Y); Start = new Sprite(new Texture("Assets/Textures/Start.png")); Start.Position = MenuOffset; Options = new Sprite(new Texture("Assets/Textures/Options.png")); Options.Position = (Vec2f)Start.Position + new Vec2f(0, Start.Texture.Size.Y + 10); Exit = new Sprite(new Texture("Assets/Textures/Exit.png")); Exit.Position = (Vec2f)Options.Position + new Vec2f(0, Options.Texture.Size.Y + 10); }
// This loads the JObject into everything needed for the game // It doesn't check validity, this is done by the SaveManager // in the LoadOperation worker object public void Load(JObject data) { GameObject loadedTeam = null; menus.CloseMenuImmediate(); try { loadedTeam = CharacterFactory.CreatePlayerTeam((JArray)data["playerTeam"]); loadedTeam.transform.SetParent(this.transform); loadedTeam.SetActive(false); loadedTeam.name = "Player Team"; if (playerTeam != null) { GameObject.Destroy(playerTeam); } playerTeam = loadedTeam; BattleManager.Instance.playerTeam = playerTeam.transform; inventory.Load((JObject)data["inventory"]); SceneLoader.Instance.Load((JObject)data["scene"]); }catch (System.Exception e) { // If something goes wrong, reset everything and go back to main menu if (loadedTeam != null) { GameObject.Destroy(loadedTeam); } if (playerTeam != null) { GameObject.Destroy(playerTeam); playerTeam = null; } BattleManager.Instance.playerTeam = null; inventory.Clear(); state = EGameStates.Menu; SceneLoader.Instance.AllowSceneActivation(); loadScreen.SelectEffect(loadScreen.defaultLoad); SceneManager.LoadScene("00 Main Menu"); // HACK would be better to show an error to the player Debug.LogWarning("Exception on loading file: " + e.Message); } }
private void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { GameObject.Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); inventory = GetComponent <RPGItems.InventoryManager>(); menus = GetComponentInChildren <MenuManager>(true); Paused = false; state = EGameStates.Menu; //HACK assumes game starts at main menu! saveManager.Init(); }
private void GameManager_OnGameStateChange(EGameStates gameState) { switch (gameState) { case EGameStates.Waiting: break; case EGameStates.Gameplay: break; case EGameStates.RoundOver: break; case EGameStates.GameOver: break; default: break; } }
public void InitializeGame() { if (playerTeam != null) { GameObject.Destroy(playerTeam); } playerTeam = new GameObject("Player Team"); playerTeam.transform.parent = this.transform; foreach (Character prefab in initialPlayerTeam) { //GameObject.Instantiate(prefab, playerTeam.transform); Utility.InstantiateSameName <Character>(prefab, playerTeam.transform); } playerTeam.SetActive(false); BattleManager.Instance.playerTeam = playerTeam.transform; SceneLoader.Instance.Init(); inventory.Initialize(initialInventory); state = EGameStates.Overworld; }
public Game() : base((int)WINDOWSIZE.X, (int)WINDOWSIZE.Y, "galaxy survival", Styles.Default) { playerName = ""; currentGameState = EGameStates.MainMenu; currentGameStateObject = new MainMenu(); backedUpGameStateObject = null; currentGameStateObject.initialize(); currentGameStateObject.loadContent(); // keyboard & mouse List <Keyboard.Key> usedButtons = new List <Keyboard.Key>(); // add keys for (int i = (int)Keyboard.Key.Num0; i <= (int)Keyboard.Key.Num9; ++i) { usedButtons.Add((Keyboard.Key)i); } for (int i = (int)Keyboard.Key.Numpad0; i <= (int)Keyboard.Key.Numpad9; ++i) { usedButtons.Add((Keyboard.Key)i); } for (int i = (int)Keyboard.Key.A; i <= (int)Keyboard.Key.Z; ++i) { usedButtons.Add((Keyboard.Key)i); } usedButtons.Add(Keyboard.Key.Escape); usedButtons.Add(Keyboard.Key.Back); usedButtons.Add(Keyboard.Key.Space); keyboardInput = new KeyboardInput(usedButtons); mouseInput = new MouseInput(window); joystickInput = new JoystickInput(); smaraFont = new Font("Content/Fonts/Days.otf"); window.SetMouseCursorVisible(false); cursor = new Sprite(new Texture("Content/Cursor.png")); cursor.Origin = new Vector2f(cursor.Texture.Size.X, cursor.Texture.Size.Y) / 2; }
// This function initialises the change of game state, and the loading of a new // state (if required, which isn't always) // public void ChangeState(EGameStates iState, string sLevelName = "", bool bClearTimers = true) { // Early out if we're already waiting for a scene to load! if (m_bWaitingForLoad) { Debug.LogError("Change State called while waiting to load!"); return; } // Clear all existing timers! No more will be processed this frame... // DevModeCheck can override this, as we'll have gone through successive state changes // in consecutive frames, some of which will have happened after Start() is called on // the scene objects loaded... if (bClearTimers) { TimerManager.ClearAll(); } // Remove the loaded scene if we need to... if (sLevelName != "" && m_LoadedScene.IsValid() && m_LoadedScene.name != sLevelName) { SceneManager.UnloadSceneAsync(m_LoadedScene); } // Load the new scene if we need it... if (sLevelName != "") { Debug.Log("Attempting to load: " + sLevelName + "\n"); m_bWaitingForLoad = true; m_iNewState = iState; SceneManager.LoadScene(sLevelName, LoadSceneMode.Additive); m_LoadedScene = SceneManager.GetSceneByName(sLevelName); Assert.IsTrue(m_LoadedScene.IsValid()); } // ...or just change the active game state to the newly requested one. else { FinaliseChangeState(iState); } }
private void GameManager_OnGamestateChange(EGameStates Param1) { switch (Param1) { case EGameStates.MainMenu: break; case EGameStates.GameBegin: break; case EGameStates.GameOver: canvasGroup?.DOFade(0, fadeTime).OnComplete(() => { gameObject.SetActive(false); }); break; case EGameStates.RoundOver: break; default: break; } }
public override void update(GameTime gameTime) { // updating mouse and keyboard mouseInput.update(); keyboardInput.update(); joystickInput.update(); if (joystickInput.getRightStick().X > 20) { mouseMove.X = 5 * joystickInput.getRightStick().X *(float)gameTime.ElapsedTime.TotalSeconds; } else if (joystickInput.getRightStick().X < -20) { mouseMove.X = 5 * joystickInput.getRightStick().X *(float)gameTime.ElapsedTime.TotalSeconds; } if (joystickInput.getRightStick().Y > 20) { mouseMove.Y = 5 * -joystickInput.getRightStick().Y *(float)gameTime.ElapsedTime.TotalSeconds; } else if (joystickInput.getRightStick().Y < -20) { mouseMove.Y = 5 * -joystickInput.getRightStick().Y *(float)gameTime.ElapsedTime.TotalSeconds; } Mouse.SetPosition(new Vector2i((int)(Mouse.GetPosition(window).X + mouseMove.X), (int)(Mouse.GetPosition(window).Y + mouseMove.Y)), window); mouseMove = new Vec2f(0, 0); // updating gamestate CurrentGameState = currentGameStateObject.update(gameTime); //throw new NotImplementedException(); }
// Adds the correct component to m_goGameState, based on the requested state. // NOTE: It's assumed that m_goGameState is always an empty gameObject! // private void AddComponentToGameStateObject(EGameStates iState) { if (null == m_goGameState) { return; } switch (iState) { case EGameStates._SPLASHSCREEN_ENTER: m_goGameState.AddComponent <gs_SplashScreen_Enter>(); break; case EGameStates._SPLASHSCREEN_IN: m_goGameState.AddComponent <gs_SplashScreen_In>(); break; case EGameStates._SPLASHSCREEN_EXIT: m_goGameState.AddComponent <gs_SplashScreen_Exit>(); break; case EGameStates._MAINMENU_ENTER: m_goGameState.AddComponent <gs_MainMenu_Enter>(); break; case EGameStates._MAINMENU_IN: m_goGameState.AddComponent <gs_MainMenu_In>(); break; case EGameStates._MAINMENU_EXIT: m_goGameState.AddComponent <gs_MainMenu_Exit>(); break; case EGameStates._GAME_ENTER: m_goGameState.AddComponent <gs_Game_Enter>(); break; case EGameStates._GAME_IN: m_goGameState.AddComponent <gs_Game_In>(); break; case EGameStates._GAME_EXIT: m_goGameState.AddComponent <gs_Game_Exit>(); break; case EGameStates._DEVMODE_ENTER_LEVEL: m_goGameState.AddComponent <gs_DevModeEnterLevel>(); break; case EGameStates._CECCONOID_HIGHSCORE_ENTER: m_goGameState.AddComponent <gs_Cecconoid_Highscore_Enter>(); break; case EGameStates._CECCONOID_HIGHSCORE_IN: m_goGameState.AddComponent <gs_Cecconoid_HighScore_In>(); break; case EGameStates._CECCONOID_HIGHSCORE_EXIT: m_goGameState.AddComponent <gs_Cecconoid_HighScore_Exit>(); break; } }
public void ChangeState(EGameStates NewGameState) { gameState = NewGameState; OnGameStateChange?.Invoke(gameState); switch (gameState) { case EGameStates.Waiting: break; case EGameStates.Gameplay: break; case EGameStates.RoundOver: StartCoroutine(ChangeNextLevel()); break; case EGameStates.GameOver: break; default: break; } }
public void ChangeGameState(EGameStates NewGameState) { gameState = NewGameState; CustomEvent.Trigger(gameObject, "_OnGamestateChange", NewGameState); OnGamestateChange?.Invoke(NewGameState); switch (gameState) { case EGameStates.GameBegin: OnGameBegin?.Invoke(); break; case EGameStates.MainMenu: OnGameOver?.Invoke(); break; case EGameStates.RoundOver: OnRoundOver?.Invoke(); break; } }
private void GameManager_OnGameStateChange(EGameStates gameState) { bElevatorReady = gameState == EGameStates.RoundOver; }
public void OnKeyPress(object sender, KeyEventArgs e) { RemoveControls(); ReturnState = EGameStates.MainMenu; }
public Game() : base(WindowSizeX, WindowSizeY, "AtomicSheeps", SFML.Window.Styles.Default) { prevGameState = EGameStates.None; currentGameState = EGameStates.TitelScreen; }
public void LoadScene(int nextSceneIndex, LoadSceneMode loadMode = LoadSceneMode.Single) { m_currentGameState = EGameStates.LOADING; SceneManager.LoadScene(nextSceneIndex, loadMode); }
public void ResumeGame() { m_currentGameState = EGameStates.PLAYING; }
public void PauseGame() { m_currentGameState = EGameStates.PAUSED; }
public void OnButtonPress(object sender, MouseButtonEventArgs e) { RemoveControls(); ReturnState = EGameStates.MainMenu; }
public void OnButtonPress(object sender, MouseButtonEventArgs e) { if(Selected == ESelectedSprite.Exit) { RemoveControls(); ReturnState = EGameStates.None; } if(Selected == ESelectedSprite.Start) { RemoveControls(); ReturnState = EGameStates.InGame; } }
public void StopGame() { m_currentGameState = EGameStates.GAME_OVER; }
public void OnKeyPress(object sender, KeyEventArgs e) { if(e.Key == Controls.Key.W) { if (Selected == ESelectedSprite.None) Selected = ESelectedSprite.Start; else Selected = (ESelectedSprite)(((int)Selected + (int)ESelectedSprite.Count - 1) % (int)ESelectedSprite.Count); } if(e.Key == Controls.Key.S) { if (Selected == ESelectedSprite.None) Selected = ESelectedSprite.Start; else Selected = (ESelectedSprite)(((int)Selected + 1) % (int)ESelectedSprite.Count); } if(e.Key == Controls.Key.Return) { if(Selected == ESelectedSprite.Exit) { RemoveControls(); ReturnState = EGameStates.None; } if(Selected == ESelectedSprite.Start) { RemoveControls(); ReturnState = EGameStates.InGame; } } }