Added cultist jump state
This commit is contained in:
@@ -4,6 +4,7 @@ extends CultistMoveState
|
||||
|
||||
|
||||
@export var look_around_state: CultistState
|
||||
@export var jump_state: CultistState
|
||||
|
||||
|
||||
func physics_process(delta: float) -> void:
|
||||
@@ -14,8 +15,10 @@ func physics_process(delta: float) -> void:
|
||||
if player != null:
|
||||
cultist.target_x = player.position.x
|
||||
|
||||
if _is_target_reached() or _wall_ray_cast.is_colliding():
|
||||
if _is_target_reached():
|
||||
switch_state.emit(look_around_state)
|
||||
elif _wall_ray_cast.is_colliding():
|
||||
switch_state.emit(jump_state)
|
||||
else:
|
||||
cultist.update_x_velocity(_direction, cultist.MAX_CHASE_SPEED, delta)
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
extends CultistJumpState
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
super.enter()
|
||||
_direction = DIRECTION_LEFT
|
||||
cultist.sprite.play(CultistSprite.ANIMATION_JUMP_LEFT)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cqlym4lqahsd3
|
||||
@@ -0,0 +1,7 @@
|
||||
extends CultistJumpState
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
super.enter()
|
||||
_direction = DIRECTION_RIGHT
|
||||
cultist.sprite.play(CultistSprite.ANIMATION_JUMP_RIGHT)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cf52bjcpasft1
|
||||
@@ -2,6 +2,10 @@ class_name CultistState
|
||||
extends AbstractState
|
||||
|
||||
|
||||
const DIRECTION_LEFT = -1
|
||||
const DIRECTION_RIGHT = 1
|
||||
|
||||
|
||||
@export var cultist: AbstractCultist
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
@abstract
|
||||
class_name CultistJumpState
|
||||
extends CultistState
|
||||
|
||||
|
||||
@export var fall_state: CultistState
|
||||
|
||||
|
||||
var _direction := 0
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
cultist.velocity.y -= cultist.JUMP_VELOCITY
|
||||
|
||||
|
||||
func physics_process(delta: float) -> void:
|
||||
if cultist.velocity.y > 0:
|
||||
switch_state.emit(fall_state)
|
||||
else:
|
||||
cultist.velocity += cultist.get_gravity() * cultist.get_gravity_factor() * delta
|
||||
cultist.update_x_velocity(_direction, cultist.MAX_WALK_SPEED, delta)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cxvl7a8o7bc1p
|
||||
@@ -3,10 +3,6 @@ class_name CultistMoveState
|
||||
extends CultistState
|
||||
|
||||
|
||||
const DIRECTION_LEFT = -1
|
||||
const DIRECTION_RIGHT = 1
|
||||
|
||||
|
||||
@export var fall_state: CultistState
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user