From 2a5629fc863f07b229e408ac32498c6353b9f062 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sun, 18 Aug 2024 16:09:31 +0800 Subject: [PATCH] =?UTF-8?q?Projectiles=20can=20now=20track=20enemies.=20?= =?UTF-8?q?=E6=8A=9B=E5=B0=84=E4=BD=93=E5=8F=AF=E4=BB=A5=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E6=95=8C=E4=BA=BA=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entitys/BlackenedAboriginalWarrior.tscn | 8 ++++ prefab/entitys/DelivererOfDarkMagic.tscn | 11 +++++ prefab/projectile/Catapult.tscn | 2 - prefab/projectile/curseOfTheUndead.tscn | 4 +- prefab/ui/HealthBar.tscn | 5 -- scenes/game.tscn | 7 +++ scenes/gameOverMenu.tscn | 8 ++++ scripts/GameSceneNodeHolder.cs | 12 +++-- scripts/character/CharacterTemplate.cs | 48 +++++++++++++++++++ scripts/projectile/Projectile.cs | 25 ++++++++-- scripts/weapon/ProjectileWeapon.cs | 1 + 11 files changed, 116 insertions(+), 15 deletions(-) diff --git a/prefab/entitys/BlackenedAboriginalWarrior.tscn b/prefab/entitys/BlackenedAboriginalWarrior.tscn index 8a4a478..cabf9a9 100644 --- a/prefab/entitys/BlackenedAboriginalWarrior.tscn +++ b/prefab/entitys/BlackenedAboriginalWarrior.tscn @@ -98,3 +98,11 @@ collision_mask = 76 [node name="CollisionShape2D" type="CollisionShape2D" parent="ScoutArea2D"] shape = SubResource("CircleShape2D_fowd5") + +[node name="TipLabel" type="Label" parent="."] +offset_left = -20.0 +offset_top = 46.0 +offset_right = 15.0 +offset_bottom = 71.0 +text = "name" +horizontal_alignment = 1 diff --git a/prefab/entitys/DelivererOfDarkMagic.tscn b/prefab/entitys/DelivererOfDarkMagic.tscn index 86c6515..fc50fc5 100644 --- a/prefab/entitys/DelivererOfDarkMagic.tscn +++ b/prefab/entitys/DelivererOfDarkMagic.tscn @@ -99,3 +99,14 @@ collision_mask = 76 [node name="CollisionShape2D" type="CollisionShape2D" parent="ScoutArea2D"] shape = SubResource("CircleShape2D_fowd5") + +[node name="TipLabel" type="Label" parent="."] +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -57.0 +offset_top = 57.0 +offset_right = 61.0 +offset_bottom = 82.0 +grow_horizontal = 2 +horizontal_alignment = 1 diff --git a/prefab/projectile/Catapult.tscn b/prefab/projectile/Catapult.tscn index 8c4a986..78c0088 100644 --- a/prefab/projectile/Catapult.tscn +++ b/prefab/projectile/Catapult.tscn @@ -16,8 +16,6 @@ platform_floor_layers = 4294967042 platform_wall_layers = 32 script = ExtResource("1_ib3qh") Speed = 300.0 -IgnoreWall = true -EnableTracking = true [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_dgro2") diff --git a/prefab/projectile/curseOfTheUndead.tscn b/prefab/projectile/curseOfTheUndead.tscn index 543ba4b..059d6e8 100644 --- a/prefab/projectile/curseOfTheUndead.tscn +++ b/prefab/projectile/curseOfTheUndead.tscn @@ -14,8 +14,10 @@ _durability = 1.0 _maxDamage = 10 _minDamage = 1 _damageType = 2 -_knockbackForce = Vector2(60, 0) +_knockBackForce = Vector2(0, 1) Speed = 500.0 +_enableTracking = true +_targetDiesDestroyProjectile = true [node name="CurseOfTheUndead" type="Sprite2D" parent="."] texture = ExtResource("1_k8el6") diff --git a/prefab/ui/HealthBar.tscn b/prefab/ui/HealthBar.tscn index 7bc5fda..ec0c6a5 100644 --- a/prefab/ui/HealthBar.tscn +++ b/prefab/ui/HealthBar.tscn @@ -12,8 +12,3 @@ texture_under = ExtResource("1_sc0v3") texture_over = ExtResource("2_ay5vh") texture_progress = ExtResource("2_s0gle") script = ExtResource("4_84gre") - -[node name="Label" type="Label" parent="."] -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 23.0 diff --git a/scenes/game.tscn b/scenes/game.tscn index 77b2408..77286a6 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -21,6 +21,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 [node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control"] layout_mode = 1 @@ -34,25 +35,31 @@ offset_right = -20.0 offset_bottom = -20.0 grow_horizontal = 2 grow_vertical = 0 +mouse_filter = 2 [node name="HealthBarUi" type="HBoxContainer" parent="CanvasLayer/Control/VBoxContainer"] layout_mode = 2 +mouse_filter = 2 script = ExtResource("2_xrm3v") [node name="TextureRect3" type="TextureRect" parent="CanvasLayer/Control/VBoxContainer/HealthBarUi"] layout_mode = 2 +mouse_filter = 2 texture = ExtResource("2_n1yht") [node name="HotBar" type="HBoxContainer" parent="CanvasLayer/Control/VBoxContainer"] layout_mode = 2 +mouse_filter = 2 script = ExtResource("2_owrhq") [node name="TextureRect3" type="TextureRect" parent="CanvasLayer/Control/VBoxContainer/HotBar"] layout_mode = 2 +mouse_filter = 2 texture = ExtResource("2_n1yht") [node name="OperationTip" type="RichTextLabel" parent="CanvasLayer/Control/VBoxContainer"] layout_mode = 2 +mouse_filter = 2 bbcode_enabled = true fit_content = true diff --git a/scenes/gameOverMenu.tscn b/scenes/gameOverMenu.tscn index 5b8e2a7..0e7cee3 100644 --- a/scenes/gameOverMenu.tscn +++ b/scenes/gameOverMenu.tscn @@ -9,6 +9,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 script = ExtResource("1_vj6du") [node name="ColorRect" type="ColorRect" parent="."] @@ -18,6 +19,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 color = Color(0.941176, 0.243137, 0.243137, 0.258824) [node name="CenterContainer" type="CenterContainer" parent="."] @@ -27,12 +29,15 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] layout_mode = 2 +mouse_filter = 2 [node name="CenterContainer" type="CenterContainer" parent="CenterContainer/VBoxContainer"] layout_mode = 2 +mouse_filter = 2 [node name="GameOverLabel" type="Label" parent="CenterContainer/VBoxContainer/CenterContainer"] layout_mode = 2 @@ -41,10 +46,12 @@ text = "ui_game_over_title" [node name="MarginContainer" type="MarginContainer" parent="CenterContainer/VBoxContainer"] layout_mode = 2 +mouse_filter = 2 theme_override_constants/margin_top = 18 [node name="CenterContainer2" type="CenterContainer" parent="CenterContainer/VBoxContainer/MarginContainer"] layout_mode = 2 +mouse_filter = 2 [node name="DeathInfoLabel" type="Label" parent="CenterContainer/VBoxContainer/MarginContainer/CenterContainer2"] layout_mode = 2 @@ -52,6 +59,7 @@ text = "ui_death_info_describe" [node name="MarginContainer2" type="MarginContainer" parent="CenterContainer/VBoxContainer"] layout_mode = 2 +mouse_filter = 2 theme_override_constants/margin_top = 10 theme_override_constants/margin_bottom = 150 diff --git a/scripts/GameSceneNodeHolder.cs b/scripts/GameSceneNodeHolder.cs index bdcd319..d98ef29 100644 --- a/scripts/GameSceneNodeHolder.cs +++ b/scripts/GameSceneNodeHolder.cs @@ -35,12 +35,18 @@ public static class GameSceneNodeHolder } } + /// + /// When the mouse enters the scope of a character, it is considered a target + /// 鼠标进入到某个角色的范围内时,会将其视作目标 + /// + public static Node2D? TemporaryTargetNode { get; set; } + /// /// ProjectileContainer /// 抛射体容器 /// public static Node2D? ProjectileContainer { get; set; } - + /// /// WeaponContainer /// 武器容器 @@ -113,16 +119,14 @@ public static class GameSceneNodeHolder NodeUtils.ForEachNode(BackpackUiContainer, node => { - //If the child node is not visible, the traversal continues. //如果子节点不可见,则继续遍历。 - if (!node.Visible) + if (!node.Visible) return false; //Until you find a visible node, hide it, and return true, ending the loop. //直到找到可见的节点,隐藏该节点,然后返回true,结束遍历。 node.Hide(); return true; - }); } } \ No newline at end of file diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index 3840a01..5886f53 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -178,6 +178,7 @@ public partial class CharacterTemplate : CharacterBody2D [Export] public string LootListId { get; private set; } = ""; private HealthBar? _healthBar; + private Label? _tipLabel; private DateTime _lastDamageTime; /// @@ -291,6 +292,7 @@ public partial class CharacterTemplate : CharacterBody2D _animatedSprite2D = GetNode("AnimatedSprite2D"); _pickingArea = GetNode("Area2DPickingArea"); _damageNumber = GetNode("DamageNumber") as DamageNumberNodeSpawn; + _tipLabel = GetNodeOrNull