map.cs

来自「A .NET Path Finder Library Path Finder 」· CS 代码 · 共 40 行

CS
40
字号
using System;

namespace HenizeSoftware
{
  namespace PathFinding
  {
    class Map
    {
      bool[,] map;

      public Map(ushort x, ushort y)
      {
        map = new bool[x, y];
      }

      public Map(ushort x, ushort y, Coordinate[] unwalkableNodes)
        : this(x, y)
      {
        if (unwalkableNodes == null)
          return;
        foreach (Coordinate c in unwalkableNodes)
        {
          map[c.X, c.Y] = true;
        }
      }

      public bool this[ushort x, ushort y]
      {
        get 
        { 
          return (!(x >= 0 && x <= map.GetUpperBound(0) && y >= 0 && y <= map.GetUpperBound(1)) || map[x, y]); 
        }
        set
        {
          map[x, y] = value;
        }
      }
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?