]>
Commit | Line | Data |
---|---|---|
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 | public class Player | |
11 | { | |
12 | public int Score; | |
13 | public int Multiplier; | |
14 | public int Lives; | |
15 | ||
16 | ||
17 | SpriteFont DebugFont; | |
18 | SuperPolarity Game; | |
19 | ||
20 | Texture2D LifeSprite; | |
21 | ||
22 | public Player(SuperPolarity game) | |
23 | { | |
24 | Score = 0; | |
25 | Multiplier = 1; | |
26 | Lives = 3; | |
27 | Game = game; | |
28 | DebugFont = Game.Content.Load<SpriteFont>("Fonts\\bigfont"); | |
29 | LifeSprite = Game.Content.Load<Texture2D>("Graphics\\neutral-ship"); | |
30 | } | |
31 | ||
32 | public void AddScore(int value) | |
33 | { | |
34 | Score = Score + (value * Multiplier); | |
35 | } | |
36 | ||
37 | public void AddMultiplier(int value) | |
38 | { | |
39 | Multiplier = Multiplier + 1; | |
40 | } | |
41 | ||
42 | public void ResetMultiplier() | |
43 | { | |
44 | Multiplier = 1; | |
45 | } | |
46 | ||
47 | public void Draw(SpriteBatch spriteBatch) | |
48 | { | |
49 | var UiColor = new Color(0, 0, 0, 200); | |
50 | var lightColor = new Color(0, 0, 0, 128); | |
51 | spriteBatch.DrawString(DebugFont, Score.ToString(), new Vector2(40, 30), UiColor); | |
52 | spriteBatch.DrawString(DebugFont, "x" + Multiplier.ToString(), new Vector2(40, 50), lightColor); | |
53 | ||
54 | var lifePosition = new Vector2(Game.GraphicsDevice.Viewport.Width - 140, 30); | |
55 | if (Lives > 4) | |
56 | { | |
57 | spriteBatch.Draw(LifeSprite, lifePosition, null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f); | |
58 | spriteBatch.DrawString(DebugFont, "x " + Lives.ToString(), new Vector2(lifePosition.X + 8, lifePosition.Y + 5), UiColor); | |
59 | } | |
60 | else | |
61 | { | |
62 | for (var i = 0; i < Lives; i++) | |
63 | { | |
64 | spriteBatch.Draw(LifeSprite, new Vector2(lifePosition.X + (i * 28), lifePosition.Y), null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f); | |
65 | } | |
66 | } | |
67 | } | |
68 | ||
69 | public void Update() | |
70 | { | |
71 | ||
72 | } | |
73 | ||
74 | public void Reset() | |
75 | { | |
76 | Score = 0; | |
77 | Multiplier = 1; | |
78 | Lives = 3; | |
79 | } | |
80 | } | |
81 | } |