Fixed enemy rays

This commit is contained in:
2026-01-29 20:58:11 +03:00
parent f870bd4dfe
commit 36c123ea5d
25 changed files with 42 additions and 30 deletions
@@ -0,0 +1,10 @@
class_name AbstractColorEnemy
extends AbstractEnemy
@onready var collision_switcher : CollisionSwitcher = $CollisionSwitcher
func _ready() -> void:
super._ready()
collision_switcher.material = sprite.material
@@ -0,0 +1 @@
uid://das7ujanefsn0
@@ -0,0 +1,26 @@
[gd_scene format=3 uid="uid://d37eyum03h83i"]
[ext_resource type="PackedScene" uid="uid://bx0luh4vdob3q" path="res://game/characters/enemies/abstract_enemy.tscn" id="1_12hr0"]
[ext_resource type="Script" uid="uid://das7ujanefsn0" path="res://game/characters/enemies/abstract_color_enemy.gd" id="2_rd56i"]
[ext_resource type="PackedScene" uid="uid://5qlocc0yu8ug" path="res://game/collision_switcher.tscn" id="3_e5cea"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_r5rx0"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ybui5"]
resource_local_to_scene = true
shader = ExtResource("3_r5rx0")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = false
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0
[node name="AbstractColorEnemy" instance=ExtResource("1_12hr0")]
script = ExtResource("2_rd56i")
[node name="AnimatedSprite2D" parent="." index="0"]
material = SubResource("ShaderMaterial_ybui5")
[node name="CollisionSwitcher" parent="." index="2" node_paths=PackedStringArray("object") instance=ExtResource("3_e5cea")]
object = NodePath("..")
+326
View File
@@ -0,0 +1,326 @@
class_name AbstractEnemy
extends CharacterBody2D
enum Type {
Standing,
Walking,
Random,
}
enum Facing {
Front,
Rear,
}
enum State {
Idle,
WalkLeft,
WalkRight,
LookAround,
ChasingLeft,
ChasingRight,
}
const ANIMATION_FALL_DOWN = "fall_down"
const ANIMATION_FALL_DOWN_LEFT = "fall_down_left"
const ANIMATION_FALL_DOWN_RIGHT = "fall_down_right"
const ANIMATION_FALL_UP = "fall_up"
const ANIMATION_FALL_UP_LEFT = "fall_up_left"
const ANIMATION_FALL_UP_RIGHT = "fall_up_right"
const ANIMATION_IDLE_FRONT = "idle_front"
const ANIMATION_IDLE_REAR = "idle_rear"
const ANIMATION_LOOK_AROUND_FRONT_1 = "look_around_front_1"
const ANIMATION_LOOK_AROUND_FRONT_2 = "look_around_front_2"
const ANIMATION_LOOK_AROUND_REAR_1 = "look_around_rear_1"
const ANIMATION_LOOK_AROUND_REAR_2 = "look_around_rear_2"
const ANIMATION_WALK_LEFT = "walk_left"
const ANIMATION_WALK_RIGHT = "walk_right"
const ANIMATION_CHASE_LEFT = "chase_left"
const ANIMATION_CHASE_RIGHT = "chase_right"
const LOOK_AROUND_FRONT_ANIMATIONS : Array[String] = [
ANIMATION_LOOK_AROUND_FRONT_1,
ANIMATION_LOOK_AROUND_FRONT_2,
]
const LOOK_AROUND_REAR_ANIMATIONS : Array[String] = [
ANIMATION_LOOK_AROUND_REAR_1,
ANIMATION_LOOK_AROUND_REAR_2,
]
const MAX_WALK_SPEED = 85
const MAX_CHASE_SPEED = 170
const ACCELERATION = 600.0
const LOOK_AROUND_CHANCE = 25
const WALK_CHANCE = 25
const DIRECTION_LEFT = -1
const DIRECTION_RIGHT = 1
@export var type : Type = Type.Standing
@export var facing : Facing = Facing.Front
@export var initial_state : State = State.Idle
var _target_x := 0.0
var _target_found := false
var _state : State:
set = _set_state
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
@onready var left_wall_ray : RayCast2D = $%LeftWallRay
@onready var right_wall_ray : RayCast2D = $%RightWallRay
@onready var left_player_close_ray : RayCast2D = $%LeftPlayerCloseRay
@onready var right_player_close_ray : RayCast2D = $%RightPlayerCloseRay
@onready var left_player_distant_ray : RayCast2D = $%LeftPlayerDistantRay
@onready var right_player_distant_ray : RayCast2D = $%RightPlayerDistantRay
func _ready() -> void:
_state = initial_state
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta
match _state:
State.ChasingLeft:
_process_player_ray(left_player_distant_ray)
if position.x < _target_x:
SoundManager.play_sfx_stream(SoundManager.sfx_stream_player_lost, global_position)
_state = State.LookAround
else:
_update_x_velocity(DIRECTION_LEFT, MAX_CHASE_SPEED, delta)
_check_wall_collision_and_switch_state(DIRECTION_LEFT)
State.ChasingRight:
_process_player_ray(right_player_distant_ray)
if position.x > _target_x:
SoundManager.play_sfx_stream(SoundManager.sfx_stream_player_lost, global_position)
_state = State.LookAround
else:
_update_x_velocity(DIRECTION_RIGHT, MAX_CHASE_SPEED, delta)
_check_wall_collision_and_switch_state(DIRECTION_RIGHT)
State.WalkLeft:
if _process_player_ray(left_player_distant_ray):
_set_chase_state()
_update_x_velocity(DIRECTION_LEFT, MAX_WALK_SPEED, delta)
_check_wall_collision_and_switch_state(DIRECTION_LEFT)
State.WalkRight:
if _process_player_ray(right_player_distant_ray):
_set_chase_state()
_update_x_velocity(DIRECTION_RIGHT, MAX_WALK_SPEED, delta)
_check_wall_collision_and_switch_state(DIRECTION_RIGHT)
State.LookAround:
_update_x_velocity(0, MAX_WALK_SPEED * 2, delta)
if not _target_found:
var close_rays : Array[RayCast2D] = [left_player_close_ray, right_player_close_ray]
_target_found = _process_player_rays(close_rays)
_update_animation()
move_and_slide()
func _set_state(value: State) -> void:
_state = value
left_player_close_ray.process_mode = Node.PROCESS_MODE_DISABLED
right_player_close_ray.process_mode = Node.PROCESS_MODE_DISABLED
left_player_distant_ray.process_mode = Node.PROCESS_MODE_DISABLED
right_player_distant_ray.process_mode = Node.PROCESS_MODE_DISABLED
left_player_close_ray.hide()
right_player_close_ray.hide()
left_player_distant_ray.hide()
right_player_distant_ray.hide()
match _state:
State.ChasingLeft, State.WalkLeft:
left_player_distant_ray.process_mode = Node.PROCESS_MODE_INHERIT
left_player_distant_ray.show()
State.ChasingRight, State.WalkRight:
right_player_distant_ray.process_mode = Node.PROCESS_MODE_INHERIT
right_player_distant_ray.show()
State.LookAround:
left_player_close_ray.process_mode = Node.PROCESS_MODE_INHERIT
right_player_close_ray.process_mode = Node.PROCESS_MODE_INHERIT
left_player_close_ray.show()
right_player_close_ray.show()
func _process_player_ray(ray: RayCast2D) -> bool:
if ray.is_colliding():
ray.force_raycast_update()
var collider := ray.get_collider()
if collider is Player:
_target_x = collider.position.x
return true
return false
func _process_player_rays(rays: Array[RayCast2D]) -> bool:
for ray in rays:
if _process_player_ray(ray):
return true
return false
func _update_x_velocity(direction: int, max_speed: float, delta: float) -> void:
velocity.x = move_toward(velocity.x, direction * max_speed, ACCELERATION * delta)
func _check_wall_collision_and_switch_state(direction: int) -> void:
var this_wall_ray := _get_wall_ray(direction)
var other_wall_ray := _get_wall_ray(-direction)
if this_wall_ray.is_colliding():
if other_wall_ray.is_colliding():
_state = State.LookAround
else:
match _state:
State.WalkLeft:
_state = State.WalkRight
State.WalkRight:
_state = State.WalkLeft
State.ChasingLeft, State.ChasingRight:
var stream := SoundManager.sfx_stream_player_lost
SoundManager.play_sfx_stream(stream, global_position)
_state = State.LookAround
func _get_wall_ray(direction: int) -> RayCast2D:
if direction < 0:
return left_wall_ray
else:
return right_wall_ray
func _update_animation() -> void:
if is_zero_approx(velocity.y):
match _state:
State.WalkLeft:
_play_animation(ANIMATION_WALK_LEFT)
State.WalkRight:
_play_animation(ANIMATION_WALK_RIGHT)
State.ChasingLeft:
_play_animation(ANIMATION_CHASE_LEFT)
State.ChasingRight:
_play_animation(ANIMATION_CHASE_RIGHT)
State.Idle:
_play_idle_animation()
State.LookAround:
_play_look_around_animation()
else:
_play_fall_animation()
func _play_idle_animation() -> void:
match facing:
Facing.Front:
_play_animation(ANIMATION_IDLE_FRONT)
Facing.Rear:
_play_animation(ANIMATION_IDLE_REAR)
func _play_look_around_animation() -> void:
if _is_current_animation_look_around(): return
match facing:
Facing.Front:
var animation := _get_random_animation(LOOK_AROUND_FRONT_ANIMATIONS)
_play_animation(animation)
Facing.Rear:
var animation := _get_random_animation(LOOK_AROUND_REAR_ANIMATIONS)
_play_animation(animation)
func _play_fall_animation() -> void:
if is_zero_approx(velocity.x):
var animation := ANIMATION_FALL_UP if velocity.y < 0 else ANIMATION_FALL_DOWN
_play_animation(animation)
elif velocity.x < 0:
var animation := ANIMATION_FALL_UP_LEFT if velocity.y < 0 else ANIMATION_FALL_DOWN_LEFT
_play_animation(animation)
else:
var animation := ANIMATION_FALL_UP_RIGHT if velocity.y < 0 else ANIMATION_FALL_DOWN_RIGHT
_play_animation(animation)
func _is_current_animation_look_around() -> bool:
if not sprite.is_playing(): return false
if sprite.animation in LOOK_AROUND_FRONT_ANIMATIONS: return true
if sprite.animation in LOOK_AROUND_REAR_ANIMATIONS: return true
return false
func _get_random_animation(animations: Array[String]) -> String:
var index := randi_range(0, animations.size() - 1)
return animations[index]
func _play_animation(animation: String) -> void:
if not sprite.is_playing() or sprite.animation != animation:
sprite.play(animation)
func _set_walking_state() -> void:
var is_left_colliding := left_wall_ray.is_colliding()
var is_right_colliding := right_wall_ray.is_colliding()
if is_left_colliding and is_right_colliding:
_state = State.Idle
elif not is_left_colliding and not is_right_colliding:
_state = State.WalkLeft if randi_range(1, 2) == 1 else State.WalkRight
elif not is_left_colliding:
_state = State.WalkLeft
else:
_state = State.WalkRight
func _set_chase_state() -> void:
SoundManager.play_sfx_stream(SoundManager.sfx_stream_player_spoted, global_position)
if _target_x < position.x:
_state = State.ChasingLeft
else:
_state = State.ChasingRight
func _is_walking_state() -> bool:
return _state == State.WalkLeft or _state == State.WalkRight
func _on_animation_finished() -> void:
if _target_found:
_set_chase_state()
_target_found = false
return
match type:
Type.Standing:
_state = State.Idle
Type.Walking:
_set_walking_state()
Type.Random:
if randi_range(1, 100) <= WALK_CHANCE:
_set_walking_state()
else:
_state = State.Idle
func _on_animation_looped() -> void:
if _state == State.Idle or (type == Type.Random and _is_walking_state()):
if randi_range(1, 100) <= LOOK_AROUND_CHANCE:
_state = State.LookAround
func _on_player_touch_area_entered(body: Node2D) -> void:
if body is Player:
_target_x = body.position.x
_set_chase_state()
@@ -0,0 +1 @@
uid://but5aeh7y1s0f
@@ -0,0 +1,82 @@
[gd_scene format=3 uid="uid://bx0luh4vdob3q"]
[ext_resource type="Script" uid="uid://but5aeh7y1s0f" path="res://game/characters/enemies/abstract_enemy.gd" id="1_2wrno"]
[ext_resource type="PackedScene" uid="uid://dtxiercm8dsfm" path="res://game/characters/enemies/enemy_sprite.tscn" id="2_tjvyk"]
[ext_resource type="PackedScene" uid="uid://dike8xgbqdut2" path="res://game/killing_area.tscn" id="3_tjvyk"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_mocsw"]
radius = 4.0
height = 28.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vecdo"]
size = Vector2(32, 28)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_tjvyk"]
radius = 4.0
height = 28.0
[node name="AbstractEnemy" type="CharacterBody2D" unique_id=1676614852]
collision_layer = 0
script = ExtResource("1_2wrno")
[node name="AnimatedSprite2D" parent="." unique_id=1997264413 instance=ExtResource("2_tjvyk")]
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=185651284]
position = Vector2(0, 2)
shape = SubResource("CapsuleShape2D_mocsw")
[node name="WallCheck" type="Node2D" parent="." unique_id=782156094]
position = Vector2(0, 9)
[node name="LeftWallRay" type="RayCast2D" parent="WallCheck" unique_id=521416854]
unique_name_in_owner = true
target_position = Vector2(-16, 0)
[node name="RightWallRay" type="RayCast2D" parent="WallCheck" unique_id=1457669135]
unique_name_in_owner = true
target_position = Vector2(16, 0)
[node name="PlayerCloseCheck" type="Node2D" parent="." unique_id=1593775088]
position = Vector2(0, 9)
[node name="LeftPlayerCloseRay" type="RayCast2D" parent="PlayerCloseCheck" unique_id=947570027]
unique_name_in_owner = true
target_position = Vector2(-48, 0)
collision_mask = 0
[node name="RightPlayerCloseRay" type="RayCast2D" parent="PlayerCloseCheck" unique_id=1559118218]
unique_name_in_owner = true
target_position = Vector2(48, 0)
collision_mask = 0
[node name="PlayerDistantCheck" type="Node2D" parent="." unique_id=1597489123]
position = Vector2(0, 9)
[node name="LeftPlayerDistantRay" type="RayCast2D" parent="PlayerDistantCheck" unique_id=1491085518]
unique_name_in_owner = true
target_position = Vector2(-320, 0)
collision_mask = 0
[node name="RightPlayerDistantRay" type="RayCast2D" parent="PlayerDistantCheck" unique_id=1377654831]
unique_name_in_owner = true
target_position = Vector2(320, 0)
collision_mask = 0
[node name="PlayerTouchArea" type="Area2D" parent="." unique_id=2147163970]
collision_layer = 0
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerTouchArea" unique_id=262478897]
position = Vector2(0, 2)
shape = SubResource("RectangleShape2D_vecdo")
[node name="KillingArea" parent="." unique_id=1891922549 instance=ExtResource("3_tjvyk")]
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="KillingArea" unique_id=1710758452]
position = Vector2(0, 2)
shape = SubResource("CapsuleShape2D_tjvyk")
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"]
[connection signal="animation_looped" from="AnimatedSprite2D" to="." method="_on_animation_looped"]
[connection signal="body_entered" from="PlayerTouchArea" to="." method="_on_player_touch_area_entered"]
+2
View File
@@ -0,0 +1,2 @@
class_name BlackEnemy
extends AbstractColorEnemy
@@ -0,0 +1 @@
uid://c2knsjcp6faf6
+53
View File
@@ -0,0 +1,53 @@
[gd_scene format=3 uid="uid://cutjutvd8dqqc"]
[ext_resource type="PackedScene" uid="uid://d37eyum03h83i" path="res://game/characters/enemies/abstract_color_enemy.tscn" id="1_gj2ks"]
[ext_resource type="Script" uid="uid://c2knsjcp6faf6" path="res://game/characters/enemies/black_enemy.gd" id="2_332ds"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_3jy5n"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0u0ii"]
resource_local_to_scene = true
shader = ExtResource("3_3jy5n")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = true
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0
[node name="BlackEnemy" unique_id=1910124567 instance=ExtResource("1_gj2ks")]
collision_layer = 4
collision_mask = 3
script = ExtResource("2_332ds")
[node name="AnimatedSprite2D" parent="." index="0" unique_id=1997264413]
material = SubResource("ShaderMaterial_0u0ii")
[node name="CollisionSwitcher" parent="." index="2"]
initial_state = 0
[node name="LeftWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="0" unique_id=521416854]
collision_mask = 3
[node name="RightWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="1" unique_id=1457669135]
collision_mask = 3
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="0" unique_id=947570027]
target_position = Vector2(-32, 0)
collision_mask = 11
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="1" unique_id=1559118218]
target_position = Vector2(32, 0)
collision_mask = 11
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="0" unique_id=1491085518]
collision_mask = 11
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="1" unique_id=1377654831]
collision_mask = 11
[node name="PlayerTouchArea" parent="." index="6" unique_id=2147163970]
collision_mask = 8
[node name="KillingArea" parent="." index="7" unique_id=1891922549]
collision_mask = 8
+455
View File
@@ -0,0 +1,455 @@
[gd_scene load_steps=47 format=3 uid="uid://dtxiercm8dsfm"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="1_b6aoy"]
[ext_resource type="Texture2D" uid="uid://drk8j57acajrq" path="res://images/characters/cultist.png" id="2_yjsd7"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vecdo"]
shader = ExtResource("1_b6aoy")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = false
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0
[sub_resource type="AtlasTexture" id="AtlasTexture_l58xb"]
atlas = ExtResource("2_yjsd7")
region = Rect2(0, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_jrclg"]
atlas = ExtResource("2_yjsd7")
region = Rect2(32, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_wwwee"]
atlas = ExtResource("2_yjsd7")
region = Rect2(64, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_law7y"]
atlas = ExtResource("2_yjsd7")
region = Rect2(96, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hme24"]
atlas = ExtResource("2_yjsd7")
region = Rect2(128, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qawtf"]
atlas = ExtResource("2_yjsd7")
region = Rect2(160, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_srxh4"]
atlas = ExtResource("2_yjsd7")
region = Rect2(192, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_x6npu"]
atlas = ExtResource("2_yjsd7")
region = Rect2(224, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_xavx3"]
atlas = ExtResource("2_yjsd7")
region = Rect2(0, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_8t4m8"]
atlas = ExtResource("2_yjsd7")
region = Rect2(32, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_3seah"]
atlas = ExtResource("2_yjsd7")
region = Rect2(64, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_koyeg"]
atlas = ExtResource("2_yjsd7")
region = Rect2(96, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_uw3v1"]
atlas = ExtResource("2_yjsd7")
region = Rect2(128, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_265lf"]
atlas = ExtResource("2_yjsd7")
region = Rect2(160, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_tav7c"]
atlas = ExtResource("2_yjsd7")
region = Rect2(192, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0xs27"]
atlas = ExtResource("2_yjsd7")
region = Rect2(224, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_tjvyk"]
atlas = ExtResource("2_yjsd7")
region = Rect2(128, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_vecdo"]
atlas = ExtResource("2_yjsd7")
region = Rect2(64, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qly8p"]
atlas = ExtResource("2_yjsd7")
region = Rect2(0, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_klrad"]
atlas = ExtResource("2_yjsd7")
region = Rect2(160, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_rjy0i"]
atlas = ExtResource("2_yjsd7")
region = Rect2(96, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ps2ar"]
atlas = ExtResource("2_yjsd7")
region = Rect2(32, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ijx3p"]
atlas = ExtResource("2_yjsd7")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_nm8xp"]
atlas = ExtResource("2_yjsd7")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_mocsw"]
atlas = ExtResource("2_yjsd7")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_y256a"]
atlas = ExtResource("2_yjsd7")
region = Rect2(160, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_yjsd7"]
atlas = ExtResource("2_yjsd7")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_b6aoy"]
atlas = ExtResource("2_yjsd7")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_voddl"]
atlas = ExtResource("2_yjsd7")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_soo8x"]
atlas = ExtResource("2_yjsd7")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_8wpvf"]
atlas = ExtResource("2_yjsd7")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_vbirv"]
atlas = ExtResource("2_yjsd7")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ntvg2"]
atlas = ExtResource("2_yjsd7")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ssc8d"]
atlas = ExtResource("2_yjsd7")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hrljr"]
atlas = ExtResource("2_yjsd7")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ng7ok"]
atlas = ExtResource("2_yjsd7")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_8s45y"]
atlas = ExtResource("2_yjsd7")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qbqct"]
atlas = ExtResource("2_yjsd7")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ga5mk"]
atlas = ExtResource("2_yjsd7")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_yu2nn"]
atlas = ExtResource("2_yjsd7")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_g4v8m"]
atlas = ExtResource("2_yjsd7")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_20lqo"]
atlas = ExtResource("2_yjsd7")
region = Rect2(192, 0, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_2wrno"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_l58xb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jrclg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wwwee")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_law7y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hme24")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qawtf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_srxh4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x6npu")
}],
"loop": true,
"name": &"chase_left",
"speed": 20.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_xavx3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8t4m8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3seah")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_koyeg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uw3v1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_265lf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tav7c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0xs27")
}],
"loop": true,
"name": &"chase_right",
"speed": 20.0
}, {
"frames": [{
"duration": 10.0,
"texture": SubResource("AtlasTexture_tjvyk")
}],
"loop": true,
"name": &"fall_down",
"speed": 5.0
}, {
"frames": [{
"duration": 5.0,
"texture": SubResource("AtlasTexture_vecdo")
}],
"loop": true,
"name": &"fall_down_left",
"speed": 5.0
}, {
"frames": [{
"duration": 5.0,
"texture": SubResource("AtlasTexture_qly8p")
}],
"loop": true,
"name": &"fall_down_right",
"speed": 5.0
}, {
"frames": [{
"duration": 5.0,
"texture": SubResource("AtlasTexture_klrad")
}],
"loop": true,
"name": &"fall_up",
"speed": 5.0
}, {
"frames": [{
"duration": 5.0,
"texture": SubResource("AtlasTexture_rjy0i")
}],
"loop": true,
"name": &"fall_up_left",
"speed": 5.0
}, {
"frames": [{
"duration": 5.0,
"texture": SubResource("AtlasTexture_ps2ar")
}],
"loop": true,
"name": &"fall_up_right",
"speed": 5.0
}, {
"frames": [{
"duration": 4.0,
"texture": SubResource("AtlasTexture_ijx3p")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nm8xp")
}, {
"duration": 5.0,
"texture": SubResource("AtlasTexture_ijx3p")
}],
"loop": true,
"name": &"idle_front",
"speed": 5.0
}, {
"frames": [{
"duration": 4.0,
"texture": SubResource("AtlasTexture_mocsw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_y256a")
}, {
"duration": 5.0,
"texture": SubResource("AtlasTexture_mocsw")
}],
"loop": true,
"name": &"idle_rear",
"speed": 5.0
}, {
"frames": [{
"duration": 3.0,
"texture": SubResource("AtlasTexture_yjsd7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_b6aoy")
}, {
"duration": 3.0,
"texture": SubResource("AtlasTexture_voddl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_soo8x")
}],
"loop": true,
"name": &"look_around",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_8wpvf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vbirv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ntvg2")
}],
"loop": false,
"name": &"look_around_front_1",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ssc8d")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hrljr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ng7ok")
}],
"loop": false,
"name": &"look_around_front_2",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_8s45y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qbqct")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ga5mk")
}],
"loop": false,
"name": &"look_around_rear_1",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_yu2nn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_g4v8m")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_20lqo")
}],
"loop": false,
"name": &"look_around_rear_2",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_l58xb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jrclg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wwwee")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_law7y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hme24")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qawtf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_srxh4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x6npu")
}],
"loop": true,
"name": &"walk_left",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_xavx3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8t4m8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3seah")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_koyeg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uw3v1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_265lf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tav7c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0xs27")
}],
"loop": true,
"name": &"walk_right",
"speed": 10.0
}]
[node name="AnimatedSprite2D" type="AnimatedSprite2D"]
material = SubResource("ShaderMaterial_vecdo")
sprite_frames = SubResource("SpriteFrames_2wrno")
animation = &"look_around"
+2
View File
@@ -0,0 +1,2 @@
class_name GrayEnemy
extends AbstractEnemy
@@ -0,0 +1 @@
uid://cern5veiqkrkc
+37
View File
@@ -0,0 +1,37 @@
[gd_scene format=3 uid="uid://cb0w6mt8g4mer"]
[ext_resource type="PackedScene" uid="uid://bx0luh4vdob3q" path="res://game/characters/enemies/abstract_enemy.tscn" id="1_q3s46"]
[ext_resource type="Script" uid="uid://cern5veiqkrkc" path="res://game/characters/enemies/gray_enemy.gd" id="2_olede"]
[ext_resource type="Material" uid="uid://dbkn3k0batj5w" path="res://game/materials/enemy_gray.tres" id="3_ho47d"]
[node name="GrayEnemy" unique_id=139812221 instance=ExtResource("1_q3s46")]
collision_layer = 16
collision_mask = 35
script = ExtResource("2_olede")
[node name="AnimatedSprite2D" parent="." index="0" unique_id=1997264413]
material = ExtResource("3_ho47d")
[node name="LeftWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="0" unique_id=521416854]
collision_mask = 35
[node name="RightWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="1" unique_id=1457669135]
collision_mask = 35
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="0" unique_id=947570027]
collision_mask = 171
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="1" unique_id=1559118218]
collision_mask = 171
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="0" unique_id=1491085518]
collision_mask = 171
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="1" unique_id=1377654831]
collision_mask = 171
[node name="PlayerTouchArea" parent="." index="5" unique_id=2147163970]
collision_mask = 136
[node name="KillingArea" parent="." index="6" unique_id=1891922549]
collision_mask = 136
+2
View File
@@ -0,0 +1,2 @@
class_name WhiteEnemy
extends AbstractColorEnemy
@@ -0,0 +1 @@
uid://dmcpkytgiuedi
+50
View File
@@ -0,0 +1,50 @@
[gd_scene format=3 uid="uid://bv2gahb4wxgb1"]
[ext_resource type="PackedScene" uid="uid://d37eyum03h83i" path="res://game/characters/enemies/abstract_color_enemy.tscn" id="1_3yi7g"]
[ext_resource type="Script" uid="uid://dmcpkytgiuedi" path="res://game/characters/enemies/white_enemy.gd" id="2_c7pdf"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_uj6yw"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gfhm1"]
resource_local_to_scene = true
shader = ExtResource("3_uj6yw")
shader_parameter/black_color = Color(0, 0, 0, 1)
shader_parameter/white_color = Color(1, 1, 1, 1)
shader_parameter/switch_colors = false
shader_parameter/threshold = 0.5
shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0
[node name="WhiteEnemy" unique_id=486389199 instance=ExtResource("1_3yi7g")]
collision_layer = 64
collision_mask = 33
script = ExtResource("2_c7pdf")
[node name="AnimatedSprite2D" parent="." index="0" unique_id=1997264413]
material = SubResource("ShaderMaterial_gfhm1")
[node name="LeftWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="0" unique_id=521416854]
collision_mask = 33
[node name="RightWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="1" unique_id=1457669135]
collision_mask = 33
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="0" unique_id=947570027]
target_position = Vector2(-32, 0)
collision_mask = 161
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="1" unique_id=1559118218]
target_position = Vector2(32, 0)
collision_mask = 161
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="0" unique_id=1491085518]
collision_mask = 161
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="1" unique_id=1377654831]
collision_mask = 161
[node name="PlayerTouchArea" parent="." index="6" unique_id=2147163970]
collision_mask = 128
[node name="KillingArea" parent="." index="7" unique_id=1891922549]
collision_mask = 128