From 05763c25b1fca8780edc1d2ee738a546959782a6 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sat, 8 Jun 2024 23:59:24 +0800 Subject: [PATCH] =?UTF-8?q?Created=20the=20ability=20to=20drop=20items=20o?= =?UTF-8?q?n=20the=20ground=20after=20the=20player=20dies.=20=E5=88=B6?= =?UTF-8?q?=E4=BD=9C=E7=8E=A9=E5=AE=B6=E6=AD=BB=E4=BA=A1=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E8=83=8C=E5=8C=85=E7=89=A9=E5=93=81=E6=8E=89=E5=9C=A8=E5=9C=B0?= =?UTF-8?q?=E4=B8=8A=E7=9A=84=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locals/DeathInfo.en.translation | Bin 482 -> 482 bytes locals/DeathInfo.ja.translation | Bin 533 -> 533 bytes locals/DeathInfo.zh.translation | Bin 501 -> 501 bytes locals/InputMapping.en.translation | Bin 438 -> 438 bytes locals/InputMapping.ja.translation | Bin 465 -> 465 bytes locals/InputMapping.zh.translation | Bin 449 -> 449 bytes locals/Log.en.translation | Bin 1770 -> 1770 bytes locals/Log.ja.translation | Bin 2545 -> 2545 bytes locals/Log.zh.translation | Bin 1977 -> 1977 bytes locals/Slogan.ja.translation | Bin 769 -> 877 bytes locals/UI.en.translation | Bin 1850 -> 1850 bytes locals/UI.ja.translation | Bin 2333 -> 2333 bytes locals/UI.zh.translation | Bin 1973 -> 1973 bytes locals/Weapon.en.translation | Bin 494 -> 494 bytes locals/Weapon.ja.translation | Bin 573 -> 573 bytes locals/Weapon.zh.translation | Bin 525 -> 525 bytes locals/slogan.csv | 4 +- locals/slogan.csv.import | 2 +- locals/slogan.en.translation | Bin 634 -> 718 bytes locals/slogan.zh.translation | Bin 701 -> 793 bytes prefab/roomTemplates/dungeon/initialRoom.tscn | 15 ++++ project.godot | 1 + scenes/mainMenu.tscn | 2 +- scripts/SloganProvider.cs | 1 + scripts/character/CharacterTemplate.cs | 84 ++++++++++++++++-- scripts/character/Player.cs | 8 +- scripts/inventory/ItemSlotNode.cs | 10 +-- .../uiLoader/GameOverLoaderMenuLoader.cs | 6 +- .../loader/uiLoader/LevelGraphEditorLoader.cs | 20 ++--- scripts/map/PlayerSpawn.cs | 1 + 30 files changed, 123 insertions(+), 31 deletions(-) diff --git a/locals/DeathInfo.en.translation b/locals/DeathInfo.en.translation index 13de0d76e4cbb2a28559024ee60da2676227002d..67279620263130746f29250f5906845c6332c71f 100644 GIT binary patch delta 17 YcmaFF{D^sjG$U(nWqMxaWCg}U06FUhMgRZ+ delta 17 YcmaFF{D^sjG$X5-L4irZWCg}U05oa^i~s-t diff --git a/locals/DeathInfo.ja.translation b/locals/DeathInfo.ja.translation index e859cccfe192faf51c111917a9c0887b9c173375..7c985160062c6122cf7279181fb794bf8992883d 100644 GIT binary patch delta 17 YcmbQrGL>b6G$U(~d4{3+WCg~r04xXvCIA2c delta 17 YcmbQrGL>b6G$U(fQc-^CWCg~r05AUq&Hw-a diff --git a/locals/DeathInfo.zh.translation b/locals/DeathInfo.zh.translation index 4ff332e19fad9c842e28dca712400099287212b5..553a2471f1a8877b3f3a4b8eef090ce75b8ba139 100644 GIT binary patch delta 17 Ycmey${FQlwG$U(c delta 18 Zcmew;{84y=G$U({MM1LhW(CHJ8~{N11~C8t diff --git a/locals/Log.zh.translation b/locals/Log.zh.translation index 5b2d9d06243549816dae0bb2ea2cbbc3d1c4f161..b13c1f938069884509b32d1bccec830cf0149521 100644 GIT binary patch delta 18 ZcmdnVzmtE1G$U(dULo;(yY0%;KD0E)i@(jc93leaNuGx0D^R%W{B z>6@9Cnp~8aR`R&1>2Xub(^b diff --git a/locals/UI.en.translation b/locals/UI.en.translation index b842904645a1e87d89617ae86c9f0ebb2005aaed..0ad0d600e44de1a6be8882892fdb405f9b10cef1 100644 GIT binary patch delta 18 ZcmdnRw~KFsG$U(baz;N_z1-AeI delta 18 ZcmbO$G*@VYG$U(LQDIK;O3x1{?qY diff --git a/locals/UI.zh.translation b/locals/UI.zh.translation index 82bff5615480b834d6d39f5acbb4a23c6c2284bf..9bb5b4c98bfaa4f221c51e7727fe27bc195199bd 100644 GIT binary patch delta 18 ZcmdnWzm1Ej<&B&TnY*bo2S%L8_04?GLi~s-t delta 17 YcmeBW>1Ej<&B&UYX_ApUS%L8_04+}ibN~PV diff --git a/locals/slogan.csv b/locals/slogan.csv index 0d163c5..0a74c59 100644 --- a/locals/slogan.csv +++ b/locals/slogan.csv @@ -3,4 +3,6 @@ slogan_0,游戏属于每一个人。,The game belongs to everyone.,ゲームは slogan_1,如果你想要得到爱,你就播种爱。,"If you want love, you sow love.",愛を手に入れたければ、愛の種をまきます。 slogan_2,快乐?伤心?痛苦?,Happy? Sad? Pain?,楽しいですか?悲しいですか?苦しいですか? slogan_3,Kawaii!,Kawaii!,Kawaii! -slogan_4,魔法是想象的世界。,Magic is an imaginary world.,魔法は想像の世界です。 \ No newline at end of file +slogan_4,魔法是想象的世界。,Magic is an imaginary world.,魔法は想像の世界です。 +slogan_5,也试试Minecraft!,Also try Minecraft!,Minecraftもやってみて! +slogan_6,也试试Terraria!,Also try Terraria!,Terrariaもやってみて! \ No newline at end of file diff --git a/locals/slogan.csv.import b/locals/slogan.csv.import index bfacd67..b9d7c86 100644 --- a/locals/slogan.csv.import +++ b/locals/slogan.csv.import @@ -2,7 +2,7 @@ importer="csv_translation" type="Translation" -uid="uid://dbgkevd34vb0d" +uid="uid://bgfmprv2sm645" [deps] diff --git a/locals/slogan.en.translation b/locals/slogan.en.translation index 01bea34b90bbc097cb89e3bb9ee5ab6e3edf22b0..b55a2768972590a4a826419df31c0de123fcb3fc 100644 GIT binary patch delta 178 zcmeyxa*lO^El2znBN5B=1>O?_6(%O|Oe|c*YL-+{X*yYf(M^+$fq{Vsi2nnD5RjGt zVmTmIfr_yLX$2tGn%vK*tjgW9?^QUE2T~~l#EekP0Tj;!vIT)yc=B?_Y{sg|!c0+y p{~X0O^YOU<^X0$Zq{IB5QIP>A5+dDH!~zmvU|@$D5)>Td3;?LnEaU(H delta 104 zcmX@d`io_PEytk+JvQQg2aF~LDojk^nOL}r)uJe~G-I*?qnqY`B*4bNz`z5uJi?<_B diff --git a/locals/slogan.zh.translation b/locals/slogan.zh.translation index 6ed2eed10cbd8cced83f80c65fbe12a8f8a4fbd2..008eea79219defbaf90a9c422d9e86856eda49c9 100644 GIT binary patch delta 187 zcmdnXI+JaJEyw%W27wn^=4nj~RG65+GqG?LYq5cWp~++g#!yW*1_lNmApQ>oLO@yq zh~Vq(wn^@;1h7#;uc;n0l?A v?418%{Zt_G&CE+pE=o)*dB3NT0WKPnT2z!+l$i(;1Oj#-2ALKV9OMiDOAR_Q delta 105 zcmbQqwwHB+Er(T2ogHV$1GkBR3KJ7}CKj$@H7-pmHJhx!7^?Xn39vCRFz^7e5D-fM oF-VFPNGkxb+~j$T%9B4bCNOqQ4r1!%V_;whiZTLmP;ihl07t4Ky8r+H diff --git a/prefab/roomTemplates/dungeon/initialRoom.tscn b/prefab/roomTemplates/dungeon/initialRoom.tscn index 73bfc19..06fa45b 100644 --- a/prefab/roomTemplates/dungeon/initialRoom.tscn +++ b/prefab/roomTemplates/dungeon/initialRoom.tscn @@ -45,3 +45,18 @@ script = ExtResource("2_6p8mv") [node name="StaffOfTheUndead" parent="." instance=ExtResource("3_ud0w8")] position = Vector2(231, 116) + +[node name="StaffOfTheUndead2" parent="." instance=ExtResource("3_ud0w8")] +position = Vector2(113, 149) + +[node name="StaffOfTheUndead5" parent="." instance=ExtResource("3_ud0w8")] +position = Vector2(213, 177) + +[node name="StaffOfTheUndead6" parent="." instance=ExtResource("3_ud0w8")] +position = Vector2(290, 167) + +[node name="StaffOfTheUndead3" parent="." instance=ExtResource("3_ud0w8")] +position = Vector2(70, 88) + +[node name="StaffOfTheUndead4" parent="." instance=ExtResource("3_ud0w8")] +position = Vector2(367, 85) diff --git a/project.godot b/project.godot index e991cd5..f453d76 100644 --- a/project.godot +++ b/project.godot @@ -147,6 +147,7 @@ hotbar_previous={ [internationalization] locale/translations=PackedStringArray("res://locals/DeathInfo.en.translation", "res://locals/DeathInfo.ja.translation", "res://locals/DeathInfo.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.ja.translation", "res://locals/InputMapping.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.ja.translation", "res://locals/Log.zh.translation", "res://locals/Slogan.en.translation", "res://locals/Slogan.ja.translation", "res://locals/Slogan.zh.translation", "res://locals/UI.en.translation", "res://locals/UI.ja.translation", "res://locals/UI.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.ja.translation", "res://locals/Weapon.zh.translation") +locale/test="ja" [layer_names] diff --git a/scenes/mainMenu.tscn b/scenes/mainMenu.tscn index 6986741..8b1cf45 100644 --- a/scenes/mainMenu.tscn +++ b/scenes/mainMenu.tscn @@ -124,7 +124,7 @@ layout_mode = 2 [node name="GodotLabel" type="Label" parent="VBoxContainer2/HBoxContainer"] layout_mode = 2 -text = "Power by" +text = "Powered by" horizontal_alignment = 2 [node name="LinkButton" type="LinkButton" parent="VBoxContainer2/HBoxContainer"] diff --git a/scripts/SloganProvider.cs b/scripts/SloganProvider.cs index 7968455..a92fe2a 100644 --- a/scripts/SloganProvider.cs +++ b/scripts/SloganProvider.cs @@ -13,6 +13,7 @@ public static class SloganProvider static SloganProvider() { // Calculate SloganCount From translation file + // 从翻译文件中计算口号计数 var sloganTrans = ResourceLoader.Load("res://locals/Slogan.en.translation")!; SloganCount = sloganTrans.GetTranslatedMessageList().Length; } diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index f7d2830..b5547d7 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -151,7 +151,7 @@ public partial class CharacterTemplate : CharacterBody2D //Check whether the new Hp is greater than the maximum Hp. If yes, set the current Hp to the maximum Hp. If no, set the current Hp to the new HP //判断新的Hp是否大于最大Hp,若大于那么将当前Hp设置为最大Hp,否则设置为新的Hp CurrentHp = newHp > MaxHp ? MaxHp : newHp; - Visible = true; + Show(); } /// @@ -318,7 +318,7 @@ public partial class CharacterTemplate : CharacterBody2D } else { - pickAbleItem.Visible = false; + pickAbleItem.Hide(); pickAbleItem.ProcessMode = ProcessModeEnum.Disabled; } @@ -358,7 +358,7 @@ public partial class CharacterTemplate : CharacterBody2D var timeSpan = DateTime.Now - _lastDamageTime; if (timeSpan > Config.HealthBarDisplaysTime) { - _healthBar.Visible = false; + _healthBar.Hide(); } } } @@ -410,7 +410,7 @@ public partial class CharacterTemplate : CharacterBody2D } } - _healthBar.Visible = true; + _healthBar.Show(); _healthBar.Value = CurrentHp; } @@ -437,6 +437,7 @@ public partial class CharacterTemplate : CharacterBody2D //Character death //角色死亡 OnDie(damageTemplate); + ThrowAllItemOnDie(); return true; } @@ -528,6 +529,44 @@ public partial class CharacterTemplate : CharacterBody2D _animatedSprite2D.FlipH = FacingLeft; } + /// + /// Throw all items when the creature dies + /// 当生物死亡后抛出所有物品 + /// + private void ThrowAllItemOnDie() + { + //If the item container is null, then return + //如果物品容器为null,那么返回 + if (_itemContainer == null) + { + return; + } + + var len = _itemContainer.GetItemSlotCount(); + if (len == 0) + { + return; + } + + CurrentItem = null; + const float height = -Config.CellSize * 7; + const float horizontalDirection = Config.CellSize * 15; + for (var i = 0; i < len; i++) + { + //Generates a random number that controls the horizontal velocity of thrown items (range: 0.01 to 1) + //生成一个随机数,用于控制抛出物品的水平方向速度(范围为:0.01到1) + var percent = GD.Randf() + 0.01f; + if (GD.Randf() > 0.5) + { + ThrowItem(i, -1, new Vector2(horizontalDirection * percent, height)); + } + else + { + ThrowItem(i, -1, new Vector2(-horizontalDirection * percent, height)); + } + } + } + /// /// Throw item /// 抛出物品 @@ -539,6 +578,8 @@ public partial class CharacterTemplate : CharacterBody2D /// /// How many to throw /// 要扔几个 + /// The amount passed into a negative number will throw all the items in the slot at once. + /// 数量传入一个负数,将一次扔出槽内的所有物品。 /// /// ///The speed to be applied to the item @@ -562,7 +603,12 @@ public partial class CharacterTemplate : CharacterBody2D { return; } - + + if (item is not Node2D node2D) + { + return; + } + switch (item) { case WeaponTemplate weaponTemplate: @@ -571,7 +617,7 @@ public partial class CharacterTemplate : CharacterBody2D return; } - weaponTemplate.Reparent(GameSceneNodeHolder.WeaponContainer); + CallDeferred("WeaponTemplateReparent", weaponTemplate); var timer = new Timer(); weaponTemplate.AddChild(timer); timer.WaitTime = _itemCollisionRecoveryTime; @@ -587,13 +633,17 @@ public partial class CharacterTemplate : CharacterBody2D }; timer.Start(); weaponTemplate.Sleeping = false; - // weaponTemplate.LinearVelocity = Vector2.Zero; + //Setting an initial speed of 0 for items here prevents the problem of throwing items too fast. + //在这里给物品设置一个为0的初始速度,可防止扔出物品时速度过快的问题。 + weaponTemplate.LinearVelocity = Vector2.Zero; break; } + node2D.ProcessMode = ProcessModeEnum.Inherit; + node2D.Show(); //We apply force to objects. //我们给物品施加力。 - switch (CurrentItem) + switch (node2D) { case CharacterBody2D characterBody2D: characterBody2D.Velocity = velocity; @@ -605,9 +655,25 @@ public partial class CharacterTemplate : CharacterBody2D //Remove items from the item container //在物品容器内移除物品 - itemSlotNode.RemoveItem(number); + if (number < 0) + { + itemSlotNode.RemoveItem(item.Quantity); + } + else + { + itemSlotNode.RemoveItem(number); + } } + /// + /// Replace the parent node of the weapon + /// 替换武器的父节点 + /// + /// + private void WeaponTemplateReparent(WeaponTemplate weaponTemplate) + { + weaponTemplate.Reparent(GameSceneNodeHolder.WeaponContainer); + } public sealed override void _PhysicsProcess(double delta) { diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index 7070d94..c91571d 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -353,9 +353,15 @@ public partial class Player : CharacterTemplate } } + /// + /// When the player dies + /// 当玩家死亡的时候 + /// + /// protected override async Task OnDie(DamageTemplate damageTemplate) { - Visible = false; + Hide(); + ProcessMode = ProcessModeEnum.Disabled; if (EventManager.GameOverEvent == null) { return; diff --git a/scripts/inventory/ItemSlotNode.cs b/scripts/inventory/ItemSlotNode.cs index dc98da9..a5d30be 100644 --- a/scripts/inventory/ItemSlotNode.cs +++ b/scripts/inventory/ItemSlotNode.cs @@ -97,7 +97,7 @@ public partial class ItemSlotNode : MarginContainer if (_quantityLabel != null) { - _quantityLabel.Visible = false; + _quantityLabel.Hide(); } } @@ -213,16 +213,16 @@ public partial class ItemSlotNode : MarginContainer switch (quantity) { case null: - _quantityLabel.Visible = false; + _quantityLabel.Hide(); return; case > 1: //When the quantity is greater than 1, we display the quantity. //当数量大于1时,我们显示数量 _quantityLabel.Text = quantity.ToString(); - _quantityLabel.Visible = true; + _quantityLabel.Show(); break; default: - _quantityLabel.Visible = false; + _quantityLabel.Hide(); break; } } @@ -236,6 +236,6 @@ public partial class ItemSlotNode : MarginContainer _iconTextureRect = GetNode("BackgroundTexture/CenterContainer/IconTextureRect"); _quantityLabel = GetNode