public override void Update(float dt) { base.Update(dt); if (from != null && TryGetComponent <HealthComponent>(out var h) && h.InvincibilityTimer <= 0.45f) { Done = true; if (from is Player) { var count = GlobalSave.GetInt("paintings_destroyed", 0) + 1; if (count >= 100) { Achievements.Unlock("bk:van_no_gogh"); } GlobalSave.Put("paintings_destroyed", count); } for (var i = 0; i < 4; i++) { var part = new ParticleEntity(Particles.Dust()); part.Position = Center; part.Particle.Scale = Lens.util.math.Rnd.Float(0.4f, 0.8f); Area.Add(part); part.Depth = Depth; } if (!HasComponent <AudioEmitterComponent>()) { AddComponent(new AudioEmitterComponent()); } AudioEmitterComponent.Dummy(Area, Center).EmitRandomizedPrefixed("level_chair_break", 2, 0.5f); Particles.BreakSprite(Area, GetComponent <InteractableSliceComponent>().Sprite, Position, Depth); Camera.Instance.Shake(2f); Engine.Instance.Freeze = 1f; } }
public override void Update(float dt) { base.Update(dt); if (from != null && TryGetComponent <HealthComponent>(out var h) && h.InvincibilityTimer <= 0.45f) { Done = true; if (!Camera.Instance.Overlaps(this)) { return; } if (TryGetComponent <PoolDropsComponent>(out var pool)) { pool.SpawnDrops(); } for (var i = 0; i < 4; i++) { var part = new ParticleEntity(Particles.Dust()); part.Position = Center; part.Particle.Scale = Lens.util.math.Rnd.Float(0.4f, 0.8f); Area.Add(part); } var d = AudioEmitterComponent.Dummy(Area, Center); if (Sprite == "cup" || Sprite.StartsWith("pot")) { d.EmitRandomizedPrefixed("level_cup", 2, 0.75f); } else { d.EmitRandomizedPrefixed("level_chair_break", 2, 0.75f); } Particles.BreakSprite(Area, GetComponent <SliceComponent>().Sprite, Position); Camera.Instance.Shake(2f); Engine.Instance.Freeze = 1f; } }
public void Break() { if (broken) { return; } On = false; broken = true; if (emitter != null) { emitter.Done = true; } AnimationUtil.Poof(Center); Particles.BreakSprite(Area, GetComponent <SliceComponent>().Sprite, Position); UpdateSprite(); }
public static void BreakRock(Level level, Dot ww, int x, int y, Tile l) { AudioEmitterComponent.Dummy(level.Area, ww).Emit($"level_rock_{Rnd.Int(1, 3)}", 0.5f); if (l.IsRock()) { Drop.Create(l == Tile.TintedRock ? "bk:tinted_rock" : "bk:rock", null, level.Area, ww); } for (var i = 0; i < 3; i++) { var part = new ParticleEntity(Particles.Dust()); part.Position = ww; level.Area.Add(part); } Particles.BreakSprite(level.Area, (l == Tile.TintedRock ? level.Tileset.TintedRock : (l == Tile.MetalBlock ? level.Tileset.MetalBlock : level.Tileset.Rock))[Rnd.Int(4)], ww); level.Set(x, y, Tile.Ember); level.UpdateTile(x, y); level.ReCreateBodyChunk(x, y); }
private bool Interact(Entity e) { if (Broken || busy) { return(true); } Run.AddScourge(true); if (trigger != null) { trigger.Interrupted = true; } HandleEvent(new BrokenEvent { BurningStatue = this }); XSpread = 1; Tween.To(1f, Camera.Instance.Zoom, xx => Camera.Instance.Zoom = xx, 0.2f); Tween.To(1.4f, Camera.Instance.TextureZoom, xx => Camera.Instance.TextureZoom = xx, 0.5f); Camera.Instance.GetComponent <ShakeComponent>().Amount = 0; GameSave.Put("statue_broken", true); var torches = GetComponent <RoomComponent>().Room.Tagged[Tags.Torch]; foreach (var t in torches) { var tr = (Torch)t; tr.XSpread = 0.1f; tr.On = true; } Timer.Add(() => { for (var i = 0; i < torches.Count; i++) { var i1 = i; Timer.Add(() => { var t = (Torch)torches[i1]; t.Break(); Camera.Instance.Shake(5); }, i); } Timer.Add(() => { Particles.BreakSprite(Area, GetComponent <InteractableSliceComponent>().Sprite, Position); Broken = true; Camera.Instance.Unfollow(this); Camera.Instance.Shake(10); Timer.Add(() => { Camera.Instance.GetComponent <ShakeComponent>().Amount = 0; }, 0.5f); Camera.Instance.Targets.Clear(); Camera.Instance.Follow(this, 0.5f); UpdateSprite(); RemoveComponent <LightComponent>(); var exit = new Exit(); Area.Add(exit); exit.To = Run.Depth + 1; var x = (int)Math.Floor(CenterX / 16); var y = (int)Math.Floor(Bottom / 16 + 0.6f); var p = new Vector2(x * 16 + 8, y * 16 + 8); exit.Center = p; Painter.Fill(Run.Level, x - 1, y - 1, 3, 3, Tiles.RandomFloor()); Painter.Fill(Run.Level, x - 1, y - 3, 3, 3, Tiles.RandomFloor()); Run.Level.TileUp(); Run.Level.CreateBody(); Timer.Add(() => { Tween.To(1f, Camera.Instance.TextureZoom, xx => Camera.Instance.TextureZoom = xx, 0.8f); ((InGameState)BK.Instance.State).ResetFollowing(); }, 1f); }, torches.Count + 1); }, 1f); return(true); }