-
Notifications
You must be signed in to change notification settings - Fork 0
/
Navigation.cs
171 lines (156 loc) · 5.89 KB
/
Navigation.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RPGlibrary {
public class Navigation {
private bool isEnemyHere, enemyHereOnNextNorth, enemyHereOnNextWest, enemyHereOnNextEast;
private int entireJourneyLength, movesSinceLastEncounter;
Random random;
public bool IsEnemyHere {
get {
return isEnemyHere;
}
set {
isEnemyHere = value;
}
}
public bool EnemyHereOnNextNorth {
get {
return enemyHereOnNextNorth;
}
set {
enemyHereOnNextNorth = value;
}
}
public bool EnemyHereOnNextWest {
get {
return enemyHereOnNextWest;
}
set {
enemyHereOnNextWest = value;
}
}
public bool EnemyHereOnNextEast {
get {
return enemyHereOnNextEast;
}
set {
enemyHereOnNextEast = value;
}
}
public int EntireJourneyLength {
get {
return entireJourneyLength;
}
set {
entireJourneyLength = value;
}
}
public int MovesSinceLastEncounter {
get {
return movesSinceLastEncounter;
}
set {
movesSinceLastEncounter = value;
}
}
public Navigation() {
this.IsEnemyHere = false;
this.EnemyHereOnNextNorth = false;
this.EnemyHereOnNextWest = false;
this.EnemyHereOnNextEast = false;
this.EntireJourneyLength = 0;
this.MovesSinceLastEncounter = 0;
random = new Random();
}
public string NavigateNorth() {
this.EntireJourneyLength++;
this.MovesSinceLastEncounter++;
//reset any 'on next move' encounters
this.EnemyHereOnNextWest = false;
this.EnemyHereOnNextEast = false;
//if it has been 5 moves since last encounter
//raise chance of encounter to 80%
if ((movesSinceLastEncounter > 5) && (random.Next(1, 101) > 20)) {
this.IsEnemyHere = true;
this.MovesSinceLastEncounter = 0;
return "An enemy has ambushed you!";
}
//10% chance of running into an enemy with no warning
//also if this is the turn after enemy here on next move
if ((random.Next(1, 101) > 90) || (this.EnemyHereOnNextNorth == true)) {
this.EnemyHereOnNextNorth = false;
this.IsEnemyHere = true;
this.MovesSinceLastEncounter = 0;
return "You've encountered an enemy!";
}
//30% chance of hearing an enemy in the distance
if (random.Next(1, 101) > 70) {
this.EnemyHereOnNextNorth = true;
this.MovesSinceLastEncounter = 0;
return "You hear skittering to the north.";
}
return "Nothing here.";
}
public string NavigateWest() {
this.EntireJourneyLength++;
this.MovesSinceLastEncounter++;
//reset any 'on next move' encounters
this.EnemyHereOnNextNorth = false;
this.EnemyHereOnNextEast = false;
//if it has been 5 moves since last encounter
//raise chance of encounter to 80%
if ((movesSinceLastEncounter > 5) && (random.Next(1, 101) > 20)) {
this.IsEnemyHere = true;
this.MovesSinceLastEncounter = 0;
return "An enemy has ambushed you!";
}
//10% chance of running into an enemy with no warning
//also if this is the turn after enemy here on next move
if ((random.Next(1, 101) > 90) || (this.EnemyHereOnNextWest == true)) {
this.EnemyHereOnNextWest = false;
this.IsEnemyHere = true;
this.MovesSinceLastEncounter = 0;
return "You've encountered an enemy!";
}
//30% chance of hearing an enemy in the distance
if (random.Next(1, 101) > 70) {
this.EnemyHereOnNextWest = true;
this.MovesSinceLastEncounter = 0;
return "You hear rustling to the west.";
}
return "Nothing here.";
}
public string NavigateEast() {
this.EntireJourneyLength++;
this.MovesSinceLastEncounter++;
//reset any 'on next move' encounters
this.EnemyHereOnNextNorth = false;
this.EnemyHereOnNextWest = false;
//if it has been 5 moves since last encounter
//raise chance of encounter to 80%
if ((movesSinceLastEncounter > 5) && (random.Next(1, 101) > 20)) {
this.IsEnemyHere = true;
this.MovesSinceLastEncounter = 0;
return "An enemy has ambushed you!";
}
//10% chance of running into an enemy with no warning
//also if this is the turn after enemy here on next move
if ((random.Next(1, 101) > 90) || (this.EnemyHereOnNextEast == true)) {
this.EnemyHereOnNextEast = false;
this.IsEnemyHere = true;
this.MovesSinceLastEncounter = 0;
return "You've encountered an enemy!";
}
//30% chance of hearing an enemy in the distance
if (random.Next(1, 101) > 70) {
this.EnemyHereOnNextEast = true;
this.MovesSinceLastEncounter = 0;
return "You hear something coming from the east";
}
return "Nothing here.";
}
}
}