//Called When Color bomb meets Bomb Tile (Alternative effect - temporary until we decide wich will remain) //TODO: Lots of redundancy between this coroutine and DestroyDirectionalTiles IEnumerator CombineWithBombDestroy() { if (OnBombColorBombCombine != null) { OnBombColorBombCombine(this); } //Update the tiles to destroy list Board.ApplyActionToAll((boardPiece) => { if (IsValidTarget(boardPiece.Tile, destroyColor)) { tilesToDestroy.Add(boardPiece.Tile as Match3Tile); } }); //tilesToDestroy.Remove(neighborTile); //Destroy(neighborTile.gameObject); StartCoroutine(ConvertTilesToBombTiles()); yield return(new WaitForSeconds(postConversionWaitTime)); for (int i = 0; i < tilesToDestroy.Count; i++) { tileIterator = tilesToDestroy[i] as NormalTile; // if ( IsGlacierShardTargetValid(tileIterator) ) { // if (prefabTilesDestroyEffect != null) { // Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform; // effectInstance.position = WorldPosition; // effectInstance.parent = cachedTransform.parent; // // effectInstance.LookAt(tileIterator.cachedTransform); // // StartCoroutine(MoveTargetTo(effectInstance, tileIterator.cachedTransform, tilesDestroyEffect.destroyTileTime)); //// HOTween.To(effectInstance, tilesDestroyEffect.destroyTileTime, "localPosition", Board[i, j].LocalPosition); // // Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime); // } yield return(new WaitForSeconds(tilesDestroyEffect.destroyTileTime)); // Repeat the tests for the targeted tile because things may have changed until the glacier shard reaches it. if (IsGlacierShardTargetValid(tileIterator)) { tileIterator.Destroy(); } // } } // Wait for an extra 0.5f seconds for extra safety. yield return(new WaitForSeconds(0.5f)); base.TileDestroy(false); Match3BoardGameLogic.Instance.TryCheckStableBoard(); }
//Called When Color bomb meets directional tile //TODO: Lots of redundancy between this coroutine and DestroyDirectionalTiles IEnumerator DestroyDirectionalTiles() { if (OnColorBombDirectionalCombine != null) { OnColorBombDirectionalCombine(this); } //Update the tiles to destroy list Board.ApplyActionToAll((boardPiece) => { // if (boardPiece.Tile != null && boardPiece.Tile.IsDestructible && (boardPiece.Tile as Match3Tile).TileColor == destroyColor) if (IsValidTarget(boardPiece.Tile, destroyColor)) { boardPiece.Tile.IsUserMoveable = false; tilesToDestroy.Add(boardPiece.Tile as Match3Tile); } }); StartCoroutine(ConvertToDirectionalDestroyers()); yield return(new WaitForSeconds(postConversionWaitTime)); for (int i = 0; i < tilesToDestroy.Count; i++) { tileIterator = tilesToDestroy[i] as NormalTile; // Ice bolt effect. Removed because no longer needed------------------------------------------------------------------- // if ( IsGlacierShardTargetValid(tileIterator) ) { // if (prefabTilesDestroyEffect != null) { // Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform; // effectInstance.position = WorldPosition; // effectInstance.parent = cachedTransform.parent; // // effectInstance.LookAt(tileIterator.cachedTransform); // // StartCoroutine(MoveTargetTo(effectInstance, tileIterator.cachedTransform, tilesDestroyEffect.destroyTileTime)); //// HOTween.To(effectInstance, tilesDestroyEffect.destroyTileTime, "localPosition", Board[i, j].LocalPosition); // // Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime); // } //------------------------------------------------------------------------------------------------------------------------------- yield return(new WaitForSeconds(tilesDestroyEffect.destroyTileTime)); // Repeat the tests for the targeted tile because things may have changed until the glacier shard reaches it. if (IsGlacierShardTargetValid(tileIterator)) { tileIterator.Destroy(); } // } } base.TileDestroy(false); Match3BoardGameLogic.Instance.TryCheckStableBoard(); }
public void OnTriggerEnter(Collider target) { if (target.gameObject.layer == LayerMask.NameToLayer("BoardTile")) { NormalTile targetTile = target.GetComponent <NormalTile>(); if (targetTile) { // Mark that these tiles are going to be destroyed one by one (not gathered in a list and then destroyed in a bulk). targetTile.isSingleDestroyed = true; targetTile.Destroy(); RaiseOnTargetDestroyed(); } } }
void WaitAndDestroyTile() { //yield return new WaitForSeconds(0.1f); if (glacierTile) { glacierTile.lastNeighborTile = tileToDestroy as NormalTile; glacierTile.destroyColor = tileToDestroy.TileColor; glacierTile.wasFirstTapped = true; glacierTile.Destroy(); // GameObject.Destroy(tileToDestroy.gameObject); tileToDestroy.useDestroyEffect = false; tileToDestroy.Destroy(); } TileSwitchInput.Instance.ActivateDrag(); base.DoItem(); DoDestroy(); }
//Called When Color bomb meets directional tile //TODO: Lots of redundancy between this coroutine and DestroyDirectionalTiles IEnumerator DestroyDirectionalTiles() { if (OnColorBombDirectionalCombine != null) { OnColorBombDirectionalCombine(this); } //Update the tiles to destroy list Board.ApplyActionToAll((boardPiece) => { // if (boardPiece.Tile != null && boardPiece.Tile.IsDestructible && (boardPiece.Tile as Match3Tile).TileColor == destroyColor) if (IsValidTarget(boardPiece.Tile, destroyColor)) { boardPiece.Tile.IsUserMoveable = false; tilesToDestroy.Add(boardPiece.Tile as Match3Tile); } }); StartCoroutine(ConvertToDirectionalDestroyers()); yield return new WaitForSeconds(postConversionWaitTime); for(int i = 0; i < tilesToDestroy.Count; i++) { tileIterator = tilesToDestroy[i] as NormalTile; // Ice bolt effect. Removed because no longer needed------------------------------------------------------------------- // if ( IsGlacierShardTargetValid(tileIterator) ) { // if (prefabTilesDestroyEffect != null) { // Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform; // effectInstance.position = WorldPosition; // effectInstance.parent = cachedTransform.parent; // // effectInstance.LookAt(tileIterator.cachedTransform); // // StartCoroutine(MoveTargetTo(effectInstance, tileIterator.cachedTransform, tilesDestroyEffect.destroyTileTime)); //// HOTween.To(effectInstance, tilesDestroyEffect.destroyTileTime, "localPosition", Board[i, j].LocalPosition); // // Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime); // } //------------------------------------------------------------------------------------------------------------------------------- yield return new WaitForSeconds(tilesDestroyEffect.destroyTileTime); // Repeat the tests for the targeted tile because things may have changed until the glacier shard reaches it. if ( IsGlacierShardTargetValid(tileIterator) ) { tileIterator.Destroy(); } // } } base.TileDestroy(false); Match3BoardGameLogic.Instance.TryCheckStableBoard(); }
//Called When Color bomb meets Bomb Tile (Alternative effect - temporary until we decide wich will remain) //TODO: Lots of redundancy between this coroutine and DestroyDirectionalTiles IEnumerator CombineWithBombDestroy() { if (OnBombColorBombCombine != null) { OnBombColorBombCombine(this); } //Update the tiles to destroy list Board.ApplyActionToAll((boardPiece) => { if (IsValidTarget(boardPiece.Tile, destroyColor)) { tilesToDestroy.Add(boardPiece.Tile as Match3Tile); } }); //tilesToDestroy.Remove(neighborTile); //Destroy(neighborTile.gameObject); StartCoroutine(ConvertTilesToBombTiles()); yield return new WaitForSeconds(postConversionWaitTime); for(int i = 0; i < tilesToDestroy.Count; i++) { tileIterator = tilesToDestroy[i] as NormalTile; // if ( IsGlacierShardTargetValid(tileIterator) ) { // if (prefabTilesDestroyEffect != null) { // Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform; // effectInstance.position = WorldPosition; // effectInstance.parent = cachedTransform.parent; // // effectInstance.LookAt(tileIterator.cachedTransform); // // StartCoroutine(MoveTargetTo(effectInstance, tileIterator.cachedTransform, tilesDestroyEffect.destroyTileTime)); //// HOTween.To(effectInstance, tilesDestroyEffect.destroyTileTime, "localPosition", Board[i, j].LocalPosition); // // Destroy(effectInstance.gameObject, tilesDestroyEffect.lifeTime); // } yield return new WaitForSeconds(tilesDestroyEffect.destroyTileTime); // Repeat the tests for the targeted tile because things may have changed until the glacier shard reaches it. if ( IsGlacierShardTargetValid(tileIterator) ) { tileIterator.Destroy(); } // } } // Wait for an extra 0.5f seconds for extra safety. yield return new WaitForSeconds(0.5f); base.TileDestroy(false); Match3BoardGameLogic.Instance.TryCheckStableBoard(); }