public void Initial() { for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { if (_cells[i, j] == null) { Vector2 tempPos = new Vector2(i, j); ICell newCell = _spawnManager.SpawnRandomNormalCell(tempPos); _checkManager.Board = this; int maxLimit = 0; while (_checkManager.SimpleCheck(newCell) && maxLimit < Strings.MAX_LIMIT_CHECK_COUNTER) { GameObject.Destroy(newCell.CurrentGameObject); newCell = _spawnManager.SpawnRandomNormalCell(tempPos); _checkManager.Board = this; maxLimit++; } maxLimit = 0; _cellRegistrator.RegistrateNormalCell(newCell as NormalCell); _cells[i, j] = newCell; } } } }
public IEnumerator Cell_SwapAndUndo(SwapTypes swapType) { #region Create Managers IMasterManager masterManager = ObjectsCreator.CreateMasterManager(); ISpawnManager spawnManager = masterManager.SpawnManager; INotifier notifier = masterManager.GameplayNotifier; IUpdateManager updateManager = masterManager.UpdateManager; ICellRegistrator cellRegistrator = new CellRegistrator(notifier, updateManager); #endregion #region Create Cell Vector3 position = new Vector3(1, 1, 0); ICell cellA = spawnManager.SpawnRandomNormalCell(position); cellRegistrator.RegistrateNormalCell(cellA as NormalCell); #endregion #region SetUp UpdateManager updateManager.AddUpdatable(cellA as IUpdatable); updateManager.IsUpdate = true; #endregion yield return(new WaitForSeconds(0.3f)); #region Swap Cell and do Undo ICommand swapCommand = TestHelper.GetSwapCommand(swapType, cellA); swapCommand.Execute(); yield return(new WaitForSeconds(0.5f)); swapCommand.Undo(); #endregion #region Remove From Scene yield return(new WaitForSeconds(0.5f)); GameObject.Destroy(cellA.CurrentGameObject); #endregion }