protected virtual void OnGameStateChanged(GameStateArgs e) { EventHandler handler = GameStateChanged; if (handler != null) { handler(this, e); } }
/// <summary> /// Listen to when game state change. Disable runner animation when game is paused. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> private void GameStateChanged(object sender, GameStateArgs args) { MinigameStates gameState = args.GetGameState(); if (gameState == MinigameStates.Paused) { MakePlayerVisible(false); } else if (gameState == MinigameStates.Playing) { MakePlayerVisible(true); } }
private void GameStateChange(object sender, GameStateArgs args) { switch (args.GetGameState()) { case MinigameStates.GameOver: PauseParallax(); break; case MinigameStates.Paused: PauseParallax(); break; case MinigameStates.Playing: PlayParallax(); break; } }
private void HandleRoomUpdateEvent(object sender, GameStateArgs e) { #region Debugging //var driftAX = e.State.ClientA.Body.X - Session.State.ClientA.Body.X; //var driftAY = e.State.ClientA.Body.Y - Session.State.ClientA.Body.Y; //var driftBX = e.State.ClientB.Body.X - Session.State.ClientB.Body.X; //var driftBY = e.State.ClientB.Body.Y - Session.State.ClientB.Body.Y; //Console.WriteLine("V---------------------- New State ----------------------V"); //Console.WriteLine($"ClientA differs by ({driftAX}, {driftAY})"); //Console.WriteLine($"ClientB differs by ({driftBX}, {driftBY})"); //Console.WriteLine($"Client InputNumber is ahead by ({LastInputState - e.State.LastProcessedInputNumber})"); #endregion var oldState = Session.State; Session.State = e.State; ApplyOldInput(e.NetworkTimeSync); //Todo: apply interpolation }
//--------------------------------------------------- // OnGameStateChanged() // When the game's state changes, the object may // want to react. //--------------------------------------------------- private void OnGameStateChanged(object sender, GameStateArgs args) { MinigameStates eState = args.GetGameState(); switch (eState) { case MinigameStates.GameOver: // pause the object OnPause(true); break; case MinigameStates.Paused: // pause the object OnPause(true); break; case MinigameStates.Playing: // unpause the object OnPause(false); break; } }
public void OnRoomUpdateEvent(object sender, GameStateArgs e) { RoomUpdateEvent?.Invoke(sender, e); }