Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 private void RemoveTiles(RemoveTile removeTile)
 {
     removeMatchTilesCommand.removeTile = removeTile;
     removeMatchTilesCommand.Execute();
 }