]> git.r.bdr.sh - rbdr/super-polarity/blame - SuperPolarity/Actors/Bullet.cs
Update README
[rbdr/super-polarity] / SuperPolarity / Actors / Bullet.cs
CommitLineData
9ad526c0 1using System;
38c7d3f9
BB
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Xna.Framework;
6using Microsoft.Xna.Framework.Graphics;
7
8namespace SuperPolarity
9{
05e4b948 10 class Bullet : GameActor
38c7d3f9
BB
11 {
12 protected ParticleEngine particleEngine;
74c15570 13 public int Power;
38c7d3f9 14
74c15570 15 public Bullet(SuperPolarity newGame)
38c7d3f9
BB
16 : base(newGame)
17 {
18 }
19
20 ~Bullet()
21 {
22 particleEngine = null;
23 }
24
25 public override void Initialize(Texture2D texture, Vector2 position)
26 {
27 base.Initialize(texture, position);
74c15570
BB
28 BoxDimensions.X = 10;
29 BoxDimensions.Y = 10;
30 BoxDimensions.W = 10;
31 BoxDimensions.Z = 10;
097781e6 32 MaxVelocity = 8;
74c15570 33 InitBox();
38c7d3f9
BB
34 particleEngine = ParticleEffectFactory.CreateBullet(position);
35 }
36
37 public override void Update(GameTime gameTime)
38 {
39 Velocity.X = (float)(MaxVelocity * Math.Cos(Angle));
40 Velocity.Y = (float)(MaxVelocity * Math.Sin(Angle));
41
74c15570
BB
42 Power = 1;
43
38c7d3f9 44 Position += Velocity;
74c15570 45 UpdateBox();
38c7d3f9
BB
46
47 particleEngine.Update();
48 particleEngine.EmitterLocation = Position;
49 }
50
51 public override void Draw(SpriteBatch spriteBatch)
52 {
53 base.Draw(spriteBatch);
54 particleEngine.Draw(spriteBatch);
55 }
74c15570
BB
56
57 public override void Collide(Actor other, Rectangle collision)
58 {
59 if (Dying) { return; }
60 if (other.GetType().IsAssignableFrom(typeof(StandardShip)))
61 {
62 Die();
63 return;
64 }
65 }
66
67 protected override void Die()
68 {
69 ActorManager.CheckOut(this);
097781e6 70 Renderer.CheckOut(this);
74c15570
BB
71 Parent.Children.Remove(this);
72 }
b587e9d8
BB
73
74 public override void CleanUp()
75 {
76 base.CleanUp();
77 this.particleEngine = null;
78 }
38c7d3f9
BB
79 }
80}