Beispiel #1
0
 private static void InitializeMaze(MazeCell[,] mazeArray)
 {
     foreach (var mazeCell in mazeArray)
     {
         if (mazeCell.Character == 'm')
         {
             EntryCell   = mazeCell;
             CurrentCell = EntryCell;
         }
         if (mazeCell.Character == 'e')
         {
             if (ExitCells.Contains(mazeCell) == false)
             {
                 ExitCells.Enqueue(mazeCell);
             }
         }
         if (mazeCell.Character == '0' || mazeCell.Character == 'm')
         {
             mazeCell.IsVisited = false;
         }
         else
         {
             mazeCell.IsVisited = true;
         }
     }
 }
Beispiel #2
0
 public static List <MazeCell> GetShortestPath(MazeCell[,] mazeArray)
 {
     StoredMazeArray      = new MazeCell[mazeArray.GetLength(0), mazeArray.GetLength(1)];
     StoredMazeToBeShowed = new MazeCell[MazeToBeShowed.GetLength(0), MazeToBeShowed.GetLength(1)];
     CopyMaze(StoredMazeArray, mazeArray);
     ExitCell = ExitCells.Dequeue();
     mazeArray[ExitCell.Y, ExitCell.X].IsVisited = false;
     CurrentCell = EntryCell;
     MazePath    = FindShortestPath(EntryCell, ExitCell, CurrentCell, MazeQueue, mazeArray);
     return(MazePath);
 }
Beispiel #3
0
        public bool DrawCurrentMap(PictureBox pictureBox, bool isCombatMap, bool showAllCells, CellInfo.FieldNames SelectedInfo)
        {
            if (mapMngr.MapData == null)
            {
                return(false);
            }
            g.Clear(Color.CadetBlue);
            g.SmoothingMode = SmoothingMode.HighQuality;
            Debug.Assert(mapMngr.MapData.Cells.Count == 560);
            int x = 0;
            int y = 0;

            //P.x = cellId % MAP_WIDTH + (cellId / MAP_WIDTH)/2
            //P.y = cellId % MAP_WIDTH - (cellId / MAP_WIDTH)/2
            for (int j = 0; j <= 39; j++)
            {
                for (int i = 0; i <= 13; i++)
                {
                    x = i * 64 + 32;
                    if ((j & 1) == 1)
                    {
                        x += 32;
                    }
                    int cellId = j * 14 + i;
                    y = j * 18 + 18;
                    Color couleur = cells[cellId].color;
                    Point center  = new Point(x, y);
                    //couleur = Color.Chartreuse;
                    if ((/*!isCombatMap && */ !cells[cellId].isWalkable) || (isCombatMap && !cells[cellId].isCombatWalkable))
                    {
                        couleur = Color.Black;
                    }
                    if (PathFindingDone)
                    {
                        //if (mapMngr.CellsInfos[cellId].isInPath1)
                        // couleur = Color.Blue;
                        //if ((cellId == StartingCell) || (cellId == ExitCell))
                        //  couleur = Color.LightBlue;
                    }
                    if (mapMngr.CellsInfos[cellId].drawable || showAllCells)
                    {
                        DrawPolygon(center, couleur, cells[cellId].isInPath1, cells[cellId].isInPath2, (cellId == StartingCell), (cellId == ExitCell), StartingCells != null && StartingCells.Contains(cellId), ExitCells != null && ExitCells.Contains(cellId));
                        if (SelectedInfo != CellInfo.FieldNames.Nothing)
                        {
                            center = new Point(center.X - 10, center.Y - 7);

                            g.DrawString(cells[cellId].getValue(SelectedInfo), Control.DefaultFont, Brushes.AliceBlue, center);
                        }
                        //g.DrawString(CellsInfos[cellId].speed.ToString(), Font, Brushes.AliceBlue, center);
                    }
                }
            }
            //mise en picturebox
            //pictureBox.Invalidate();
            pictureBox.Image = (Image)b.Clone();
            return(true);
        }