Reset() public method

public Reset ( EpPathFinding.cs.GridPos iStartPos, EpPathFinding.cs.GridPos iEndPos, BaseGrid iSearchGrid = null ) : void
iStartPos EpPathFinding.cs.GridPos
iEndPos EpPathFinding.cs.GridPos
iSearchGrid BaseGrid
return void
Example #1
0
 public List<Vector2> Ruta_a(Punt2d origen, Punt2d final)
 {
     var jpParam = new JumpPointParam(mapa_pa_sala, false, false, false, HeuristicMode.MANHATTAN);
     //jpParam.Reset(new GridPos(0,14), new GridPos(0,12));
     jpParam.Reset(new GridPos(origen.X, origen.Y), new GridPos(final.X, final.Y));
     //Debug.Log(Vector_Grid(origen).x+" "+Vector_Grid(origen).y+"origen");
     var ruta_a = JumpPointFinder.FindPath(jpParam);
     var ruta_a_tra = new List<Vector2>();
     foreach (var cosa in ruta_a)
     {
         //Debug.Log(cosa.x+" "+cosa.y);
         ruta_a_tra.Add(Grid_Vector(cosa));
     }
     //Debug.Log(ruta_a_tra.Count + " Hola");
     return ruta_a_tra;
 }  
Example #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            for (int resultTrav = 0; resultTrav < m_resultLine.Count; resultTrav++)
            {
                m_resultLine[resultTrav].Dispose();
            }
            m_resultLine.Clear();
            for (int resultTrav = 0; resultTrav < m_resultBox.Count; resultTrav++)
            {
                m_resultBox[resultTrav].Dispose();
            }
            m_resultBox.Clear();

            GridPos startPos = new GridPos();
            GridPos endPos   = new GridPos();

            for (int widthTrav = 0; widthTrav < width; widthTrav++)
            {
                for (int heightTrav = 0; heightTrav < height; heightTrav++)
                {
                    if (m_rectangles[widthTrav][heightTrav].boxType != BoxType.Wall)
                    {
                        searchGrid.SetWalkableAt(new GridPos(widthTrav, heightTrav), true);
                    }
                    else
                    {
                        searchGrid.SetWalkableAt(new GridPos(widthTrav, heightTrav), false);
                    }
                    if (m_rectangles[widthTrav][heightTrav].boxType == BoxType.Start)
                    {
                        startPos.x = widthTrav;
                        startPos.y = heightTrav;
                    }
                    if (m_rectangles[widthTrav][heightTrav].boxType == BoxType.End)
                    {
                        endPos.x = widthTrav;
                        endPos.y = heightTrav;
                    }
                }
            }
            jumpParam.CrossCorner        = cbCrossCorners.Checked;
            jumpParam.CrossAdjacentPoint = cbCrossAdjacentPoint.Checked;
            jumpParam.UseRecursive       = cbUseRecursive.Checked;
            jumpParam.Reset(startPos, endPos);
            List <GridPos> resultList = JumpPointFinder.FindPath(jumpParam);


            for (int resultTrav = 0; resultTrav < resultList.Count - 1; resultTrav++)
            {
                m_resultLine.Add(new GridLine(m_rectangles[resultList[resultTrav].x][resultList[resultTrav].y], m_rectangles[resultList[resultTrav + 1].x][resultList[resultTrav + 1].y]));
            }
            for (int widthTrav = 0; widthTrav < jumpParam.SearchGrid.width; widthTrav++)
            {
                for (int heightTrav = 0; heightTrav < jumpParam.SearchGrid.height; heightTrav++)
                {
                    if (jumpParam.SearchGrid.GetNodeAt(widthTrav, heightTrav) == null)
                    {
                        continue;
                    }
                    if (jumpParam.SearchGrid.GetNodeAt(widthTrav, heightTrav).isOpened)
                    {
                        ResultBox resultBox = new ResultBox(widthTrav * 20, heightTrav * 20 + 50, ResultBoxType.Opened);
                        m_resultBox.Add(resultBox);
                    }
                    if (jumpParam.SearchGrid.GetNodeAt(widthTrav, heightTrav).isClosed)
                    {
                        ResultBox resultBox = new ResultBox(widthTrav * 20, heightTrav * 20 + 50, ResultBoxType.Closed);
                        m_resultBox.Add(resultBox);
                    }
                }
            }
            this.Invalidate();
        }