public override void Added(Scene scene) { base.Added(scene); Level level = Scene as Level; Collider.Height = level.Bounds.Height; Position = new Vector2(level.Bounds.Left - 32, level.Bounds.Top); _loopSfx.Play("event:/game/09_core/rising_threat", "room_state", 0); _loopSfx.Position = new Vector2(Width, Height / 2f); _steamPoofPoints = new int[level.Bounds.Height / 12]; for (int i = 0; i < _steamPoofPoints.Length; i++) { _steamPoofPoints[i] = (int)Top + 6 + i * 12; } foreach (int y in _steamPoofPoints) { SteamPoof.Create(Scene, new Vector2(Right - 4, y), new Vector2(6, 6), 2); } _baseParticleEmittionPeriod = 150 / Height; _particleEmittionPeriodVariance = 50 / Height; SetParticleEmittionPeriod(); }
public static IEnumerable <SteamPoof> Create(Scene scene, Vector2 position, Vector2 range, int count = 1, float fade = 1f, Action <SteamPoof> onRemoved = null) { SteamPoof[] poofs = new SteamPoof[count]; for (int i = 0; i < count; i++) { SteamPoof poof = new SteamPoof(new Vector2(position.X - range.X / 2 + Calc.Random.NextFloat(range.X), position.Y - range.Y / 2 + Calc.Random.NextFloat(range.Y)), fade); scene.Add(poof); poofs[i] = poof; poof.OnRemoved = onRemoved; } return(poofs); }
private IEnumerator SteamPoofSpawnSequence() { int index = 0; while (true) { yield return(0.3f / Height + Calc.Random.NextFloat(0.01f / Height)); _steamPoofs.AddRange(SteamPoof.Create(Scene, new Vector2(Right - 8, _steamPoofPoints[index]), new Vector2(16, 6), 1, Fade, RemovePoof)); index = (index + 1) % _steamPoofPoints.Length; } }
private void RemovePoof(SteamPoof poof) { _steamPoofs.Remove(poof); }