Пример #1
0
        //执行寻路
        private (SeekPathCom SeekPathCom, List <Vector2Int> Path) ExcuteFindPath(SeekPathCom seekPathCom, MapData mapData)
        {
            List <Vector2Int> path = null;

            if (seekPathCom.CanFly)
            {
                path = AstarHelp.FindPath(seekPathCom.CurrPos, seekPathCom.TargetPos, mapData.ObstaclePos);
            }
            else
            {
                path = AstarHelp.FindPath(seekPathCom.CurrPos, seekPathCom.TargetPos, mapData.ObstaclePos, mapData.RoadPos);
            }
            return(seekPathCom, path);
        }
Пример #2
0
        private void OnGUI()
        {
            EDLayout.CreateVertical("box", position.width, position.height, () => {
                SelMap    = (MapData)EditorGUILayout.ObjectField(SelMap, typeof(MapData), true);
                CurPos    = (Vector2Int)EditorGUILayout.Vector2IntField("当前位置", CurPos);
                TargetPos = (Vector2Int)EditorGUILayout.Vector2IntField("目标位置", TargetPos);

                EDButton.CreateBtn("寻路", 100, 50, () => {
                    //Debug.LogWarningFormat("寻路({0},{1} ==> ({2},{3}))",CurPos.x,CurPos.y,TargetPos.x,TargetPos.y);
                    Path = AstarHelp.FindPath(CurPos, TargetPos, SelMap.ObstaclePos);
                    //Debug.LogWarningFormat("找到 {0} 路径点",Path.Count);
                });


                EDButton.CreateBtn("道路寻路", 100, 50, () => {
                    //Debug.LogWarningFormat("道路寻路({0},{1} ==> ({2},{3}))",CurPos.x,CurPos.y,TargetPos.x,TargetPos.y);
                    Path = AstarHelp.FindPath(CurPos, TargetPos, SelMap.ObstaclePos, SelMap.RoadPos);
                    //Debug.LogWarningFormat("找到 {0} 路径点",Path.Count);
                });

                EditorGUILayout.Space();

                if (SelMap != null)
                {
                    for (int y = TempConfig.MapSizeY - 1; y >= 0; y--)
                    {
                        EDLayout.CreateHorizontal("box", BoxSize * TempConfig.MapSizeY, BoxSize, () => {
                            for (int x = 0; x < TempConfig.MapSizeX; x++)
                            {
                                // Color showColor = GetShowTextColor(x,y);
                                // GUI.color=showColor;
                                // string pos=string.Format("{0},{1}",x,y);
                                Texture showImg = GetBoxShowImg(x, y);
                                GUILayout.Box(new GUIContent(showImg), GUILayout.Height(BoxSize), GUILayout.Width(BoxSize));
                            }
                        });
                    }
                }
            });
        }