diff --git a/DungeonShooting_Godot/prefab/ui/BottomTips.tscn b/DungeonShooting_Godot/prefab/ui/BottomTips.tscn new file mode 100644 index 0000000..64914ab --- /dev/null +++ b/DungeonShooting_Godot/prefab/ui/BottomTips.tscn @@ -0,0 +1,66 @@ +[gd_scene load_steps=4 format=3 uid="uid://dxmjm1pgctyid"] + +[ext_resource type="Script" path="res://src/game/ui/bottomTips/BottomTipsPanel.cs" id="1_c63vs"] +[ext_resource type="Texture2D" uid="uid://bls55gj8h3mgv" path="res://resource/sprite/prop/buff/Buff0001.png" id="2_gaykt"] + +[sub_resource type="LabelSettings" id="LabelSettings_xtn1u"] +font_size = 32 + +[node name="BottomTips" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +script = ExtResource("1_c63vs") + +[node name="Panel" type="PanelContainer" 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 = -78.5 +offset_top = -93.0 +offset_right = 78.5 +offset_bottom = -9.0 +grow_horizontal = 2 +grow_vertical = 0 +mouse_filter = 2 + +[node name="MarginContainer" type="MarginContainer" parent="Panel"] +layout_mode = 2 +size_flags_vertical = 8 +mouse_filter = 2 +theme_override_constants/margin_left = 30 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 30 +theme_override_constants/margin_bottom = 10 + +[node name="CenterContainer" type="CenterContainer" parent="Panel/MarginContainer"] +layout_mode = 2 +mouse_filter = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="Panel/MarginContainer/CenterContainer"] +layout_mode = 2 +size_flags_vertical = 4 +mouse_filter = 2 +theme_override_constants/separation = 9 + +[node name="AspectRatioContainer" type="AspectRatioContainer" parent="Panel/MarginContainer/CenterContainer/HBoxContainer"] +custom_minimum_size = Vector2(64, 64) +layout_mode = 2 + +[node name="TextureRect" type="TextureRect" parent="Panel/MarginContainer/CenterContainer/HBoxContainer/AspectRatioContainer"] +custom_minimum_size = Vector2(16, 16) +layout_mode = 2 +mouse_filter = 2 +texture = ExtResource("2_gaykt") + +[node name="Label" type="Label" parent="Panel/MarginContainer/CenterContainer/HBoxContainer"] +layout_mode = 2 +text = "0" +label_settings = SubResource("LabelSettings_xtn1u") +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/DungeonShooting_Godot/prefab/ui/RoomUI.tscn b/DungeonShooting_Godot/prefab/ui/RoomUI.tscn index 1ed0ec7..a2cfd75 100644 --- a/DungeonShooting_Godot/prefab/ui/RoomUI.tscn +++ b/DungeonShooting_Godot/prefab/ui/RoomUI.tscn @@ -26,8 +26,6 @@ grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_tfcrp") -metadata/_edit_vertical_guides_ = [960.0] -metadata/_edit_horizontal_guides_ = [552.0] [node name="InteractiveTipBar" type="Control" parent="."] anchors_preset = 0 diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 3a0dd7b..e5bbc63 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -31,6 +31,9 @@ public const string prefab_prop_buff_Buff0005_tscn = "res://prefab/prop/buff/Buff0005.tscn"; public const string prefab_prop_buff_Buff0006_tscn = "res://prefab/prop/buff/Buff0006.tscn"; public const string prefab_prop_buff_Buff0007_tscn = "res://prefab/prop/buff/Buff0007.tscn"; + public const string prefab_prop_buff_Buff0008_tscn = "res://prefab/prop/buff/Buff0008.tscn"; + public const string prefab_prop_buff_Buff0009_tscn = "res://prefab/prop/buff/Buff0009.tscn"; + public const string prefab_prop_buff_Buff0010_tscn = "res://prefab/prop/buff/Buff0010.tscn"; public const string prefab_role_Enemy0001_tscn = "res://prefab/role/Enemy0001.tscn"; public const string prefab_role_Role0001_tscn = "res://prefab/role/Role0001.tscn"; public const string prefab_role_RoleTemplate_tscn = "res://prefab/role/RoleTemplate.tscn"; @@ -39,6 +42,7 @@ public const string prefab_shell_Shell0003_tscn = "res://prefab/shell/Shell0003.tscn"; public const string prefab_test_MoveComponent_tscn = "res://prefab/test/MoveComponent.tscn"; public const string prefab_test_TestActivity_tscn = "res://prefab/test/TestActivity.tscn"; + public const string prefab_ui_BottomTips_tscn = "res://prefab/ui/BottomTips.tscn"; public const string prefab_ui_EditorTools_tscn = "res://prefab/ui/EditorTools.tscn"; public const string prefab_ui_Loading_tscn = "res://prefab/ui/Loading.tscn"; public const string prefab_ui_Main_tscn = "res://prefab/ui/Main.tscn"; @@ -129,6 +133,9 @@ public const string resource_sprite_prop_buff_Buff0005_png = "res://resource/sprite/prop/buff/Buff0005.png"; public const string resource_sprite_prop_buff_Buff0006_png = "res://resource/sprite/prop/buff/Buff0006.png"; public const string resource_sprite_prop_buff_Buff0007_png = "res://resource/sprite/prop/buff/Buff0007.png"; + public const string resource_sprite_prop_buff_Buff0008_png = "res://resource/sprite/prop/buff/Buff0008.png"; + public const string resource_sprite_prop_buff_Buff0009_png = "res://resource/sprite/prop/buff/Buff0009.png"; + public const string resource_sprite_prop_buff_Buff0010_png = "res://resource/sprite/prop/buff/Buff0010.png"; public const string resource_sprite_role_role10_png = "res://resource/sprite/role/role10.png"; public const string resource_sprite_role_role2_png = "res://resource/sprite/role/role2.png"; public const string resource_sprite_role_role3_png = "res://resource/sprite/role/role3.png"; @@ -194,6 +201,9 @@ public const string resource_spriteFrames_prop_buff_Buff0005_tres = "res://resource/spriteFrames/prop/buff/Buff0005.tres"; public const string resource_spriteFrames_prop_buff_Buff0006_tres = "res://resource/spriteFrames/prop/buff/Buff0006.tres"; public const string resource_spriteFrames_prop_buff_Buff0007_tres = "res://resource/spriteFrames/prop/buff/Buff0007.tres"; + public const string resource_spriteFrames_prop_buff_Buff0008_tres = "res://resource/spriteFrames/prop/buff/Buff0008.tres"; + public const string resource_spriteFrames_prop_buff_Buff0009_tres = "res://resource/spriteFrames/prop/buff/Buff0009.tres"; + public const string resource_spriteFrames_prop_buff_Buff0010_tres = "res://resource/spriteFrames/prop/buff/Buff0010.tres"; public const string resource_spriteFrames_role_Role0001_tres = "res://resource/spriteFrames/role/Role0001.tres"; public const string resource_spriteFrames_role_Role1001_tres = "res://resource/spriteFrames/role/Role1001.tres"; public const string resource_spriteFrames_shell_Shell0001_tres = "res://resource/spriteFrames/shell/Shell0001.tres"; diff --git a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs index 431fc32..2576d6a 100644 --- a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs +++ b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs @@ -6,6 +6,7 @@ public static class UiName { + public const string BottomTips = "BottomTips"; public const string EditorTools = "EditorTools"; public const string Loading = "Loading"; public const string Main = "Main"; @@ -14,6 +15,46 @@ } /// + /// 打开 BottomTips, 并返回UI实例 + /// + public static UI.BottomTips.BottomTipsPanel Open_BottomTips() + { + return OpenUi(UiName.BottomTips); + } + + /// + /// 隐藏 BottomTips 的所有实例 + /// + public static void Hide_BottomTips() + { + var uiInstance = Get_BottomTips_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.HideUi(); + } + } + + /// + /// 销毁 BottomTips 的所有实例 + /// + public static void Dispose_BottomTips() + { + var uiInstance = Get_BottomTips_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.DisposeUi(); + } + } + + /// + /// 获取所有 BottomTips 的实例, 如果没有实例, 则返回一个空数组 + /// + public static UI.BottomTips.BottomTipsPanel[] Get_BottomTips_Instance() + { + return GetUiInstance(nameof(UI.BottomTips.BottomTips)); + } + + /// /// 打开 EditorTools, 并返回UI实例 /// public static UI.EditorTools.EditorToolsPanel Open_EditorTools() diff --git a/DungeonShooting_Godot/src/game/ui/bottomTips/BottomTips.cs b/DungeonShooting_Godot/src/game/ui/bottomTips/BottomTips.cs new file mode 100644 index 0000000..f406a8c --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/bottomTips/BottomTips.cs @@ -0,0 +1,167 @@ +namespace UI.BottomTips; + +/// +/// Ui代码, 该类是根据ui场景自动生成的, 请不要手动编辑该类, 以免造成代码丢失 +/// +public abstract partial class BottomTips : UiBase +{ + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: BottomTips.Panel + /// + public UiNode_Panel L_Panel + { + get + { + if (_L_Panel == null) _L_Panel = new UiNode_Panel(GetNodeOrNull("Panel")); + return _L_Panel; + } + } + private UiNode_Panel _L_Panel; + + + public BottomTips() : base(nameof(BottomTips)) + { + } + + /// + /// 类型: , 路径: BottomTips.Panel.MarginContainer.CenterContainer.HBoxContainer.AspectRatioContainer.TextureRect + /// + public class UiNode_TextureRect : IUiNode + { + public UiNode_TextureRect(Godot.TextureRect node) : base(node) { } + public override UiNode_TextureRect Clone() => new ((Godot.TextureRect)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: BottomTips.Panel.MarginContainer.CenterContainer.HBoxContainer.AspectRatioContainer + /// + public class UiNode_AspectRatioContainer : IUiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: BottomTips.Panel.MarginContainer.CenterContainer.HBoxContainer.TextureRect + /// + public UiNode_TextureRect L_TextureRect + { + get + { + if (_L_TextureRect == null) _L_TextureRect = new UiNode_TextureRect(Instance.GetNodeOrNull("TextureRect")); + return _L_TextureRect; + } + } + private UiNode_TextureRect _L_TextureRect; + + public UiNode_AspectRatioContainer(Godot.AspectRatioContainer node) : base(node) { } + public override UiNode_AspectRatioContainer Clone() => new ((Godot.AspectRatioContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: BottomTips.Panel.MarginContainer.CenterContainer.HBoxContainer.Label + /// + public class UiNode_Label : IUiNode + { + public UiNode_Label(Godot.Label node) : base(node) { } + public override UiNode_Label Clone() => new ((Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: BottomTips.Panel.MarginContainer.CenterContainer.HBoxContainer + /// + public class UiNode_HBoxContainer : IUiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: BottomTips.Panel.MarginContainer.CenterContainer.AspectRatioContainer + /// + public UiNode_AspectRatioContainer L_AspectRatioContainer + { + get + { + if (_L_AspectRatioContainer == null) _L_AspectRatioContainer = new UiNode_AspectRatioContainer(Instance.GetNodeOrNull("AspectRatioContainer")); + return _L_AspectRatioContainer; + } + } + private UiNode_AspectRatioContainer _L_AspectRatioContainer; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: BottomTips.Panel.MarginContainer.CenterContainer.Label + /// + public UiNode_Label L_Label + { + get + { + if (_L_Label == null) _L_Label = new UiNode_Label(Instance.GetNodeOrNull("Label")); + return _L_Label; + } + } + private UiNode_Label _L_Label; + + public UiNode_HBoxContainer(Godot.HBoxContainer node) : base(node) { } + public override UiNode_HBoxContainer Clone() => new ((Godot.HBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: BottomTips.Panel.MarginContainer.CenterContainer + /// + public class UiNode_CenterContainer : IUiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: BottomTips.Panel.MarginContainer.HBoxContainer + /// + public UiNode_HBoxContainer L_HBoxContainer + { + get + { + if (_L_HBoxContainer == null) _L_HBoxContainer = new UiNode_HBoxContainer(Instance.GetNodeOrNull("HBoxContainer")); + return _L_HBoxContainer; + } + } + private UiNode_HBoxContainer _L_HBoxContainer; + + public UiNode_CenterContainer(Godot.CenterContainer node) : base(node) { } + public override UiNode_CenterContainer Clone() => new ((Godot.CenterContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: BottomTips.Panel.MarginContainer + /// + public class UiNode_MarginContainer : IUiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: BottomTips.Panel.CenterContainer + /// + public UiNode_CenterContainer L_CenterContainer + { + get + { + if (_L_CenterContainer == null) _L_CenterContainer = new UiNode_CenterContainer(Instance.GetNodeOrNull("CenterContainer")); + return _L_CenterContainer; + } + } + private UiNode_CenterContainer _L_CenterContainer; + + public UiNode_MarginContainer(Godot.MarginContainer node) : base(node) { } + public override UiNode_MarginContainer Clone() => new ((Godot.MarginContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: BottomTips.Panel + /// + public class UiNode_Panel : IUiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: BottomTips.MarginContainer + /// + public UiNode_MarginContainer L_MarginContainer + { + get + { + if (_L_MarginContainer == null) _L_MarginContainer = new UiNode_MarginContainer(Instance.GetNodeOrNull("MarginContainer")); + return _L_MarginContainer; + } + } + private UiNode_MarginContainer _L_MarginContainer; + + public UiNode_Panel(Godot.PanelContainer node) : base(node) { } + public override UiNode_Panel Clone() => new ((Godot.PanelContainer)Instance.Duplicate()); + } + +} diff --git a/DungeonShooting_Godot/src/game/ui/bottomTips/BottomTipsPanel.cs b/DungeonShooting_Godot/src/game/ui/bottomTips/BottomTipsPanel.cs new file mode 100644 index 0000000..13c6010 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/bottomTips/BottomTipsPanel.cs @@ -0,0 +1,34 @@ +using Godot; + +namespace UI.BottomTips; + +public partial class BottomTipsPanel : BottomTips +{ + public override void OnCreateUi() + { + L_Panel.Instance.Resized += OnPanelResized; + } + + public override void OnShowUi() + { + L_Panel.L_MarginContainer.L_CenterContainer.L_HBoxContainer.L_Label.Instance.Text = "提示内容"; + } + + public override void OnHideUi() + { + + } + + public override void OnDisposeUi() + { + L_Panel.Instance.Resized += OnPanelResized; + } + + private void OnPanelResized() + { + var pivotOffset = L_Panel.Instance.PivotOffset; + pivotOffset.X = L_Panel.Instance.Size.X / 2; + L_Panel.Instance.PivotOffset = pivotOffset; + } + +} diff --git a/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs b/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs index 0c0b36b..14e04e6 100644 --- a/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs @@ -9,6 +9,8 @@ { L_ButtonList.L_Start.Instance.Pressed += OnStartGameClick; L_ButtonList.L_Exit.Instance.Pressed += OnExitClick; + + UiManager.Open_BottomTips(); } public override void OnHideUi()