Ejemplo n.º 1
0
        private bool CheckAroundAvail(Coords mc) // TODO: Rewrite to linked cell
        {
            if (mc.X > 0)
            {
                if (!CompleteMaze[mc.X - 1, mc.Y, mc.Z].Visited)
                {
                    return(true);
                }
            }
            if (mc.Y > 0)
            {
                if (!CompleteMaze[mc.X, mc.Y - 1, mc.Z].Visited)
                {
                    return(true);
                }
            }
            if (mc.Z > 0)
            {
                if (!CompleteMaze[mc.X, mc.Y, mc.Z - 1].Visited)
                {
                    return(true);
                }
            }
            if (mc.X < CompleteMaze.GetLength(0) - 1)
            {
                if (!CompleteMaze[mc.X + 1, mc.Y, mc.Z].Visited)
                {
                    return(true);
                }
            }
            if (mc.Y < CompleteMaze.GetLength(1) - 1)
            {
                if (!CompleteMaze[mc.X, mc.Y + 1, mc.Z].Visited)
                {
                    return(true);
                }
            }
            if (mc.Z < CompleteMaze.GetLength(2) - 1)
            {
                if (!CompleteMaze[mc.X, mc.Y, mc.Z + 1].Visited)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
 private void TryToUnstuck(IList <MazeCell> mList, MazeCell currentCell, int index)
 {
     if (mList.Count == 1) // Temp check for tricky params when maze generation being corrupted
     {
         var first = mList.First();
         if (CheckAroundAvail(first))
         {
             if (first.Z < CompleteMaze.GetLength(2) - 1)
             {
                 if (!CompleteMaze[first.X, first.Y, first.Z + 1].Visited)
                 {
                     currentCell.Down = true;
                     var nextCell = CompleteMaze[currentCell.X, currentCell.Y, currentCell.Z + 1];
                     nextCell.DistanceFromStart = currentCell.DistanceFromStart + 1;
                     mList.Add(nextCell);
                     nextCell.Visited = true;
                 }
             }
             else if (first.Z > 0)
             {
                 if (!CompleteMaze[first.X, first.Y, first.Z - 1].Visited)
                 {
                     var nextCell = CompleteMaze[currentCell.X, currentCell.Y, currentCell.Z - 1];
                     nextCell.Down = true;
                     nextCell.DistanceFromStart = currentCell.DistanceFromStart + 1;
                     mList.Add(nextCell);
                     nextCell.Visited = true;
                 }
             }
         }
         else
         {
             RemoveCellFromListAndMarkAsDone(mList[index], mList);
         }
     }
     else
     {
         RemoveCellFromListAndMarkAsDone(mList[index], mList);
     }
 }