diff --git a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json index 836925a..284191c 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json @@ -9,8 +9,22 @@ "PreinstallPath": "resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json" } ], - "InletList": [], - "OutletList": [], + "InletList": [ + { + "Ready": true, + "RoomPath": "resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_roomInfo.json", + "TilePath": "resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_tileInfo.json", + "PreinstallPath": "resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_preinstall.json" + } + ], + "OutletList": [ + { + "Ready": true, + "RoomPath": "resource/map/tileMaps/TestGroup1/outlet/End1/End1_roomInfo.json", + "TilePath": "resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json", + "PreinstallPath": "resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json" + } + ], "BossList": [], "RewardList": [], "ShopList": [], diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_preinstall.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_preinstall.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_roomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_roomInfo.json new file mode 100644 index 0000000..7fcc776 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_roomInfo.json @@ -0,0 +1 @@ +{"Position":{"X":-3,"Y":-4},"Size":{"X":10,"Y":10},"DoorAreaInfos":[{"Direction":3,"Start":0,"End":128},{"Direction":0,"Start":0,"End":128},{"Direction":2,"Start":0,"End":128},{"Direction":1,"Start":0,"End":128}],"GroupName":"TestGroup1","RoomType":1,"RoomName":"Start1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_tileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_tileInfo.json new file mode 100644 index 0000000..bfb8380 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_tileInfo.json @@ -0,0 +1 @@ +{"NavigationList":[{"Type":0,"Points":[-24,-40,88,-40,88,80,-24,80]}],"Floor":[5,4,0,0,8,5,3,0,0,8,5,2,0,0,8,5,1,0,0,8,5,0,0,0,8,5,-1,0,0,8,5,-2,0,0,8,5,-3,0,0,8,4,4,0,0,8,4,3,0,0,8,4,2,0,0,8,4,1,0,0,8,4,0,0,0,8,4,-1,0,0,8,4,-2,0,0,8,4,-3,0,0,8,3,4,0,0,8,3,3,0,0,8,3,2,0,0,8,3,1,0,0,8,3,0,0,0,8,3,-1,0,0,8,3,-2,0,0,8,3,-3,0,0,8,2,4,0,0,8,2,3,0,0,8,2,2,0,0,8,2,1,0,0,8,2,0,0,0,8,2,-1,0,0,8,2,-2,0,0,8,2,-3,0,0,8,1,4,0,0,8,1,3,0,0,8,1,2,0,0,8,1,1,0,0,8,1,0,0,0,8,1,-1,0,0,8,1,-2,0,0,8,1,-3,0,0,8,0,4,0,0,8,0,3,0,0,8,0,2,0,0,8,0,1,0,0,8,0,0,0,0,8,0,-1,0,0,8,0,-2,0,0,8,0,-3,0,0,8,-1,4,0,0,8,-1,3,0,0,8,-1,2,0,0,8,-1,1,0,0,8,-1,0,0,0,8,-1,-1,0,0,8,-1,-2,0,0,8,-1,-3,0,0,8,-2,4,0,0,8,-2,3,0,0,8,-2,2,0,0,8,-2,1,0,0,8,-2,0,0,0,8,-2,-1,0,0,8,-2,-2,0,0,8,-2,-3,0,0,8],"Middle":[-2,-4,0,2,7,-1,-4,0,2,7,0,-4,0,2,7,1,-4,0,2,7,2,-4,0,2,7,3,-4,0,2,7,4,-4,0,2,7,5,-4,0,2,7],"Top":[-3,-4,0,3,4,-3,-3,0,3,3,-3,-2,0,3,3,-3,-1,0,3,3,-3,0,0,3,3,-3,1,0,3,3,-3,2,0,3,3,-3,3,0,3,3,-3,4,0,3,3,-3,5,0,11,2,-2,5,0,2,2,-1,5,0,2,2,0,5,0,2,2,1,5,0,2,2,2,5,0,2,2,3,5,0,2,2,4,5,0,2,2,5,5,0,2,2,6,-4,0,1,4,6,-3,0,1,3,6,-2,0,1,3,6,-1,0,1,3,6,0,0,1,3,6,1,0,1,3,6,2,0,1,3,6,3,0,1,3,6,4,0,1,3,6,5,0,13,2]} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_roomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_roomInfo.json new file mode 100644 index 0000000..d1770b2 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_roomInfo.json @@ -0,0 +1 @@ +{"Position":{"X":-5,"Y":-6},"Size":{"X":13,"Y":11},"DoorAreaInfos":[{"Direction":3,"Start":0,"End":176},{"Direction":0,"Start":0,"End":144},{"Direction":2,"Start":0,"End":176},{"Direction":1,"Start":0,"End":144}],"GroupName":"TestGroup1","RoomType":2,"RoomName":"End1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json new file mode 100644 index 0000000..34d5dc3 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json @@ -0,0 +1 @@ +{"NavigationList":[{"Type":0,"Points":[-56,-72,104,-72,104,64,-56,64]}],"Floor":[6,3,0,0,8,6,2,0,0,8,6,1,0,0,8,6,0,0,0,8,6,-1,0,0,8,6,-2,0,0,8,6,-3,0,0,8,6,-4,0,0,8,6,-5,0,0,8,5,3,0,0,8,5,2,0,0,8,5,1,0,0,8,5,0,0,0,8,5,-1,0,0,8,5,-2,0,0,8,5,-3,0,0,8,5,-4,0,0,8,5,-5,0,0,8,4,3,0,0,8,4,2,0,0,8,4,1,0,0,8,4,0,0,0,8,4,-1,0,0,8,4,-2,0,0,8,4,-3,0,0,8,4,-4,0,0,8,4,-5,0,0,8,3,3,0,0,8,3,2,0,0,8,3,1,0,0,8,3,0,0,0,8,3,-1,0,0,8,3,-2,0,0,8,3,-3,0,0,8,3,-4,0,0,8,3,-5,0,0,8,2,3,0,0,8,2,2,0,0,8,2,1,0,0,8,2,0,0,0,8,2,-1,0,0,8,2,-2,0,0,8,2,-3,0,0,8,2,-4,0,0,8,2,-5,0,0,8,1,3,0,0,8,1,2,0,0,8,1,1,0,0,8,1,0,0,0,8,1,-1,0,0,8,1,-2,0,0,8,1,-3,0,0,8,1,-4,0,0,8,1,-5,0,0,8,0,3,0,0,8,0,2,0,0,8,0,1,0,0,8,0,0,0,0,8,0,-1,0,0,8,0,-2,0,0,8,0,-3,0,0,8,0,-4,0,0,8,0,-5,0,0,8,-1,3,0,0,8,-1,2,0,0,8,-1,1,0,0,8,-1,0,0,0,8,-1,-1,0,0,8,-1,-2,0,0,8,-1,-3,0,0,8,-1,-4,0,0,8,-1,-5,0,0,8,-2,3,0,0,8,-2,2,0,0,8,-2,1,0,0,8,-2,0,0,0,8,-2,-1,0,0,8,-2,-2,0,0,8,-2,-3,0,0,8,-2,-4,0,0,8,-2,-5,0,0,8,-3,3,0,0,8,-3,2,0,0,8,-3,1,0,0,8,-3,0,0,0,8,-3,-1,0,0,8,-3,-2,0,0,8,-3,-3,0,0,8,-3,-4,0,0,8,-3,-5,0,0,8,-4,3,0,0,8,-4,2,0,0,8,-4,1,0,0,8,-4,0,0,0,8,-4,-1,0,0,8,-4,-2,0,0,8,-4,-3,0,0,8,-4,-4,0,0,8,-4,-5,0,0,8],"Middle":[-4,-6,0,2,7,-3,-6,0,2,7,-2,-6,0,2,7,-1,-6,0,2,7,0,-6,0,2,7,1,-6,0,2,7,2,-6,0,2,7,3,-6,0,2,7,4,-6,0,2,7,5,-6,0,2,7,6,-6,0,2,7],"Top":[-5,-6,0,3,4,-5,-5,0,3,3,-5,-4,0,3,3,-5,-3,0,3,3,-5,-2,0,3,3,-5,-1,0,3,3,-5,0,0,3,3,-5,1,0,3,3,-5,2,0,3,3,-5,3,0,3,3,-5,4,0,11,2,-4,4,0,2,2,-3,4,0,2,2,-2,4,0,2,2,-1,4,0,2,2,0,4,0,2,2,1,4,0,2,2,2,4,0,2,2,3,4,0,2,2,4,4,0,2,2,5,4,0,2,2,6,4,0,2,2,7,-6,0,1,4,7,-5,0,1,3,7,-4,0,1,3,7,-3,0,1,3,7,-2,0,1,3,7,-1,0,1,3,7,0,0,1,3,7,1,0,1,3,7,2,0,1,3,7,3,0,1,3,7,4,0,13,2]} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs index 34a938f..4fded36 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs @@ -72,12 +72,46 @@ } else { + var rectSize = roomInfo.RoomSplit.RoomInfo.Size; + var rectPos = roomInfo.RoomSplit.RoomInfo.Position; + var offset = roomInfo.GetOffsetPosition() / GameConfig.TileCellSizeVector2I; + //填充tile操作 + var tileInfo = roomInfo.RoomSplit.TileInfo; + for (var i = 0; i < tileInfo.Floor.Count; i += 5) + { + var posX = tileInfo.Floor[i]; + var posY = tileInfo.Floor[i + 1]; + var sourceId = tileInfo.Floor[i + 2]; + var atlasCoordsX = tileInfo.Floor[i + 3]; + var atlasCoordsY = tileInfo.Floor[i + 4]; + var pos = new Vector2I(roomInfo.Position.X + posX - offset.X, roomInfo.Position.Y + posY - offset.Y); + _tileRoot.SetCell(GameConfig.FloorMapLayer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); + } + for (var i = 0; i < tileInfo.Middle.Count; i += 5) + { + var posX = tileInfo.Middle[i]; + var posY = tileInfo.Middle[i + 1]; + var sourceId = tileInfo.Middle[i + 2]; + var atlasCoordsX = tileInfo.Middle[i + 3]; + var atlasCoordsY = tileInfo.Middle[i + 4]; + var pos = new Vector2I(roomInfo.Position.X + posX - offset.X, roomInfo.Position.Y + posY - offset.Y); + _tileRoot.SetCell(GameConfig.MiddleMapLayer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); + } + for (var i = 0; i < tileInfo.Top.Count; i += 5) + { + var posX = tileInfo.Top[i]; + var posY = tileInfo.Top[i + 1]; + var sourceId = tileInfo.Top[i + 2]; + var atlasCoordsX = tileInfo.Top[i + 3]; + var atlasCoordsY = tileInfo.Top[i + 4]; + var pos = new Vector2I(roomInfo.Position.X + posX - offset.X, roomInfo.Position.Y + posY - offset.Y); + _tileRoot.SetCell(GameConfig.TopMapLayer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); + } + GD.PrintErr("初始化流程得改"); - // var rectSize = roomInfo.RoomSplit.RoomInfo.Size; - // var rectPos = roomInfo.RoomSplit.RoomInfo.Position; + //roomInfo.RoomSplit.TileInfo. // var template = ResourceManager.Load(roomInfo.RoomSplit.ScenePath); // var tileInstance = template.Instantiate(); - // var offset = roomInfo.GetOffsetPosition(); // // //其它物体 // var childCount = tileInstance.GetChildCount(); @@ -597,17 +631,6 @@ _connectNavigationItemList.Add(new DoorNavigationInfo(doorInfo, openPolygonData, closePolygonData)); } - - //报错数据 - // private void TestData() - // { - // _polygonDataList.Clear(); - // _polygonDataList.Add(new NavigationPolygonData(){Type = NavigationPolygonType.Out, Points = new List(new []{ new Vector2(-456, 712), new Vector2(-440, 712), new Vector2(-440, 792), new Vector2(-456, 792) })}); - // _polygonDataList.Add(new NavigationPolygonData(){Type = NavigationPolygonType.In, Points = new List(new []{ new Vector2(-1048, 744), new Vector2(-840, 744), new Vector2(-840, 840), new Vector2(-1048, 840) })}); - // _polygonDataList.Add(new NavigationPolygonData(){Type = NavigationPolygonType.Out, Points = new List(new []{ new Vector2(488, 920), new Vector2(504, 920), new Vector2(504, 1128), new Vector2(488, 1128) })}); - // _polygonDataList.Add(new NavigationPolygonData(){Type = NavigationPolygonType.Out, Points = new List(new []{ new Vector2(1320, 984), new Vector2(1352, 984), new Vector2(1352, 1096), new Vector2(1432, 1096), new Vector2(1432, 984), new Vector2(1576, 984), new Vector2(1576, 1128), new Vector2(1544, 1128), new Vector2(1544, 1000), new Vector2(1464, 1000), new Vector2(1464, 1128), new Vector2(1320, 1128) })}); - // _polygonDataList.Add(new NavigationPolygonData(){Type = NavigationPolygonType.Out, Points = new List(new []{ new Vector2(712, 1432), new Vector2(984, 1432), new Vector2(984, 1592), new Vector2(712, 1592) })}); - // } /// /// 计算并动生成导航区域, layer 为需要计算的层级,如果没有设置 floorAtlasCoords,则该 layer 下不为空的地砖都将视为可行走区域 diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index 955b4d8..a4f50ce 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using Config; using Godot; @@ -38,12 +39,6 @@ [Export] public bool Debug = false; /// - /// 测试用, 指定生成的房间 - /// - [Export] - public PackedScene[] DesignatedRoom; - - /// /// 鼠标指针 /// public Cursor Cursor { get; private set; } @@ -63,10 +58,10 @@ /// public Dictionary RoomConfig { get; private set; } - /// - /// 房间配置数据, key: 模板房间资源路径 - /// - public Dictionary RoomConfigMap { get; private set; } + // /// + // /// 房间配置数据, key: 模板房间资源路径 + // /// + // public Dictionary RoomConfigMap { get; private set; } /// /// 游戏视图大小 @@ -100,7 +95,7 @@ Weapon.InitWeaponAttribute(); DungeonConfig = new DungeonConfig(); - DungeonConfig.GroupName = "testGroup"; + DungeonConfig.GroupName = RoomConfig.FirstOrDefault().Key; DungeonConfig.RoomCount = 20; } @@ -119,10 +114,7 @@ //窗体大小改变 GetWindow().SizeChanged += OnWindowSizeChanged; RefreshSubViewportSize(); - -#if TOOLS - InitDesignatedRoom(); -#endif + //初始化ui UiManager.Init(); // 初始化鼠标 @@ -135,10 +127,8 @@ MapProjectManager.Init(); BottomTipsPanel.Init(); //打开主菜单Ui - //UiManager.Open_Main(); - //UiManager.Open_MapEditor(); - UiManager.Open_MapEditorProject(); - //EditorWindowManager.ShowSelectObject("选择物体"); + UiManager.Open_Main(); + //UiManager.Open_MapEditorProject(); } public override void _Process(double delta) @@ -225,7 +215,7 @@ RoomConfig = JsonSerializer.Deserialize>(asText); //初始化RoomConfigMap - RoomConfigMap = new Dictionary(); + //RoomConfigMap = new Dictionary(); //加载流程更改 // foreach (var dungeonRoomGroup in RoomConfig) // { @@ -292,24 +282,4 @@ } } } - -#if TOOLS - //调试模式下, 指定生成哪些房间 - private void InitDesignatedRoom() - { - if (DesignatedRoom != null && DesignatedRoom.Length > 0) - { - var list = new List(); - foreach (var packedScene in DesignatedRoom) - { - if (RoomConfigMap.TryGetValue(packedScene.ResourcePath, out var dungeonRoomSplit)) - { - list.Add(dungeonRoomSplit); - } - } - DungeonGenerator.SetDesignatedRoom(list); - } - } -#endif - } diff --git a/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs b/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs index 36a7493..4e49eab 100644 --- a/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs @@ -31,7 +31,6 @@ //点击开发者工具 private void OnToolsClick() { - UiManager.Open_MapEditorProject(); - HideUi(); + OpenNextUi(UiManager.UiName.MapEditorProject); } } diff --git a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs index f8c5fd6..80a007d 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs @@ -587,10 +587,6 @@ Scale = scale; SetMapPosition(Position + pos * 0.1f * scale); } - else - { - GD.Print("太小了"); - } } //放大 private void Magnify() @@ -603,10 +599,6 @@ Scale = scale; SetMapPosition(Position - pos * 0.1f * prevScale); } - else - { - GD.Print("太大了"); - } } //绘制单个自动贴图