private void PlayDestroyAnimation(TileAnimator tileAnimator) { // TODO: Move spawning of these particles to Destroyer ParticlesSpawner.Instance.Spawn( tileAnimator.transform, tileAnimator.GetComponent <TileColor>().MyColor ); Destroyer destroyer = tileAnimator.GetComponent <Destroyer>(); destroyer.DestroyCube(); }
public override void OnBeat() { if (_isDead) { //this.enabled = false; //this.GetComponent<TileAnimator>().enabled = false; //this.get Debug.Log("isdead"); BeatController.GetInstance().BeatSubject.RemoveObserver(this); Destroy(this.gameObject); } base.OnBeat(); endMovement(); foreach (GameObject gameObject in _currentTrapTileList) { Debug.Log("Currently on trap " + gameObject.name); TileAnimator tileAnimator = gameObject.GetComponent <TileAnimator>(); if (tileAnimator != null && tileAnimator.isActive) { switch (gameObject.tag) { case "SpikeTrap": sprites = deathAnim; break; case "Lava": sprites = deathAnim; break; case "SpearTrap": sprites = deathAnim; break; } _isDead = true; } TrapDoorAnimator trapDoorAnimator = gameObject.GetComponent <TrapDoorAnimator>(); if (trapDoorAnimator != null && gameObject.tag == "TrapDoor") { if (trapDoorAnimator.isOpen) { _isDead = true; sprites = trapDoorAnim; } else { trapDoorAnimator.isActivated = true; } } } }
public void PlayCollectLastStandingTilesAnimation(float resizeDelay, float collectDelay) { for (int i = 0; i < tileList.Count; i++) { TileAnimator tileAnimator = tileList[i].GetComponent <TileAnimator>(); float delay = resizeDelay * i; tileAnimator.DoSelectedTween(delay, () => { tileAnimator.DoCollectTween(collectDelay, () => { OnCollectAnimationFinished(tileAnimator); }); }); } }
/// <summary> /// Check if this animation batch has finished /// </summary> /// <param name="tileAnimator"></param> private void CheckForAnimationBatchFinished(TileAnimator tileAnimator) { tileList.Remove(tileAnimator.gameObject); if (tileList.Count == 0) { if (AnimationBatchFinishedEvent != null) { AnimationBatchFinishedEvent(this); } if (callback != null) { callback(); } } }
public void PlayCollectAnimation(float delayPerTile, float batchDelay = 0f) { for (int i = 0; i < tileList.Count; i++) { TileAnimator tileAnimator = tileList[i].GetComponent <TileAnimator>(); // NOTE: Not playing a tween when collecting during gameplay PlayDestroyAnimation(tileAnimator); } // Have to loop twice as we don't want to mess up the list for (int i = 0; i < tileList.Count; i++) { TileAnimator tileAnimator = tileList[i].GetComponent <TileAnimator>(); CheckForAnimationBatchFinished(tileAnimator); } }
public void PlayBuildAnimation(float delayPerTile, int maxDelayedTiles = 30) { for (int i = 0; i < tileList.Count; i++) { GameObject tile = tileList[i]; tile.transform.localScale = Vector3.zero; TileAnimator tileAnimator = tile.GetComponent <TileAnimator>(); float delayMultiplier = i >= maxDelayedTiles ? maxDelayedTiles : i; float delay = delayPerTile * delayMultiplier; tileAnimator.DoStartupResize(delay, () => { CheckForAnimationBatchFinished(tileAnimator); }); } }
private void Start() { tileAnimator = GetComponent <TileAnimator>(); }
private void OnCollectAnimationFinished(TileAnimator tileAnimator) { PlayDestroyAnimation(tileAnimator); CheckForAnimationBatchFinished(tileAnimator); }