private void CheckForFallingAndDamagingPlaceables(GameTime gameTime) { Placeable placeable = this.GetCollidingPlaceable(new Vector2(0, -2)); if (placeable != null) { if (placeable.Damage > 0) { Console.WriteLine("1 Teh ultimate collision!!!! " + placeable.Position.Y); // Item is falling if (placeable.Velocity.Y > 0) { Console.WriteLine("0 Teh ultimate collision!!!!" + placeable.Position.Y); this.health -= placeable.Damage; EffectEngine.GetInstance().AddEffect(game, placeable.Position, placeable.Animation.Texture, 1.0f); placeable.Destroy(); } // Item horribly dangeroud and incollidable else if (placeable.Incollidable) { this.health -= placeable.Damage; EffectEngine.GetInstance().AddEffect(game, placeable.Position, placeable.Animation.Texture, 1.0f); placeable.Destroy(); } // See if player died if (this.health <= 0) { this.alive = false; EffectEngine.GetInstance().AddEffect(game, this.Position, this.Animation.Texture, 1.0f); EffectEngine.GetInstance().AddEffect(game, this.spriteDrillFront.Position, this.spriteDrillFront.Animation.Texture, 1.0f); this.Visible = false; this.spriteDrillBack.Visible = false; this.spriteDrillFront.Visible = false; this.PlayDestroyedSoundEffect(); } } placeable.PlayDialog(); } }
private void DoDrilling(GameTime gameTime) { if (this.drilling) { Rectangle collider = new Rectangle(); int xShift = 0; int yShift = 0; switch (this.drillingDirection) { case Direction.Left: xShift = -50; break; case Direction.Right: xShift = 50; break; case Direction.Down: yShift = 30; break; case Direction.Up: yShift = -50; break; } this.currentDrillRotatingSpeed += gameTime.ElapsedGameTime.Milliseconds / 1000.0f; if (this.currentDrillRotatingSpeed >= this.minDrillRotatingSpeedToDrill) { collider = new Rectangle((int)this.position.X + xShift, (int)this.position.Y + yShift, 10, 10); Placeable placeable = GetCollidingPlaceable(collider); if (placeable != null) {// Found an placeable // See if it is drillable if (placeable.Drillable) { EffectEngine.GetInstance().AddEffect(game, placeable.Position, placeable.Animation.Texture, 1.0f); placeable.Destroy(); } } } } else { this.currentDrillRotatingSpeed = 0.0f; } }