private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Respawn")) { if (restartInProgress || playerWon) { return; } PlayerLostEvent?.Invoke(); restartInProgress = true; Invoke(nameof(RestartTimer), 3.0f); } else if (other.gameObject.CompareTag("Finish")) { if (restartInProgress) { return; } WinEvent?.Invoke(); playerWon = true; movementScript.enabled = false; } }
private void HandlePlayerLostEvent(PlayerLostEvent playerLostEvent) { Entity responsibleEntity = playerLostEvent.ResponsibleEntity; responsibleEntity.StripAllComponentsExcept(typeof(TransformComponent), typeof(VectorSpriteComponent), typeof(SpriteComponent), typeof(ColoredExplosionComponent), typeof(DontDestroyForGameOverComponent)); responsibleEntity.AddComponent(new DontDestroyForGameOverComponent()); // Make the camera zoom to include the entity responsibleEntity.AddComponent(new CameraTrackingComponent()); ProcessManager.Attach(new SpriteEntityFlashProcess(Engine, responsibleEntity, CVars.Get <int>("game_over_responsible_enemy_flash_count"), CVars.Get <float>("game_over_responsible_enemy_flash_period") / 2)) .SetNext(new DelegateProcess(() => { // Explosion TransformComponent transformComp = responsibleEntity.GetComponent <TransformComponent>(); ColoredExplosionComponent coloredExplosionComp = responsibleEntity.GetComponent <ColoredExplosionComponent>(); EventManager.Instance.QueueEvent(new CreateExplosionEvent(transformComp.Position, coloredExplosionComp.Color, false)); })).SetNext(new EntityDestructionProcess(Engine, responsibleEntity)).SetNext(new DelegateProcess(() => { EventManager.Instance.QueueEvent(new PlayerLostAnimationCompletedEvent(playerLostEvent.Player)); })); }
public bool Handle(IEvent evt) { PlayerLostEvent playerLostEvent = evt as PlayerLostEvent; if (playerLostEvent != null) { WaitProcess processChain = new WaitProcess(Constants.Animations.GAME_OVER_WAIT); string gameOverContent = playerLostEvent.WinPlayer.Name + Constants.Pong.GAME_OVER_CONTENT_SUFFIX; processChain.SetNext(new GameOverTextAnimation(_engine, FontEntity.Create(_engine, Vector2.Zero, Content.Load <BitmapFont>(Constants.Resources.FONT_PONG_INTRO), gameOverContent), _mainCamera, GameManager.GraphicsDevice)) .SetNext(new WaitProcess(Constants.Animations.GAME_OVER_POST_WAIT)) .SetNext(new DelegateCommand(() => { GameManager.ChangeState(new LobbyGameState(GameManager, _player1.InputMethod, (_player2 is AIPlayer) ? null : _player2.InputMethod)); })); _processManager.Attach(processChain); return(false); } return(false); }
private void HandlePlayerLostEvent(PlayerLostEvent playerLostEvent) { if (_playerShipEntities.Count == 0 || !CVars.Get <bool>("player_individual_deaths")) { EventManager.Instance.QueueEvent(new GameOverEvent()); } }
public override bool Handle(IEvent evt) { PlayerLostEvent playerLostEvent = evt as PlayerLostEvent; if (playerLostEvent != null) { HandlePlayerLostEvent(playerLostEvent); } return(false); }
public async Task <IActionResult> PingAsync(PlayerLostEvent gameProcessEvent, CancellationToken cancellationToken) { _logger.LogInformation("Player {PlayerName} lost current take ", gameProcessEvent.PlayerName); var gameState = await _daprClient.GetStateAsync <GameState>("game-store", "game-state", ConsistencyMode.Strong, cancellationToken : cancellationToken).ConfigureAwait(false); gameState.Current = State.NewGame; await _daprClient.SaveStateAsync("game-store", "game-state", gameState, cancellationToken : cancellationToken) .ConfigureAwait(false); return(new OkResult()); }
/// <summary> /// Marks a player as a loser in the current round and increases their losing score. /// Player must be active in order to lose, otherwise this method returns false. /// </summary> /// <param name="plr"></param> public virtual bool PlayerLost(Player plr) { if (plr.Active) { plr.Losses++; PlayerLostEvent ev = new PlayerLostEvent(plr); AppendEvent(ev); if (OnPlayerLose != null) { OnPlayerLose(this, ev); } return(true); } return(false); }
private void OnCollisionEnter(Collision other) { if (!other.gameObject.CompareTag("Obstacle")) { return; } if (restartInProgress || playerWon) { return; } movementScript.enabled = false; PlayerLostEvent?.Invoke(); restartInProgress = true; Invoke(nameof(RestartTimer), 3.0f); }
/// <summary> /// Marks a player as a loser in the current round and increases their losing score. /// Player must be active in order to lose, otherwise this method returns false. /// </summary> /// <param name="plr"></param> public virtual bool PlayerLost(Player plr) { if (plr.Active) { plr.Losses++; PlayerLostEvent ev = new PlayerLostEvent(plr); AppendEvent(ev); if (OnPlayerLose != null) { OnPlayerLose(this, ev); } return true; } return false; }