示例#1
0
 //crea la matriz de estados de casillas a partir del mundo
 public void CrearMatriz(Mundo m)
 {
     estadosCasillas = new MyPathNode[columnas, filas];
     for (int x = 0; x < columnas; x++)
     {
         for (int y = 0; y < filas; y++)
         {
             Point   p   = new Point(x, y);
             Casilla cas = (Casilla)m.tableLayoutPanel1.GetControlFromPosition(x, y);
             Casilla.EstadoCasilla edo = cas.GetEstadoCasilla();
             estadosCasillas[x, y] = new MyPathNode()
             {
                 coordenadas = p,
                 estado      = edo
             };
             if (edo == Casilla.EstadoCasilla.Activa)
             {
                 estadosCasillas[x, y].isWall = false;
             }
             else
             {
                 estadosCasillas[x, y].isWall = true;
             }
         }
     }
 }
示例#2
0
        //recibe unas coordenadas, pone un fantasmaC en su mundo y regresa el mismo Point
        public Point SetNewPhantom(Point p)
        {
            Casilla casilla = (Casilla)mundoReal.tableLayoutPanel1.GetControlFromPosition(p.X, p.Y);

            casilla.SetEstadoCasilla(Casilla.EstadoCasilla.FantasmaC);
            return(p);
        }
示例#3
0
 //constructor que llena el mundo con las casillas Activas
 public Mundo(int x, int y)
 {
     InitializeComponent();
     this.x = x;
     this.y = y;
     this.tableLayoutPanel1.Dock        = DockStyle.Fill;
     this.tableLayoutPanel1.ColumnCount = x;
     this.tableLayoutPanel1.RowCount    = y;
     this.tableLayoutPanel1.RowStyles.Clear();
     this.tableLayoutPanel1.ColumnStyles.Clear();
     this.tableLayoutPanel1.SuspendLayout();
     for (int i = 0; i < x; i++)
     {
         for (int j = 0; j < y; j++)
         {
             Casilla casilla = new Casilla(i, j);
             casilla.Dock = DockStyle.Fill;
             this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, (100 / y)));
             this.tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, (100 / x)));
             this.tableLayoutPanel1.Controls.Add(casilla, i, j);
             casilla.CanDrawCasilla += new CanDrawEventHandler(casilla_CanDrawCasilla);
         }
     }
     this.tableLayoutPanel1.ResumeLayout();
 }
示例#4
0
        //recibe un Point y verifica en mundoReal si se puede mover ahí
        public bool PossibleMove(Point p)
        {
            Casilla casilla = (Casilla)mundoReal.tableLayoutPanel1.GetControlFromPosition(p.X, p.Y);

            if (casilla.GetEstadoCasilla() == Casilla.EstadoCasilla.Obstaculo | casilla.GetEstadoCasilla() == Casilla.EstadoCasilla.FantasmaP | casilla.GetEstadoCasilla() == Casilla.EstadoCasilla.FantasmaC)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#5
0
 //Para dar un paso
 public void Avanzar()
 {
     if (pusoLaMeta)
     {
         if (!primerPaso)
         {
             ciego.SetUbicacion(posCiego);
             explorador.CaclPath(posCiego, posMeta);
             primerPaso = true;
         }
         if (primerPaso)
         {
             if (!noHaySalida)
             {
                 Point nextMove = explorador.nextMove();
                 nodos.Add("Player 1: " + nextMove.ToString());
                 if (ciego.PossibleMove(nextMove))
                 {
                     Casilla c = (Casilla)m.tableLayoutPanel1.GetControlFromPosition(ciego.GetUbicacion().X, ciego.GetUbicacion().Y);
                     c.SetEstadoCasilla(Casilla.EstadoCasilla.Activa);
                     ciego.SetUbicacion(nextMove);
                     posCiego = nextMove;
                     c        = (Casilla)m.tableLayoutPanel1.GetControlFromPosition(ciego.GetUbicacion().X, ciego.GetUbicacion().Y);
                     if (c.GetEstadoCasilla() == Casilla.EstadoCasilla.Meta)
                     {
                         c.SetEstadoCasilla(Casilla.EstadoCasilla.Finish);
                     }
                     else
                     {
                         c.SetEstadoCasilla(Casilla.EstadoCasilla.Ciego);
                     }
                 }
                 else
                 {
                     nodos.Add("Mario se encontró un Boo!");
                     explorador.SetNewPhantom(nextMove);
                     Casilla c = (Casilla)m.tableLayoutPanel1.GetControlFromPosition(nextMove.X, nextMove.Y);
                     c.SetEstadoCasilla(Casilla.EstadoCasilla.FantasmaC);
                     explorador.CaclPath(posCiego, posMeta);
                 }
             }
             else
             {
                 Casilla c = (Casilla)m.tableLayoutPanel1.GetControlFromPosition(ciego.GetUbicacion().X, ciego.GetUbicacion().Y);
                 c.SetEstadoCasilla(Casilla.EstadoCasilla.Estresado); //estresado
                 posCiego = posMeta;
             }
         }
     }
 }
示例#6
0
        //evento
        void casilla_CanDrawCasilla(object sender)
        {
            Casilla c = (Casilla)sender;

            if (!Form1.inicio & !Form1.primerPaso & !Form1.pusoAlCiego & !Form1.pusoLaMeta)
            {
                if (c.GetEstadoCasilla() == Casilla.EstadoCasilla.Activa)
                {
                    c.SetEstadoCasilla(Casilla.EstadoCasilla.Obstaculo);
                }
            }

            if (Form1.inicio & !Form1.primerPaso & !Form1.pusoAlCiego & !Form1.pusoLaMeta)
            {
                if (c.GetEstadoCasilla() == Casilla.EstadoCasilla.Activa)
                {
                    c.SetEstadoCasilla(Casilla.EstadoCasilla.Ciego);
                    Form1.pusoAlCiego = true;
                    Form1.posCiego    = c.GetUbicacion();
                }
            }

            if (Form1.inicio & !Form1.primerPaso & Form1.pusoAlCiego & !Form1.pusoLaMeta)
            {
                if (c.GetEstadoCasilla() == Casilla.EstadoCasilla.Activa)
                {
                    c.SetEstadoCasilla(Casilla.EstadoCasilla.Meta);
                    Form1.pusoLaMeta = true;
                    Form1.posMeta    = c.GetUbicacion();
                }
            }

            if (Form1.inicio & Form1.primerPaso & Form1.pusoAlCiego & Form1.pusoLaMeta)
            {
                if (c.GetEstadoCasilla() == Casilla.EstadoCasilla.Migajas || c.GetEstadoCasilla() == Casilla.EstadoCasilla.Activa)
                {
                    c.SetEstadoCasilla(Casilla.EstadoCasilla.FantasmaP);
                }
            }
        }