예제 #1
0
    // Start is called before the first frame update
    void Start()
    {
        SceneTerrainMgr instance = SceneTerrainMgr.Instance;

        /**
         *
         * 0 :路
         * 1 :障碍物
         * 2 :比较艰难的路
         */
        m_Grides = new int[] {
            0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
            0, 1, 1, 1, 0, 1, 0, 1, 1, 0,
            0, 0, 0, 1, 0, 1, 0, 1, 0, 0,
            1, 1, 0, 1, 0, 1, 0, 1, 0, 0,
            0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
            0, 1, 0, 1, 0, 1, 0, 1, 1, 0,
            0, 0, 0, 1, 0, 1, 0, 1, 1, 1,
            1, 1, 1, 1, 0, 1, 0, 0, 0, 0,
            0, 0, 0, 1, 0, 1, 1, 1, 1, 0,
            0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
        };

        MapFlag[] grids = new MapFlag[m_Grides.Length];
        for (int i = 0; i < m_Grides.Length; i++)
        {
            int v = m_Grides[i];
            switch (v)
            {
            case 0:
                grids[i] = MapFlag.walkable;
                break;

            case 1:
                grids[i] = MapFlag.unwalkable;
                break;

            case 2:
                grids[i] = MapFlag.shadow;
                break;
            }
        }

        m_MapData = new IMapInfo()
        {
            gridCols = 10,
            gridRows = 10,
            grids    = grids
        };

        instance.InitMap(m_MapData);
        findPath(0, 5, 9, 5);
    }
예제 #2
0
 public static MapFlag ConvertMapFlag(int i)
 {
     return(MapFlag.GetMapFlag(i));
 }