diff --git a/DungeonShooting_Godot/src/framework/generator/UiGenerator.cs b/DungeonShooting_Godot/src/framework/generator/UiGenerator.cs index fd72026..ae12d23 100644 --- a/DungeonShooting_Godot/src/framework/generator/UiGenerator.cs +++ b/DungeonShooting_Godot/src/framework/generator/UiGenerator.cs @@ -1,30 +1,40 @@ using System.Collections.Generic; +using System.IO; using System.Text.RegularExpressions; using Godot; namespace Generator; +/// +/// Ui类生成器 +/// public static class UiGenerator { private static int _nodeIndex = 0; - public static void GenerateUi(Control control) + /// + /// 根据指定ui节点生成相应的Ui类, 并保存到指定路径下 + /// + public static void GenerateUi(Control control, string path) { _nodeIndex = 0; var uiNode = EachNode(control); var code = GenerateClassCode(uiNode); - GD.Print("code: \n" + code); + File.WriteAllText(path, code); } private static string GenerateClassCode(UiNode uiNode) { return $"namespace UI;\n\n" + - $"public abstract partial class {uiNode.Name} : UiBase\n" + + $"/// \n" + + $"/// Ui代码, 该类是根据ui场景自动生成的, 请不要手动编辑该类, 以免造成代码丢失\n" + + $"/// \n" + + $"public abstract partial class {uiNode.OriginName} : UiBase\n" + $"{{\n" + - GeneratePropertyListClassCode("", uiNode.Name + ".", uiNode, " ") + + GeneratePropertyListClassCode("", uiNode.OriginName + ".", uiNode, " ") + $"\n\n" + - GenerateAllChildrenClassCode(uiNode.Name + ".", uiNode, " ") + + GenerateAllChildrenClassCode(uiNode.OriginName + ".", uiNode, " ") + $"}}\n"; } @@ -36,7 +46,7 @@ for (var i = 0; i < uiNode.Children.Count; i++) { var item = uiNode.Children[i]; - str += GenerateAllChildrenClassCode(parent + item.Name + ".", item, retraction); + str += GenerateAllChildrenClassCode(parent + item.OriginName + ".", item, retraction); str += GenerateChildrenClassCode(parent, item, retraction); } } @@ -47,12 +57,12 @@ private static string GenerateChildrenClassCode(string parent, UiNode uiNode, string retraction) { return retraction + $"/// \n" + - retraction + $"/// 类型: , 路径: {parent}{uiNode.Name}\n" + + retraction + $"/// 类型: , 路径: {parent}{uiNode.OriginName}\n" + retraction + $"/// \n" + retraction + $"public class {uiNode.ClassName}\n" + retraction + $"{{\n" + retraction + $" /// \n" + - retraction + $" /// Ui节点实例, 节点类型: , 节点路径: {parent}{uiNode.Name}\n" + + retraction + $" /// Ui节点实例, 节点类型: , 节点路径: {parent}{uiNode.OriginName}\n" + retraction + $" /// \n" + retraction + $" public {uiNode.TypeName} Instance {{ get; }}\n\n" + GeneratePropertyListClassCode("Instance.", parent, uiNode, retraction + " ") + @@ -79,30 +89,30 @@ private static string GeneratePropertyCode(string target, string parent, UiNode uiNode, string retraction) { return retraction + $"/// \n" + - retraction + $"/// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: {parent}{uiNode.Name}\n" + + retraction + $"/// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: {parent}{uiNode.OriginName}\n" + retraction + $"/// \n" + retraction + $"public {uiNode.ClassName} {uiNode.Name}\n" + retraction + $"{{\n" + retraction + $" get\n" + retraction + $" {{\n" + - retraction + $" if (_{uiNode.Name} == null) _{uiNode.Name} = new {uiNode.ClassName}({target}GetNode<{uiNode.TypeName}>(\"{uiNode.Name}\"));\n" + + retraction + $" if (_{uiNode.Name} == null) _{uiNode.Name} = new {uiNode.ClassName}({target}GetNode<{uiNode.TypeName}>(\"{uiNode.OriginName}\"));\n" + retraction + $" return _{uiNode.Name};\n" + retraction + $" }}\n" + retraction + $"}}\n" + retraction + $"private {uiNode.ClassName} _{uiNode.Name};\n\n"; } - private static UiNode EachNode(Control control) + private static UiNode EachNode(Node node) { - var name = Regex.Replace(control.Name, "[^\\w_]", ""); - var uiNode = new UiNode(name, "UiNode" + (_nodeIndex++) + "_" + name, control.GetType().FullName); + var name = Regex.Replace(node.Name, "[^\\w_]", ""); + var uiNode = new UiNode("L_" + name, name, "UiNode" + (_nodeIndex++) + "_" + name, node.GetType().FullName); - var childCount = control.GetChildCount(); + var childCount = node.GetChildCount(); if (childCount > 0) { for (var i = 0; i < childCount; i++) { - var children = control.GetChildOrNull(i); + var children = node.GetChild(i); if (children != null) { if (uiNode.Children == null) @@ -121,13 +131,15 @@ private class UiNode { public string Name; + public string OriginName; public string ClassName; public string TypeName; public List Children; - public UiNode(string name, string className, string typeName) + public UiNode(string name, string originName, string className, string typeName) { Name = name; + OriginName = originName; ClassName = className; TypeName = typeName; } diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUI.cs b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUI.cs index 0a9ac2e..405aa65 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUI.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUI.cs @@ -1,19 +1,61 @@ namespace UI; +/// +/// Ui代码, 该类是根据ui场景自动生成的, 请不要手动编辑该类, 以免造成代码丢失 +/// public abstract partial class RoomUI : UiBase { /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control /// - public UiNode1_Control Control + public UiNode1_Control L_Control { get { - if (_Control == null) _Control = new UiNode1_Control(GetNode("Control")); - return _Control; + if (_L_Control == null) _L_Control = new UiNode1_Control(GetNode("Control")); + return _L_Control; } } - private UiNode1_Control _Control; + private UiNode1_Control _L_Control; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.GlobalNode + /// + public UiNode11_GlobalNode L_GlobalNode + { + get + { + if (_L_GlobalNode == null) _L_GlobalNode = new UiNode11_GlobalNode(GetNode("GlobalNode")); + return _L_GlobalNode; + } + } + private UiNode11_GlobalNode _L_GlobalNode; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.ViewNode + /// + public UiNode12_ViewNode L_ViewNode + { + get + { + if (_L_ViewNode == null) _L_ViewNode = new UiNode12_ViewNode(GetNode("ViewNode")); + return _L_ViewNode; + } + } + private UiNode12_ViewNode _L_ViewNode; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Cursor + /// + public UiNode20_Cursor L_Cursor + { + get + { + if (_L_Cursor == null) _L_Cursor = new UiNode20_Cursor(GetNode("Cursor")); + return _L_Cursor; + } + } + private UiNode20_Cursor _L_Cursor; @@ -44,15 +86,15 @@ /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.HealthBar.HpBar /// - public UiNode4_HpBar HpBar + public UiNode4_HpBar L_HpBar { get { - if (_HpBar == null) _HpBar = new UiNode4_HpBar(Instance.GetNode("HpBar")); - return _HpBar; + if (_L_HpBar == null) _L_HpBar = new UiNode4_HpBar(Instance.GetNode("HpBar")); + return _L_HpBar; } } - private UiNode4_HpBar _HpBar; + private UiNode4_HpBar _L_HpBar; public UiNode3_HpSlot(Godot.NinePatchRect node) => Instance = node; public UiNode3_HpSlot Clone() => new ((Godot.NinePatchRect)Instance.Duplicate()); @@ -85,15 +127,15 @@ /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.HealthBar.ShieldBar /// - public UiNode6_ShieldBar ShieldBar + public UiNode6_ShieldBar L_ShieldBar { get { - if (_ShieldBar == null) _ShieldBar = new UiNode6_ShieldBar(Instance.GetNode("ShieldBar")); - return _ShieldBar; + if (_L_ShieldBar == null) _L_ShieldBar = new UiNode6_ShieldBar(Instance.GetNode("ShieldBar")); + return _L_ShieldBar; } } - private UiNode6_ShieldBar _ShieldBar; + private UiNode6_ShieldBar _L_ShieldBar; public UiNode5_ShieldSlot(Godot.NinePatchRect node) => Instance = node; public UiNode5_ShieldSlot Clone() => new ((Godot.NinePatchRect)Instance.Duplicate()); @@ -112,28 +154,28 @@ /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.HpSlot /// - public UiNode3_HpSlot HpSlot + public UiNode3_HpSlot L_HpSlot { get { - if (_HpSlot == null) _HpSlot = new UiNode3_HpSlot(Instance.GetNode("HpSlot")); - return _HpSlot; + if (_L_HpSlot == null) _L_HpSlot = new UiNode3_HpSlot(Instance.GetNode("HpSlot")); + return _L_HpSlot; } } - private UiNode3_HpSlot _HpSlot; + private UiNode3_HpSlot _L_HpSlot; /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.ShieldSlot /// - public UiNode5_ShieldSlot ShieldSlot + public UiNode5_ShieldSlot L_ShieldSlot { get { - if (_ShieldSlot == null) _ShieldSlot = new UiNode5_ShieldSlot(Instance.GetNode("ShieldSlot")); - return _ShieldSlot; + if (_L_ShieldSlot == null) _L_ShieldSlot = new UiNode5_ShieldSlot(Instance.GetNode("ShieldSlot")); + return _L_ShieldSlot; } } - private UiNode5_ShieldSlot _ShieldSlot; + private UiNode5_ShieldSlot _L_ShieldSlot; public UiNode2_HealthBar(Godot.TextureRect node) => Instance = node; public UiNode2_HealthBar Clone() => new ((Godot.TextureRect)Instance.Duplicate()); @@ -194,28 +236,28 @@ /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.GunSprite /// - public UiNode9_GunSprite GunSprite + public UiNode9_GunSprite L_GunSprite { get { - if (_GunSprite == null) _GunSprite = new UiNode9_GunSprite(Instance.GetNode("GunSprite")); - return _GunSprite; + if (_L_GunSprite == null) _L_GunSprite = new UiNode9_GunSprite(Instance.GetNode("GunSprite")); + return _L_GunSprite; } } - private UiNode9_GunSprite _GunSprite; + private UiNode9_GunSprite _L_GunSprite; /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.BulletText /// - public UiNode10_BulletText BulletText + public UiNode10_BulletText L_BulletText { get { - if (_BulletText == null) _BulletText = new UiNode10_BulletText(Instance.GetNode("BulletText")); - return _BulletText; + if (_L_BulletText == null) _L_BulletText = new UiNode10_BulletText(Instance.GetNode("BulletText")); + return _L_BulletText; } } - private UiNode10_BulletText _BulletText; + private UiNode10_BulletText _L_BulletText; public UiNode8_GunBar(Godot.Control node) => Instance = node; public UiNode8_GunBar Clone() => new ((Godot.Control)Instance.Duplicate()); @@ -234,44 +276,383 @@ /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.HealthBar /// - public UiNode2_HealthBar HealthBar + public UiNode2_HealthBar L_HealthBar { get { - if (_HealthBar == null) _HealthBar = new UiNode2_HealthBar(Instance.GetNode("HealthBar")); - return _HealthBar; + if (_L_HealthBar == null) _L_HealthBar = new UiNode2_HealthBar(Instance.GetNode("HealthBar")); + return _L_HealthBar; } } - private UiNode2_HealthBar _HealthBar; + private UiNode2_HealthBar _L_HealthBar; /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.MapBar /// - public UiNode7_MapBar MapBar + public UiNode7_MapBar L_MapBar { get { - if (_MapBar == null) _MapBar = new UiNode7_MapBar(Instance.GetNode("MapBar")); - return _MapBar; + if (_L_MapBar == null) _L_MapBar = new UiNode7_MapBar(Instance.GetNode("MapBar")); + return _L_MapBar; } } - private UiNode7_MapBar _MapBar; + private UiNode7_MapBar _L_MapBar; /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.GunBar /// - public UiNode8_GunBar GunBar + public UiNode8_GunBar L_GunBar { get { - if (_GunBar == null) _GunBar = new UiNode8_GunBar(Instance.GetNode("GunBar")); - return _GunBar; + if (_L_GunBar == null) _L_GunBar = new UiNode8_GunBar(Instance.GetNode("GunBar")); + return _L_GunBar; } } - private UiNode8_GunBar _GunBar; + private UiNode8_GunBar _L_GunBar; public UiNode1_Control(Godot.Control node) => Instance = node; public UiNode1_Control Clone() => new ((Godot.Control)Instance.Duplicate()); } + /// + /// 类型: , 路径: RoomUI.GlobalNode + /// + public class UiNode11_GlobalNode + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.GlobalNode + /// + public Godot.Node Instance { get; } + + public UiNode11_GlobalNode(Godot.Node node) => Instance = node; + public UiNode11_GlobalNode Clone() => new ((Godot.Node)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.ViewNode.InteractiveTipBar.Icon + /// + public class UiNode14_Icon + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.ViewNode.InteractiveTipBar.Icon + /// + public Godot.Sprite2D Instance { get; } + + public UiNode14_Icon(Godot.Sprite2D node) => Instance = node; + public UiNode14_Icon Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.ViewNode.InteractiveTipBar.InteractiveIcon + /// + public class UiNode15_InteractiveIcon + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.ViewNode.InteractiveTipBar.InteractiveIcon + /// + public Godot.Sprite2D Instance { get; } + + public UiNode15_InteractiveIcon(Godot.Sprite2D node) => Instance = node; + public UiNode15_InteractiveIcon Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.ViewNode.InteractiveTipBar.Line2D + /// + public class UiNode16_Line2D + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.ViewNode.InteractiveTipBar.Line2D + /// + public Godot.Line2D Instance { get; } + + public UiNode16_Line2D(Godot.Line2D node) => Instance = node; + public UiNode16_Line2D Clone() => new ((Godot.Line2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.ViewNode.InteractiveTipBar + /// + public class UiNode13_InteractiveTipBar + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.ViewNode.InteractiveTipBar + /// + public InteractiveTipBar Instance { get; } + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.ViewNode.Icon + /// + public UiNode14_Icon L_Icon + { + get + { + if (_L_Icon == null) _L_Icon = new UiNode14_Icon(Instance.GetNode("Icon")); + return _L_Icon; + } + } + private UiNode14_Icon _L_Icon; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.ViewNode.InteractiveIcon + /// + public UiNode15_InteractiveIcon L_InteractiveIcon + { + get + { + if (_L_InteractiveIcon == null) _L_InteractiveIcon = new UiNode15_InteractiveIcon(Instance.GetNode("InteractiveIcon")); + return _L_InteractiveIcon; + } + } + private UiNode15_InteractiveIcon _L_InteractiveIcon; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.ViewNode.Line2D + /// + public UiNode16_Line2D L_Line2D + { + get + { + if (_L_Line2D == null) _L_Line2D = new UiNode16_Line2D(Instance.GetNode("Line2D")); + return _L_Line2D; + } + } + private UiNode16_Line2D _L_Line2D; + + public UiNode13_InteractiveTipBar(InteractiveTipBar node) => Instance = node; + public UiNode13_InteractiveTipBar Clone() => new ((InteractiveTipBar)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.ViewNode.ReloadBar.Slot.Block + /// + public class UiNode19_Block + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.ViewNode.ReloadBar.Slot.Block + /// + public Godot.Sprite2D Instance { get; } + + public UiNode19_Block(Godot.Sprite2D node) => Instance = node; + public UiNode19_Block Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.ViewNode.ReloadBar.Slot + /// + public class UiNode18_Slot + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.ViewNode.ReloadBar.Slot + /// + public Godot.Sprite2D Instance { get; } + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.ViewNode.ReloadBar.Block + /// + public UiNode19_Block L_Block + { + get + { + if (_L_Block == null) _L_Block = new UiNode19_Block(Instance.GetNode("Block")); + return _L_Block; + } + } + private UiNode19_Block _L_Block; + + public UiNode18_Slot(Godot.Sprite2D node) => Instance = node; + public UiNode18_Slot Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.ViewNode.ReloadBar + /// + public class UiNode17_ReloadBar + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.ViewNode.ReloadBar + /// + public ReloadBar Instance { get; } + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.ViewNode.Slot + /// + public UiNode18_Slot L_Slot + { + get + { + if (_L_Slot == null) _L_Slot = new UiNode18_Slot(Instance.GetNode("Slot")); + return _L_Slot; + } + } + private UiNode18_Slot _L_Slot; + + public UiNode17_ReloadBar(ReloadBar node) => Instance = node; + public UiNode17_ReloadBar Clone() => new ((ReloadBar)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.ViewNode + /// + public class UiNode12_ViewNode + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.ViewNode + /// + public Godot.Node Instance { get; } + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.InteractiveTipBar + /// + public UiNode13_InteractiveTipBar L_InteractiveTipBar + { + get + { + if (_L_InteractiveTipBar == null) _L_InteractiveTipBar = new UiNode13_InteractiveTipBar(Instance.GetNode("InteractiveTipBar")); + return _L_InteractiveTipBar; + } + } + private UiNode13_InteractiveTipBar _L_InteractiveTipBar; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.ReloadBar + /// + public UiNode17_ReloadBar L_ReloadBar + { + get + { + if (_L_ReloadBar == null) _L_ReloadBar = new UiNode17_ReloadBar(Instance.GetNode("ReloadBar")); + return _L_ReloadBar; + } + } + private UiNode17_ReloadBar _L_ReloadBar; + + public UiNode12_ViewNode(Godot.Node node) => Instance = node; + public UiNode12_ViewNode Clone() => new ((Godot.Node)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.Cursor.LT + /// + public class UiNode21_LT + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.Cursor.LT + /// + public Godot.Sprite2D Instance { get; } + + public UiNode21_LT(Godot.Sprite2D node) => Instance = node; + public UiNode21_LT Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.Cursor.LB + /// + public class UiNode22_LB + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.Cursor.LB + /// + public Godot.Sprite2D Instance { get; } + + public UiNode22_LB(Godot.Sprite2D node) => Instance = node; + public UiNode22_LB Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.Cursor.RT + /// + public class UiNode23_RT + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.Cursor.RT + /// + public Godot.Sprite2D Instance { get; } + + public UiNode23_RT(Godot.Sprite2D node) => Instance = node; + public UiNode23_RT Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.Cursor.RB + /// + public class UiNode24_RB + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.Cursor.RB + /// + public Godot.Sprite2D Instance { get; } + + public UiNode24_RB(Godot.Sprite2D node) => Instance = node; + public UiNode24_RB Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: RoomUI.Cursor + /// + public class UiNode20_Cursor + { + /// + /// Ui节点实例, 节点类型: , 节点路径: RoomUI.Cursor + /// + public Cursor Instance { get; } + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.LT + /// + public UiNode21_LT L_LT + { + get + { + if (_L_LT == null) _L_LT = new UiNode21_LT(Instance.GetNode("LT")); + return _L_LT; + } + } + private UiNode21_LT _L_LT; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.LB + /// + public UiNode22_LB L_LB + { + get + { + if (_L_LB == null) _L_LB = new UiNode22_LB(Instance.GetNode("LB")); + return _L_LB; + } + } + private UiNode22_LB _L_LB; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.RT + /// + public UiNode23_RT L_RT + { + get + { + if (_L_RT == null) _L_RT = new UiNode23_RT(Instance.GetNode("RT")); + return _L_RT; + } + } + private UiNode23_RT _L_RT; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.RB + /// + public UiNode24_RB L_RB + { + get + { + if (_L_RB == null) _L_RB = new UiNode24_RB(Instance.GetNode("RB")); + return _L_RB; + } + } + private UiNode24_RB _L_RB; + + public UiNode20_Cursor(Cursor node) => Instance = node; + public UiNode20_Cursor Clone() => new ((Cursor)Instance.Duplicate()); + } + } diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs index 1ed4271..7ff1e6c 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs @@ -54,6 +54,8 @@ public override void _Ready() { + //Generator.UiGenerator.GenerateUi(this, "src/game/ui/roomUI/RoomUI.cs"); + //将 GlobalNode 节点下的 ui 节点放入全局坐标中 var globalNode = GetNode("GlobalNode"); var root = GameApplication.Instance.GlobalNodeRoot; @@ -85,7 +87,7 @@ public void SetMaxHp(int maxHp) { MaxHp = Mathf.Max(maxHp, 0); - Control.HealthBar.HpSlot.Instance.Size = new Vector2(maxHp + 3, Control.HealthBar.HpSlot.Instance.Size.Y); + L_Control.L_HealthBar.L_HpSlot.Instance.Size = new Vector2(maxHp + 3, L_Control.L_HealthBar.L_HpSlot.Instance.Size.Y); if (Hp > maxHp) { SetHp(maxHp); @@ -97,8 +99,8 @@ /// public void SetMaxShield(int maxShield) { - MaxShield = Mathf.Max(maxShield, 0); ; - Control.HealthBar.ShieldSlot.Instance.Size = new Vector2(maxShield + 2, Control.HealthBar.ShieldSlot.Instance.Size.Y); + MaxShield = Mathf.Max(maxShield, 0); + L_Control.L_HealthBar.L_ShieldSlot.Instance.Size = new Vector2(maxShield + 2, L_Control.L_HealthBar.L_ShieldSlot.Instance.Size.Y); if (Shield > MaxShield) { SetShield(maxShield); @@ -111,7 +113,7 @@ public void SetHp(int hp) { Hp = Mathf.Clamp(hp, 0, MaxHp); - Control.HealthBar.HpSlot.Instance.Size = new Vector2(hp, Control.HealthBar.HpSlot.Instance.Size.Y); + L_Control.L_HealthBar.L_HpSlot.Instance.Size = new Vector2(hp, L_Control.L_HealthBar.L_HpSlot.Instance.Size.Y); } /// @@ -120,7 +122,7 @@ public void SetShield(int shield) { Shield = Mathf.Clamp(shield, 0, MaxShield); - Control.HealthBar.ShieldSlot.Instance.Size = new Vector2(shield, Control.HealthBar.ShieldSlot.Instance.Size.Y); + L_Control.L_HealthBar.L_ShieldSlot.Instance.Size = new Vector2(shield, L_Control.L_HealthBar.L_ShieldSlot.Instance.Size.Y); } /// @@ -139,14 +141,14 @@ { if (gun != null) { - Control.GunBar.GunSprite.Instance.Texture = gun; - Control.GunBar.GunSprite.Instance.Visible = true; - Control.GunBar.BulletText.Instance.Visible = true; + L_Control.L_GunBar.L_GunSprite.Instance.Texture = gun; + L_Control.L_GunBar.L_GunSprite.Instance.Visible = true; + L_Control.L_GunBar.L_BulletText.Instance.Visible = true; } else { - Control.GunBar.GunSprite.Instance.Visible = false; - Control.GunBar.BulletText.Instance.Visible = false; + L_Control.L_GunBar.L_GunSprite.Instance.Visible = false; + L_Control.L_GunBar.L_BulletText.Instance.Visible = false; } } @@ -157,7 +159,7 @@ /// 剩余弹药总数 public void SetAmmunition(int curr, int total) { - Control.GunBar.BulletText.Instance.Text = curr + " / " + total; + L_Control.L_GunBar.L_BulletText.Instance.Text = curr + " / " + total; } } \ No newline at end of file