-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
208 lines (177 loc) · 7.74 KB
/
Copy pathProgram.cs
File metadata and controls
208 lines (177 loc) · 7.74 KB
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
using System.Runtime.InteropServices;
using System.Text;
using Spectre.Console;
using System.Media;
namespace Project;
class Program
{
public static Grid? grid;
public static Objects? maze_exit;
public static Objects? Shelter;
public static Objects? Key;
public static Objects? FKey;
public static Trap[]? _Traps;
public static Trap? Trap1;
public static Trap? Trap2;
public static Trap? Trap3;
public static Trap? Trap4;
public static Trap? Trap5;
public static Trap? Trap6;
public static Character? badGuy;
public static Character? goodGuy;
public static int cool_bad;
public static int cool_good;
public static bool game_Initialized;
static void Main(string[] args)
{
if (OperatingSystem.IsWindows()) {
SoundPlayer main = new SoundPlayer();
main.SoundLocation = "Haunting_Menu.wav";
main.Load();
main.PlayLooping();
}
Menu.Start();
(string, string) Selections = Menu.PlayerSelection();
string charSelection1 = Selections.Item1;
string charSelection2 = Selections.Item2;
grid = new Grid(13,13);
MazeResolve.CreateMaze(grid);
MazeResolve.CreateMaze(grid);
// Instanciar asesino
if (charSelection1.StartsWith("Jason") || charSelection2.StartsWith("Jason"))
badGuy = new Character ("Jason", grid.Rows - 1, 0, 3, 3);
else if (charSelection1.StartsWith("Fred") || charSelection2.StartsWith("Fred"))
badGuy = new Character ("Freddy Krueger", grid.Rows - 1, 0, 2, 4);
else if (charSelection1.StartsWith("Luci") || charSelection2.StartsWith("Luci"))
badGuy = new Character ("Lucifer", grid.Rows - 1, 0, 4, 5);
// Instanciar sobreviviente
if (charSelection1.StartsWith("Joel") || charSelection2.StartsWith("Joel"))
goodGuy = new Character ("Joel", 0, 0, 3, 2);
else if (charSelection1.StartsWith("Alan") || charSelection2.StartsWith("Alan"))
goodGuy = new Character ("Alan Wake", 0, 0, 2, 4, 4);
else if (charSelection1.StartsWith("Constan") || charSelection2.StartsWith("Constan"))
goodGuy = new Character ("Constantine", 0, 0, 4, 6);
// Objetos del laberinto
Random rand = new Random();
maze_exit = new Objects (grid.Rows/2, grid.Columns - 1);
Key = new Objects (3, rand.Next(grid.Columns - 1));
FKey = new Objects (rand.Next(grid.Rows - 1), rand.Next(grid.Columns - 1));
Shelter = new Objects (rand.Next(1,grid.Rows - 2), rand.Next(1,grid.Columns/2));
_Traps = [
Trap1 = new Trap ("Retener",rand.Next(2,grid.Rows - 1), rand.Next(0, grid.Columns/2)),
Trap2 = new Trap ("Retener",rand.Next(0,grid.Rows - 2), rand.Next(grid.Columns/2, grid.Columns - 1)),
Trap3 = new Trap ("Acercar",rand.Next(4,grid.Rows - 1), rand.Next(0, grid.Columns/2)),
Trap4 = new Trap ("Acercar",rand.Next(6,grid.Rows - 4), rand.Next(grid.Columns/2, grid.Columns - 1)),
Trap5 = new Trap ("Ralentizar",rand.Next(0,grid.Rows - 1), rand.Next(0, grid.Columns/2)),
Trap6 = new Trap ("Ralentizar",rand.Next(4,grid.Rows - 4), rand.Next(0, grid.Columns - 1)),
];
PaintMaze(grid);
GameStatus();
if (OperatingSystem.IsWindows()) {
SoundPlayer main = new SoundPlayer();
main.SoundLocation = "Haunting_Play.wav";
main.Load();
main.PlayLooping();
}
cool_bad = badGuy!.AbilityCooldown;
cool_good = goodGuy!.AbilityCooldown;
while (true) {
game_Initialized = true;
Game.Play(goodGuy!);
if (goodGuy.AbilityCooldown > 0)
goodGuy.AbilityCooldown --;
Game.Play(badGuy!);
if (badGuy.AbilityCooldown > 0)
badGuy.AbilityCooldown --;
}
}
public static void PaintMaze(Grid g)
{
Console.Clear();
// Tope del tablero
StringBuilder output = new StringBuilder(" + ");
for (int i = 0; i < g.Columns; i++) {
output.Append("--- + ");
}
output.AppendLine();
foreach (var row in g.Row) {
var top = " | ";
var bottom = " + ";
foreach (var cell in row) {
// Paredes de la derecha de cada celda
string east = cell.IsLinked(cell.East!) ? " " : " | ";
// Ubicacion de personajes y objetos
string body = " ";
foreach (var trap in _Traps!) {
if (trap.TrapCell == cell && trap.Fell == false)
body = "T1 ";
}
if (cell == Key!.ObjectCell && Game.KeyTaken == false)
body = "Key";
if (cell == FKey!.ObjectCell && Game.FKT == false)
body = "Key";
if (cell == goodGuy!.PlayerCell) {
switch (goodGuy.Name)
{
case "Joel":
body = "Jo ";
break;
case "Constantine":
body = "Co ";
break;
case "Alan Wake":
body = "AW ";
break;
}
}
if (cell == badGuy!.PlayerCell) {
switch (badGuy.Name)
{
case "Jason":
body = "Ja ";
break;
case "Freddy Krueger":
body = "FK ";
break;
case "Lucifer":
body = "Lu ";
break;
}
}
if (cell == Shelter!.ObjectCell)
body = "Ref";
if (cell == maze_exit!.ObjectCell)
body = "Sal";
top += body + east;
// Paredes inferiores de cada celda
string south = cell.IsLinked(cell.South!) ? " " : "---";
const string corner = " + ";
bottom += south + corner;
}
// Estructura del laberinto excepto el tope
output.AppendLine(top);
output.AppendLine(bottom);
}
Console.WriteLine(output);
}
public static void GameStatus() {
Table table = new Table();
table.Title = new TableTitle (text:"");
table.AddColumn("Jugadores");
table.AddColumn("Velocidad");
table.AddColumn("Tiempo de reposo de la habilidad");
table.AddColumn("Capturas restantes");
table.Columns[1].Alignment(Justify.Center);
table.Columns[2].Alignment(Justify.Center);
table.Columns[3].Alignment(Justify.Center);
string capture_left = Convert.ToString(goodGuy!.Life);
string stamina_bad = Convert.ToString(badGuy!.Turns);
string stamina_good = Convert.ToString(goodGuy!.Turns);
string cooldown_bad = Convert.ToString(badGuy.AbilityCooldown);
string cooldown_good = Convert.ToString(goodGuy.AbilityCooldown);
table.AddRow([badGuy!.Name, stamina_bad, cooldown_bad, capture_left]);
table.AddRow([goodGuy!.Name, stamina_good, cooldown_good]);
AnsiConsole.Write(table);
Console.WriteLine("Presione (esc) para pausar juego");
}
}