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 a563eabab3 feat(战斗系统): 添加技能攻击支持并修复武器数组越界问题
- 在EntityBase.gd中添加武器数组越界检查,防止崩溃
- 在Rooster.gd中新增技能攻击输入处理,支持3个技能按键
- 在project.godot中配置技能按键映射(1,2,3键)
2025-09-06 12:02:44 +08:00

36 lines
942 B
GDScript

extends EntityBase
class_name Rooster
func register():
attackCooldownMap[0] = 200
attackCooldownMap[1] = 6000
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_pressed("attack"):
tryAttack(0)
elif Input.is_action_pressed("attack2"):
tryAttack(1)
for i in range(3):
if Input.is_action_pressed("skill" + str(i)):
tryAttack(2 + i)
if Input.is_action_just_pressed("sprint"):
trySprint()
if Input.is_action_just_pressed("heal"):
tryHeal(20)
func sprint():
move(Vector2(
Input.get_axis("m_left", "m_right"),
Input.get_axis("m_up", "m_down")
) * sprintMultiplier, true)
func heal(count: float):
health += count
DamageLabel.create(-count, false, damageAnchor.global_position + MathTool.randv2_range(GameRule.damageLabelSpawnOffset))
return count