1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-13 07:07:12 +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
+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
}