diff --git a/data/itemRegs/weapons.yaml b/data/itemRegs/weapons.yaml index 784ffc6..ca29e2e 100644 --- a/data/itemRegs/weapons.yaml +++ b/data/itemRegs/weapons.yaml @@ -18,4 +18,8 @@ - id: iron_axe scene_path: res://prefab/weapons/IronAxe.tscn icon_path: res://sprites/weapon/StaffNecromancy_Icon.png + max_stack_value: 1 +- id: beginner_staff + scene_path: res://prefab/weapons/BeginnerStaff.tscn + icon_path: res://sprites/weapon/BeginnerStaff_Icon.png max_stack_value: 1 \ No newline at end of file diff --git a/locals/Item.csv b/locals/Item.csv index ae5e524..442baac 100644 --- a/locals/Item.csv +++ b/locals/Item.csv @@ -12,4 +12,6 @@ item_resignation_certificate_desc,冷薄荷,感谢您在职时为公司做出 item_iron_axe,铁斧子,Iron axe,鉄の斧です item_iron_axe_desc,铁斧子,Iron axe,鉄の斧です item_curse,死灵诅咒法术,The curse of the Dead,死霊呪いの術 -item_curse_desc,杀死敌人后在生成死灵敌人。,Spawn Undead enemies after killing them.,敵を殺すと死霊敵が発生します。 \ No newline at end of file +item_curse_desc,杀死敌人后在生成死灵敌人。,Spawn Undead enemies after killing them.,敵を殺すと死霊敵が発生します。 +item_beginner_staff,初学者法杖,Beginner's staff,初心者用の杖です +item_beginner_staff_desc,送给初来乍到的冒险家。,For new adventurers.,初心者の冒険家に贈ります。 \ No newline at end of file diff --git a/prefab/entitys/BlackenedAboriginalWarrior.tscn b/prefab/entitys/BlackenedAboriginalWarrior.tscn index 67ceb30..43d9ec7 100644 --- a/prefab/entitys/BlackenedAboriginalWarrior.tscn +++ b/prefab/entitys/BlackenedAboriginalWarrior.tscn @@ -33,6 +33,7 @@ radius = 172.29 collision_layer = 64 collision_mask = 38 script = ExtResource("1_ubaid") +InitWeaponId = "staff_necromancy" CharacterName = "character_evil_crow" CanMutateAfterDeath = false MaxHp = 50 diff --git a/prefab/roomTemplates/tutorials/spellEditor.tscn b/prefab/roomTemplates/tutorials/spellEditor.tscn index e48ed08..2a25ba3 100644 --- a/prefab/roomTemplates/tutorials/spellEditor.tscn +++ b/prefab/roomTemplates/tutorials/spellEditor.tscn @@ -113,7 +113,7 @@ position = Vector2(134, 248) script = ExtResource("4_6ihp7") _itemIdList = PackedStringArray("necromancy") -[node name="staff_necromancy" type="Marker2D" parent="AutoSpawn"] +[node name="beginner_staff" type="Marker2D" parent="AutoSpawn"] position = Vector2(100, 250) script = ExtResource("4_6ihp7") -_itemIdList = PackedStringArray("staff_necromancy") +_itemIdList = PackedStringArray("beginner_staff") diff --git a/prefab/weapons/BeginnerStaff.tscn b/prefab/weapons/BeginnerStaff.tscn new file mode 100644 index 0000000..bde7a79 --- /dev/null +++ b/prefab/weapons/BeginnerStaff.tscn @@ -0,0 +1,51 @@ +[gd_scene load_steps=7 format=3 uid="uid://cg2jmn7cs8m2c"] + +[ext_resource type="Script" path="res://scripts/weapon/ProjectileWeapon.cs" id="1_w4b6p"] +[ext_resource type="Texture2D" uid="uid://pf2ilanjwino" path="res://sprites/weapon/BeginnerStaff_Icon.png" id="2_ip8xd"] +[ext_resource type="Texture2D" uid="uid://b4g1mkvjf7uns" path="res://sprites/weapon/BeginnerStaff.png" id="3_rhhwp"] +[ext_resource type="AudioStream" uid="uid://cak6chjjsu7wo" path="res://sounds/fire.wav" id="4_p12sk"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_obcq2"] +size = Vector2(49, 5) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_14m1g"] +size = Vector2(49, 5.25) + +[node name="BeginnerStaff" type="RigidBody2D"] +collision_layer = 8 +collision_mask = 34 +script = ExtResource("1_w4b6p") +_numberSlots = 5 +_fireSequentially = true +FiringIntervalAsMillisecond = 300 +_recoilStrength = 5 +UniqueIcon = ExtResource("2_ip8xd") + +[node name="DamageArea2D" type="Area2D" parent="."] +collision_layer = 8 +collision_mask = 102 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="DamageArea2D"] +position = Vector2(25.5, 0.5) +shape = SubResource("RectangleShape2D_obcq2") + +[node name="StaffOfTheUndead2" type="Sprite2D" parent="."] +position = Vector2(30, 0) +texture = ExtResource("3_rhhwp") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(25.5, 0.375) +shape = SubResource("RectangleShape2D_14m1g") + +[node name="Marker2D" type="Marker2D" parent="."] +position = Vector2(65, 0) + +[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="Marker2D"] +stream = ExtResource("4_p12sk") +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/scenes/mapContainer.tscn b/scenes/mapContainer.tscn index cdd4b20..1e1438d 100644 --- a/scenes/mapContainer.tscn +++ b/scenes/mapContainer.tscn @@ -4,6 +4,33 @@ [ext_resource type="Script" path="res://scripts/map/miniMap/MiniMap.cs" id="2_ltp8b"] [ext_resource type="Texture2D" uid="uid://cfpcm0hkmpu38" path="res://sprites/ui/mark.png" id="3_x80y0"] +[sub_resource type="Animation" id="Animation_dkx17"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Control/MiniMap:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(983, 480)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Control/MiniMap:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} + [sub_resource type="Animation" id="Animation_jdj6o"] resource_name = "hide" length = 0.3 @@ -32,33 +59,6 @@ tracks/1/keys = { "values": [true, false] } -[sub_resource type="Animation" id="Animation_dkx17"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Control/MiniMap:position") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(983, 480)] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Control/MiniMap:visible") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [true] -} - [sub_resource type="Animation" id="Animation_icaqa"] resource_name = "show" length = 0.3 diff --git a/scripts/character/AiCharacter.cs b/scripts/character/AiCharacter.cs index cbefc43..20e5390 100644 --- a/scripts/character/AiCharacter.cs +++ b/scripts/character/AiCharacter.cs @@ -106,10 +106,10 @@ public sealed partial class AiCharacter : CharacterTemplate private BubbleMarker? _bubbleMarker; /// - /// The initial weapons scene - /// 初始的武器场景 + /// Initial weapon ID + /// 初始的武器ID /// - [Export] public string? InitWeaponRes; + [Export] public string? InitWeaponId; public override void _Ready() { @@ -184,30 +184,26 @@ public sealed partial class AiCharacter : CharacterTemplate ProtectedItemContainer = universalItemContainer; //Add initial weapon //添加初始武器 - AddInitialWeapon(InitWeaponRes); + AddInitialWeapon(InitWeaponId); } /// /// Adds an initial weapon to the character /// 为角色添加初始的武器 /// - private void AddInitialWeapon(string? initWeaponRes) + private void AddInitialWeapon(string? initWeaponId) { - if (string.IsNullOrEmpty(initWeaponRes)) + if (string.IsNullOrEmpty(initWeaponId)) { return; } - //Set the resource path of the initial weapon and try to create the object of the initial weapon. - //设置了初始武器的资源路径,尝试创建初始武器的对象。 - var packedScene = ResourceLoader.Load(initWeaponRes); - var weaponTemplate = NodeUtils.InstantiatePackedScene(packedScene); - if (weaponTemplate == null) + var item = ItemTypeManager.CreateItem(initWeaponId, this); + if (item is not WeaponTemplate weaponTemplate) { return; } - - NodeUtils.CallDeferredAddChild(this, weaponTemplate); + NodeUtils.CallDeferredReparent(this, weaponTemplate); PickItem(weaponTemplate); } @@ -477,4 +473,4 @@ public sealed partial class AiCharacter : CharacterTemplate StateMachine.Stop(); } } -} +} \ No newline at end of file diff --git a/sprites/weapon/BeginnerStaff.png b/sprites/weapon/BeginnerStaff.png new file mode 100644 index 0000000..53af66f Binary files /dev/null and b/sprites/weapon/BeginnerStaff.png differ diff --git a/sprites/weapon/BeginnerStaff.png.import b/sprites/weapon/BeginnerStaff.png.import new file mode 100644 index 0000000..6476866 --- /dev/null +++ b/sprites/weapon/BeginnerStaff.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b4g1mkvjf7uns" +path="res://.godot/imported/BeginnerStaff.png-b812f1377a68497cf5d497a50a7dc4eb.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/weapon/BeginnerStaff.png" +dest_files=["res://.godot/imported/BeginnerStaff.png-b812f1377a68497cf5d497a50a7dc4eb.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/sprites/weapon/BeginnerStaffIcon.png.import b/sprites/weapon/BeginnerStaffIcon.png.import new file mode 100644 index 0000000..6919fe1 --- /dev/null +++ b/sprites/weapon/BeginnerStaffIcon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://r2obk433du1r" +path="res://.godot/imported/BeginnerStaffIcon.png-e12838ace0d9a63d4c717c73ff599a24.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/weapon/BeginnerStaffIcon.png" +dest_files=["res://.godot/imported/BeginnerStaffIcon.png-e12838ace0d9a63d4c717c73ff599a24.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/sprites/weapon/BeginnerStaff_Icon.png b/sprites/weapon/BeginnerStaff_Icon.png new file mode 100644 index 0000000..594ba38 Binary files /dev/null and b/sprites/weapon/BeginnerStaff_Icon.png differ diff --git a/sprites/weapon/BeginnerStaff_Icon.png.import b/sprites/weapon/BeginnerStaff_Icon.png.import new file mode 100644 index 0000000..30ec7f0 --- /dev/null +++ b/sprites/weapon/BeginnerStaff_Icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://pf2ilanjwino" +path="res://.godot/imported/BeginnerStaff_Icon.png-5f3c025d334f338333d0f48cf2e52c0e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/weapon/BeginnerStaff_Icon.png" +dest_files=["res://.godot/imported/BeginnerStaff_Icon.png-5f3c025d334f338333d0f48cf2e52c0e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1