From d3f2076b114e89e45fbb9e797944042416ec2023 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Tue, 20 Aug 2024 22:17:07 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20the=20issue=20of=20picking=20up=20lost=20?= =?UTF-8?q?attributes=20after=20losing=20weapons.=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=A4=B1=E5=8E=BB=E6=AD=A6=E5=99=A8=E5=90=8E=E5=86=8D=E6=8D=A1?= =?UTF-8?q?=E8=B5=B7=E4=B8=A2=E5=A4=B1=E5=B1=9E=E6=80=A7=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locals/Misc.csv | 1 - prefab/packsacks/PortableBackpacks.tscn | 5 ++ prefab/ui/FloatLabel.tscn | 14 ----- prefab/weapons/StaffNecromancy.tscn | 6 ++ scripts/character/CharacterTemplate.cs | 18 +----- scripts/character/Player.cs | 83 +++---------------------- scripts/inventory/ItemSlotNode.cs | 9 ++- scripts/pickable/PickAbleTemplate.cs | 47 ++++++++++++++ 8 files changed, 78 insertions(+), 105 deletions(-) delete mode 100644 prefab/ui/FloatLabel.tscn diff --git a/locals/Misc.csv b/locals/Misc.csv index 1d3370e..295c8a7 100644 --- a/locals/Misc.csv +++ b/locals/Misc.csv @@ -1,4 +1,3 @@ id,zh,en,ja -de,的,"'s",の default_player_name,白纸,blankPaper,しらかみ item_prompt_debug,ID:{0}\n名称:{1}\n数量:{2}\n最大叠加数量:{3}\n数据类型:{4}\n描述:{5},ID: {0}\nName: {1}\nQuantity: {2}\nMaximum stacking quantity: {3}\nData type: {4}\nDescription:{5},id:{0}\n名称:{1}\nの数は最大{2}\nシナジー数:{3}\nデータタイプ:{4}\n述べ表わす:{5} \ No newline at end of file diff --git a/prefab/packsacks/PortableBackpacks.tscn b/prefab/packsacks/PortableBackpacks.tscn index 3079339..0e0dff1 100644 --- a/prefab/packsacks/PortableBackpacks.tscn +++ b/prefab/packsacks/PortableBackpacks.tscn @@ -30,3 +30,8 @@ shape = SubResource("RectangleShape2D_xqyue") [node name="Packsack" type="Sprite2D" parent="."] scale = Vector2(0.5, 0.5) texture = ExtResource("2_l0fbh") + +[node name="TipLabel" type="Label" parent="."] +offset_top = 31.0 +offset_right = 40.0 +offset_bottom = 56.0 diff --git a/prefab/ui/FloatLabel.tscn b/prefab/ui/FloatLabel.tscn deleted file mode 100644 index ce612b5..0000000 --- a/prefab/ui/FloatLabel.tscn +++ /dev/null @@ -1,14 +0,0 @@ -[gd_scene format=3 uid="uid://b7se73tsnlpd6"] - -[node name="FloatLabel" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="Label" type="Label" parent="."] -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 23.0 diff --git a/prefab/weapons/StaffNecromancy.tscn b/prefab/weapons/StaffNecromancy.tscn index ce940cc..17df48c 100644 --- a/prefab/weapons/StaffNecromancy.tscn +++ b/prefab/weapons/StaffNecromancy.tscn @@ -45,3 +45,9 @@ position = Vector2(65, 0) [node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="Marker2D"] stream = ExtResource("4_ffr2k") bus = &"SoundEffect" + +[node name="TipLabel" type="Label" parent="."] +offset_left = 6.0 +offset_top = 48.0 +offset_right = 46.0 +offset_bottom = 73.0 diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index 73c1837..ccf871a 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -322,26 +322,15 @@ public partial class CharacterTemplate : CharacterBody2D } - private bool _mouseEntered; - - public override void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx) - { - if (!_mouseEntered) - { - return; - } - } + public override void _MouseEnter() { - _mouseEntered = true; - var canCauseHarm = false; if (GameSceneNodeHolder.Player != null) { var targetCamp = CampManager.GetCamp(CampId); var playerCamp = CampManager.GetCamp(GameSceneNodeHolder.Player.CampId); - canCauseHarm = CampManager.CanCauseHarm(targetCamp, playerCamp); - if (canCauseHarm) + if (CampManager.CanCauseHarm(targetCamp, playerCamp)) { GameSceneNodeHolder.TemporaryTargetNode = this; } @@ -350,7 +339,7 @@ public partial class CharacterTemplate : CharacterBody2D if (_tipLabel != null) { _tipLabel.Visible = true; - _tipLabel.Text = canCauseHarm + CharacterName; + _tipLabel.Text = CharacterName; //Vertical Centering Tip //垂直居中提示 var oldPosition = _tipLabel.Position; @@ -361,7 +350,6 @@ public partial class CharacterTemplate : CharacterBody2D public override void _MouseExit() { - _mouseEntered = false; if (_tipLabel != null) { _tipLabel.Visible = false; diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index 3977a58..a0fc58b 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -1,4 +1,3 @@ -using System; using System.Text; using System.Threading.Tasks; using ColdMint.scripts.damage; @@ -17,8 +16,6 @@ namespace ColdMint.scripts.character; /// public partial class Player : CharacterTemplate { - private Control? _floatLabel; - //Empty object projectile //空的物品抛射线 private readonly Vector2[] _emptyVector2Array = [Vector2.Zero]; @@ -29,10 +26,6 @@ public partial class Player : CharacterTemplate //用于检测玩家是否站在平台上的射线 private RayCast2D? _platformDetectionRayCast2D; - - private const float PromptTextDistance = 50; - - //抛出物品的飞行速度 private float _throwingVelocity = Config.CellSize * 13; @@ -50,17 +43,6 @@ public partial class Player : CharacterTemplate CharacterName = TranslationServerUtils.Translate("default_player_name"); LogCat.LogWithFormat("player_spawn_debug", LogCat.LogLabel.Default, LogCat.UploadFormat, ReadOnlyCharacterName, GlobalPosition); - var floatLabelPackedScene = GD.Load("res://prefab/ui/FloatLabel.tscn"); - //Initializes the float label. - //初始化悬浮标签。 - _floatLabel = NodeUtils.InstantiatePackedScene(floatLabelPackedScene); - if (_floatLabel == null) - { - throw new NullReferenceException(TranslationServer.Translate("float_label_instantiate_failed")); - } - - _floatLabel.Hide(); - NodeUtils.CallDeferredAddChild(this, _floatLabel); _parabola = GetNode("Parabola"); _platformDetectionRayCast2D = GetNode("PlatformDetectionRayCast"); UpdateOperationTip(); @@ -109,6 +91,14 @@ public partial class Player : CharacterTemplate } } + public override void _MouseEnter() + { + } + + public override void _MouseExit() + { + } + /// /// Update operation prompt /// 更新操作提示 @@ -243,8 +233,6 @@ public partial class Player : CharacterTemplate { PickingRangeBodiesList?.Remove(pickAbleItem); } - - RecycleFloatLabel(); } } @@ -430,48 +418,11 @@ public partial class Player : CharacterTemplate return; } - if (node is not Node2D node2D) + if (node is not Node2D) { return; } - if (_floatLabel != null) - { - if (node is not PickAbleTemplate pickAbleTemplate) - { - return; - } - - if (pickAbleTemplate.Picked) - { - //If the pickables are picked up, the label is not displayed. - //如果可拾捡物被捡起了,那么不显示标签。 - LogCat.LogWarning("pickable_picked_up"); - return; - } - - NodeUtils.CallDeferredReparent(node, _floatLabel); - var rotationDegreesNode2D = node2D.RotationDegrees; - var rotationDegreesNode2DAbs = Math.Abs(rotationDegreesNode2D); - _floatLabel.GlobalPosition = node2D.GlobalPosition; - _floatLabel.Position = rotationDegreesNode2DAbs > 90 - ? new Vector2(0, PromptTextDistance) - : new Vector2(0, -PromptTextDistance); - _floatLabel.RotationDegrees = 0 - rotationDegreesNode2D; - var label = _floatLabel.GetNode