public override void RaiseEventTileSwitchAnimBegan(Match3Tile neighborTile) { base.RaiseEventTileSwitchAnimBegan(neighborTile); if (neighborTile is BombTile) { BombTile neighborBomb = neighborTile as BombTile; // Mark this tile and it's neighbor as moving and without any gravity because there will be a custom animation on them // to try and keep things consistent. neighborBomb.DisableTileLogic(); DisableTileLogic(); // Prepare the bigger directional destroy effect on this directional tile. prefabTilesDestroyEffect = prefabBombCombineDestroyEffect; } if (neighborTile is DirectionalDestroyTile) { DirectionalDestroyTile directionalTile = neighborTile as DirectionalDestroyTile; directionalTile.SwitchBackOnMatchFail = false; SwitchBackOnMatchFail = false; CanBeMatched = false; (neighborTile as NormalTile).CanBeMatched = false; } }
public void OnTileTapped(AbstractTile tile) { BoardCoord targetCoord = tile.BoardPiece.BoardPosition; if (selectedTile == typeof(BombTile)) { GameObject.Destroy(tile.gameObject); BombTile newTile = Match3BoardRenderer.Instance.SpawnSpecificTileAt(targetCoord, selectedTile, TileColorType.None) as BombTile; newTile.TileColor = RuleEntry.genericColors[Random.Range(0, Match3BoardRenderer.maxNumBoardColors)]; newTile.UpdateMaterial(); } else if (selectedTile == typeof(DirectionalDestroyTile)) { GameObject.Destroy(tile.gameObject); DirectionalDestroyTile newTile = null; if (Random.value > 0.5f) { newTile = Match3BoardRenderer.Instance.SpawnSpecificTileAt(targetCoord, typeof(RowDestroyTile), TileColorType.None) as DirectionalDestroyTile; } else { newTile = Match3BoardRenderer.Instance.SpawnSpecificTileAt(targetCoord, typeof(ColumnDestroyTile), TileColorType.None) as DirectionalDestroyTile; } newTile.TileColor = RuleEntry.genericColors[Random.Range(0, Match3BoardRenderer.maxNumBoardColors)]; newTile.UpdateMaterial(); } else if (selectedTile == typeof(ColorBombTile)) { GameObject.Destroy(tile.gameObject); ColorBombTile newTile = Match3BoardRenderer.Instance.SpawnSpecificTileAt(targetCoord, selectedTile, TileColorType.None) as ColorBombTile; } }
Match3Tile SpawnTimeBomb() { BombTile bombTile = (BoardRenderer as Match3BoardRenderer).SpawnSpecificTileAt(BoardPiece.BoardPosition, typeof(TimeBombTile), TileColorType.None) as BombTile; if (useBigTimeBomb) { bombTile.prefabDestroyEffect = bombTile.prefabDoubleDestroyEffect; } bombTile.TileColor = TileColor; bombTile.UpdateMaterial(); BoardPiece.Tile = bombTile; return(bombTile); }
public override void RaiseEventTileSwitchAnimBegan(Match3Tile neighborTile) { base.RaiseEventTileSwitchAnimBegan(neighborTile); if ((neighborTile is BombTile || neighborTile is ColorBombTile) && TappedFirst) { Match3BoardGameLogic.Instance.loseConditions.NewMove(); } if (neighborTile is BombTile) { // Don't allow this tile and it's neighbour with who it was switched to switch back on match fail. BombTile neighborBomb = neighborTile as BombTile; neighborBomb.SwitchBackOnMatchFail = false; neighborBomb.DisableTileLogic(); // Replace the default destroy effect with a bigger destroy effect neighborBomb.prefabDestroyEffect = neighborBomb.prefabDoubleDestroyEffect; neighborBomb.useBigTimeBomb = true; } }
/// <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)); }
public void OnBombBombCombineSndEvent(BombTile bombTile) { sndBombBombCombine.Play(); // SoundManager.Instance.PlayOneShot(sndBombBombCombine); }
public void OnTriggerBombTileDestroySndEvent(BombTile bombTile) { sndTriggerBombTileDestroy.Play(); }
public void OnTriggerBombTileFreezeSndEvent(BombTile bombTile) { sndTriggerBombTileFreeze.Play(); }
public void OnBombTileCreatedSndEvent(BombTile bombTile) { // sndBombCreate.Play(); SoundManager.Instance.PlayOneShot(sndBombCreate); }
protected IEnumerator StartCombineWithBombEffect(BombTile neighborBombTile) { Match3Tile nextToEffectOriginTile; // TileColorType movedTileColor; IsDestroying = true; neighborBombTile.IsDestroying = true; if (OnDirectionalBombCombine != null) { OnDirectionalBombCombine(this); } isCombineWithBombEffect = true; if ( !TappedFirst ) { // Do the combo destroy effect from the other tiles world position because that one was moved by input. winterchilOriginTile = neighborBombTile; nextToEffectOriginTile = this; } else { nextToEffectOriginTile = neighborBombTile; } // Spawn the combined tile effect (an enlarging cross directional tile that builds up and the destroys itself) CrossBombCombineVisualEffect combinedTileEffect = (Instantiate(prefabBombCombinedTileEffect) as GameObject).GetComponent<CrossBombCombineVisualEffect>(); combinedTileEffect.InitComponent(); // Bring this giant tile in the front combinedTileEffect.cachedTransform.position = winterchilOriginTile.WorldPosition - Vector3.forward * 0.5f; // Set the delay between the horizontal and vertical direction destroy effect. delayBetweenCrossDirections = combinedTileEffect.horizontalAnimTime; HOTween.To(nextToEffectOriginTile.cachedTransform, 0.2f, new TweenParms() .Prop("localPosition", winterchilOriginTile.LocalPosition) .Prop("localScale", Vector3.zero)); bombCombineEffectColumn = winterchilOriginTile.BoardPiece.BoardPosition.col; yield return new WaitForSeconds(0.2f); neighborBombTile.gameObject.SetActive(false); // Disable the default visual effect for this directional tile because we're doing a special combine effect. useDestroyEffect = false; StartCoroutine(DelayedTileRelease(0.1f)); // Destroy the cross tile effect after a delay. GameObject.Destroy(combinedTileEffect.gameObject, combinedTileEffect.totalAnimTime); SetVerticalColumnsLock(bombCombineEffectColumn, true); canDestroyBaseTileAfterWinterchill = false; direction = Direction.Horizontal; StartDirectionalDestroy(() => { canDestroyBaseTileAfterWinterchill = true; direction = Direction.Vertical; StartDirectionalDestroy(); if(neighborBombTile.BoardPiece) { neighborBombTile.BoardPiece.Tile = null; } GameObject.Destroy(neighborBombTile.gameObject, 0.2f); }); }
protected IEnumerator StartCombineWithBombEffect(BombTile neighborBombTile) { Match3Tile nextToEffectOriginTile; // TileColorType movedTileColor; IsDestroying = true; neighborBombTile.IsDestroying = true; if (OnDirectionalBombCombine != null) { OnDirectionalBombCombine(this); } isCombineWithBombEffect = true; if (!TappedFirst) { // Do the combo destroy effect from the other tiles world position because that one was moved by input. winterchilOriginTile = neighborBombTile; nextToEffectOriginTile = this; } else { nextToEffectOriginTile = neighborBombTile; } // Spawn the combined tile effect (an enlarging cross directional tile that builds up and the destroys itself) CrossBombCombineVisualEffect combinedTileEffect = (Instantiate(prefabBombCombinedTileEffect) as GameObject).GetComponent <CrossBombCombineVisualEffect>(); combinedTileEffect.InitComponent(); // Bring this giant tile in the front combinedTileEffect.cachedTransform.position = winterchilOriginTile.WorldPosition - Vector3.forward * 0.5f; // Set the delay between the horizontal and vertical direction destroy effect. delayBetweenCrossDirections = combinedTileEffect.horizontalAnimTime; HOTween.To(nextToEffectOriginTile.cachedTransform, 0.2f, new TweenParms() .Prop("localPosition", winterchilOriginTile.LocalPosition) .Prop("localScale", Vector3.zero)); bombCombineEffectColumn = winterchilOriginTile.BoardPiece.BoardPosition.col; yield return(new WaitForSeconds(0.2f)); neighborBombTile.gameObject.SetActive(false); // Disable the default visual effect for this directional tile because we're doing a special combine effect. useDestroyEffect = false; StartCoroutine(DelayedTileRelease(0.1f)); // Destroy the cross tile effect after a delay. GameObject.Destroy(combinedTileEffect.gameObject, combinedTileEffect.totalAnimTime); SetVerticalColumnsLock(bombCombineEffectColumn, true); canDestroyBaseTileAfterWinterchill = false; direction = Direction.Horizontal; StartDirectionalDestroy(() => { canDestroyBaseTileAfterWinterchill = true; direction = Direction.Vertical; StartDirectionalDestroy(); if (neighborBombTile.BoardPiece) { neighborBombTile.BoardPiece.Tile = null; } GameObject.Destroy(neighborBombTile.gameObject, 0.2f); }); }
/// <summary> /// Spawns the new tile. /// </summary> /// <param name='targetPiece'> /// Target piece. /// </param> public Match3Tile SpawnNewTile(bool isBoardSetup = false) { Match3Tile tileResult = null; // Early out if rule if (ruleEntries == null || ruleEntries.Count == 0) { return(tileResult); } if (numberOfExecutions == 0) { EndSpawnRule(); return(tileResult); } //Select random rule entry and acquire its info spawnedEntry = ruleEntries[Random.Range(0, ruleEntries.Count)]; spawnedType = spawnedEntry.RuleTileType; spawnedColor = spawnedEntry.RuleTileColor; if (ownerList != null && ownerList.Count > 0) { numberOfExecutions--; } // bool offBoard = false; // // if(ownerList != null) // { // if (ownerList.Count == 0) // { // offBoard = false; // } // else // { // offBoard = true; // numberOfExecutions--; // } // } //Spawn tile as described by the spawn rule // Debug.LogWarning("[SpawnRule] Spawning [" + spawnedType.ToString() + "] [" + spawnedColor.ToString() + "] [offboard:" + offBoard + "]"); if (typeof(BombTile) == spawnedType) { BombTile spawnedTile = Match3BoardRenderer.Instance.SpawnSpecificTile(spawnedType, TileColorType.None, isBoardSetup) as BombTile; // BombTile spawnedTile = Match3BoardRenderer.Instance.SpawnSpecificTileAt(targetPiece.BoardPosition, spawnedType, TileColorType.None, offBoard, isBoardSetup) as BombTile; spawnedTile.TileColor = spawnedColor; spawnedTile.UpdateMaterial(); tileResult = spawnedTile; } else if (typeof(DirectionalDestroyTile).IsAssignableFrom(spawnedType)) { DirectionalDestroyTile spawnedTile = Match3BoardRenderer.Instance.SpawnSpecificTile(spawnedType, TileColorType.None, isBoardSetup) as DirectionalDestroyTile; // DirectionalDestroyTile spawnedTile = Match3BoardRenderer.Instance.SpawnSpecificTileAt(targetPiece.BoardPosition, spawnedType, TileColorType.None, offBoard, isBoardSetup) as DirectionalDestroyTile; spawnedTile.TileColor = spawnedColor; spawnedTile.UpdateMaterial(); tileResult = spawnedTile; } else { // tileResult = Match3BoardRenderer.Instance.SpawnSpecificTileAt(targetPiece.BoardPosition, spawnedType, spawnedColor, offBoard, isBoardSetup); tileResult = Match3BoardRenderer.Instance.SpawnSpecificTile(spawnedType, spawnedColor, isBoardSetup); } if (tileResult != null) { tileResult.IsTileIgnoredByAntiMatchSystems = isTileIgnoredByAntiMatchSystems; } return(tileResult); }