private void CalculateTilesToRemove(List <MatchTile> tilesTouched) { for (int i = 0; i < tilesTouched.Count; i++) { MatchTile tile = tilesTouched [i]; if (tile.tileObject != null) { int touchedCount = i + 1; RemoveTile removeTile = new RemoveTile(); removeTile.touched = true; removeTile.matchTiles = new List <MatchTile> (); removeTile.matchTiles.Add(tile); if (touchedCount == tilesTouched.Count) { removeTile.lastInChain = true; removeTile.tilesChained = touchedCount; } eventDispatcher.Broadcast(MatchTileGridMessage.REMOVE_TILES, removeTile); } } }
public void GiveTwoMatchTilesAddedToRemoveTile_WhenExecute_ThenRemoveBothMatchTiles() { MatchTile matchTile = new MatchTile(); matchTile.type = MatchTileType.MatchToken_A; matchTile.canMove = true; List <MatchTile> matchTiles = new List <MatchTile> (); matchTiles.Add(matchTile); matchTiles.Add(matchTile); RemoveTile removeTile = new RemoveTile(); removeTile.matchTiles = matchTiles; matchTileGridModel.CanMove(matchTile).Returns(true); removeMatchTilesCommand.removeTile = removeTile; removeMatchTilesCommand.Execute(); IEnumerator iEnum = removeMatchTilesCommand.enumerator; iEnum.MoveNext(); iEnum.MoveNext(); iEnum.MoveNext(); iEnum.MoveNext(); matchTileFactory.Received(2).RemoveMatchTile(matchTile); }
public void GivenOneMatchTileInRemoveTile_WhenExecute_ThenClearTilesTouched() { MatchTile matchTile = new MatchTile(); matchTile.type = MatchTileType.MatchToken_A; matchTile.canMove = true; List <MatchTile> matchTiles = new List <MatchTile> (); matchTiles.Add(matchTile); RemoveTile removeTile = new RemoveTile(); removeTile.matchTiles = matchTiles; removeMatchTilesCommand.removeTile = removeTile; removeMatchTilesCommand.Execute(); IEnumerator iEnum = removeMatchTilesCommand.enumerator; iEnum.MoveNext(); iEnum.MoveNext(); IEnumerator loopEnumerator = removeMatchTilesCommand.loopEnumerator; loopEnumerator.MoveNext(); loopEnumerator.MoveNext(); IEnumerator endEnumerator = removeMatchTilesCommand.endEnumerator; endEnumerator.MoveNext(); endEnumerator.MoveNext(); matchTileGridModel.Received().ClearTilesTouched(); }
public void GivenOneMatchTileInRemoveTile_WhenExecute_ThenBroadcastRemoveTilesComplete() { MatchTile matchTile = new MatchTile(); matchTile.type = MatchTileType.MatchToken_A; matchTile.canMove = true; List <MatchTile> matchTiles = new List <MatchTile> (); matchTiles.Add(matchTile); RemoveTile removeTile = new RemoveTile(); removeTile.matchTiles = matchTiles; removeMatchTilesCommand.removeTile = removeTile; removeMatchTilesCommand.Execute(); IEnumerator iEnum = removeMatchTilesCommand.enumerator; iEnum.MoveNext(); iEnum.MoveNext(); IEnumerator loopEnumerator = removeMatchTilesCommand.loopEnumerator; loopEnumerator.MoveNext(); loopEnumerator.MoveNext(); eventDispatcher.Received().Broadcast(MatchTileGridMessage.ALLOW_FALLING_TILES); }
private void RemoveTiles(RemoveTile removeTile) { removeMatchTilesCommand.removeTile = removeTile; removeMatchTilesCommand.Execute(); }