protected IEnumerator SpawnExplosions() { Transform explosionSource = gameObject.FindOrCreateChild("ExplosionSource").transform; double timeStarted = WorldClock.AdjustedRealTime; List <ExplosionTemplate> explosions = new List <ExplosionTemplate>(); explosions.AddRange(State.Explosions); while (explosions.Count > 0) { double currentTime = WorldClock.AdjustedRealTime; for (int i = explosions.LastIndex(); i >= 0; i--) { ExplosionTemplate explosion = explosions[i]; if (explosion.Delay < currentTime - timeStarted) { explosionSource.position = transform.position + explosion.Position; State.ExplosionDamage.Point = explosionSource.position; State.ExplosionDamage.SenderName = "Explosion"; FXManager.Get.SpawnExplosion( explosion.Type, State.ExplosionDamage.Point, explosion.Radius, explosion.ForceAtEdge, explosion.MinimumForce, explosion.Duration, State.ExplosionDamage); MasterAudio.PlaySound(MasterAudio.SoundType.Explosions, explosionSource, explosion.ExplosionSound); Player.Local.DoEarthquake(explosion.Duration, explosion.BombShake); //spawn falling dust for (int j = 0; j < State.FallingSandPositions.Count; j++) { FXManager.Get.SpawnFX(transform.position + State.FallingSandPositions[j], State.FallingSandFX); } explosions.RemoveAt(i); } } yield return(null); } mSpawningExplosions = false; GameObject.Destroy(explosionSource.gameObject, 0.5f); yield break; }
public override void OnEditorRefresh() { State.Explosions.Clear(); foreach (Transform child in transform) { if (child.name == "FallingSand") { State.FallingSandPositions.Add(new SVector3(child.localPosition)); } else { ExplosionTemplate explosion = new ExplosionTemplate(); explosion.Delay = float.Parse(child.name); explosion.Radius = child.transform.localScale.x; explosion.Position = child.position - transform.position; explosion.Duration = 0.25f; explosion.ForceAtEdge = 1f; explosion.Type = ExplosionType.Simple; State.Explosions.Add(explosion); State.TotalDuration = Mathf.Max(State.TotalDuration, explosion.Delay); } } }