dev-base #36

Merged
Snoweuph merged 54 commits from dev-base into nightly 2023-04-05 21:01:03 +00:00
3 changed files with 35 additions and 11 deletions
Showing only changes of commit 6983001d45 - Show all commits

View file

@ -1,14 +1,32 @@
[gd_scene load_steps=7 format=3 uid="uid://bvo0wgi38gdo0"] [gd_scene load_steps=8 format=3 uid="uid://yitiyfwr4txh"]
[ext_resource type="TileSet" uid="uid://bf1eb4aogv8ru" path="res://Assets/Tilesets/colony.tres" id="2"] [ext_resource type="TileSet" uid="uid://bf1eb4aogv8ru" path="res://Assets/Tilesets/colony.tres" id="2"]
[ext_resource type="Texture2D" uid="uid://dp4tdg3fxe5bf" path="res://Assets/Textures/color_cube.png" id="2_0flm2"] [ext_resource type="Texture2D" uid="uid://dp4tdg3fxe5bf" path="res://Assets/Textures/color_cube.png" id="2_0flm2"]
[ext_resource type="Script" path="res://Scripts/Player/PlayerMovement.gd" id="2_gw00d"] [ext_resource type="Script" path="res://Scripts/Player/PlayerController.gd" id="2_pk6k4"]
[ext_resource type="Texture2D" uid="uid://dx5k5qa1pwbfl" path="res://Assets/Textures/basic_enemy.png" id="4_4sn7h"] [ext_resource type="Texture2D" uid="uid://dx5k5qa1pwbfl" path="res://Assets/Textures/basic_enemy.png" id="4_4sn7h"]
[ext_resource type="Script" path="res://Scripts/Enemy/EnemyLook.gd" id="5_k7y3d"] [ext_resource type="Script" path="res://Scripts/Enemy/EnemyController.gd" id="5_5xgcv"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_m15tu"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_m15tu"]
size = Vector2(5, 5) size = Vector2(5, 5)
[sub_resource type="GDScript" id="GDScript_xkf0t"]
script/source = "extends Node
enum STATES {
Partroling,
Targeting
}
@export var sees := STATES.Partroling
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
"
[node name="Test Scene" type="Node2D"] [node name="Test Scene" type="Node2D"]
[node name="TileMap" type="TileMap" parent="."] [node name="TileMap" type="TileMap" parent="."]
@ -22,7 +40,7 @@ layer_0/tile_data = PackedInt32Array(1114138, 262144, 1, 1048602, 0, 1, 983066,
[node name="Player" type="CharacterBody2D" parent="."] [node name="Player" type="CharacterBody2D" parent="."]
position = Vector2(203, 60) position = Vector2(203, 60)
collision_layer = 2 collision_layer = 2
script = ExtResource("2_gw00d") script = ExtResource("2_pk6k4")
speed = 100 speed = 100
[node name="Sprite2D" type="Sprite2D" parent="Player"] [node name="Sprite2D" type="Sprite2D" parent="Player"]
@ -39,16 +57,17 @@ editor_draw_drag_margin = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
shape = SubResource("RectangleShape2D_m15tu") shape = SubResource("RectangleShape2D_m15tu")
[node name="Sprite2D" type="Sprite2D" parent="." node_paths=PackedStringArray("ray")] [node name="Enemy" type="Sprite2D" parent="." node_paths=PackedStringArray("ray")]
z_index = 1 z_index = 1
position = Vector2(237, 46) position = Vector2(237, 46)
rotation = 2.04581 rotation = 2.04581
texture = ExtResource("4_4sn7h") texture = ExtResource("4_4sn7h")
script = ExtResource("5_k7y3d") script = ExtResource("5_5xgcv")
ray = NodePath("RayCast2D") ray = NodePath("RayCast2D")
debug_vision = true debug_vision = true
[node name="RayCast2D" type="RayCast2D" parent="Sprite2D"] [node name="RayCast2D" type="RayCast2D" parent="Enemy"]
target_position = Vector2(15, 0) target_position = Vector2(15, 0)
collision_mask = 3 collision_mask = 3
hit_from_inside = true hit_from_inside = true
script = SubResource("GDScript_xkf0t")

View file

@ -12,7 +12,12 @@ extends Node2D
@export_range(0, 72) var sweeping_steps : int = 24 @export_range(0, 72) var sweeping_steps : int = 24
@export var debug_vision := false @export var debug_vision := false
var sees_player : bool enum STATES {
IDLE,
TARGETING
}
var state : STATES
# Only used for Debugging purposes right now # Only used for Debugging purposes right now
var player_positions : Array var player_positions : Array
@ -62,9 +67,9 @@ func look_at_player(delta : float):
# If The Player cant be seen, return and do nothing # If The Player cant be seen, return and do nothing
if hit_angles.size() <= 0: if hit_angles.size() <= 0:
sees_player = false state = STATES.IDLE
return return
sees_player = true state = STATES.TARGETING
# Calculate Average Angle Of Player # Calculate Average Angle Of Player
var average_angle : float var average_angle : float
@ -94,7 +99,7 @@ func _draw():
self.draw_arc(Vector2(), max_view_distance, deg_to_rad(-angle_cone_of_vision / 2), deg_to_rad(angle_cone_of_vision / 2), sweeping_steps + 1, Color.RED, 0.5, false) self.draw_arc(Vector2(), max_view_distance, deg_to_rad(-angle_cone_of_vision / 2), deg_to_rad(angle_cone_of_vision / 2), sweeping_steps + 1, Color.RED, 0.5, false)
# Draw A Circle Around the Player if hes seen # Draw A Circle Around the Player if hes seen
if sees_player: if state == STATES.TARGETING:
for pos in player_positions: for pos in player_positions:
self.draw_circle(pos, 4, Color.ORANGE_RED) self.draw_circle(pos, 4, Color.ORANGE_RED)
queue_redraw() queue_redraw()