From edaa490b5beb828084a2656a28f87d40269757b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9C=A7=E9=9B=A8=E7=83=A8?= Date: Sat, 15 Jun 2024 17:16:41 +0800 Subject: [PATCH] =?UTF-8?q?Updated=20WeaponTemplate's=20FiringInterval=20c?= =?UTF-8?q?alculation=20so=20that=20it=20can=20be=20changed=20by=20FiringI?= =?UTF-8?q?ntervalAsMillisecond=20even=20after=20instantiation.=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86WeaponTemplate=E7=9A=84FiringInterva?= =?UTF-8?q?l=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F=E4=BB=A5=E4=BD=BF?= =?UTF-8?q?=E8=AF=A5=E5=80=BC=E5=8D=B3=E4=BE=BF=E5=9C=A8=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E5=8C=96=E4=B9=8B=E5=90=8E=E4=B9=9F=E5=8F=AF=E9=80=9A=E8=BF=87?= =?UTF-8?q?FiringIntervalAsMillisecond=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prefab/weapons/staffOfTheUndead.tscn | 1 + scripts/item/weapon/WeaponTemplate.cs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/prefab/weapons/staffOfTheUndead.tscn b/prefab/weapons/staffOfTheUndead.tscn index d4732bf..ca0c9c0 100644 --- a/prefab/weapons/staffOfTheUndead.tscn +++ b/prefab/weapons/staffOfTheUndead.tscn @@ -16,6 +16,7 @@ collision_mask = 34 script = ExtResource("1_w8hhv") ProjectileScenes = [ExtResource("2_34250")] Id = "staff_of_the_undead" +FiringIntervalAsMillisecond = 300 metadata/Projectiles = PackedStringArray("res://prefab/projectile/curseOfTheUndead.tscn") [node name="DamageArea2D" type="Area2D" parent="."] diff --git a/scripts/item/weapon/WeaponTemplate.cs b/scripts/item/weapon/WeaponTemplate.cs index e05fc82..c7e600a 100644 --- a/scripts/item/weapon/WeaponTemplate.cs +++ b/scripts/item/weapon/WeaponTemplate.cs @@ -3,6 +3,7 @@ using System; using ColdMint.scripts.camp; using ColdMint.scripts.character; using ColdMint.scripts.damage; + using Godot; namespace ColdMint.scripts.item.weapon; @@ -70,7 +71,16 @@ public abstract partial class WeaponTemplate : RigidBody2D, IItem /// 开火间隔 /// private TimeSpan _firingInterval; - [Export] private long _firingIntervalAsMillisecond = 100; + private long _firingIntervalAsMillisecond = 100; + [Export] protected long FiringIntervalAsMillisecond + { + get => _firingIntervalAsMillisecond; + set + { + _firingIntervalAsMillisecond = value; + _firingInterval = TimeSpan.FromMilliseconds(_firingIntervalAsMillisecond); + } + } /// @@ -101,8 +111,6 @@ public abstract partial class WeaponTemplate : RigidBody2D, IItem _damageArea2D = GetNode("DamageArea2D"); _damageArea2D.BodyEntered += OnBodyEnter; _damageArea2D.BodyExited += OnBodyExited; - - _firingInterval = TimeSpan.FromMilliseconds(_firingIntervalAsMillisecond); } private void OnBodyExited(Node node)