-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
338 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,51 @@ | ||
[gd_scene load_steps=6 format=3 uid="uid://cqfgwqqpwrg51"] | ||
[gd_scene load_steps=7 format=3 uid="uid://cqfgwqqpwrg51"] | ||
|
||
[ext_resource type="Script" path="res://scenes/ships/enemy/enemy.gd" id="1_w35kq"] | ||
[ext_resource type="Texture2D" uid="uid://dua5c2gcufo14" path="res://assets/images/ships/enemy/enemy_ship.webp" id="2_fsep2"] | ||
[ext_resource type="PackedScene" uid="uid://de3ymp8rbho6h" path="res://scenes/ui/ui_elements/health_bar/health_bar.tscn" id="3_rgjex"] | ||
[ext_resource type="PackedScene" uid="uid://dsg7rv0et4eym" path="res://scenes/ships/hardpoint.tscn" id="4_asdpv"] | ||
[ext_resource type="PackedScene" uid="uid://dvamksc1tkhj1" path="res://scenes/ships/enemy/vision_cone.tscn" id="5_2jwbw"] | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_n63kb"] | ||
size = Vector2(33, 39) | ||
size = Vector2(39, 33) | ||
|
||
[node name="Enemy" type="CharacterBody2D" node_paths=PackedStringArray("health_bar", "sprite")] | ||
[node name="Enemy" type="CharacterBody2D" node_paths=PackedStringArray("vision_cone", "health_bar", "sprite", "weapon_hardpoints")] | ||
z_index = 10 | ||
collision_layer = 3 | ||
collision_mask = 2 | ||
script = ExtResource("1_w35kq") | ||
vision_cone = NodePath("VisionCone") | ||
attack_cooldown = 1.5 | ||
patrol_distance = 500 | ||
health_bar = NodePath("HealthBar") | ||
sprite = NodePath("Sprite2D") | ||
max_speed = 50 | ||
max_speed = 300 | ||
yaw_max_speed = 2.0 | ||
weapon_hardpoints = [NodePath("LeftPhaser"), NodePath("CenterMissile"), NodePath("RightPhaser")] | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
shape = SubResource("RectangleShape2D_n63kb") | ||
|
||
[node name="Sprite2D" type="Sprite2D" parent="."] | ||
rotation = 1.5708 | ||
texture = ExtResource("2_fsep2") | ||
|
||
[node name="HealthBar" parent="." instance=ExtResource("3_rgjex")] | ||
offset_left = -13.0 | ||
offset_top = -22.0 | ||
offset_bottom = -20.0 | ||
offset_left = -18.0 | ||
offset_top = -13.0 | ||
offset_right = 8.0 | ||
offset_bottom = -11.0 | ||
rotation = 1.5708 | ||
|
||
[node name="LeftPhaser" parent="." instance=ExtResource("4_asdpv")] | ||
position = Vector2(-8, 0) | ||
position = Vector2(0, -8) | ||
|
||
[node name="RightPhaser" parent="." instance=ExtResource("4_asdpv")] | ||
position = Vector2(8, 0) | ||
position = Vector2(0, 8) | ||
|
||
[node name="CenterMissile" parent="." instance=ExtResource("4_asdpv")] | ||
position = Vector2(0, 2.5) | ||
hardpoint_type = 1 | ||
|
||
[node name="VisionCone" parent="." instance=ExtResource("5_2jwbw")] | ||
position = Vector2(19, 0) | ||
peripheral_radious = 250 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
@tool | ||
|
||
class_name VisionCone | ||
extends Area2D | ||
|
||
@export var width: int : | ||
set(value): | ||
width = value | ||
change_size() | ||
|
||
@export var height: int : | ||
set(value): | ||
height = value | ||
change_size() | ||
|
||
@export var peripheral_radious: int : | ||
set(value): | ||
peripheral_radious = value | ||
change_size() | ||
|
||
@export var peripheral_indicator_points: int : | ||
set(value): | ||
peripheral_indicator_points = value | ||
change_size() | ||
|
||
@export var collision_polygon: CollisionPolygon2D : | ||
set(value): | ||
collision_polygon = value | ||
change_size() | ||
|
||
@export var collision_shape: CollisionShape2D : | ||
set(value): | ||
collision_shape = value | ||
change_size() | ||
|
||
@export var color: Color = Color(1, 1, 1, 0.5) : | ||
set(value): | ||
color = value | ||
queue_redraw() | ||
|
||
func _ready() -> void: | ||
change_size() | ||
|
||
func change_size() -> void: | ||
if collision_polygon == null: | ||
return | ||
|
||
collision_polygon.polygon = [ | ||
Vector2(0, 0), | ||
Vector2(height, width / 2.0), | ||
Vector2(height, -(width / 2.0)), | ||
] | ||
|
||
if collision_shape == null: | ||
return | ||
|
||
collision_shape.shape.radius = peripheral_radious | ||
|
||
queue_redraw() | ||
|
||
func _draw() -> void: | ||
draw_line(Vector2(0, 0), Vector2(height, width / 2.0), color, -1) | ||
draw_line(Vector2(0, 0), Vector2(height, -(width / 2.0)), color, -1) | ||
draw_line(Vector2(height, width / 2.0), Vector2(height, -(width / 2.0)), color, -1) | ||
draw_arc(Vector2(0, 0), peripheral_radious, 0, TAU, peripheral_indicator_points, color) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dvamksc1tkhj1"] | ||
|
||
[ext_resource type="Script" path="res://scenes/ships/enemy/vision_cone.gd" id="1_uj4p1"] | ||
|
||
[sub_resource type="CircleShape2D" id="CircleShape2D_y6307"] | ||
radius = 250.0 | ||
|
||
[node name="VisionCone" type="Area2D" node_paths=PackedStringArray("collision_polygon", "collision_shape")] | ||
collision_layer = 3 | ||
collision_mask = 8 | ||
script = ExtResource("1_uj4p1") | ||
width = 600 | ||
height = 600 | ||
peripheral_radious = 60 | ||
peripheral_indicator_points = 64 | ||
collision_polygon = NodePath("CollisionPolygon2D") | ||
collision_shape = NodePath("CollisionShape2D") | ||
color = Color(1, 0.172549, 0.12549, 1) | ||
|
||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] | ||
polygon = PackedVector2Array(0, 0, 600, 300, 600, -300) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
shape = SubResource("CircleShape2D_y6307") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.