Exemple #1
0
 //搜尋可以走的區塊並加入資料
 public void CanGo(int x, int y, int times)//原始座標x,y剩餘次數
 {
     //超出範圍
     if (x < 0 || y < 0 || x > 16 || y > 9)
     {
         return;
     }
     //剩餘步數大於0
     if (times-- > 0)
     {
         if ((_mapData.getWall(x, y) | UP) == UP)
         {
             // if (!_mapData.isExistCanMoveArea(new Point(x, y - 1)))
             // {
             _mapData.setCanMoveArea(new Point(x, y - 1));
             CanGo(x, y - 1, times);
             //Debug.Log("GO X = " + x + "Y = " + (y - 1) + "times = " + times + " UP");
             // }
         }
         if ((_mapData.getWall(x, y) | RIGHT) == RIGHT)
         {
             //if (!_mapData.isExistCanMoveArea(new Point(x + 1, y)))
             //{
             _mapData.setCanMoveArea(new Point(x + 1, y));
             CanGo(x + 1, y, times);
             //Debug.Log("GO X = " + (x + 1) + "Y = " + y + "times = " + times + " RIGHT");
             //}
         }
         if ((_mapData.getWall(x, y) | DOWN) == DOWN)
         {
             // if (!_mapData.isExistCanMoveArea(new Point(x, y + 1)))
             //{
             _mapData.setCanMoveArea(new Point(x, y + 1));
             CanGo(x, y + 1, times);
             //Debug.Log("GO X = " + x + "Y = " + (y + 1) + "times = " + times + " DOWN");
             //}
         }
         if ((_mapData.getWall(x, y) | LEFT) == LEFT)
         {
             //if (!_mapData.isExistCanMoveArea(new Point(x - 1, y)))
             //{
             _mapData.setCanMoveArea(new Point(x - 1, y));
             CanGo(x - 1, y, times);
             //Debug.Log("GO X = " + (x - 1) + "Y = " + y + "times = " + times + " LEFT");
             //}
         }
     }
     return;
 }