Added high wall rays
This commit is contained in:
@@ -3,7 +3,8 @@ extends CultistChaseState
|
||||
|
||||
func init() -> void:
|
||||
_direction = DIRECTION_LEFT
|
||||
_wall_ray_cast = cultist.left_wall_ray
|
||||
_wall_high_ray_cast = cultist.left_wall_high_ray
|
||||
_wall_low_ray_cast = cultist.left_wall_low_ray
|
||||
_player_ray_cast = cultist.left_player_distant_ray
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ extends CultistChaseState
|
||||
|
||||
func init() -> void:
|
||||
_direction = DIRECTION_RIGHT
|
||||
_wall_ray_cast = cultist.right_wall_ray
|
||||
_wall_high_ray_cast = cultist.right_wall_high_ray
|
||||
_wall_low_ray_cast = cultist.right_wall_low_ray
|
||||
_player_ray_cast = cultist.right_player_distant_ray
|
||||
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ func physics_process(delta: float) -> void:
|
||||
if player != null:
|
||||
cultist.target_x = player.position.x
|
||||
|
||||
if _is_target_reached():
|
||||
if _is_target_reached() or _wall_high_ray_cast.is_colliding():
|
||||
switch_state.emit(look_around_state)
|
||||
elif _wall_ray_cast.is_colliding():
|
||||
elif _wall_low_ray_cast.is_colliding():
|
||||
switch_state.emit(jump_state)
|
||||
else:
|
||||
cultist.update_x_velocity(_direction, cultist.MAX_CHASE_SPEED, delta)
|
||||
|
||||
@@ -12,7 +12,7 @@ var state_by_ray_cast : Dictionary[RayCast2D, CultistState]
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
cultist.sprite.animation_finished.connect(_on_animation_finished, CONNECT_ONE_SHOT)
|
||||
cultist.sprite.animation_finished.connect(_on_animation_finished)
|
||||
cultist.sprite.play(CultistSprite.LOOK_AROUND_ANIMATIONS.pick_random())
|
||||
cultist.velocity = Vector2.ZERO
|
||||
cultist._set_ray_cast_enable(cultist.left_player_close_ray, true)
|
||||
@@ -36,6 +36,7 @@ func physics_process(_delta: float) -> void:
|
||||
|
||||
|
||||
func exit() -> void:
|
||||
cultist.sprite.animation_finished.disconnect(_on_animation_finished)
|
||||
cultist._set_ray_cast_enable(cultist.left_player_close_ray, false)
|
||||
cultist._set_ray_cast_enable(cultist.right_player_close_ray, false)
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ extends CultistState
|
||||
@warning_ignore("unused_private_class_variable")
|
||||
var _direction := 0
|
||||
@warning_ignore("unused_private_class_variable")
|
||||
var _wall_ray_cast : RayCast2D
|
||||
var _wall_high_ray_cast : RayCast2D
|
||||
@warning_ignore("unused_private_class_variable")
|
||||
var _wall_low_ray_cast : RayCast2D
|
||||
var _player_ray_cast : RayCast2D
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ extends CultistWalkState
|
||||
|
||||
func init() -> void:
|
||||
_direction = DIRECTION_LEFT
|
||||
_wall_ray_cast = cultist.left_wall_ray
|
||||
_wall_high_ray_cast = cultist.left_wall_high_ray
|
||||
_wall_low_ray_cast = cultist.left_wall_low_ray
|
||||
_player_ray_cast = cultist.left_player_distant_ray
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ extends CultistWalkState
|
||||
|
||||
func init() -> void:
|
||||
_direction = DIRECTION_RIGHT
|
||||
_wall_ray_cast = cultist.right_wall_ray
|
||||
_wall_high_ray_cast = cultist.right_wall_high_ray
|
||||
_wall_low_ray_cast = cultist.right_wall_low_ray
|
||||
_player_ray_cast = cultist.right_player_distant_ray
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ func physics_process(delta: float) -> void:
|
||||
if player != null:
|
||||
switch_state.emit(chase_state)
|
||||
else:
|
||||
if _wall_ray_cast.is_colliding():
|
||||
if _wall_low_ray_cast.is_colliding() or _wall_high_ray_cast.is_colliding():
|
||||
var stream := SoundManager.sfx_stream_player_lost
|
||||
SoundManager.play_sfx_stream(stream, cultist.global_position)
|
||||
switch_state.emit(another_direction_walk_state)
|
||||
|
||||
Reference in New Issue
Block a user