]> git.r.bdr.sh - rbdr/super-polarity/blame - SuperPolarity/Actors/GameActor.cs
Update source to compile on VS Studio for mac
[rbdr/super-polarity] / SuperPolarity / Actors / GameActor.cs
CommitLineData
9ad526c0 1using System;
05e4b948
BB
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Xna.Framework;
6using Microsoft.Xna.Framework.Content;
7using Microsoft.Xna.Framework.Graphics;
8
9namespace 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
9ad526c0
BB
58 try {
59 spriteBatch.Draw(Texture, Position, null, Color, Angle, Origin, 1f, SpriteEffects.None, 0f);
60 } catch (ArgumentNullException) {
61 Console.WriteLine ("Where'd the texture go?.");
62 }
05e4b948
BB
63 }
64
65 public override void CleanUp()
66 {
67 base.CleanUp ();
68 Texture = null;
69 }
70
71
72 public void TakeDamage(int amount)
73 {
74 if (!Immortal)
75 {
76 HP = HP - amount;
77 if (HP < 0)
78 {
79 Die();
80 }
81 }
82 }
83 }
84}