]> Dogcows Code - chaz/carfire/blob - CarFire/CarFire/CarFire/Human.cs
Began basic interface for Character, Player and Monster, Began Human Class
[chaz/carfire] / CarFire / CarFire / CarFire / Human.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 using Microsoft.Xna.Framework.Input;
9
10 namespace CarFire
11 {
12 public class Human : IPlayer
13 {
14 //Member Variables
15 String CharName;
16 Map theMap;
17 int movementSpeed;
18 int gridX;
19 int gridY;
20 Texture2D charModel;
21 int health;
22 int damage;
23 int range;
24 int score;
25 bool isMoving;
26 int pixelX;
27 int pixelY;
28 bool visible;
29
30 public Human(Map _theMap, String Name)
31 {
32 theMap = _theMap;
33 CharName = Name;
34
35 movementSpeed = 20; // randomly set now
36 health = 100;
37 score = 0;
38 visible = false;
39 }
40
41 public void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics)
42 {
43 charModel = contentManager.Load<Texture2D>("deselectBox"); //change to charModel when designed
44 }
45
46 public void UnloadContent()
47 {
48
49 }
50
51 public long Update(GameTime gameTime, NetworkManager networkGame)
52 {
53 return 0;
54
55 }
56
57 public long Draw(SpriteBatch spriteBatch)
58 {
59 return 0;
60 }
61
62 public int Health { get { return health; } }
63 public int Score { get { return score; } }
64 public bool alive { get { return health > 0; } }
65
66 public void causeDamageTo(int amount)
67 {
68 health -= amount;
69 }
70
71 /// <summary>
72 /// Moves the current player being controlled based on a given set of key presses.
73 /// The player can only move one grid space per movePlayer call. Thus this method
74 /// is made to be called ever update. The player will only move if the grid space
75 /// that is being moved to is an open space.
76 /// </summary>
77 /// <param name="keysPressed">A general list of keys that are pressed. Other keys can be included but only direction keys will be used</param>
78 public void MovePlayer(List<Keys> keysPressed)
79 {
80 // move upleft
81 keysPressed.Contains<Keys>(Keys.Left);
82 if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY - 1))
83 {
84 gridX -= 1;
85 gridY -= 1;
86 }
87 // move upright
88 else if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1))
89 {
90 gridX += 1;
91 gridY -= 1;
92 }
93 // move downleft
94 else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1))
95 {
96 gridX -= 1;
97 gridY += 1;
98 }
99 // move downright
100 else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))
101 {
102 gridX += 1;
103 gridY += 1;
104 }
105 // move up
106 else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))
107 {
108 gridY -= 1;
109 }
110 // move down
111 else if (keysPressed.Contains<Keys>(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1))
112 {
113 gridY += 1;
114 }
115 // move left
116 else if (keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY))
117 {
118 gridX -= 1;
119 }
120 // move right
121 else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))
122 {
123 gridX += 1;
124 }
125 }
126
127
128 public void powerUp(int amount)
129 {
130 health += amount;
131 }
132
133 public void Spawn(Point mapPoint)
134 {
135 gridX = mapPoint.X;
136 gridY = mapPoint.Y;
137 visible = true;
138 }
139
140
141 }
142 }
This page took 0.03463 seconds and 4 git commands to generate.