diff --git a/prefab/furnitures/SpellEditor.tscn b/prefab/furnitures/SpellEditor.tscn index b4e33cd..f2695c9 100644 --- a/prefab/furnitures/SpellEditor.tscn +++ b/prefab/furnitures/SpellEditor.tscn @@ -1,7 +1,7 @@ -[gd_scene load_steps=5 format=3 uid="uid://djsh4unystlf0"] +[gd_scene load_steps=16 format=3 uid="uid://djsh4unystlf0"] -[ext_resource type="Texture2D" uid="uid://qowlv0viyqbb" path="res://sprites/ui/Null.png" id="1_346je"] [ext_resource type="Script" path="res://scripts/furniture/GuiFurniture.cs" id="1_t1qdg"] +[ext_resource type="Texture2D" uid="uid://cyciw4drjvrs8" path="res://sprites/furnitures/SpellEditor.png" id="2_sbshw"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_vx4tg"] size = Vector2(31, 31) @@ -9,15 +9,90 @@ size = Vector2(31, 31) [sub_resource type="CircleShape2D" id="CircleShape2D_in1f7"] radius = 52.6118 +[sub_resource type="AtlasTexture" id="AtlasTexture_yq6e3"] +atlas = ExtResource("2_sbshw") +region = Rect2(0, 0, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ljyfv"] +atlas = ExtResource("2_sbshw") +region = Rect2(44, 0, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_46j2i"] +atlas = ExtResource("2_sbshw") +region = Rect2(88, 0, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_q6a2v"] +atlas = ExtResource("2_sbshw") +region = Rect2(132, 0, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lyh2i"] +atlas = ExtResource("2_sbshw") +region = Rect2(0, 43, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_84sml"] +atlas = ExtResource("2_sbshw") +region = Rect2(44, 43, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_xncbb"] +atlas = ExtResource("2_sbshw") +region = Rect2(88, 43, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eaqhr"] +atlas = ExtResource("2_sbshw") +region = Rect2(132, 43, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bcdl4"] +atlas = ExtResource("2_sbshw") +region = Rect2(0, 86, 44, 43) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a4mgy"] +atlas = ExtResource("2_sbshw") +region = Rect2(44, 86, 44, 43) + +[sub_resource type="SpriteFrames" id="SpriteFrames_mppe5"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_yq6e3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ljyfv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_46j2i") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_q6a2v") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lyh2i") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_84sml") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xncbb") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eaqhr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bcdl4") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_a4mgy") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + [node name="RigidBody2D" type="RigidBody2D"] collision_layer = 256 collision_mask = 160 script = ExtResource("1_t1qdg") Path = "res://prefab/ui/SpellEditorUI.tscn" -[node name="Null" type="Sprite2D" parent="."] -texture = ExtResource("1_346je") - [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(-0.5, -0.5) shape = SubResource("RectangleShape2D_vx4tg") @@ -27,3 +102,9 @@ visible = false [node name="CollisionShape2D" type="CollisionShape2D" parent="OperateArea2D"] shape = SubResource("CircleShape2D_in1f7") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.7, 0.7) +sprite_frames = SubResource("SpriteFrames_mppe5") +autoplay = "default" +frame_progress = 0.717769 diff --git a/scenes/game.tscn b/scenes/game.tscn index 4f0f259..fe5936c 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -84,13 +84,16 @@ text = "ui_re_create_map" [node name="SeedLabel" type="Label" parent="CanvasLayer/Control"] layout_mode = 1 -anchors_preset = 5 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -20.0 -offset_right = 20.0 -offset_bottom = 25.0 -grow_horizontal = 2 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -45.0 +offset_top = -16.0 +grow_horizontal = 0 +grow_vertical = 0 +theme_override_font_sizes/font_size = 10 [node name="MapContainer" parent="CanvasLayer/Control" instance=ExtResource("6_ljdj4")] layout_mode = 1 diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index 294cdd6..5258480 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -784,6 +784,7 @@ public partial class CharacterTemplate : CharacterBody2D { //Remove the item from the item container //从物品容器内取出物品 + originalItem.OnThrow(velocity); var item = originalItem.CreateItem(1); if (item is not Node2D node2D) { diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index 270c0ed..cd68e22 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -89,7 +89,6 @@ public partial class Player : CharacterTemplate private void SelectedItemChangeEvent(SelectedItemChangeEvent selectedItemChangeEvent) { var item = selectedItemChangeEvent.NewItem; - GameSceneDepend.DynamicUiGroup?.HideAllControl(); if (item is Node2D node2D) { CurrentItem = node2D; @@ -229,9 +228,6 @@ public partial class Player : CharacterTemplate { UseItem(GetGlobalMousePosition()); } - - - //Pick up an item //捡起物品 if (Input.IsActionJustPressed("pick_up")) @@ -305,7 +301,6 @@ public partial class Player : CharacterTemplate } ThrowItem(ItemContainer.GetSelectIndex(), 1, GetThrowVelocity()); - GameSceneDepend.DynamicUiGroup?.HideAllControl(); CurrentItem = null; } } diff --git a/scripts/inventory/IItem.cs b/scripts/inventory/IItem.cs index 70e2242..38a4d69 100644 --- a/scripts/inventory/IItem.cs +++ b/scripts/inventory/IItem.cs @@ -121,4 +121,11 @@ public interface IItem /// Owner of current item, if any /// Target position, such as the position of the cursor when used by the player void Use(Node2D? owner, Vector2 targetGlobalPosition); + + /// + /// When the item is thrown + /// 当物品被抛出时 + /// + /// + void OnThrow(Vector2 velocity); } \ No newline at end of file diff --git a/scripts/inventory/Packsack.cs b/scripts/inventory/Packsack.cs index e02532f..b0768c9 100644 --- a/scripts/inventory/Packsack.cs +++ b/scripts/inventory/Packsack.cs @@ -25,6 +25,20 @@ public partial class Packsack : PickAbleTemplate }); } + protected override void OnSelectChange(bool isSelected) + { + if (isSelected) + { + return; + } + GameSceneDepend.DynamicUiGroup?.HideControl(Path); + } + + public override void OnThrow(Vector2 velocity) + { + GameSceneDepend.DynamicUiGroup?.HideControl(Path); + } + public override void CopyAttributes(Node node) { base.CopyAttributes(node); diff --git a/scripts/inventory/PlaceholderItem.cs b/scripts/inventory/PlaceholderItem.cs index f26e0aa..e7a7f1d 100644 --- a/scripts/inventory/PlaceholderItem.cs +++ b/scripts/inventory/PlaceholderItem.cs @@ -48,5 +48,11 @@ public class PlaceholderItem : IItem public void Use(Node2D? owner, Vector2 targetGlobalPosition) { + throw new System.NotImplementedException(); + } + + public void OnThrow(Vector2 velocity) + { + throw new System.NotImplementedException(); } } \ No newline at end of file diff --git a/scripts/loader/uiLoader/SpellEditorUi.cs b/scripts/loader/uiLoader/SpellEditorUi.cs index 9052a3c..027a6ec 100644 --- a/scripts/loader/uiLoader/SpellEditorUi.cs +++ b/scripts/loader/uiLoader/SpellEditorUi.cs @@ -1,4 +1,5 @@ using ColdMint.scripts.inventory; +using ColdMint.scripts.map.events; using Godot; namespace ColdMint.scripts.loader.uiLoader; @@ -14,9 +15,28 @@ public partial class SpellEditorUi : UiLoaderTemplate _exitButton = GetNode