diff --git a/data/itemRegs/packsacks.yaml b/data/itemRegs/packsacks.yaml index 20b9eff..8c83de3 100644 --- a/data/itemRegs/packsacks.yaml +++ b/data/itemRegs/packsacks.yaml @@ -1,4 +1,4 @@ - id: packsack scene_path: res://prefab/packsacks/packsack.tscn - icon_path: res://sprites/Player.png + icon_path: res://sprites/packsack.png max_stack_value: 1 diff --git a/data/itemRegs/weapons.yaml b/data/itemRegs/weapons.yaml index 9637a34..a6a62f4 100644 --- a/data/itemRegs/weapons.yaml +++ b/data/itemRegs/weapons.yaml @@ -1,4 +1,4 @@ - id: staff_of_the_undead scene_path: res://prefab/weapons/staffOfTheUndead.tscn - icon_path: res://sprites/weapon/staffOfTheUndead.png + icon_path: res://sprites/weapon/staffOfTheUndead_icon.png max_stack_value: 1 diff --git a/prefab/packsacks/packsack.tscn b/prefab/packsacks/packsack.tscn index 8160034..2b6750f 100644 --- a/prefab/packsacks/packsack.tscn +++ b/prefab/packsacks/packsack.tscn @@ -1,20 +1,34 @@ -[gd_scene load_steps=4 format=3 uid="uid://cn10fimoem04m"] +[gd_scene load_steps=5 format=3 uid="uid://cn10fimoem04m"] [ext_resource type="Script" path="res://scripts/item/Packsack.cs" id="1_slakl"] -[ext_resource type="Texture2D" uid="uid://b1twcink38sh0" path="res://sprites/Player.png" id="2_e1ale"] +[ext_resource type="Texture2D" uid="uid://dvx10dfjctn7t" path="res://sprites/packsack.png" id="2_40jca"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_brthl"] +size = Vector2(21, 29) [sub_resource type="RectangleShape2D" id="RectangleShape2D_xqyue"] -size = Vector2(41, 57) +size = Vector2(21, 29) [node name="RigidBody2D" type="RigidBody2D"] collision_layer = 8 collision_mask = 38 script = ExtResource("1_slakl") Id = "packsack" +_minContactInjury = null +_maxContactInjury = null -[node name="Player" type="Sprite2D" parent="."] -texture = ExtResource("2_e1ale") +[node name="DamageArea2D" type="Area2D" parent="."] +collision_layer = 8 +collision_mask = 102 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="DamageArea2D"] +position = Vector2(-2.5, 1.5) +shape = SubResource("RectangleShape2D_brthl") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(-0.5, 3.5) +position = Vector2(-2.5, 1.5) shape = SubResource("RectangleShape2D_xqyue") + +[node name="Packsack" type="Sprite2D" parent="."] +scale = Vector2(0.5, 0.5) +texture = ExtResource("2_40jca") diff --git a/prefab/roomTemplates/dungeon/initialRoom.tscn b/prefab/roomTemplates/dungeon/initialRoom.tscn index c313f04..06fa45b 100644 --- a/prefab/roomTemplates/dungeon/initialRoom.tscn +++ b/prefab/roomTemplates/dungeon/initialRoom.tscn @@ -45,42 +45,18 @@ script = ExtResource("2_6p8mv") [node name="StaffOfTheUndead" parent="." instance=ExtResource("3_ud0w8")] position = Vector2(231, 116) -_minContactInjury = null -_maxContactInjury = null -_firingIntervalAsMillisecond = null -_recoil = null [node name="StaffOfTheUndead2" parent="." instance=ExtResource("3_ud0w8")] position = Vector2(113, 149) -_minContactInjury = null -_maxContactInjury = null -_firingIntervalAsMillisecond = null -_recoil = null [node name="StaffOfTheUndead5" parent="." instance=ExtResource("3_ud0w8")] position = Vector2(213, 177) -_minContactInjury = null -_maxContactInjury = null -_firingIntervalAsMillisecond = null -_recoil = null [node name="StaffOfTheUndead6" parent="." instance=ExtResource("3_ud0w8")] position = Vector2(290, 167) -_minContactInjury = null -_maxContactInjury = null -_firingIntervalAsMillisecond = null -_recoil = null [node name="StaffOfTheUndead3" parent="." instance=ExtResource("3_ud0w8")] position = Vector2(70, 88) -_minContactInjury = null -_maxContactInjury = null -_firingIntervalAsMillisecond = null -_recoil = null [node name="StaffOfTheUndead4" parent="." instance=ExtResource("3_ud0w8")] position = Vector2(367, 85) -_minContactInjury = null -_maxContactInjury = null -_firingIntervalAsMillisecond = null -_recoil = null diff --git a/prefab/ui/ItemSlot.tscn b/prefab/ui/ItemSlot.tscn index 4b1437c..bb518a1 100644 --- a/prefab/ui/ItemSlot.tscn +++ b/prefab/ui/ItemSlot.tscn @@ -6,6 +6,7 @@ [node name="ItemSlot" type="MarginContainer"] offset_right = 38.0 offset_bottom = 38.0 +size_flags_vertical = 3 theme_override_constants/margin_left = 3 theme_override_constants/margin_top = 3 theme_override_constants/margin_right = 3 @@ -16,16 +17,18 @@ script = ExtResource("1_fbwot") layout_mode = 2 texture = ExtResource("1_y2wyt") -[node name="CenterContainer" type="CenterContainer" parent="BackgroundTexture"] -layout_mode = 2 -offset_right = 160.0 -offset_bottom = 160.0 +[node name="IconTextureRect" type="TextureRect" parent="BackgroundTexture"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 3.0 +offset_top = 3.0 +offset_right = -3.0 +offset_bottom = -3.0 grow_horizontal = 2 grow_vertical = 2 -scale = Vector2(0.2, 0.2) - -[node name="IconTextureRect" type="TextureRect" parent="BackgroundTexture/CenterContainer"] -layout_mode = 2 +expand_mode = 1 [node name="Control" type="Control" parent="."] layout_mode = 2 diff --git a/prefab/ui/contributorGroup.tscn b/prefab/ui/contributorGroup.tscn index 8f30514..688b8d3 100644 --- a/prefab/ui/contributorGroup.tscn +++ b/prefab/ui/contributorGroup.tscn @@ -9,7 +9,6 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -size_flags_horizontal = 3 size_flags_vertical = 3 script = ExtResource("1_xwjh1") @@ -17,6 +16,8 @@ script = ExtResource("1_xwjh1") layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 +offset_left = 20.0 +offset_right = -1082.0 offset_bottom = 39.0 grow_horizontal = 2 theme_override_font_sizes/font_size = 25 @@ -27,6 +28,9 @@ layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_top = 51.0 +offset_left = 15.0 +offset_top = 45.0 +offset_right = -14.0 +offset_bottom = -6.0 grow_horizontal = 2 grow_vertical = 2 diff --git a/prefab/ui/packsackUI.tscn b/prefab/ui/packsackUI.tscn new file mode 100644 index 0000000..97249e6 --- /dev/null +++ b/prefab/ui/packsackUI.tscn @@ -0,0 +1,32 @@ +[gd_scene load_steps=2 format=3 uid="uid://dsat7xk63bfg2"] + +[ext_resource type="Script" path="res://scripts/inventory/PacksackUi.cs" id="1_jgs18"] + +[node name="PacksackUi" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 33.0 +offset_top = 81.0 +offset_right = -58.0 +offset_bottom = -35.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_jgs18") + +[node name="GridContainer" type="GridContainer" parent="."] +layout_mode = 1 +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_left = 3.0 +offset_top = -43.0 +offset_right = 43.0 +offset_bottom = -18.0 +text = "背包" diff --git a/prefab/weapons/staffOfTheUndead.tscn b/prefab/weapons/staffOfTheUndead.tscn index 29cebc9..63d73e1 100644 --- a/prefab/weapons/staffOfTheUndead.tscn +++ b/prefab/weapons/staffOfTheUndead.tscn @@ -15,16 +15,16 @@ collision_layer = 8 collision_mask = 34 script = ExtResource("1_w8hhv") ProjectileScenes = [ExtResource("2_34250")] +_firingIntervalAsMillisecond = null +_recoil = null Id = "staff_of_the_undead" _minContactInjury = null _maxContactInjury = null -_firingIntervalAsMillisecond = null -_recoil = null metadata/Projectiles = PackedStringArray("res://prefab/projectile/curseOfTheUndead.tscn") [node name="DamageArea2D" type="Area2D" parent="."] collision_layer = 8 -collision_mask = 71 +collision_mask = 70 [node name="CollisionShape2D" type="CollisionShape2D" parent="DamageArea2D"] position = Vector2(25.5, 0.5) diff --git a/project.godot b/project.godot index 933865e..fa06aa6 100644 --- a/project.godot +++ b/project.godot @@ -153,7 +153,7 @@ locale/translations=PackedStringArray("res://locals/DeathInfo.en.translation", " 2d_physics/layer_1="RoomArea" 2d_physics/layer_2="Ground" 2d_physics/layer_3="Player" -2d_physics/layer_4="Weapon" +2d_physics/layer_4="PickAbleItem" 2d_physics/layer_5="Projectile" 2d_physics/layer_6="Platform" 2d_physics/layer_7="Mob" diff --git a/scripts/Config.cs b/scripts/Config.cs index 5263cc5..e159156 100644 --- a/scripts/Config.cs +++ b/scripts/Config.cs @@ -377,7 +377,7 @@ public static class Config public const int RoomArea = 1; public const int Ground = 2; public const int Player = 3; - public const int Weapon = 4; + public const int PickAbleItem = 4; public const int Projectile = 5; public const int Platform = 6; public const int Mob = 7; diff --git a/scripts/SloganProvider.cs b/scripts/SloganProvider.cs index a92fe2a..384c140 100644 --- a/scripts/SloganProvider.cs +++ b/scripts/SloganProvider.cs @@ -1,4 +1,4 @@ -using ColdMint.scripts.utils; +using ColdMint.scripts.utils; using Godot; diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index dac5540..1391747 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -10,7 +10,7 @@ using ColdMint.scripts.inventory; using ColdMint.scripts.item; using ColdMint.scripts.utils; using ColdMint.scripts.item.weapon; - +using ColdMint.scripts.pickable; using Godot; namespace ColdMint.scripts.character; @@ -309,14 +309,14 @@ public partial class CharacterTemplate : CharacterBody2D //设置捡起物品的常规处理。 //You can supplement picking up state handling for more types of objects here. //您可以在这里补充更多类型对象的捡起状态处理。 - if (pickAbleItem is WeaponTemplate weaponTemplate) + if (pickAbleItem is PickAbleTemplate pickAbleTemplate) { - weaponTemplate.Owner = this; - weaponTemplate.Picked = true; - weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Platform, false); - weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Ground, false); - weaponTemplate.EnableContactInjury = false; - weaponTemplate.Sleeping = true; + pickAbleTemplate.Owner = this; + pickAbleTemplate.Picked = true; + pickAbleTemplate.SetCollisionMaskValue(Config.LayerNumber.Platform, false); + pickAbleTemplate.SetCollisionMaskValue(Config.LayerNumber.Ground, false); + pickAbleTemplate.EnableContactInjury = false; + pickAbleTemplate.Sleeping = true; } if (itemSlotNode.GetItem() != null && itemSlotNode.GetItem() == item && _currentItem == null) @@ -674,31 +674,31 @@ public partial class CharacterTemplate : CharacterBody2D CallDeferred("NodeReparent", node2D); switch (item) { - case WeaponTemplate weaponTemplate: + case PickAbleTemplate pickAbleTemplate: if (GameSceneNodeHolder.WeaponContainer == null) { return; } - weaponTemplate.Picked = false; + pickAbleTemplate.Picked = false; var timer = new Timer(); - weaponTemplate.AddChild(timer); + pickAbleTemplate.AddChild(timer); timer.WaitTime = _itemCollisionRecoveryTime; timer.OneShot = true; timer.Timeout += () => { //We cannot immediately resume the physical collision when the weapon is discharged, which will cause the weapon to collide with the ground and platform earlier, preventing the weapon from flying. //仍出武器时,我们不能立即恢复物理碰撞,立即恢复会导致武器更早的与地面和平台碰撞,阻止武器的飞行。 - weaponTemplate.EnableContactInjury = true; - weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Ground, true); - weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Platform, true); + pickAbleTemplate.EnableContactInjury = true; + pickAbleTemplate.SetCollisionMaskValue(Config.LayerNumber.Ground, true); + pickAbleTemplate.SetCollisionMaskValue(Config.LayerNumber.Platform, true); timer.QueueFree(); }; timer.Start(); - weaponTemplate.Sleeping = false; + pickAbleTemplate.Sleeping = false; //Setting an initial speed of 0 for items here prevents the problem of throwing items too fast. //在这里给物品设置一个为0的初始速度,可防止扔出物品时速度过快的问题。 - weaponTemplate.LinearVelocity = Vector2.Zero; + pickAbleTemplate.LinearVelocity = Vector2.Zero; break; } diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index a965b5c..f60298f 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -4,11 +4,11 @@ using System.Threading.Tasks; using ColdMint.scripts.damage; using ColdMint.scripts.deathInfo; +using ColdMint.scripts.debug; using ColdMint.scripts.item; using ColdMint.scripts.map.events; using ColdMint.scripts.utils; -using ColdMint.scripts.item.weapon; - +using ColdMint.scripts.pickable; using Godot; namespace ColdMint.scripts.character; @@ -24,7 +24,7 @@ public partial class Player : CharacterTemplate //Empty object projectile //空的物品抛射线 - private readonly Vector2[] _emptyVector2Array = new[] { Vector2.Zero }; + private readonly Vector2[] _emptyVector2Array = [Vector2.Zero]; //抛物线 private Line2D? _parabola; @@ -337,9 +337,9 @@ public partial class Player : CharacterTemplate base.Flip(); //If there is a weapon, flip it too //如果有武器的话,也要翻转 - if (CurrentItem is WeaponTemplate weapon) + if (CurrentItem is PickAbleTemplate pickAbleTemplate) { - weapon.Flip(FacingLeft); + pickAbleTemplate.Flip(FacingLeft); } } @@ -408,16 +408,16 @@ public partial class Player : CharacterTemplate : new Vector2(0, -PromptTextDistance); _floatLabel.RotationDegrees = 0 - rotationDegreesNode2D; var label = _floatLabel.GetNode