public static PowerUpTypesEnum StringToPowerType(string powerTypeString) { PowerUpTypesEnum powerUpTypeEnum = PowerUpTypesEnum.Vertical; switch (powerTypeString) { case Strings.TAG_HORIZONTAL: powerUpTypeEnum = PowerUpTypesEnum.Horizontal; break; case Strings.TAG_VERICAL: powerUpTypeEnum = PowerUpTypesEnum.Vertical; break; case Strings.TAG_BOMB: powerUpTypeEnum = PowerUpTypesEnum.Bomb; break; case Strings.TAG_COLORBOMB: powerUpTypeEnum = PowerUpTypesEnum.ColorBomb; break; default: Debug.LogWarning("PowerUp with this tag no found: " + powerTypeString); break; } return(powerUpTypeEnum); }
public static PowerUpTypesEnum DetectPowerUp(int matchCount, AxisTypesEnum axis) { PowerUpTypesEnum powerUp = PowerUpTypesEnum.Vertical; if (matchCount == 4) { switch (axis) { case AxisTypesEnum.Vertical: powerUp = PowerUpTypesEnum.Vertical; break; case AxisTypesEnum.Horizontal: powerUp = PowerUpTypesEnum.Horizontal; break; } } else if (matchCount == 5) { powerUp = PowerUpTypesEnum.Bomb; } else { powerUp = PowerUpTypesEnum.ColorBomb; } return(powerUp); }
public IList <ICell> PowerCheck(PowerUpTypesEnum powerUpTypeEnum, Vector2 position) { IList <ICell> checkedCells = new List <ICell>(); int posX = (int)position.x; int posY = (int)position.y; switch (powerUpTypeEnum) { case PowerUpTypesEnum.Horizontal: checkedCells = HorizontalPower(posY); break; case PowerUpTypesEnum.Vertical: checkedCells = VerticalPower(posX); break; case PowerUpTypesEnum.Bomb: checkedCells = BombPower(posX, posY); break; case PowerUpTypesEnum.ColorBomb: checkedCells = RandomColorBombPower(); break; default: checkedCells.Add(_board.Cells[posX, posY]); break; } return(checkedCells); }
public GameObject SpawnPowerPrefab(PowerUpTypesEnum powerUpTypeEnum, Vector3 position) { GameObject powerGameObject = _objectStorage.GetPowerElement(powerUpTypeEnum); powerGameObject.name = powerGameObject.tag; powerGameObject.transform.position = position; return(powerGameObject); }
private IEnumerator MarkAndDestroy(IDictionary <ICell, IDictionary <IList <ICell>, AxisTypesEnum> > cellsWithAxisDictionary) { foreach (var cellDictionary in cellsWithAxisDictionary) { foreach (var cellList in cellDictionary.Value) { MarkMatchedCells(cellList.Key); } } yield return(new WaitForSeconds(Strings.TIME_AFTER_MARK)); foreach (var cellDictionary in cellsWithAxisDictionary) { foreach (var cellList in cellDictionary.Value) { if (cellDictionary.Key.CurrentGameObject != null) { if (cellList.Key.Count > 3 && cellDictionary.Key.CurrentGameObject.CompareTag(Strings.TAG_POWER) == false) { AxisTypesEnum majorAxis = cellList.Value; int matchCount = cellList.Key.Count; PowerUpTypesEnum powerUp = Helper.DetectPowerUp(matchCount, majorAxis); _spawnedPowerUpDictionary.Add( new Vector3(cellDictionary.Key.TargetX, cellDictionary.Key.TargetY, 0f), powerUp); } } WorkAfterMatch(cellList.Key); } } _matchedCellsWithAxisDictionary.Clear(); _matchedCellsDictionary.Clear(); yield return(new WaitForSeconds(Strings.TIME_AFTER_DESTROY)); OnEvent(EventTypesEnum.BOARD_EndDestroyMatchedCells, null); }
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 }
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 OnEvent(EventTypesEnum eventTypeEnum, object messageData) { switch (eventTypeEnum) { case EventTypesEnum.LMB_Down: _clickA = Camera.main.ScreenToWorldPoint(Input.mousePosition); break; case EventTypesEnum.LMB_Up: _clickB = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (_gameStateEnum == GameStatesEnum.Ready) { if (_clickA.x >= 0 && _clickA.x < _board.Width && _clickA.y >= 0 && _clickA.y < _board.Height && (Mathf.Abs(_clickB.x - _clickA.x) > Strings.SWIPE_SENSITIVITY || Mathf.Abs(_clickB.y - _clickA.y) > Strings.SWIPE_SENSITIVITY)) { MoveDirectionTypesEnum swipeDirection = Helper.FindMoveDirection(_clickA, _clickB); SwipeCells(swipeDirection); } } break; case EventTypesEnum.Swipe: _gameStateEnum = GameStatesEnum.Wait; SetMacroCommand((ICommand[])messageData); ExecuteMacroCommand(); break; case EventTypesEnum.BOARD_collapse: ExecuteMacroCommand(); break; case EventTypesEnum.BOARD_EndDestroyMatchedCells: if (_powersDictionary.Count > 0) { Vector2 pos = _powersDictionary.First().Key; PowerUpTypesEnum powerUpTypeEnum = _powersDictionary.First().Value; List <ICell> cellsList = new List <ICell>(_checkManager.PowerCheck(powerUpTypeEnum, pos)); ICell cell = _board.Cells[(int)pos.x, (int)pos.y]; _matchedCellsDictionary.Add(cellsList, AxisTypesEnum.Undefined); _matchedCellsWithAxisDictionary.Add(cell, _matchedCellsDictionary); _powersDictionary.Remove(_powersDictionary.First()); StartCoroutine(MarkAndDestroy(_matchedCellsWithAxisDictionary)); } else { StartCoroutine(RefillBoard()); } break; case EventTypesEnum.CELL_EndMove: TryCheckSwipedCells((ICell)messageData); break; case EventTypesEnum.CELL_EndMoveBack: ICell cellBack = (ICell)messageData; _board.Cells[cellBack.TargetX, cellBack.TargetY] = cellBack; cellBack.CellStateEnum = CellStatesEnum.Wait; _gameStateEnum = GameStatesEnum.Ready; break; case EventTypesEnum.CELL_Fall: ICell cellFall = (ICell)messageData; cellFall.CellStateEnum = CellStatesEnum.Wait; if (cellFall == _lastFallCell) { CheckBoard(); } break; case EventTypesEnum.CELL_Destroy: string cellTag = (string)messageData; Notify(EventTypesEnum.CELL_Destroy, cellTag); break; case EventTypesEnum.POWER_Use: ArrayList arr = (ArrayList)messageData; PowerUpTypesEnum powerUp = Helper.StringToPowerType(arr[0].ToString()); Vector3 position = (Vector3)arr[1]; _powersDictionary.Add(position, powerUp); break; case EventTypesEnum.TASK_Finished: if (_gameStateEnum != GameStatesEnum.End) { _navigationManager.MasterManager.UpdateManager.IsUpdate = false; _gameStateEnum = GameStatesEnum.End; Notify(EventTypesEnum.TASK_Finished, null); } break; default: Debug.Log("EVENT NOT FOUND"); break; } }
public GameObject GetPowerElement(PowerUpTypesEnum powerUpTypeEnum) { GameObject powerGameObject = Object.Instantiate(_powersPrefabs[powerUpTypeEnum]); return(powerGameObject); }