mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(战斗系统): 添加技能攻击支持并修复武器数组越界问题
- 在EntityBase.gd中添加武器数组越界检查,防止崩溃 - 在Rooster.gd中新增技能攻击输入处理,支持3个技能按键 - 在project.godot中配置技能按键映射(1,2,3键)
This commit is contained in:
@@ -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]
|
||||
|
||||
|
||||
@@ -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"):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user