mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 15:01:53 +08:00
d4501ae45d
refactor: 重构子弹生成逻辑,支持分裂和折射效果 fix: 修复掉落物拾取范围和碰撞检测问题 style: 优化UI显示,添加武器品质和类型标签 docs: 更新字段描述,调整部分饲料名称和分类 perf: 优化数学工具函数,添加随机数处理工具 test: 调整波次生成逻辑,添加新敌人类型 build: 添加新资源文件和相关导入配置
40 lines
1.2 KiB
GDScript
40 lines
1.2 KiB
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)
|
|
if Input.is_action_just_pressed("sprint"):
|
|
trySprint()
|
|
if Input.is_action_just_pressed("heal"):
|
|
tryHeal(20)
|
|
func attack(type):
|
|
if type == 0:
|
|
var weaponPos = findWeaponAnchor("normal")
|
|
BulletBase.generate(preload("res://components/Bullets/LGBTBullet.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360)))
|
|
elif type == 1:
|
|
var weaponPos = findWeaponAnchor("normal")
|
|
return BulletBase.generate(preload("res://components/Bullets/BigLaser.tscn"), self, weaponPos, (get_global_mouse_position() - weaponPos).angle())
|
|
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
|