You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB
GDScript

2 years ago
extends Node3D
class_name PlayerAction
@onready var test_bullet = load("res://config/character/bullet01.tres")
2 years ago
@onready var character = (get_owner() as Character)
@onready var status = (%Status as Status)
@onready var combo = (%Combo as Combo)
2 years ago
2 years ago
func check_action(key:String,is_pressed:bool) -> bool:
if is_pressed and check_action_pressed(key):
return true
2 years ago
match key:
"lock":lock(is_pressed)
"switch":switch(is_pressed)
2 years ago
_:return false
return true
func check_action_pressed(key:String) -> bool:
match key:
"weapon_pre":combo.weapon_index_change(-1)
"weapon_next":combo.weapon_index_change(1)
"test_1":
Global.character_mgr.create_character(test_bullet,character.team(),character.pos())
_:return false
return true
2 years ago
func lock(is_pressed:bool):
2 years ago
var has_target = status.target != 0
2 years ago
if is_pressed == has_target:
return
if is_pressed:
2 years ago
var enemy_list = Global.character_mgr.get_enemy_list(character.id())
if enemy_list:
2 years ago
character.set_target(enemy_list[0].id())
2 years ago
else:
2 years ago
character.set_target(0)
2 years ago
func switch(is_pressed:bool):
character.set_status("is_switch",is_pressed)