/ Ficha.cs
Ficha.cs
 1  using System;
 2  using System.Collections.Generic;
 3  using System.Linq;
 4  using System.Runtime.CompilerServices;
 5  using System.Text;
 6  using System.Threading.Tasks;
 7  
 8  namespace Laberinto
 9  {
10      public class Ficha
11      {
12          public int[] Posicion;
13  
14          public Ficha(int x, int y)
15          { Posicion = new int[] { x, y }; }
16  
17          public void MoverFicha(ConsoleKeyInfo tecla, Juego tab)
18          {
19              switch (tecla.Key)
20              {
21                  case ConsoleKey.UpArrow:
22                      if (!tab.Tablero[this.Posicion[0] - 1, this.Posicion[1]].colisionable)
23                          this.Posicion[0]--;
24                      break;
25  
26                  case ConsoleKey.DownArrow:
27                      if (!tab.Tablero[this.Posicion[0] + 1, this.Posicion[1]].colisionable)
28                          this.Posicion[0]++;
29                      break;
30  
31                  case ConsoleKey.LeftArrow:
32                      if (!tab.Tablero[this.Posicion[0], this.Posicion[1] - 1].colisionable)
33                          this.Posicion[1]--;
34                      break;
35  
36                  case ConsoleKey.RightArrow:
37                      if (!tab.Tablero[this.Posicion[0], this.Posicion[1] + 1].colisionable)
38                          this.Posicion[1]++;
39                      break;
40  
41  
42                  default:
43                      break;
44  
45              }
46          }
47  
48          public bool CheckVictoria(Juego tab)
49          {
50              return (Posicion[0] == 0 || Posicion[1] == 0 || Posicion[0] == tab.Tablero.GetLength(0) - 1 || Posicion[1] == tab.Tablero.GetLength(1) - 1) ? true : false;
51          }
52      }
53  
54  }