Add combat combo gameplay
This commit is contained in:
@@ -8,18 +8,22 @@ const GRAVITY := 1200.0
|
||||
@export var attack_duration := 0.4
|
||||
@export var attack_lunge_duration := 0.18
|
||||
@export var attack_lunge_speed := 220.0
|
||||
@export var air_attack_duration := 0.45
|
||||
@export var air_attack_lunge_duration := 0.22
|
||||
@export var air_attack_lunge_speed := 260.0
|
||||
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var character_sprite: Sprite2D = $CharacterSprite
|
||||
|
||||
enum State { IDLE, WALK, JUMP, LAND, ATTACK }
|
||||
enum State { IDLE, WALK, JUMP, LAND, ATTACK, AIR_ATTACK }
|
||||
|
||||
var anim_map := {
|
||||
State.IDLE: "idle",
|
||||
State.WALK: "idle",
|
||||
State.JUMP: "jump",
|
||||
State.LAND: "idle",
|
||||
State.ATTACK: "挥砍",
|
||||
State.IDLE: "warrior_idle",
|
||||
State.WALK: "warrior_idle",
|
||||
State.JUMP: "warrior_w",
|
||||
State.LAND: "warrior_idle",
|
||||
State.ATTACK: "warrior_a",
|
||||
State.AIR_ATTACK: "warrior_a",
|
||||
}
|
||||
var attack_direction := Vector2.RIGHT
|
||||
var attack_lunge_time_left := 0.0
|
||||
@@ -55,7 +59,7 @@ func handle_air_time(delta: float) -> void:
|
||||
height_speed -= GRAVITY * delta
|
||||
|
||||
func handle_attack_time(delta: float) -> void:
|
||||
if state != State.ATTACK:
|
||||
if state != State.ATTACK and state != State.AIR_ATTACK:
|
||||
return
|
||||
velocity.y = 0.0
|
||||
attack_time_left -= delta
|
||||
@@ -68,7 +72,7 @@ func handle_attack_time(delta: float) -> void:
|
||||
velocity.x = 0.0
|
||||
|
||||
func handle_movement() -> void:
|
||||
if state == State.JUMP or state == State.ATTACK:
|
||||
if state == State.JUMP or state == State.ATTACK or state == State.AIR_ATTACK:
|
||||
return
|
||||
if absf(velocity.x) > 0.0:
|
||||
state = State.WALK
|
||||
@@ -97,6 +101,9 @@ func can_jump() -> bool:
|
||||
func can_attack() -> bool:
|
||||
return state == State.IDLE or state == State.WALK
|
||||
|
||||
func can_air_attack() -> bool:
|
||||
return state == State.IDLE or state == State.WALK
|
||||
|
||||
func start_jump() -> void:
|
||||
state = State.JUMP
|
||||
height_speed = jump_intensity
|
||||
@@ -112,3 +119,15 @@ func start_directional_attack(direction: Vector2) -> void:
|
||||
attack_time_left = attack_duration
|
||||
attack_lunge_time_left = attack_lunge_duration
|
||||
velocity = Vector2(attack_x * attack_lunge_speed, 0.0)
|
||||
|
||||
func start_air_attack() -> void:
|
||||
start_directional_air_attack(heading)
|
||||
|
||||
func start_directional_air_attack(direction: Vector2) -> void:
|
||||
var attack_x := -1.0 if direction.x < 0.0 else 1.0
|
||||
attack_direction = Vector2(attack_x, 0.0)
|
||||
heading = Vector2.RIGHT if attack_x > 0.0 else Vector2.LEFT
|
||||
state = State.AIR_ATTACK
|
||||
attack_time_left = air_attack_duration
|
||||
attack_lunge_time_left = air_attack_lunge_duration
|
||||
velocity = Vector2(attack_x * air_attack_lunge_speed, 0.0)
|
||||
|
||||
Reference in New Issue
Block a user