public static IGameplayLogicManager CreateGameplayLogicManager()
        {
            GameObject gameplayLogicManagerGO = new GameObject("Gameplay Logic Manager");

            gameplayLogicManagerGO.AddComponent <GameplayLogicManager>();
            IGameplayLogicManager gameplayLogicManager = gameplayLogicManagerGO.GetComponent <GameplayLogicManager>();

            return(gameplayLogicManager);
        }
        private void Initial()
        {
            _updateManager        = _NavigationManager.MasterManager.UpdateManager;
            _gameplayLogicManager = new GameObject("Gameplay Logic Manager").AddComponent <GameplayLogicManager>();
            GameObject empty = new GameObject("---------------");

            _gameplayNotifier = _NavigationManager.MasterManager.GameplayNotifier;
            _uiNotifier       = _NavigationManager.MasterManager.UINotifier;
            _taskNotifier     = new Notifier();

            _inputManager = new InputManager(_gameplayNotifier);
            _spawnManager = _NavigationManager.MasterManager.SpawnManager;
            _checkManager = new CheckManager();
            _taskManager  = new TaskManager(_level.LevelTasks);

            _uiManager      = new UIGameplayLevelManager(_level);
            _buttonsManager = new ButtonsGameplaySceneManager(_uiNotifier);

            _cellRegistrator = new CellRegistrator(_gameplayNotifier, _updateManager);

            _board = new Board(_level.BoardWidth, _level.BoardHeight, _spawnManager, _checkManager, _cellRegistrator);
        }
Example #3
0
        public IEnumerator PowerUp_UseTwoPowerUp_Review(PowerUpTypesEnum powerUpTypeEnumA, PowerUpTypesEnum powerUpTypeEnumB)
        {
            #region Create Managers

            IMasterManager        masterManager;
            ICellRegistrator      cellRegistrator;
            IBoard                board                = ObjectsCreator.CreateBoard(9, 9, out masterManager, out cellRegistrator);
            IUpdateManager        updateManager        = masterManager.UpdateManager;
            IGameplayLogicManager gameplayLogicManager = ObjectsCreator.CreateGameplayLogicManager();
            INotifier             gameplayNotifier     = masterManager.GameplayNotifier;
            ISpawnManager         spawnManager         = masterManager.SpawnManager;
            IInputManager         inputManager         = new InputManager(gameplayNotifier);
            ICheckManager         checkManager         = new CheckManager();

            #endregion

            #region Create And SetUp Cells with PowerUp

            IList <ICell> cellsWithPowerUp = new List <ICell>();

            IList <Vector3> positions = new List <Vector3>();

            switch (powerUpTypeEnumA)
            {
            case PowerUpTypesEnum.Bomb:
                positions.Add(new Vector2(4, 4));
                positions.Add(new Vector2(2, 4));
                break;

            case PowerUpTypesEnum.Vertical:
                positions.Add(new Vector2(3, 3));
                positions.Add(new Vector2(3, 6));
                break;

            case PowerUpTypesEnum.Horizontal:
                positions.Add(new Vector2(3, 3));
                positions.Add(new Vector2(6, 3));
                break;
            }

            for (int i = 0; i < 2; i++)
            {
                ICell   cell         = new NormalCell((int)positions[i].x, (int)positions[i].y);
                Vector3 cellPosition = new Vector2((int)positions[i].x, (int)positions[i].y);
                cell.CurrentGameObject =
                    spawnManager.SpawnPowerPrefab(i == 0 ? powerUpTypeEnumA : powerUpTypeEnumB, positions[i]);
                cellRegistrator.RegistrateNormalCell(cell as NormalCell);
                board.Cells[cell.TargetX, cell.TargetY] = cell;
                cellsWithPowerUp.Add(cell);
            }

            #endregion

            yield return(new WaitForSeconds(0.1f));

            #region SetUp Board and Managers

            board.Initial();

            checkManager.Board = board;

            gameplayLogicManager.Board        = board;
            gameplayLogicManager.CheckManager = checkManager;
            gameplayLogicManager.SpawnManager = spawnManager;
            gameplayLogicManager.Notifier     = new Notifier();

            inputManager.AddSubscriber(gameplayLogicManager);
            updateManager.AddUpdatable(inputManager as IUpdatable);

            updateManager.IsUpdate = true;

            #endregion

            yield return(new WaitForSeconds(0.3f));

            #region Try Use PowerUp

            int swipeCount = 2;
            gameplayLogicManager.TryCheckSwipedCells(cellsWithPowerUp[0], swipeCount);

            #endregion

            #region Remove From Scene

            yield return(new WaitForSeconds(2f));

            updateManager.IsUpdate = false;
            foreach (var cell in board.Cells)
            {
                GameObject.Destroy(cell.CurrentGameObject);
            }

            #endregion
        }
Example #4
0
        public IEnumerator PowerUp_UseOnePowerUp_Review(PowerUpTypesEnum powerUpTypeEnum)
        {
            #region Create Managers

            IMasterManager        masterManager;
            ICellRegistrator      cellRegistrator;
            IBoard                board                = ObjectsCreator.CreateBoard(9, 9, out masterManager, out cellRegistrator);
            IUpdateManager        updateManager        = masterManager.UpdateManager;
            IGameplayLogicManager gameplayLogicManager = ObjectsCreator.CreateGameplayLogicManager();
            INotifier             gameplayNotifier     = masterManager.GameplayNotifier;
            ISpawnManager         spawnManager         = masterManager.SpawnManager;
            IInputManager         inputManager         = new InputManager(gameplayNotifier);
            ICheckManager         checkManager         = new CheckManager();


            #endregion

            #region Create And SetUp Cell with PowerUp

            ICell   cellWithPowerUp = new NormalCell(4, 4);
            Vector3 cellPosition    = new Vector2(4, 4);
            cellWithPowerUp.CurrentGameObject = spawnManager.SpawnPowerPrefab(powerUpTypeEnum, cellPosition);
            cellRegistrator.RegistrateNormalCell(cellWithPowerUp as NormalCell);
            board.Cells[cellWithPowerUp.TargetX, cellWithPowerUp.TargetY] = cellWithPowerUp;

            #endregion

            yield return(new WaitForSeconds(0.1f));

            #region SetUp Board and Managers

            board.Initial();

            checkManager.Board = board;

            gameplayLogicManager.Board        = board;
            gameplayLogicManager.CheckManager = checkManager;
            gameplayLogicManager.SpawnManager = spawnManager;
            gameplayLogicManager.Notifier     = new Notifier();

            inputManager.AddSubscriber(gameplayLogicManager);
            updateManager.AddUpdatable(inputManager as IUpdatable);

            updateManager.IsUpdate = true;

            #endregion

            yield return(new WaitForSeconds(0.3f));

            #region Try Use PowerUp

            int swipeCount = 2;
            gameplayLogicManager.TryCheckSwipedCells(cellWithPowerUp, swipeCount);

            #endregion

            #region Remove From Scene

            yield return(new WaitForSeconds(2f));

            updateManager.IsUpdate = false;
            foreach (var cell in board.Cells)
            {
                GameObject.Destroy(cell.CurrentGameObject);
            }

            #endregion
        }
        public void GameplayLogicManager_Create_NotNull()
        {
            IGameplayLogicManager gameplayLogicManager = ObjectsCreator.CreateGameplayLogicManager();

            Assert.IsNotNull(gameplayLogicManager);
        }
Example #6
0
        public IEnumerator Cells_TryCheck(int equalsCellsCount, bool isVertical)
        {
            #region Create Managers And Board

            IMasterManager        masterManager;
            ICellRegistrator      cellRegistrator;
            IBoard                board                = ObjectsCreator.CreateBoard(equalsCellsCount + 3, equalsCellsCount + 3, out masterManager, out cellRegistrator);
            IUpdateManager        updateManager        = masterManager.UpdateManager;
            IGameplayLogicManager gameplayLogicManager = ObjectsCreator.CreateGameplayLogicManager();
            INotifier             gameplayNotifier     = masterManager.GameplayNotifier;
            ISpawnManager         spawnManager         = masterManager.SpawnManager;
            IInputManager         inputManager         = new InputManager(gameplayNotifier);
            ICheckManager         checkManager         = new CheckManager();

            #endregion

            #region Create Cells

            int   startX     = 2;
            int   startY     = 2;
            ICell swipedCell = null;

            for (int i = 0; i < equalsCellsCount; i++)
            {
                int x = startX;
                int y = startY;

                if (isVertical)
                {
                    if (i == Mathf.Floor(equalsCellsCount / 2))
                    {
                        x = startX + 1;
                    }
                    else
                    {
                        x = startX;
                    }

                    y = startY + i;
                }
                else
                {
                    if (i == Mathf.Floor(equalsCellsCount / 2))
                    {
                        y = startY + 1;
                    }
                    else
                    {
                        y = startY;
                    }

                    x = startX + i;
                }

                ICell cell = new NormalCell(x, y);
                cell.CurrentGameObject = spawnManager.SpawnPrefab(GameElementTypesEnum.RedCircle, new Vector3(x, y, 0));
                cellRegistrator.RegistrateNormalCell(cell as NormalCell);
                board.Cells[cell.TargetX, cell.TargetY] = cell;

                if (i == Mathf.Floor(equalsCellsCount / 2))
                {
                    swipedCell = board.Cells[cell.TargetX, cell.TargetY];
                }
            }

            #endregion

            yield return(new WaitForSeconds(1f));

            #region SetUp Board And Managers

            board.Initial();

            checkManager.Board = board;

            gameplayLogicManager.Board        = board;
            gameplayLogicManager.CheckManager = checkManager;
            gameplayLogicManager.SpawnManager = spawnManager;
            gameplayLogicManager.Notifier     = masterManager.UINotifier;

            inputManager.AddSubscriber(gameplayLogicManager);
            updateManager.AddUpdatable(inputManager as IUpdatable);

            updateManager.IsUpdate = true;

            #endregion

            yield return(new WaitForSeconds(1f));

            #region Create And SetUp MacroCommand to use swap cells

            ICommand[] commands;

            if (isVertical)
            {
                commands = new ICommand[]
                {
                    new SwipeLeftCommand(swipedCell),
                    new SwipeRightCommand(board.Cells[swipedCell.TargetX - 1, swipedCell.TargetY]),
                };
            }
            else
            {
                commands = new ICommand[]
                {
                    new SwipeDownCommand(swipedCell),
                    new SwipeUpCommand(board.Cells[swipedCell.TargetX, swipedCell.TargetY - 1]),
                };
            }

            ICommand macroCommand = new MacroCommand(commands);

            gameplayLogicManager.MacroCommand = macroCommand;

            #endregion

            #region Try Swap Cells and get Check

            gameplayLogicManager.MacroCommand.Execute();

            yield return(new WaitForSeconds(1f));

            gameplayLogicManager.TryCheckSwipedCells(swipedCell);

            #endregion

            #region Remove From Scene

            yield return(new WaitForSeconds(0.2f));

            updateManager.IsUpdate = false;
            foreach (var boadrdCell in board.Cells)
            {
                updateManager.RemoveUpdatable(boadrdCell as IUpdatable);
            }
            foreach (var cell in board.Cells)
            {
                GameObject.Destroy(cell.CurrentGameObject);
            }

            #endregion
        }