Ejemplo n.º 1
0
    private void HandleGameEnd()
    {
        _gameEndEventFilter.HandleEvents(_world, (eventData) =>
        {
            var directions = new List <DirectionEnum>
            {
                DirectionEnum.Top,
                DirectionEnum.Right,
                DirectionEnum.Bottom,
                DirectionEnum.Left,
            };
            var hasAvailablePosition = HasAvailablePosition(
                eventData.Column,
                eventData.Row,
                eventData.Round,
                eventData.Number,
                directions
                );
            if (!hasAvailablePosition)
            {
                ShowScoreUI(false);
                ShowGameOverScreen(true);

                _gameManager.ClearAll();
                _manager.EndGame();

                var scoreEntity = _scoreFilter.ToEntitiesList().First();
                SaveLeaderboard.AddResultAndSave(scoreEntity.Amount);

                _stateManager.Clear();
            }
        });
    }
Ejemplo n.º 2
0
 private void HandleSwipeDoneEvent()
 {
     _swipeDoneEventFilter.HandleEvents(_world, (eventData) =>
     {
         SwipeDone(eventData.Direction);
     });
 }
Ejemplo n.º 3
0
 private void HandleGameStartEvent()
 {
     _gameStartFilter.HandleEvents(_world, (gameStart) =>
     {
         _inputHelper.Clear();
         _isGameActive = gameStart.IsActive;
         _grid.SetActive(gameStart.IsActive);
     });
 }
Ejemplo n.º 4
0
 private void HandleLoadEvent()
 {
     _loadEvents.HandleEvents(_world, (eventData) => {
         _world.State.Targets     = eventData.State.Targets;
         _world.State.Steps       = eventData.State.Steps;
         _world.State.ActiveWalls = eventData.State.ActiveWalls;
         _world.State.Score       = eventData.State.Score;
     });
 }
Ejemplo n.º 5
0
 private void HandleClearEvent()
 {
     _clearEvents.HandleEvents(_world, (eventData) => {
         _world.State.Targets.Clear();
         _world.State.Steps.Clear();
         _world.State.ActiveWalls.Clear();
         _world.State.Score = 0;
     });
 }
Ejemplo n.º 6
0
 private void HandleRemoveWallsEvent()
 {
     _removeWallsEvents.HandleEvents(_world, (eventData) => {
         _world.State.ActiveWalls = _world.State.ActiveWalls
                                    .Where((wall) => {
             return(!eventData.Walls.Any((w) =>
             {
                 return w.Column == wall.Column &&
                 w.Row == wall.Row &&
                 w.Direction == wall.Direction;
             }));
         })
                                    .ToList();
     });
 }
Ejemplo n.º 7
0
 private void HandleRemoveTargetsEvent()
 {
     _removeTargetsEvents.HandleEvents(_world, (eventData) => {
         _world.State.Targets = _world.State.Targets
                                .Where((target) => {
             return(!eventData.Targets.Any((t) =>
             {
                 return t.Column == target.Column &&
                 t.Row == target.Row &&
                 t.Round == target.Round &&
                 t.Value == target.Value;
             }));
         })
                                .ToList();
     });
 }
Ejemplo n.º 8
0
 private void HandleRemoveStepsEvent()
 {
     _removeStepsEvent.HandleEvents(_world, (eventData) => {
         _world.State.Steps = _world.State.Steps
                              .Where((step) => {
             var stepToRemove = eventData.Steps.Find(s =>
             {
                 return(s.Column == step.Column &&
                        s.Row == step.Row &&
                        s.Round == step.Round &&
                        s.Number == step.Number);
             });
             return(stepToRemove == null);
         })
                              .ToList();
     });
 }
Ejemplo n.º 9
0
 private void HandleAddTargetsEvent()
 {
     _addTargetsEvents.HandleEvents(_world, (eventData) => {
         _world.State.Targets.AddRange(eventData.Targets);
     });
 }
Ejemplo n.º 10
0
 private void HandleAddStepsEvent()
 {
     _addStepsEvents.HandleEvents(_world, (eventData) => {
         _world.State.Steps.AddRange(eventData.Steps);
     });
 }
Ejemplo n.º 11
0
 private void HandleSetScoreEvent()
 {
     _setScoreEvents.HandleEvents(_world, (eventData) => {
         _world.State.Score = eventData.Score;
     });
 }
Ejemplo n.º 12
0
 private void HandleAddWallsEvent()
 {
     _addWallsEvents.HandleEvents(_world, (eventData) => {
         _world.State.ActiveWalls.AddRange(eventData.Walls);
     });
 }