feat: 1. 添加武器击退功能,player 使用weapon_behavior/melee_behavior(hitbox 会调用 setup 初始化) 的 hitbox 击中 enemy_slow,enemy_slow拿到hitbox的knockback_power,以及hitbox指向enemy的方向,然后朝着该方向,使用power击退:调用enemy.gd 的 apply_knockback,然后_process中会对position修改,同时开启定时器,定时器结束的时候,使用 reset_knockback 重置

This commit is contained in:
luke358
2026-05-19 17:39:58 +08:00
parent cf8c5b90ff
commit 4fa565e0e9
10 changed files with 110 additions and 7 deletions
+27
View File
@@ -0,0 +1,27 @@
extends Node2D
class_name WeaponBehavior
@export var weapon: Weapon
var critical := false
func execute_attack() -> void:
pass
func get_damage() -> float:
var damage := weapon.data.stats.damage + Global.player.stats.damage
var crit_chance := weapon.data.stats.crit_chance
if Global.get_chance_success(crit_chance):
crit_chance = true
damage = ceil(damage * weapon.data.stats.crit_damage)
return damage
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass