diff --git a/DungeonShooting_Godot/prefab/ui/RoomUI.tscn b/DungeonShooting_Godot/prefab/ui/RoomUI.tscn index 75e8a12..02b764d 100644 --- a/DungeonShooting_Godot/prefab/ui/RoomUI.tscn +++ b/DungeonShooting_Godot/prefab/ui/RoomUI.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=17 format=3 uid="uid://bvpmtfupny8iu"] +[gd_scene load_steps=19 format=3 uid="uid://bvpmtfupny8iu"] [ext_resource type="Script" path="res://src/game/ui/roomUI/RoomUIPanel.cs" id="1_tfcrp"] [ext_resource type="Texture2D" uid="uid://b67i86mtqrn32" path="res://resource/sprite/ui/roomUI/icon_bullet.png" id="2_ruc0p"] @@ -11,7 +11,9 @@ [ext_resource type="Texture2D" uid="uid://b8u6s5n37157" path="res://resource/sprite/ui/roomUI/Panel2.png" id="10_eokvx"] [ext_resource type="Texture2D" uid="uid://0swkya4hn82c" path="res://resource/sprite/ui/roomUI/Panel.png" id="10_q3fs8"] [ext_resource type="Texture2D" uid="uid://504f1r0mi33n" path="res://resource/sprite/weapon/weapon0005/Weapon0005.png" id="11_lsai4"] +[ext_resource type="Texture2D" uid="uid://bsu7re1lxnr72" path="res://resource/sprite/ui/roomUI/Cooldown.png" id="11_p0smc"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="12_fgyob"] +[ext_resource type="Texture2D" uid="uid://dwysndc5ffski" path="res://resource/sprite/ui/roomUI/ChargeProgress.png" id="13_vuglj"] [sub_resource type="Gradient" id="1"] colors = PackedColorArray(0.4, 0.498039, 1, 1, 0.4, 0.498039, 1, 0.313726) @@ -200,8 +202,10 @@ grow_vertical = 2 texture = ExtResource("10_q3fs8") region_rect = Rect2(2, 2, 4, 4) -patch_margin_left = 4 -patch_margin_right = 4 +patch_margin_left = 3 +patch_margin_top = 3 +patch_margin_right = 3 +patch_margin_bottom = 3 [node name="ActivePropSprite" type="TextureRect" parent="Control/ActivePropBar"] material = SubResource("ShaderMaterial_msp2c") @@ -214,19 +218,13 @@ texture = ExtResource("10_5d4np") stretch_mode = 3 -[node name="ActivePropGrey" type="ColorRect" parent="Control/ActivePropBar"] -visible = false -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 1.0 -offset_top = 1.0 -offset_right = -1.0 -offset_bottom = -1.0 -grow_horizontal = 2 -grow_vertical = 2 -color = Color(0, 0, 0, 0.717647) +[node name="ActivePropGrey" type="Sprite2D" parent="Control/ActivePropBar"] +position = Vector2(1, 0.99999) +scale = Vector2(43, 25) +texture = ExtResource("11_p0smc") +centered = false +region_enabled = true +region_rect = Rect2(0, 0, 1, 1) [node name="ActivePropCount" type="Label" parent="Control/ActivePropBar"] layout_mode = 1 @@ -261,6 +259,18 @@ patch_margin_right = 2 patch_margin_bottom = 2 +[node name="ActivePropChargeProgress" type="NinePatchRect" parent="Control/ActivePropBar"] +layout_mode = 1 +anchors_preset = 9 +anchor_bottom = 1.0 +offset_right = 5.0 +grow_vertical = 2 +texture = ExtResource("13_vuglj") +patch_margin_left = 2 +patch_margin_top = 3 +patch_margin_right = 1 +patch_margin_bottom = 3 + [node name="WeaponBar" type="Control" parent="Control"] layout_mode = 1 anchors_preset = 3 diff --git a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import index b20c9a6..c36be94 100644 --- a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import +++ b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://chd2vtesap5cf" -path="res://.godot/imported/enemy0001.png-1247a3ddf8a1a163d812cad12c4340fd.ctex" +path="res://.godot/imported/Enemy0001.png-148a38dfa95953b26d890356e8875de4.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://resource/sprite/role/enemy0001/enemy0001.png" -dest_files=["res://.godot/imported/enemy0001.png-1247a3ddf8a1a163d812cad12c4340fd.ctex"] +source_file="res://resource/sprite/role/enemy0001/Enemy0001.png" +dest_files=["res://.godot/imported/Enemy0001.png-148a38dfa95953b26d890356e8875de4.ctex"] [params] diff --git a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import index 56388a2..d563acf 100644 --- a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import +++ b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://d2f55lu60x64i" -path="res://.godot/imported/enemy0001_Debris.png-297a2fb6680cb862a9a085cf58f8268c.ctex" +path="res://.godot/imported/Enemy0001_Debris.png-ac416dc79cd3c1217b27e1ef1fbe0d0b.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://resource/sprite/role/enemy0001/enemy0001_Debris.png" -dest_files=["res://.godot/imported/enemy0001_Debris.png-297a2fb6680cb862a9a085cf58f8268c.ctex"] +source_file="res://resource/sprite/role/enemy0001/Enemy0001_Debris.png" +dest_files=["res://.godot/imported/Enemy0001_Debris.png-ac416dc79cd3c1217b27e1ef1fbe0d0b.ctex"] [params] diff --git a/DungeonShooting_Godot/resource/sprite/ui/roomUI/ChargeProgress.png b/DungeonShooting_Godot/resource/sprite/ui/roomUI/ChargeProgress.png new file mode 100644 index 0000000..4891c5c --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/roomUI/ChargeProgress.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/ui/roomUI/ChargeProgress.png.import b/DungeonShooting_Godot/resource/sprite/ui/roomUI/ChargeProgress.png.import new file mode 100644 index 0000000..b36cc76 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/roomUI/ChargeProgress.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dwysndc5ffski" +path="res://.godot/imported/ChargeProgress.png-a966b083a7f0e9adb2c3b308c3007e22.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/ui/roomUI/ChargeProgress.png" +dest_files=["res://.godot/imported/ChargeProgress.png-a966b083a7f0e9adb2c3b308c3007e22.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/DungeonShooting_Godot/resource/sprite/ui/roomUI/Cooldown.png b/DungeonShooting_Godot/resource/sprite/ui/roomUI/Cooldown.png new file mode 100644 index 0000000..1445214 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/roomUI/Cooldown.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/ui/roomUI/Cooldown.png.import b/DungeonShooting_Godot/resource/sprite/ui/roomUI/Cooldown.png.import new file mode 100644 index 0000000..55a9b93 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/roomUI/Cooldown.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bsu7re1lxnr72" +path="res://.godot/imported/Cooldown.png-b977dc8c9e5e0d70e453236da5bb2f3d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/ui/roomUI/Cooldown.png" +dest_files=["res://.godot/imported/Cooldown.png-b977dc8c9e5e0d70e453236da5bb2f3d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/DungeonShooting_Godot/src/framework/ui/UiBase.cs b/DungeonShooting_Godot/src/framework/ui/UiBase.cs index e454424..01bc2a8 100644 --- a/DungeonShooting_Godot/src/framework/ui/UiBase.cs +++ b/DungeonShooting_Godot/src/framework/ui/UiBase.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using Godot; @@ -164,4 +165,60 @@ { ProxyCoroutineHandler.ProxyStopAllCoroutine(ref _coroutineList); } + + /// + /// 延时指定时间调用一个回调函数 + /// + public void CallDelay(float delayTime, Action cb) + { + StartCoroutine(_CallDelay(delayTime, cb)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public void CallDelay(float delayTime, Action cb, T1 arg1) + { + StartCoroutine(_CallDelay(delayTime, cb, arg1)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public void CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2) + { + StartCoroutine(_CallDelay(delayTime, cb, arg1, arg2)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public void CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) + { + StartCoroutine(_CallDelay(delayTime, cb, arg1, arg2, arg3)); + } + + private IEnumerator _CallDelay(float delayTime, Action cb) + { + yield return new WaitForSeconds(delayTime); + cb(); + } + + private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1) + { + yield return new WaitForSeconds(delayTime); + cb(arg1); + } + + private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2) + { + yield return new WaitForSeconds(delayTime); + cb(arg1, arg2); + } + + private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) + { + yield return new WaitForSeconds(delayTime); + cb(arg1,arg2, arg3); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs index 646c449..fa9867e 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -190,7 +190,7 @@ else //正常状态 { HurtArea.CollisionLayer = _currentLayer; - SetBlendColor(new Color(1, 1, 1, 1)); + SetBlendModulate(new Color(1, 1, 1, 1)); } } @@ -400,12 +400,12 @@ if (_flashingInvincibleFlag) { _flashingInvincibleFlag = false; - SetBlendColor(new Color(1, 1, 1, 0.7f)); + SetBlendModulate(new Color(1, 1, 1, 0.7f)); } else { _flashingInvincibleFlag = true; - SetBlendColor(new Color(1, 1, 1, 0)); + SetBlendModulate(new Color(1, 1, 1, 0)); } } diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/ActivePropBar.cs b/DungeonShooting_Godot/src/game/ui/roomUI/ActivePropBar.cs index a301de3..a9872e0 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/ActivePropBar.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/ActivePropBar.cs @@ -6,15 +6,18 @@ { private RoomUI.UiNode_ActivePropBar _activePropBar; private ShaderMaterial _shaderMaterial; - private Rect2 _startRect; + private Vector2 _startPos; + private Vector2 _startSize; public ActivePropBar(RoomUI.UiNode_ActivePropBar activePropBar) { _activePropBar = activePropBar; _shaderMaterial = (ShaderMaterial)_activePropBar.L_ActivePropSprite.Instance.Material; - _startRect = _activePropBar.L_ActivePropGrey.Instance.GetRect(); + _startPos = _activePropBar.L_ActivePropGrey.Instance.Position; + _startSize = _activePropBar.L_ActivePropGrey.Instance.Scale; SetActivePropTexture(null); + SetChargeProgressVisible(false); } public void OnShow() @@ -102,14 +105,46 @@ { colorRect.Visible = true; - var height = _startRect.Size.Y * progress; - var size = colorRect.Size; - size.Y = height; - colorRect.Size = size; + //调整蒙板高度 + var rect = colorRect.RegionRect; + var size = rect.Size; + size.Y = progress; + rect.Size = size; + colorRect.RegionRect = rect; + //调整蒙板位置 + var height = _startSize.Y * progress; var position = colorRect.Position; - position.Y = _startRect.Position.Y + (_startRect.Size.Y - height); + position.Y = _startPos.Y + (_startSize.Y - height); colorRect.Position = position; } } + + /// + /// 设置充能进度条是否显示 + /// + public void SetChargeProgressVisible(bool visible) + { + var ninePatchRect = _activePropBar.L_ActivePropChargeProgress.Instance; + ninePatchRect.Visible = visible; + //调整冷却蒙板大小 + var sprite = _activePropBar.L_ActivePropGrey.Instance; + if (visible) + { + var rect = ninePatchRect.GetRect(); + + var position = sprite.Position; + position.X = _startPos.X + rect.Size.X - 1; + sprite.Position = position; + + var scale = sprite.Scale; + scale.X = _startSize.X - rect.Size.X + 1; + sprite.Scale = scale; + } + else + { + sprite.Position = _startPos; + sprite.Scale = _startSize; + } + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUI.cs b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUI.cs index 245431f..2adb72e 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUI.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUI.cs @@ -258,12 +258,12 @@ } /// - /// 类型: , 路径: RoomUI.Control.ActivePropBar.ActivePropGrey + /// 类型: , 路径: RoomUI.Control.ActivePropBar.ActivePropGrey /// - public class UiNode_ActivePropGrey : IUiNode + public class UiNode_ActivePropGrey : IUiNode { - public UiNode_ActivePropGrey(Godot.ColorRect node) : base(node) { } - public override UiNode_ActivePropGrey Clone() => new ((Godot.ColorRect)Instance.Duplicate()); + public UiNode_ActivePropGrey(Godot.Sprite2D node) : base(node) { } + public override UiNode_ActivePropGrey Clone() => new ((Godot.Sprite2D)Instance.Duplicate()); } /// @@ -285,6 +285,15 @@ } /// + /// 类型: , 路径: RoomUI.Control.ActivePropBar.ActivePropChargeProgress + /// + public class UiNode_ActivePropChargeProgress : IUiNode + { + public UiNode_ActivePropChargeProgress(Godot.NinePatchRect node) : base(node) { } + public override UiNode_ActivePropChargeProgress Clone() => new ((Godot.NinePatchRect)Instance.Duplicate()); + } + + /// /// 类型: , 路径: RoomUI.Control.ActivePropBar /// public class UiNode_ActivePropBar : IUiNode @@ -316,13 +325,13 @@ private UiNode_ActivePropSprite _L_ActivePropSprite; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.ActivePropGrey + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.ActivePropGrey /// public UiNode_ActivePropGrey L_ActivePropGrey { get { - if (_L_ActivePropGrey == null) _L_ActivePropGrey = new UiNode_ActivePropGrey(Instance.GetNodeOrNull("ActivePropGrey")); + if (_L_ActivePropGrey == null) _L_ActivePropGrey = new UiNode_ActivePropGrey(Instance.GetNodeOrNull("ActivePropGrey")); return _L_ActivePropGrey; } } @@ -354,6 +363,19 @@ } private UiNode_ActivePropPanel _L_ActivePropPanel; + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomUI.Control.ActivePropChargeProgress + /// + public UiNode_ActivePropChargeProgress L_ActivePropChargeProgress + { + get + { + if (_L_ActivePropChargeProgress == null) _L_ActivePropChargeProgress = new UiNode_ActivePropChargeProgress(Instance.GetNodeOrNull("ActivePropChargeProgress")); + return _L_ActivePropChargeProgress; + } + } + private UiNode_ActivePropChargeProgress _L_ActivePropChargeProgress; + public UiNode_ActivePropBar(Godot.Control node) : base(node) { } public override UiNode_ActivePropBar Clone() => new ((Godot.Control)Instance.Duplicate()); }