public void freeze(float dur) { FreezeTime = Time.time + dur; if (Frozen) { return; } Frozen = true; foreach (Animator anim in this.GetComponentsInChildren <Animator>()) { anim.enabled = false; //May not apply to all animators } FreezeSprite.enabled = true; LavaPillarTelegraph.Stop(); LavaPillarSpout.Stop(); }
void FixedUpdate() { float time = (Time.time - StartTime); if (Falling) { Debug.Log("Going Down"); if (Offset > 0f) { //Rise float df = (Time.fixedDeltaTime * RISESPEED); if ((Offset) < df) { df = Offset; } Offset -= df; this.transform.position = (this.transform.position - (Vector3.up * df)); } if (Offset <= 0f) { //Orphan the particles. if (!removed) { removed = true; foreach (ParticleSystem ps in this.GetComponentsInChildren <ParticleSystem>()) { ps.Stop(true); ps.transform.SetParent(null); GameObject.Destroy(ps.gameObject, 10f); } GameObject.Destroy(this.gameObject); } } } else { if (Rising) { if (Offset < MaxOffset) { //Rise float df = (Time.fixedDeltaTime * RISESPEED); if ((MaxOffset - Offset) < df) { df = (MaxOffset - Offset); } Offset += df; this.transform.position = this.transform.position + (Vector3.up * df); } if (time >= PillarDuration) { GlowingParticles.Stop(); StartTime = Time.time; Falling = true; Am.am.M.crossfade(LavaPillarSpout, 0f, 1f); } else { if (!GlowingParticles.isPlaying) { GlowingParticles.Play(); } } } else { if (time >= TelegraphTime) { TelegraphParticles.Stop(); LavaPillarSpout.Play(); Am.am.M.crossfade(LavaPillarTelegraph, 0f, .5f); Rising = true; StartTime = Time.time; } else { if (!TelegraphParticles.isPlaying) { TelegraphParticles.Play(); LavaPillarTelegraph.Play(); } } } } }