-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPeople.cs
144 lines (123 loc) · 3.25 KB
/
People.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game
{
// holds all People - including NPC's
public class People
{
public int health;
public Loc location = new Loc();
public string symbol;
protected People(int HP, string Symbol)
{
health = HP;
symbol = Symbol;
}
// two functions to generate the new X and Y coords of NPCs
protected int genRandomX()
{
Random rnd = new Random(DateTime.Now.Millisecond);
return rnd.Next(-1, 3);
}
protected int genRandomY()
{
Random rnd = new Random(DateTime.Now.Millisecond);
return rnd.Next(-1, 3);
}
// virtual function to define actions
public virtual void Action(Player mainPlayer)
{
}
}
// define the Player class
public class Player : People
{
// define the base damage, HP, Symbol, and starting position
int damage = 10;
public Player()
: base(100, "#")
{
location.Is(14, 14);
}
// attack a Bad Guy
public void Attack(BadGuy badGuy)
{
badGuy.health = badGuy.health - damage;
}
// logic to move the character around
public int Right()
{
return ++location.y;
}
public int Left()
{
return --location.y;
}
public int Up()
{
return --location.x;
}
public int Down()
{
return ++location.x;
}
}
// define a Bad Guy
public class BadGuy : People
{
public BadGuy()
: base(20, "&")
{
// location.Is(genRandom(), genRandom());
location.Is(5, 5);
}
public override void Action(Player mainPlayer)
{
mainPlayer.health = mainPlayer.health - 20;
}
public Loc UpdateLocation()
{
location.Is(location.x + genRandomX(), location.y + genRandomY());
return location;
}
}
// define the Mines
public class Mines : People
{
public Mines()
: base(50, "@")
{
location.Is(2, 1);
}
public override void Action(Player mainPlayer)
{
mainPlayer.health = mainPlayer.health - 50;
}
public Loc UpdateLocation()
{
location.Is(location.x + genRandomX(), location.y + genRandomY());
return location;
}
}
// define the Medics
public class Medic : People
{
public Medic()
: base(20, "$")
{
location.Is(10, 10);
}
public override void Action(Player mainPlayer)
{
mainPlayer.health = mainPlayer.health + 30;
}
public Loc UpdateLocation()
{
location.Is(location.x + genRandomX(), location.y + genRandomY());
return location;
}
}
}