public override void RaiseEventTileSwitchAnimEnded(AbstractTile neighborTile) { // Check if this directional tile was combined with a BombTile. // isCombineWithBombEffect flag check was added to remove some unwanted behaviors where (2x bomb/directional effects would spawn) // TODO: Investigate further into why this is happening. if (neighborTile is BombTile && !isCombineWithBombEffect) { Match3BoardGameLogic.Instance.loseConditions.NewMove(); StartCoroutine(StartCombineWithBombEffect(neighborTile as BombTile)); } // Setup directional with directional tile combine effect. if (neighborTile is DirectionalDestroyTile && TappedFirst) { Match3BoardGameLogic.Instance.loseConditions.NewMove(); IsDestroying = true; neighborTile.IsDestroying = true; Match3Tile crossTile = match3BoardRenderer.SpawnSpecificTileAt(BoardPiece.BoardPosition.row, BoardPiece.BoardPosition.col, typeof(CrossDestroyTile), TileColorType.None ); crossTile.TileColor = TileColor; crossTile.DisableTileLogic(); (crossTile as DirectionalDestroyTile).UpdateMaterial(); if (neighborTile.BoardPiece.Tile == neighborTile) { neighborTile.BoardPiece.Tile = null; } Destroy(neighborTile.gameObject); Destroy(gameObject); } if (neighborTile is ColorBombTile && TappedFirst) { Match3BoardGameLogic.Instance.loseConditions.NewMove(); } // In the base classes "movedByInput" and "tappedFirst" flags are reset so we call the base at the end of the overriden code. base.RaiseEventTileSwitchAnimEnded(neighborTile); }
/// <summary> /// TODO: temporary method used by "CombineWithBombDestroy" method until we decide which effect for this combo remains final. /// Converts the tiles from "tilesToDestroy" into bomb tiles. /// </summary> /// <returns> /// The tiles to bomb tiles. /// </returns> protected IEnumerator ConvertTilesToBombTiles() { // Debug.LogWarning("[ConvertTilesToBombTiles] Found: " + tilesToDestroy.Count + " elements."); Match3Tile cachedIterator; //Start the ICE TRAIL effect towards all the tiles soon to be converted. for (int i = 0; i < tilesToDestroy.Count; i++) { cachedIterator = tilesToDestroy[i]; cachedIterator.DisableTileLogic(); if (cachedIterator is BombTile) { continue; } //TODO: Get rid of the reduntand code Transform effectInstance = (Instantiate(iceTrailEffect) as GameObject).transform; effectInstance.position = WorldPosition; // + new Vector3(0f, 0f, -5f); effectInstance.parent = cachedTransform.parent; effectInstance.LookAt(cachedTransform); StartCoroutine(MoveTargetTo(effectInstance, cachedIterator.cachedTransform, iceTrailTravelTime)); GameObject.Destroy(effectInstance.gameObject, iceTrailTravelTime * 1.5f); } yield return(new WaitForSeconds(iceTrailTravelTime)); for (int i = 0; i < tilesToDestroy.Count; i++) { cachedIterator = tilesToDestroy[i]; if (cachedIterator is BombTile) { continue; } //TODO: Get rid of the reduntand code //instantiate and fire the conversion effect Transform effectInstance = (Instantiate(switchToDirectionalEffect) as GameObject).transform; effectInstance.position = cachedIterator.WorldPosition; // + new Vector3(0f, 0f, -5f); effectInstance.parent = cachedIterator.cachedTransform.parent; effectInstance.LookAt(cachedIterator.cachedTransform); effectInstance.animation.Play(); GameObject.Destroy(effectInstance.gameObject, effectInstance.animation.clip.length); BombTile newBombTile = match3BoardRenderer.SpawnSpecificTileAt(cachedIterator.BoardPiece.BoardPosition.row, cachedIterator.BoardPiece.BoardPosition.col, typeof(BombTile), TileColorType.None ) as BombTile; newBombTile.TileColor = cachedIterator.TileColor; newBombTile.UpdateMaterial(); newBombTile.spawnTimeBomb = false; tilesToDestroy[i] = newBombTile; GameObject.Destroy(cachedIterator.gameObject); } yield return(new WaitForSeconds(switchToDirectionalEffect.animation.clip.length)); }