예제 #1
0
        private IEnumerator RefillBoard()
        {
            if (_spawnedPowerUpDictionary.Count > 0)
            {
                int i = 0;
                foreach (var spawnedPowerUp in _spawnedPowerUpDictionary)
                {
                    GameObject spawnedPowerUpGO =
                        _spawnManager.SpawnPowerPrefab(spawnedPowerUp.Value, spawnedPowerUp.Key);

                    Helper.SetGravityPowerUpColor(spawnedPowerUpGO, _colorsList[i]);

                    _board.Cells[(int)spawnedPowerUp.Key.x, (int)spawnedPowerUp.Key.y].CurrentGameObject =
                        spawnedPowerUpGO;

                    i++;
                }
            }

            _spawnedPowerUpDictionary.Clear();
            _colorsList.Clear();

            DecreaseBoard();

            yield return(new WaitForSeconds(StringsAndConst.TIME_AFTER_DECREASE));

            SpawnNewCells();
        }
        private IEnumerator RefillBoard()
        {
            if (_spawnedPowerUpDictionary.Count > 0)
            {
                foreach (var spawnedPowerUp in _spawnedPowerUpDictionary)
                {
                    GameObject spawnedPowerUpGO = _spawnManager.SpawnPowerPrefab(spawnedPowerUp.Value, spawnedPowerUp.Key);
                    _board.Cells[(int)spawnedPowerUp.Key.x, (int)spawnedPowerUp.Key.y].CurrentGameObject =
                        spawnedPowerUpGO;
                }
            }

            _spawnedPowerUpDictionary.Clear();

            DecreaseBoard();

            yield return(new WaitForSeconds(Strings.TIME_AFTER_DECREASE));

            SpawnNewCells();
        }
예제 #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
        }
예제 #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
        }