-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHabilidad.cs
More file actions
163 lines (146 loc) · 5.47 KB
/
Copy pathHabilidad.cs
File metadata and controls
163 lines (146 loc) · 5.47 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Spectre.Console;
namespace MazeRunners
{
public abstract class Habilidad
{
public abstract void UseSkill(Jugador jugador, List<Jugador> jugadores, Casilla[,] maze);
public string? Name { get; set; }
public bool IsBlock(int x, int y, Casilla[,] maze)
{
return x>=0 && x<maze.GetLength(0) && y>=0 && y<maze.GetLength(1);
}
}
public class EliminarTrampa : Habilidad
{
public EliminarTrampa()
{
Name = "Eliminar Trampa";
}
public override void UseSkill(Jugador jugador, List<Jugador> jugadores, Casilla[,] maze)
{
AnsiConsole.Markup("[blue] Usando habilidad: Eliminar Trampas.[/]\n");
var dir = new List<(int x,int y)> { (0,1), (1,0), (0,-1), (-1,0) };
foreach (var(dx,dy) in dir)
{
for (int i = 0; i <= 3; i++)
{
int x = jugador.Posicion.x + dx * i;
int y = jugador.Posicion.y + dy * i;
if (IsBlock(x, y, maze) && maze[x,y] is Trampa)
{
AnsiConsole.Markup($"[red] Eliminando trampa en la posicion ({x}, {y})[/]\n");
maze[x, y] = new Camino((x,y));
}
else
{
AnsiConsole.Markup("[red] No se encontro ninguna trampa[/]");
}
}
}
jugador.Cooldown = 3;
}
}
public class AturdirTodos : Habilidad
{
public AturdirTodos()
{
Name = "Aturdir a todos";
}
public override void UseSkill(Jugador jugador, List<Jugador> jugadores, Casilla[,] maze)
{
AnsiConsole.Markup("[blue] Usando habilidad: Aturdir a todos los jugadores.[/]\n");
foreach (var j in jugadores)
{
if (j != jugador)
{
j.Status = "Stunned";
}
}
jugador.Cooldown = 3;
}
}
public class DuplicarVelocidad : Habilidad
{
public DuplicarVelocidad()
{
Name = "Duplicar Velocidad";
}
public override void UseSkill(Jugador jugador, List<Jugador> jugadores, Casilla[,] maze)
{
AnsiConsole.Markup("[blue] Usando habilidad: Duplicar velocidad.[/]\n");
jugador.Speed*= 2;
jugador.Cooldown = 3;
}
}
public class Teleport : Habilidad
{
public Teleport()
{
Name = "Teleport";
}
public override void UseSkill(Jugador jugador, List<Jugador> jugadores, Casilla[,] maze)
{
Random rand = new Random();
var currentPos = jugadores.Select(j => j.Posicion).ToList();
int newX, newY;
do
{
newX = rand.Next(1, maze.GetLength(0) - 2);
newY = rand.Next(1, maze.GetLength(1) - 2);
}
while (!IsBlock(newX, newY, maze));
if (!currentPos.Contains((newX,newY)))
{
jugador.Posicion = (newX,newY);
}
else
{
UseSkill(jugador,jugadores,maze);
}
AnsiConsole.Markup($"[blue] Usando habilidad: Transportandose a la casilla {(newX,newY)}.[/]\n");
jugador.Cooldown = 3;
}
}
public class BreakWalls: Habilidad
{
public BreakWalls()
{
Name = "Romper Muro";
}
public override void UseSkill(Jugador jugador, List<Jugador> jugadores, Casilla[,] maze)
{
List<(int x,int y)> dir = new List<(int,int)> {(-1,0), (0,1), (1,0), (0,-1)};
var key = Console.ReadKey(true).Key;
switch (key)
{
case ConsoleKey.W:
RomperMuros(jugador, dir[0], maze);
break;
case ConsoleKey.S:
RomperMuros(jugador, dir[2], maze);
break;
case ConsoleKey.A:
RomperMuros(jugador, dir[3], maze);
break;
case ConsoleKey.D:
RomperMuros(jugador, dir[2], maze);
break;
}
}
public void RomperMuros(Jugador jugador, (int x, int y) direction, Casilla[,] maze)
{
int newX = jugador.Posicion.Item1 + direction.Item1;
int newY = jugador.Posicion.Item2 + direction.Item2;
if (IsBlock(newX,newY, maze) && maze[newX,newY] is Muro)
{
maze[newX,newY] = new Camino((newX,newY));
Console.WriteLine($"Rompiendo muro en la posición ({newX}, {newY})");
}
}
public bool IsBlock(int x, int y, Casilla[,] maze) => x > 0 && x < maze.GetLength(0) && y > 0 && y < maze.GetLength(1);
}
}