1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

refactor(武器系统): 用emitType枚举替换chargable和oneShoot布尔值

重构武器发射逻辑,使用枚举类型EmitType来管理不同的武器发射方式
更新相关武器配置文件和角色控制逻辑
This commit is contained in:
2026-04-13 23:07:48 +08:00
parent a4f923a14f
commit d6680bf506
6 changed files with 38 additions and 17 deletions
+10
View File
@@ -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")
+1 -1
View File
@@ -11,7 +11,7 @@ avatarTexture = ExtResource("3_mdipf")
displayName = "光标刃轮"
typeTopic = 1
costBeachball = 350
oneShoot = true
emitType = 1
store = {
"atk": 10,
"speed": 0.004
+7 -1
View File
@@ -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
+3 -3
View File
@@ -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]点伤害,
+8 -10
View File
@@ -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
+9 -2
View File
@@ -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
}