From a563eabab338f4dad13ddff95d6d9c687f96180c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Sat, 6 Sep 2025 12:02:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=88=98=E6=96=97=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8A=80=E8=83=BD=E6=94=BB=E5=87=BB=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=B9=B6=E4=BF=AE=E5=A4=8D=E6=AD=A6=E5=99=A8=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E8=B6=8A=E7=95=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在EntityBase.gd中添加武器数组越界检查,防止崩溃 - 在Rooster.gd中新增技能攻击输入处理,支持3个技能按键 - 在project.godot中配置技能按键映射(1,2,3键) --- project.godot | 15 +++++++++++++++ scripts/Contents/Characters/Rooster.gd | 3 +++ scripts/Statemachine/EntityBase.gd | 5 ++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/project.godot b/project.godot index 2ba9343..04baa8e 100644 --- a/project.godot +++ b/project.godot @@ -82,6 +82,21 @@ openWeapon={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null) ] } +skill0={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"key_label":0,"unicode":49,"location":0,"echo":false,"script":null) +] +} +skill1={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":50,"key_label":0,"unicode":50,"location":0,"echo":false,"script":null) +] +} +skill2={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":51,"key_label":0,"unicode":51,"location":0,"echo":false,"script":null) +] +} [physics] diff --git a/scripts/Contents/Characters/Rooster.gd b/scripts/Contents/Characters/Rooster.gd index c186888..bd604ad 100644 --- a/scripts/Contents/Characters/Rooster.gd +++ b/scripts/Contents/Characters/Rooster.gd @@ -17,6 +17,9 @@ func ai(): 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"): diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 6662a9f..3ee6d02 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -199,7 +199,10 @@ func useEnergy(value: float): func tryAttack(type: int, needChargeUp: bool = false): var weapon: Weapon if isPlayer(): - weapon = weapons[type] + if len(weapons) > type: + weapon = weapons[type] + else: + return var state if isPlayer(): state = true