diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index 51b8a45..1a97425 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -1,4 +1,4 @@ - + net6.0 true diff --git a/DungeonShooting_Godot/prefab/ui/Main.tscn b/DungeonShooting_Godot/prefab/ui/Main.tscn index 6bae01b..fa4657f 100644 --- a/DungeonShooting_Godot/prefab/ui/Main.tscn +++ b/DungeonShooting_Godot/prefab/ui/Main.tscn @@ -21,33 +21,28 @@ grow_vertical = 2 color = Color(0.109804, 0.0666667, 0.0901961, 1) -[node name="Title" type="Label" parent="."] +[node name="VBoxContainer" type="VBoxContainer" parent="."] layout_mode = 1 -anchors_preset = 10 +anchors_preset = 15 anchor_right = 1.0 -offset_top = 172.0 -offset_bottom = 405.0 +anchor_bottom = 1.0 grow_horizontal = 2 +grow_vertical = 2 + +[node name="Title" type="Label" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 6 theme_override_font_sizes/font_size = 160 text = "Program dungeon" horizontal_alignment = 1 vertical_alignment = 1 -[node name="ButtonList" type="VBoxContainer" parent="."] -layout_mode = 1 -anchors_preset = 7 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -96.0 -offset_top = -641.0 -offset_right = 96.0 -grow_horizontal = 2 -grow_vertical = 0 +[node name="ButtonList" type="VBoxContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 alignment = 1 -[node name="Start" type="Button" parent="ButtonList"] +[node name="Start" type="Button" parent="VBoxContainer/ButtonList"] custom_minimum_size = Vector2(0, 50) layout_mode = 2 focus_neighbor_top = NodePath("../Exit") @@ -56,7 +51,7 @@ text = "开始游戏 " -[node name="Tools" type="Button" parent="ButtonList"] +[node name="Tools" type="Button" parent="VBoxContainer/ButtonList"] custom_minimum_size = Vector2(0, 50) layout_mode = 2 focus_neighbor_top = NodePath("../Start") @@ -65,7 +60,7 @@ theme_override_font_sizes/font_size = 32 text = "开发者工具" -[node name="Setting" type="Button" parent="ButtonList"] +[node name="Setting" type="Button" parent="VBoxContainer/ButtonList"] custom_minimum_size = Vector2(0, 50) layout_mode = 2 focus_neighbor_top = NodePath("../Start") @@ -74,7 +69,7 @@ theme_override_font_sizes/font_size = 32 text = "设置" -[node name="Exit" type="Button" parent="ButtonList"] +[node name="Exit" type="Button" parent="VBoxContainer/ButtonList"] custom_minimum_size = Vector2(0, 50) layout_mode = 2 focus_neighbor_top = NodePath("../Setting") diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot index c36c7b6..39d86eb 100644 --- a/DungeonShooting_Godot/project.godot +++ b/DungeonShooting_Godot/project.godot @@ -21,8 +21,8 @@ [display] -window/size/viewport_width=1920 -window/size/viewport_height=1080 +window/size/viewport_width=1280 +window/size/viewport_height=720 window/stretch/aspect="keep_width" window/vsync/use_vsync=false diff --git a/DungeonShooting_Godot/scene/Main.tscn b/DungeonShooting_Godot/scene/Main.tscn index b034a25..9eb9dd5 100644 --- a/DungeonShooting_Godot/scene/Main.tscn +++ b/DungeonShooting_Godot/scene/Main.tscn @@ -40,7 +40,7 @@ [node name="SubViewport" type="SubViewport" parent="ViewCanvas/SubViewportContainer"] handle_input_locally = false canvas_item_default_texture_filter = 0 -size = Vector2i(480, 270) +size = Vector2i(320, 180) render_target_update_mode = 4 [node name="SceneRoot" type="Node2D" parent="ViewCanvas/SubViewportContainer/SubViewport"] diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index f66b1d9..34e9761 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -96,7 +96,7 @@ DungeonConfig = new DungeonConfig(); DungeonConfig.GroupName = RoomConfig.FirstOrDefault().Key; - DungeonConfig.RoomCount = 0; + DungeonConfig.RoomCount = 10; } public override void _EnterTree() @@ -110,12 +110,14 @@ //调试绘制开关 ActivityObject.IsDebug = Debug; //Engine.TimeScale = 0.2f; - - ImageCanvas.Init(GetTree().CurrentScene); + //调整窗口分辨率 + OnWindowSizeChanged(); + RefreshSubViewportSize(); //窗体大小改变 GetWindow().SizeChanged += OnWindowSizeChanged; - RefreshSubViewportSize(); + + ImageCanvas.Init(GetTree().CurrentScene); //初始化ui UiManager.Init(); diff --git a/DungeonShooting_Godot/src/game/ui/main/Main.cs b/DungeonShooting_Godot/src/game/ui/main/Main.cs index 3db6d93..779be78 100644 --- a/DungeonShooting_Godot/src/game/ui/main/Main.cs +++ b/DungeonShooting_Godot/src/game/ui/main/Main.cs @@ -19,30 +19,17 @@ private ColorRect _L_ColorRect; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.Title + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.VBoxContainer /// - public Title L_Title + public VBoxContainer L_VBoxContainer { get { - if (_L_Title == null) _L_Title = new Title((MainPanel)this, GetNode("Title")); - return _L_Title; + if (_L_VBoxContainer == null) _L_VBoxContainer = new VBoxContainer((MainPanel)this, GetNode("VBoxContainer")); + return _L_VBoxContainer; } } - private Title _L_Title; - - /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.ButtonList - /// - public ButtonList L_ButtonList - { - get - { - if (_L_ButtonList == null) _L_ButtonList = new ButtonList((MainPanel)this, GetNode("ButtonList")); - return _L_ButtonList; - } - } - private ButtonList _L_ButtonList; + private VBoxContainer _L_VBoxContainer; /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.Version @@ -77,7 +64,7 @@ } /// - /// 类型: , 路径: Main.Title + /// 类型: , 路径: Main.VBoxContainer.Title /// public class Title : UiNode { @@ -86,7 +73,7 @@ } /// - /// 类型: , 路径: Main.ButtonList.Start + /// 类型: , 路径: Main.VBoxContainer.ButtonList.Start /// public class Start : UiNode { @@ -95,7 +82,7 @@ } /// - /// 类型: , 路径: Main.ButtonList.Tools + /// 类型: , 路径: Main.VBoxContainer.ButtonList.Tools /// public class Tools : UiNode { @@ -104,7 +91,7 @@ } /// - /// 类型: , 路径: Main.ButtonList.Setting + /// 类型: , 路径: Main.VBoxContainer.ButtonList.Setting /// public class Setting : UiNode { @@ -113,7 +100,7 @@ } /// - /// 类型: , 路径: Main.ButtonList.Exit + /// 类型: , 路径: Main.VBoxContainer.ButtonList.Exit /// public class Exit : UiNode { @@ -122,12 +109,12 @@ } /// - /// 类型: , 路径: Main.ButtonList + /// 类型: , 路径: Main.VBoxContainer.ButtonList /// public class ButtonList : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.Start + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.VBoxContainer.Start /// public Start L_Start { @@ -140,7 +127,7 @@ private Start _L_Start; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.Tools + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.VBoxContainer.Tools /// public Tools L_Tools { @@ -153,7 +140,7 @@ private Tools _L_Tools; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.Setting + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.VBoxContainer.Setting /// public Setting L_Setting { @@ -166,7 +153,7 @@ private Setting _L_Setting; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.Exit + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.VBoxContainer.Exit /// public Exit L_Exit { @@ -183,6 +170,41 @@ } /// + /// 类型: , 路径: Main.VBoxContainer + /// + public class VBoxContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.Title + /// + public Title L_Title + { + get + { + if (_L_Title == null) _L_Title = new Title(UiPanel, Instance.GetNode("Title")); + return _L_Title; + } + } + private Title _L_Title; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Main.ButtonList + /// + public ButtonList L_ButtonList + { + get + { + if (_L_ButtonList == null) _L_ButtonList = new ButtonList(UiPanel, Instance.GetNode("ButtonList")); + return _L_ButtonList; + } + } + private ButtonList _L_ButtonList; + + public VBoxContainer(MainPanel uiPanel, Godot.VBoxContainer node) : base(uiPanel, node) { } + public override VBoxContainer Clone() => new (UiPanel, (Godot.VBoxContainer)Instance.Duplicate()); + } + + /// /// 类型: , 路径: Main.Version /// public class Version : UiNode @@ -198,34 +220,39 @@ public ColorRect S_ColorRect => L_ColorRect; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.Title + /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.VBoxContainer.Title /// - public Title S_Title => L_Title; + public Title S_Title => L_VBoxContainer.L_Title; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.ButtonList.Start + /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.VBoxContainer.ButtonList.Start /// - public Start S_Start => L_ButtonList.L_Start; + public Start S_Start => L_VBoxContainer.L_ButtonList.L_Start; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.ButtonList.Tools + /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.VBoxContainer.ButtonList.Tools /// - public Tools S_Tools => L_ButtonList.L_Tools; + public Tools S_Tools => L_VBoxContainer.L_ButtonList.L_Tools; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.ButtonList.Setting + /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.VBoxContainer.ButtonList.Setting /// - public Setting S_Setting => L_ButtonList.L_Setting; + public Setting S_Setting => L_VBoxContainer.L_ButtonList.L_Setting; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.ButtonList.Exit + /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.VBoxContainer.ButtonList.Exit /// - public Exit S_Exit => L_ButtonList.L_Exit; + public Exit S_Exit => L_VBoxContainer.L_ButtonList.L_Exit; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.ButtonList + /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.VBoxContainer.ButtonList /// - public ButtonList S_ButtonList => L_ButtonList; + public ButtonList S_ButtonList => L_VBoxContainer.L_ButtonList; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.VBoxContainer + /// + public VBoxContainer S_VBoxContainer => L_VBoxContainer; /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: Main.Version