Beispiel #1
0
        //将自身坐标转换为父级场景坐标
        public AStarRange ToParentRange(AStarRange range, Scene toTopParentScene)
        {
            Vector2Int leftBottom =
                ToParentPos(new Vector2Int(range.leftBottomX, range.leftBottomY), toTopParentScene);
            Vector2Int rightTop = ToParentPos(new Vector2Int(range.rightTopX, range.rightTopY), toTopParentScene);

            return(new AStarRange(leftBottom, rightTop));
        }
Beispiel #2
0
 //将父级场景坐标转换为自身坐标
 public AStarRange FromParentRange(AStarRange range)
 {
     if (IsChildScene())
     {
         Vector2Int leftBottom = FromParentPos(new Vector2Int(range.leftBottomX, range.leftBottomY));
         Vector2Int rightTop   = FromParentPos(new Vector2Int(range.rightTopX, range.rightTopY));
         return(new AStarRange(leftBottom, rightTop));
     }
     else
     {
         return(range);
     }
 }
Beispiel #3
0
        //获得指定范围的物品(仅供父级场景调用)
        public Item[] GetRangeItems(AStarRange range, string belong = null, bool isNotIncludeChildScene = false)
        {
            List <Item> result = new List <Item>();
            var         items  = GetItems(null, belong, isNotIncludeChildScene);

            for (var i = 0; i < items.Length; i++)
            {
                var        item = items[i];
                Vector2Int pos  = item.GetEnv <Scene>().ToParentPos(item.GetPos(), this);
                if (range.IsInRange(pos))
                {
                    result.Add(item);
                }
            }

            return(result.ToArray());
        }
Beispiel #4
0
        //获得指定范围的子场景(仅供父级场景调用)
        public Scene[] GetRangeScenes(AStarRange range, string belong)
        {
            CheckParentCall();

            List <Scene> list   = new List <Scene>();
            var          scenes = GetChildScenes(null, belong);

            for (var i = 0; i < scenes.Length; i++)
            {
                Scene childScene = scenes[i];
                if (range.IsInRange(childScene.GetPos()))
                {
                    list.Add(childScene);
                }
            }

            return(list.ToArray());
        }
Beispiel #5
0
 public AStarRange(AStarRange range)
 {
     SetRange(range.leftBottomX, range.leftBottomY, range.rightTopX, range.rightTopY);
 }