]>
Commit | Line | Data |
---|---|---|
38c7d3f9 BB |
1 | using System; |
2 | using System.Collections.Generic; | |
3 | using System.Linq; | |
4 | using System.Text; | |
5 | using Microsoft.Xna.Framework; | |
6 | using Microsoft.Xna.Framework.Graphics; | |
7 | ||
8 | namespace SuperPolarity | |
9 | { | |
10 | class Bullet : Actor | |
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 | } |