Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 private void RemoveTiles(RemoveTile removeTile)
 {
     removeMatchTilesCommand.removeTile = removeTile;
     removeMatchTilesCommand.Execute();
 }