Пример #1
0
        // 设置子场景投影障碍到主场景(仅供父级场景调用)
        public void SetProjectGrids(Vector2Int baseOnParentPos, Scene child_scene)
        {
            CheckParentCall();

            AStarMapPath mapPath = GetMapPath();

            if (mapPath == null || mapPath.grids == null)
            {
                return;
            }
            int[][] projectGrids;
            projectGrids = child_scene.GetMapType() == 1 ? child_scene.GetGrids() : child_scene.GetProjectGrids();
            if (projectGrids != null)
            {
                Vector2Int offsetPos = child_scene.GetOffsetPos();
                for (int x = 0; x < projectGrids.Length; x++)
                {
                    for (int y = 0; y < projectGrids[x].Length; y++)
                    {
                        int v = projectGrids[x][y];
                        if (v == 0 || !AStarUtil.IsValidObstacleType(v))                         // 子场景无效区域不投影
                        {
                            continue;
                        }
                        int px = ToParentX(baseOnParentPos, offsetPos, x);
                        int py = ToParentY(baseOnParentPos, offsetPos, y);
                        if (mapPath.IsValidPoint(px, py))                         // 父场景无效区域不投影
                        {
                            mapPath.projectGrids[px][py] = v;
                        }
                    }
                }
            }
        }
Пример #2
0
 //是否有效地图坐标(不含填充区域)
 public bool IsValidPoint(int x, int y)
 {
     if (!AStarUtil.IsInRange(grids, x, y))
     {
         return(false);
     }
     return(AStarUtil.IsValidObstacleType(grids[x][y]));
 }
Пример #3
0
 public static void Test_IsValidObstacleType()
 {
     LogCat.log(AStarUtil.IsValidObstacleType(255));
 }