public Bullet(Engine engine, Vector2 position, Vector2 direction, float angle, Global.CollisionCategories category) : base(engine) { DrawOrder = (int)Global.Layers.Projectiles; bulletPhysicsComponent = new BulletPhysicsComponent(engine, position, direction, angle, category); bulletPhysicsComponent.MainFixture.OnCollision += BulletOnCollision; bulletSprite = new Sprite(engine, @"Miscellaneous\RedBullet"); bulletSprite.DrawOrder = DrawOrder; bulletSprite.Angle = angle; light = new Light(engine); light.Color = Color.Red; light.Fov = MathHelper.TwoPi; light.Intensity = 0.8f; light.Position = bulletPhysicsComponent.Position; light.Range = 200; light.ShadowType = Krypton.Lights.ShadowType.Illuminated; switch (category) { case Global.CollisionCategories.PlayerBullet: bulletPhysicsComponent.MainFixture.CollisionFilter.CollidesWith = (Category)(Global.CollisionCategories.Enemy | Global.CollisionCategories.EnemyBullet | Global.CollisionCategories.Light | Global.CollisionCategories.Structure); break; case Global.CollisionCategories.EnemyBullet: bulletPhysicsComponent.MainFixture.CollisionFilter.CollidesWith = (Category)(Global.CollisionCategories.Player | Global.CollisionCategories.PlayerBullet | Global.CollisionCategories.Light | Global.CollisionCategories.Structure); break; default: // do nothing break; } collided = false; flashAnimation = new Animation(Engine, @"Miscellaneous\flash", 512, 512, 3, 3, 6, 20, Global.Animations.PlayOnce); flashAnimation.Scale = 0.4f; flashAnimation.Position = bulletPhysicsComponent.Position; flashAnimation.DrawOrder = (int)Global.Layers.Projectiles; flashLight = new Light(engine); flashLight.Color = Color.Yellow; flashLight.Fov = MathHelper.TwoPi; flashLight.Intensity = 0.8f; flashLight.Position = bulletPhysicsComponent.Position; flashLight.Range = 100; flashLight.ShadowType = Krypton.Lights.ShadowType.Illuminated; flashLight.IsOn = false; engine.AddComponent(this); }
public override void Dispose(bool disposing) { if (bulletPhysicsComponent != null) { bulletPhysicsComponent.Dispose(disposing); bulletPhysicsComponent = null; } bulletSprite.Dispose(true); bulletSprite = null; light.Dispose(true); light = null; flashAnimation.Dispose(true); flashAnimation = null; flashLight.Dispose(true); flashLight = null; base.Dispose(disposing); }