From d6680bf506b30500cff2c7c6eb4f186073cda588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Mon, 13 Apr 2026 23:07:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=AD=A6=E5=99=A8=E7=B3=BB=E7=BB=9F):?= =?UTF-8?q?=20=E7=94=A8emitType=E6=9E=9A=E4=B8=BE=E6=9B=BF=E6=8D=A2chargab?= =?UTF-8?q?le=E5=92=8ConeShoot=E5=B8=83=E5=B0=94=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构武器发射逻辑,使用枚举类型EmitType来管理不同的武器发射方式 更新相关武器配置文件和角色控制逻辑 --- components/Characters/Rooster.tscn | 10 ++++++++++ components/Weapons/CursorKnife.tscn | 2 +- components/Weapons/Pipe.tscn | 8 +++++++- components/Weapons/Tree.tscn | 6 +++--- scripts/Contents/Characters/Rooster.gd | 18 ++++++++---------- scripts/Structs/Weapon.gd | 11 +++++++++-- 6 files changed, 38 insertions(+), 17 deletions(-) diff --git a/components/Characters/Rooster.tscn b/components/Characters/Rooster.tscn index b547192..22c7646 100644 --- a/components/Characters/Rooster.tscn +++ b/components/Characters/Rooster.tscn @@ -2,8 +2,11 @@ [ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_e5pl8"] [ext_resource type="Script" uid="uid://cthtupc6dtbav" path="res://scripts/Contents/Characters/Rooster.gd" id="2_oqdqd"] +[ext_resource type="PackedScene" uid="uid://c0n3igy4hucrg" path="res://components/Weapons/PurpleCrystal.tscn" id="3_joj4g"] [ext_resource type="AudioStream" uid="uid://cdrevrq7n6yqa" path="res://resources/sounds/effect/Boing.mp3" id="4_66s6c"] +[ext_resource type="PackedScene" uid="uid://cx7nogfnv7s8t" path="res://components/Weapons/Tree.tscn" id="4_jluqw"] [ext_resource type="AudioStream" uid="uid://benyec5bqni0b" path="res://resources/sounds/effect/Chomp.wav" id="4_k0yme"] +[ext_resource type="PackedScene" uid="uid://dyanyf044boxp" path="res://components/Weapons/Pipe.tscn" id="5_fkh3f"] [ext_resource type="AudioStream" uid="uid://dmxh3bpk8vyy5" path="res://resources/sounds/effect/Coin.mp3" id="5_xnbhq"] [ext_resource type="AudioStream" uid="uid://4wuuf1osk0yv" path="res://resources/sounds/effect/Low Boing.wav" id="6_m5px1"] [ext_resource type="Texture2D" uid="uid://fn8qx72clh38" path="res://resources/characters/cock/rooster-a.svg" id="8_da2ca"] @@ -100,6 +103,13 @@ process_material = SubResource("ParticleProcessMaterial_joj4g") [node name="weaponStore" parent="." index="2"] process_mode = 4 +[node name="PurpleCrystal" parent="weaponStore" index="0" unique_id=1478939386 instance=ExtResource("3_joj4g")] +debugRebuild = false + +[node name="Tree" parent="weaponStore" index="1" unique_id=185228402 instance=ExtResource("4_jluqw")] + +[node name="Pipe" parent="weaponStore" index="2" unique_id=946948425 instance=ExtResource("5_fkh3f")] + [node name="sprint" parent="sounds" index="0"] stream = ExtResource("4_66s6c") diff --git a/components/Weapons/CursorKnife.tscn b/components/Weapons/CursorKnife.tscn index 0814a5c..f562b96 100644 --- a/components/Weapons/CursorKnife.tscn +++ b/components/Weapons/CursorKnife.tscn @@ -11,7 +11,7 @@ avatarTexture = ExtResource("3_mdipf") displayName = "光标刃轮" typeTopic = 1 costBeachball = 350 -oneShoot = true +emitType = 1 store = { "atk": 10, "speed": 0.004 diff --git a/components/Weapons/Pipe.tscn b/components/Weapons/Pipe.tscn index 88e634d..e32a916 100644 --- a/components/Weapons/Pipe.tscn +++ b/components/Weapons/Pipe.tscn @@ -9,7 +9,7 @@ script = ExtResource("2_p67v7") avatarTexture = ExtResource("2_mmtf8") displayName = "钢管" costBeachball = 350 -chargable = true +emitType = 2 store = { "atk": 5 } @@ -30,5 +30,11 @@ count = 350 [node name="name" parent="container/info/displays" parent_id_path=PackedInt32Array(784441328) index="0" unique_id=1576068972] displayName = "钢管" +[node name="source" parent="container/info/displays" parent_id_path=PackedInt32Array(784441328) index="1" unique_id=365191794] +text = "MEME" + [node name="description" parent="container" parent_id_path=PackedInt32Array(575698869) index="2" unique_id=566230682] text = "[center]按住蓄力扔出钢管,蓄力越久伤害越高,至少造成[color=cyan]5[/color]点伤害,发射钢管后继续按住鼠标可进行连续发射。[/center]" + +[node name="tease" parent="container" parent_id_path=PackedInt32Array(575698869) index="3" unique_id=689277044] +visible = false diff --git a/components/Weapons/Tree.tscn b/components/Weapons/Tree.tscn index f04bf72..4ba36de 100644 --- a/components/Weapons/Tree.tscn +++ b/components/Weapons/Tree.tscn @@ -11,7 +11,7 @@ displayName = "扶桑元神" quality = 4 typeTopic = 3 costBeachball = 900 -oneShoot = true +emitType = 1 store = { "atk": 20, "count": 1.0, @@ -57,9 +57,9 @@ text = "Nine Sols × Terraria" text = "[center]进行[b]格挡[/b],化解飞来的子弹。 每成功格挡一次,获得一点[b]气力[/b]。 每拥有一点气力,增加[color=yellow]1[/color]点冲刺初速度,闪避穿过敌人时对其贴上一层[b]符咒[/b],符咒会自动引爆,召唤[b]乾坤剑[/b]穿透敌人。 -近战攻击造成乾坤剑的[color=cyan]100.0%[/color]点伤害。 +近战攻击造成乾坤剑的[color=cyan]25.0%[/color]点伤害。 -每次格挡有[color=cyan]100.0%[/color]的概率弹反,子弹弹反后造成乾坤剑的[color=cyan]100.0%[/color]伤害。 +每次格挡有[color=cyan]25.0%[/color]的概率弹反,子弹弹反后造成乾坤剑的[color=cyan]25.0%[/color]伤害。 每次格挡最多化解[color=cyan]1[/color]个子弹, 体内最多储存[color=cyan]3[/color]点气力。 每化解[color=yellow]1[/color]点伤害, diff --git a/scripts/Contents/Characters/Rooster.gd b/scripts/Contents/Characters/Rooster.gd index bed3a06..a588584 100644 --- a/scripts/Contents/Characters/Rooster.gd +++ b/scripts/Contents/Characters/Rooster.gd @@ -49,21 +49,19 @@ func tryLaunch(action: String, weaponIndex: int): if Input.is_action_just_pressed(action): if len(weapons) > weaponIndex: var weapon = weapons[weaponIndex] - if weapon.chargable and weapon.canAttackBy(self ): - chargeStartTime[weaponIndex] = Time.get_ticks_msec() - chargeParticle.emitting = true - chargeParticle.speed_scale = 1 - if Input.is_action_just_pressed(action): - if len(weapons) > weaponIndex: - var weapon = weapons[weaponIndex] - if weapon.oneShoot: + if weapon.emitType == Weapon.EmitType.CHARGE: + if weapon.canAttackBy(self ): + chargeStartTime[weaponIndex] = Time.get_ticks_msec() + chargeParticle.emitting = true + chargeParticle.speed_scale = 1 + elif weapon.emitType == Weapon.EmitType.CLICK_SHOOT: tryAttack(weaponIndex) if Input.is_action_pressed(action): if len(weapons) > weaponIndex: var weapon = weapons[weaponIndex] if chargeStartTime.has(weaponIndex): chargeParticle.speed_scale += 0.01 * self.fields.get(FieldStore.Entity.CHARGE_SPEED) - elif !weapon.oneShoot: + elif weapon.emitType == Weapon.EmitType.HOLD_SHOOT: tryAttack(weaponIndex) if Input.is_action_just_released(action): if chargeStartTime.has(weaponIndex): @@ -73,7 +71,7 @@ func tryLaunch(action: String, weaponIndex: int): chargeStartTime.erase(weaponIndex) if len(weapons) > weaponIndex: var weapon = weapons[weaponIndex] - if weapon.chargable: + if weapon.emitType == Weapon.EmitType.CHARGE: weapon.chargedTime = chargedTime * self.fields.get(FieldStore.Entity.CHARGE_SPEED) tryAttack(weaponIndex) chargeParticle.emitting = false diff --git a/scripts/Structs/Weapon.gd b/scripts/Structs/Weapon.gd index 5ee5015..4179530 100644 --- a/scripts/Structs/Weapon.gd +++ b/scripts/Structs/Weapon.gd @@ -2,14 +2,21 @@ extends PanelContainer class_name Weapon +enum EmitType { + HOLD_SHOOT, + CLICK_SHOOT, + CHARGE +} + @export var avatarTexture: Texture2D = null @export var displayName: String = "未命名武器" @export var quality: WeaponName.Quality = WeaponName.Quality.COMMON @export var typeTopic: WeaponName.TypeTopic = WeaponName.TypeTopic.IMPACT @export var soulLevel: int = 1 @export var costBeachball: int = 500 -@export var chargable: bool = false -@export var oneShoot: bool = false +# @export var chargable: bool = false +# @export var oneShoot: bool = false +@export var emitType: EmitType = EmitType.HOLD_SHOOT @export var store: Dictionary = { "atk": 10 }