]> git.r.bdr.sh - rbdr/super-polarity/blob - SuperPolarity/Actors/GameActor.cs
8015ffa30db9547eeefa36b61596cb4908297974
[rbdr/super-polarity] / SuperPolarity / Actors / GameActor.cs
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.Content;
7 using Microsoft.Xna.Framework.Graphics;
8
9 namespace SuperPolarity
10 {
11 public class GameActor : Actor
12 {
13 // Graphics / In-Game
14 protected Texture2D Texture;
15 protected Vector2 Origin;
16
17 // Constraints / Behavior
18 public int HP;
19 protected bool Immortal;
20 public int Value;
21
22 public override int Width
23 {
24 get { return Texture.Width; }
25 }
26
27 public override int Height
28 {
29 get { return Texture.Height; }
30 }
31
32 public GameActor(SuperPolarity newGame)
33 : base(newGame)
34 {
35 }
36
37 public virtual void Initialize(Texture2D texture, Vector2 position)
38 {
39 base.Initialize (position);
40
41 Texture = texture;
42
43 Collides = true;
44
45 Origin = new Vector2(Texture.Width / 2, Texture.Height / 2);
46
47 HP = 1;
48 Immortal = false;
49
50 Value = 1;
51 InitBox ();
52 }
53
54 public override void Draw(SpriteBatch spriteBatch)
55 {
56 base.Draw(spriteBatch);
57
58 spriteBatch.Draw(Texture, Position, null, Color, Angle, Origin, 1f, SpriteEffects.None, 0f);
59 }
60
61 public override void CleanUp()
62 {
63 base.CleanUp ();
64 Texture = null;
65 }
66
67
68 public void TakeDamage(int amount)
69 {
70 if (!Immortal)
71 {
72 HP = HP - amount;
73 if (HP < 0)
74 {
75 Die();
76 }
77 }
78 }
79 }
80 }