/// <summary> /// Spawns the directional destroy effect oriented with "angle" degrees around the world X axis of the effects transform thus rotating the /// it's forward axis in the direction the effect will do it's animation. /// </summary> /// <returns> /// The effect. /// </returns> /// <param name='angle'> /// The X rotation angle in degrees. /// On the board, the possible angle of the effect corresponds to the following animation directions: /// - 0 degrees: right direction /// - 90: bottom /// - 180: left /// - 270: up /// </param> // public override bool Freeze () // { // bool effectApplied = base.Freeze(); // // if(effectApplied) { // freezeEffect.GetComponent<FreezeEffectMaterialPicker>().AssignMaterialsForColor(TileColor); // } // // return effectApplied; // } WinterchillEffect SpawnEffect(float angle) { Transform effectInstance = (Instantiate(prefabTilesDestroyEffect) as GameObject).transform; effectInstance.position = winterchilOriginTile.WorldPosition + new Vector3(0f, 0f, -19f); Vector3 newRotation = effectInstance.eulerAngles; newRotation.x = angle; effectInstance.eulerAngles = newRotation; // Disable this tiles collider to avoid being detected by its own effect trigger (or by any other effects trigger) cachedCollider.enabled = false; WinterchillEffect effect = effectInstance.GetComponent <WinterchillEffect>(); // Register to the freeze trigger. effect.triggerListener.OnTileEntered = OnTileEnteredFreezeTrigger; effect.triggerListener.OnBoardPieceEntered = OnBoardPieceEnteredFreezeTrigger; effect.OnEffectFinished = OnWinterchillEffectFinished; Destroy(effectInstance.gameObject, effect.lifeTime); winterchillEffects.Add(effect); numEffectsFinished++; return(effect); }
IEnumerator DestroyTilesAfterDelay(float delay) { yield return(new WaitForSeconds(delay)); // Disable all winterchill effect freeze triggers after the winterchill ends. for (int i = 0; i < winterchillEffects.Count; i++) { WinterchillEffect winterchillEffect = winterchillEffects[i]; if (winterchillEffect != null && winterchillEffect.freezeTrigger != null) { winterchillEffect.freezeTrigger.enabled = false; } } LayeredBoardPiece layeredBoardPiece; for (int i = 0; i < layeredBoardPiecesToDestroy.Count; i++) { layeredBoardPiece = layeredBoardPiecesToDestroy[i] as LayeredBoardPiece; if (layeredBoardPiece != null && layeredBoardPiece.Tile == null) { layeredBoardPiece.NumLayers--; } } layeredBoardPiecesToDestroy.Clear(); // Destroy all tiles touched by the winterchill effect freeze triggers AbstractTile tile; for (int i = 0; i < tilesToDestroy.Count; i++) { tile = tilesToDestroy[i]; if (tile != null) { tile.Destroy(); } } tilesToDestroy.Clear(); if (canDestroyBaseTileAfterWinterchill) { if (isCombineWithBombEffect) { SetVerticalColumnsLock(bombCombineEffectColumn, false); } base.TileDestroy(false); } if (isCombineWithBombEffect && onFinishedDirectional != null) { onFinishedDirectional(); onFinishedDirectional = null; } }
protected override void TileDestroy(bool useEffect) { CheckForSpawnPatterns(); tilesDestroyEffect = prefabTilesDestroyEffect.GetComponent<WinterchillEffect>(); tilesToDestroy.Clear(); // StartCoroutine(DestroyRow()); // StartCoroutine(DestroyColumn()); if (useEffect) { if (prefabDestroyEffect != null) { SpawnDestroyEffect(new Vector3(0f, 0f, -10f)); } else { destroyEffect = tilesDestroyEffect; } TriggerTileAbility(); // to see the tile destroy animation if (useDestroyEffect) { tileModelTransform.gameObject.SetActive(true); //TODO:Remove redundant chunks of code if u will ever have the time / decency to do so //TODO: MIO: Revise this .. it was way too late when you wrote this. if(PrefabEffectBreakFragments) { Transform effectInstance = (Instantiate(PrefabEffectBreakFragments) as GameObject).transform; effectInstance.position = WorldPosition; Destroy(effectInstance.gameObject, destroyEffect.lifeTime); effectBreakFragmentsInstance = effectInstance.GetComponent<TileDestroyEffect>(); if (freezeEffect) { Destroy(freezeEffect); effectBreakFragmentsInstance.GetComponent<TileDestroyEffect>().UpdateMaterial(PrefabFreezeDestroyMaterialArray[(int)TileColor - 1]); } else { effectBreakFragmentsInstance.GetComponent<TileDestroyEffect>().UpdateMaterial(TileColor); } tileModelRenderer.enabled = false; } //-------------------------------------------------------------------------------------- animation.Play(parentDestroyAnimationName, PlayMode.StopAll); additionalChildAnimationComponent.Play(childDestroyAnimationName, PlayMode.StopAll); } if(freezeEffect) { Destroy(freezeEffect); } } else { if (tilesDestroyEffect.waitBetweenTiles) { tileModelTransform.gameObject.SetActive(false); if (this == BoardPiece.Tile) { BoardPiece.Tile = null; } } else { base.TileDestroy(false); } } }
protected override void TileDestroy(bool useEffect) { CheckForSpawnPatterns(); tilesDestroyEffect = prefabTilesDestroyEffect.GetComponent <WinterchillEffect>(); tilesToDestroy.Clear(); // StartCoroutine(DestroyRow()); // StartCoroutine(DestroyColumn()); if (useEffect) { if (prefabDestroyEffect != null) { SpawnDestroyEffect(new Vector3(0f, 0f, -10f)); } else { destroyEffect = tilesDestroyEffect; } TriggerTileAbility(); // to see the tile destroy animation if (useDestroyEffect) { tileModelTransform.gameObject.SetActive(true); //TODO:Remove redundant chunks of code if u will ever have the time / decency to do so //TODO: MIO: Revise this .. it was way too late when you wrote this. if (PrefabEffectBreakFragments) { Transform effectInstance = (Instantiate(PrefabEffectBreakFragments) as GameObject).transform; effectInstance.position = WorldPosition; Destroy(effectInstance.gameObject, destroyEffect.lifeTime); effectBreakFragmentsInstance = effectInstance.GetComponent <TileDestroyEffect>(); if (freezeEffect) { Destroy(freezeEffect); effectBreakFragmentsInstance.GetComponent <TileDestroyEffect>().UpdateMaterial(PrefabFreezeDestroyMaterialArray[(int)TileColor - 1]); } else { effectBreakFragmentsInstance.GetComponent <TileDestroyEffect>().UpdateMaterial(TileColor); } tileModelRenderer.enabled = false; } //-------------------------------------------------------------------------------------- animation.Play(parentDestroyAnimationName, PlayMode.StopAll); additionalChildAnimationComponent.Play(childDestroyAnimationName, PlayMode.StopAll); } if (freezeEffect) { Destroy(freezeEffect); } } else { if (tilesDestroyEffect.waitBetweenTiles) { tileModelTransform.gameObject.SetActive(false); if (this == BoardPiece.Tile) { BoardPiece.Tile = null; } } else { base.TileDestroy(false); } } }