1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00
Files
Dog-Lynx-And-HCN/scripts/Contents/Characters/Rooster.gd
T
fallingshrimp d1bf911c79 feat(武器): 添加钢管武器蓄力特效和音效
- 为钢管武器添加蓄力粒子效果
- 新增钢管落地音效资源
- 修改钢管子弹碰撞形状为圆形
- 添加钢管武器能量消耗和冷却时间配置
- 实现钢管子弹销毁时的落地效果
2026-02-05 20:26:47 +08:00

81 lines
2.4 KiB
GDScript

extends EntityBase
class_name Rooster
@onready var chargeParticle: GPUParticles2D = $%chargeParticle
func register():
attackCooldownMap[0] = 200
attackCooldownMap[1] = 6000
hit.connect(
func(_damage: float, bullet: BulletBase, _crit: bool):
if bullet is DogCircle:
EffectController.create(ComponentManager.getEffect("FeatherFall"), texture.global_position).shot()
elif bullet is FoxZhua:
EffectController.create(ComponentManager.getEffect("BloodFall"), texture.global_position).shot()
)
chargeParticle.emitting = false
var chargeStartTime = {}
func ai():
texture.play("walk")
var direction = Vector2(
Input.get_axis("m_left", "m_right"),
Input.get_axis("m_up", "m_down")
)
move(direction)
if direction.length() == 0:
texture.play("idle")
if Input.is_action_just_pressed("attack"):
startCharge(0)
if Input.is_action_just_released("attack"):
endCharge(0)
if Input.is_action_just_pressed("attack2"):
startCharge(1)
if Input.is_action_just_released("attack2"):
endCharge(1)
if Input.is_action_just_pressed("smallSkill"):
startCharge(2)
if Input.is_action_just_released("smallSkill"):
endCharge(2)
if Input.is_action_just_pressed("superSkill"):
startCharge(3)
if Input.is_action_just_released("superSkill"):
endCharge(3)
for i in range(3):
if Input.is_action_just_pressed("cardSkill" + str(i)):
startCharge(4 + i)
if Input.is_action_just_released("cardSkill" + str(i)):
endCharge(4 + i)
if Input.is_action_just_pressed("sprint"):
trySprint()
if Input.is_action_just_pressed("heal"):
if health < fields.get(FieldStore.Entity.MAX_HEALTH):
if useItem({
ItemStore.ItemType.APPLE: 1
}):
tryHeal(20)
func sprint():
move(Vector2(
Input.get_axis("m_left", "m_right"),
Input.get_axis("m_up", "m_down")
) * sprintMultiplier, true)
func startCharge(weaponIndex: int):
if len(weapons) > weaponIndex:
var weapon = weapons[weaponIndex]
if weapon.chargable:
chargeStartTime[weaponIndex] = Time.get_ticks_msec()
chargeParticle.emitting = true
func endCharge(weaponIndex: int):
if chargeStartTime.has(weaponIndex):
var startTime = chargeStartTime[weaponIndex]
var endTime = Time.get_ticks_msec()
var chargedTime = endTime - startTime
chargeStartTime.erase(weaponIndex)
if len(weapons) > weaponIndex:
var weapon = weapons[weaponIndex]
if weapon.chargable:
weapon.chargedTime = chargedTime
tryAttack(weaponIndex)
chargeParticle.emitting = false