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 df1f837195 fix: 调整子弹偏移值并优化齿轮子弹逻辑
调整EntityBase中子弹偏移值从3改为5
在Cogwheel.gd中添加spawn函数并优化减速逻辑
在Rooster.gd中修复chargeStartTime变量位置并添加测试用额外子弹数
2026-02-16 17:57:57 +08:00

75 lines
2.4 KiB
GDScript

extends EntityBase
class_name Rooster
var chargeStartTime = {}
@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
if !WorldManager.isRelease():
fields[FieldStore.Entity.EXTRA_BULLET_COUNT] = 3
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")
tryLaunch("attack", 0)
tryLaunch("attack2", 1)
tryLaunch("smallSkill", 2)
tryLaunch("superSkill", 3)
for i in range(3):
tryLaunch("cardSkill%d" % i, 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 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_pressed(action):
if chargeStartTime.has(weaponIndex):
chargeParticle.speed_scale += 0.01 * self.fields.get(FieldStore.Entity.CHARGE_SPEED)
else:
tryAttack(weaponIndex)
if Input.is_action_just_released(action):
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 * self.fields.get(FieldStore.Entity.CHARGE_SPEED)
tryAttack(weaponIndex)
chargeParticle.emitting = false