Added shield and armor sprite usage
This commit is contained in:
@@ -22,9 +22,6 @@ const WEAPONS := [
|
||||
signal destroyed
|
||||
|
||||
|
||||
@onready var sprite := $Sprite2D
|
||||
|
||||
|
||||
@export_range(0, 250) var acceleration : int = 0
|
||||
@export_range(0, 250) var deceleration : int = 0
|
||||
@export_range(0, 250) var max_speed : int = 0
|
||||
@@ -33,6 +30,13 @@ signal destroyed
|
||||
@export_range(0, 360) var weapon_rotation : int = 0
|
||||
|
||||
|
||||
@onready var ship_sprite : Sprite2D = $ShipSprite
|
||||
@onready var armor_sprite : Sprite2D = $ArmorSprite
|
||||
@onready var shield_sprite : Sprite2D = $ShieldSprite
|
||||
|
||||
@onready var health : Health = $Health
|
||||
|
||||
|
||||
var weapon_positions: Array[Vector2]
|
||||
|
||||
|
||||
@@ -40,6 +44,9 @@ var _weapons : Array[AbstractWeapon]
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
shield_sprite.visible = health.shield != 0
|
||||
armor_sprite.visible = health.armor != 0
|
||||
|
||||
for slot in $WeaponSlots.get_children():
|
||||
if slot is Node2D:
|
||||
weapon_positions.append(slot.global_position - global_position)
|
||||
@@ -99,3 +106,15 @@ func _add_weapon(weapon: AbstractWeapon, weapon_position: Vector2) -> void:
|
||||
weapon.rotation_degrees = weapon_rotation
|
||||
add_child(weapon)
|
||||
_weapons.append(weapon)
|
||||
|
||||
|
||||
func _on_shield_updated(value: int, _max_value: int) -> void:
|
||||
shield_sprite.visible = value != 0
|
||||
|
||||
|
||||
func _on_armor_updated(value: int, _max_value: int) -> void:
|
||||
armor_sprite.visible = value != 0
|
||||
|
||||
|
||||
func _on_hull_updated(_value: int, _max_value: int) -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
@@ -10,7 +10,11 @@ motion_mode = 1
|
||||
wall_min_slide_angle = 3.1415927
|
||||
script = ExtResource("1_6isjb")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
[node name="ShipSprite" type="Sprite2D" parent="."]
|
||||
|
||||
[node name="ArmorSprite" type="Sprite2D" parent="."]
|
||||
|
||||
[node name="ShieldSprite" type="Sprite2D" parent="."]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d3epy8w15qmjm"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://d3epy8w15qmjm"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dwsn0lf1e3578" path="res://game/entities/ships/enemies/abstract_enemy_ship.tscn" id="1_wvvpj"]
|
||||
[ext_resource type="Script" uid="uid://cxomr1oojcrcl" path="res://game/entities/ships/enemies/heavy/heavy_enemy_ship.gd" id="2_3umer"]
|
||||
@@ -8,6 +8,14 @@
|
||||
atlas = ExtResource("3_xqe8d")
|
||||
region = Rect2(0, 0, 64, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qawoi"]
|
||||
atlas = ExtResource("3_xqe8d")
|
||||
region = Rect2(0, 48, 64, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_c4do6"]
|
||||
atlas = ExtResource("3_xqe8d")
|
||||
region = Rect2(0, 96, 64, 48)
|
||||
|
||||
[node name="HeavyEnemyShip" instance=ExtResource("1_wvvpj")]
|
||||
script = ExtResource("2_3umer")
|
||||
acceleration = 30
|
||||
@@ -15,22 +23,28 @@ deceleration = 18
|
||||
max_speed = 60
|
||||
mass = 600
|
||||
|
||||
[node name="Sprite2D" parent="." index="0"]
|
||||
[node name="ShipSprite" parent="." index="0"]
|
||||
texture = SubResource("AtlasTexture_xqe8d")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="1"]
|
||||
[node name="ArmorSprite" parent="." index="1"]
|
||||
texture = SubResource("AtlasTexture_qawoi")
|
||||
|
||||
[node name="ShieldSprite" parent="." index="2"]
|
||||
texture = SubResource("AtlasTexture_c4do6")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="3"]
|
||||
polygon = PackedVector2Array(-31, 2, -31, -2, -17, -19, -11, -22, 8, -23, 30, -23, 30, 23, 8, 23, -11, 22, -17, 19)
|
||||
|
||||
[node name="Health" parent="." index="2"]
|
||||
max_hull = 200
|
||||
|
||||
[node name="HeathBar" parent="." index="3"]
|
||||
offset_top = 30.0
|
||||
offset_bottom = 30.0
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" parent="." index="5"]
|
||||
rect = Rect2(-29, -21, 58, 42)
|
||||
|
||||
[node name="Health" parent="." index="6"]
|
||||
max_hull = 200
|
||||
|
||||
[node name="HeathBar" parent="." index="7"]
|
||||
offset_top = 30.0
|
||||
offset_bottom = 30.0
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(-8, 0)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cye5ndbh0ht7w"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://cye5ndbh0ht7w"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dwsn0lf1e3578" path="res://game/entities/ships/enemies/abstract_enemy_ship.tscn" id="1_16owb"]
|
||||
[ext_resource type="Script" uid="uid://dcpqrdvp4nk82" path="res://game/entities/ships/enemies/medium/medium_enemy_ship.gd" id="2_dgwiy"]
|
||||
@@ -8,6 +8,14 @@
|
||||
atlas = ExtResource("3_d2xji")
|
||||
region = Rect2(0, 0, 48, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_om3xa"]
|
||||
atlas = ExtResource("3_d2xji")
|
||||
region = Rect2(0, 32, 48, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jorhn"]
|
||||
atlas = ExtResource("3_d2xji")
|
||||
region = Rect2(0, 64, 48, 32)
|
||||
|
||||
[node name="MediumEnemyShip" instance=ExtResource("1_16owb")]
|
||||
script = ExtResource("2_dgwiy")
|
||||
acceleration = 92
|
||||
@@ -15,22 +23,28 @@ deceleration = 46
|
||||
max_speed = 92
|
||||
mass = 250
|
||||
|
||||
[node name="Sprite2D" parent="." index="0"]
|
||||
[node name="ShipSprite" parent="." index="0"]
|
||||
texture = SubResource("AtlasTexture_d2xji")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="1"]
|
||||
[node name="ArmorSprite" parent="." index="1"]
|
||||
texture = SubResource("AtlasTexture_om3xa")
|
||||
|
||||
[node name="ShieldSprite" parent="." index="2"]
|
||||
texture = SubResource("AtlasTexture_jorhn")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="3"]
|
||||
polygon = PackedVector2Array(-23, -2, -12, -13, -6, -15, 22, -15, 23, -14, 23, 14, 22, 15, -6, 15, -12, 13, -23, 2)
|
||||
|
||||
[node name="Health" parent="." index="2"]
|
||||
max_hull = 100
|
||||
|
||||
[node name="HeathBar" parent="." index="3"]
|
||||
offset_top = 30.0
|
||||
offset_bottom = 30.0
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" parent="." index="5"]
|
||||
rect = Rect2(-13, -21, 26, 42)
|
||||
|
||||
[node name="Health" parent="." index="6"]
|
||||
max_hull = 100
|
||||
|
||||
[node name="HeathBar" parent="." index="7"]
|
||||
offset_top = 30.0
|
||||
offset_bottom = 30.0
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(4, -8)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cbf3kumeoqpba"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://cbf3kumeoqpba"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dwsn0lf1e3578" path="res://game/entities/ships/enemies/abstract_enemy_ship.tscn" id="1_lt1av"]
|
||||
[ext_resource type="Script" uid="uid://btcce3nflycrs" path="res://game/entities/ships/enemies/small/small_enemy_ship.gd" id="2_bw04d"]
|
||||
@@ -8,6 +8,14 @@
|
||||
atlas = ExtResource("3_tb2nn")
|
||||
region = Rect2(0, 0, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3asrx"]
|
||||
atlas = ExtResource("3_tb2nn")
|
||||
region = Rect2(0, 16, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_20te2"]
|
||||
atlas = ExtResource("3_tb2nn")
|
||||
region = Rect2(0, 32, 32, 16)
|
||||
|
||||
[node name="SmallEnemyShip" instance=ExtResource("1_lt1av")]
|
||||
script = ExtResource("2_bw04d")
|
||||
acceleration = 180
|
||||
@@ -15,21 +23,27 @@ deceleration = 80
|
||||
max_speed = 120
|
||||
mass = 100
|
||||
|
||||
[node name="Sprite2D" parent="." index="0"]
|
||||
[node name="ShipSprite" parent="." index="0"]
|
||||
texture = SubResource("AtlasTexture_tb2nn")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="1"]
|
||||
[node name="ArmorSprite" parent="." index="1"]
|
||||
texture = SubResource("AtlasTexture_3asrx")
|
||||
|
||||
[node name="ShieldSprite" parent="." index="2"]
|
||||
texture = SubResource("AtlasTexture_20te2")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="3"]
|
||||
polygon = PackedVector2Array(-3, -7, 12, -7, 15, -4, 15, 4, 12, 7, -3, 7, -15, 1, -15, -1)
|
||||
|
||||
[node name="Health" parent="." index="2"]
|
||||
max_hull = 50
|
||||
|
||||
[node name="HeathBar" parent="." index="3"]
|
||||
offset_top = 14.0
|
||||
offset_bottom = 14.0
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" parent="." index="5"]
|
||||
rect = Rect2(-13, -5, 26, 10)
|
||||
|
||||
[node name="Health" parent="." index="6"]
|
||||
max_hull = 50
|
||||
|
||||
[node name="HeathBar" parent="." index="7"]
|
||||
offset_top = 14.0
|
||||
offset_bottom = 14.0
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(5, 0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://br074cqcnul3d"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://br074cqcnul3d"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://jvyagshykmgb" path="res://game/entities/ships/abstract_ship.tscn" id="1_6otxb"]
|
||||
[ext_resource type="Script" uid="uid://ruxw1n03iq4i" path="res://game/entities/ships/player/player_ship.gd" id="2_625ti"]
|
||||
@@ -9,10 +9,18 @@
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 0, 48, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_34rhw"]
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uf2n1"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 32, 48, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ui1ht"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 64, 48, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_34rhw"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 96, 48, 32)
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_pjmi2"]
|
||||
particle_flag_disable_z = true
|
||||
spread = 0.0
|
||||
@@ -30,27 +38,23 @@ deceleration = 46
|
||||
max_speed = 92
|
||||
mass = 250
|
||||
|
||||
[node name="Sprite2D" parent="." index="0"]
|
||||
[node name="ShipSprite" parent="." index="0"]
|
||||
texture = SubResource("AtlasTexture_4mjo1")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="1"]
|
||||
[node name="ArmorSprite" parent="." index="1"]
|
||||
texture = SubResource("AtlasTexture_uf2n1")
|
||||
|
||||
[node name="ShieldSprite" parent="." index="2"]
|
||||
texture = SubResource("AtlasTexture_ui1ht")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="3"]
|
||||
polygon = PackedVector2Array(-23, -10, -17, -14, -3, -15, 21, -13, 22, -12, 22, 12, 21, 13, -3, 15, -17, 14, -23, 10)
|
||||
|
||||
[node name="Health" parent="." index="2"]
|
||||
max_shield = 250
|
||||
max_hull = 1000
|
||||
|
||||
[node name="HeathBar" parent="." index="3"]
|
||||
offset_top = 22.0
|
||||
offset_bottom = 22.0
|
||||
|
||||
[node name="PlayerController" parent="." index="4" instance=ExtResource("3_4mjo1")]
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(-2, 8)
|
||||
|
||||
[node name="Second" type="Node2D" parent="WeaponSlots" index="1"]
|
||||
position = Vector2(-2, -8)
|
||||
[node name="Health" parent="." index="5"]
|
||||
max_shield = 250
|
||||
max_hull = 1000
|
||||
|
||||
[node name="BlinkTimer" type="Timer" parent="." index="6"]
|
||||
process_callback = 0
|
||||
@@ -65,6 +69,19 @@ lifetime = 0.1
|
||||
one_shot = true
|
||||
process_material = SubResource("ParticleProcessMaterial_pjmi2")
|
||||
|
||||
[node name="HeathBar" parent="." index="8"]
|
||||
offset_top = 22.0
|
||||
offset_bottom = 22.0
|
||||
|
||||
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
|
||||
position = Vector2(-2, 8)
|
||||
|
||||
[node name="Second" type="Node2D" parent="WeaponSlots" index="1"]
|
||||
position = Vector2(-2, -8)
|
||||
|
||||
[connection signal="accelerate" from="PlayerController" to="." method="accelerate"]
|
||||
[connection signal="blink" from="PlayerController" to="." method="_blink"]
|
||||
[connection signal="shoot" from="PlayerController" to="." method="shoot"]
|
||||
[connection signal="armor_updated" from="Health" to="." method="_on_armor_updated"]
|
||||
[connection signal="hull_updated" from="Health" to="." method="_on_hull_updated"]
|
||||
[connection signal="shield_updated" from="Health" to="." method="_on_shield_updated"]
|
||||
|
||||
@@ -7,7 +7,6 @@ extends BlastProjectile
|
||||
|
||||
@onready var sprite_on := $Sprite2D_On
|
||||
@onready var sprite_off := $Sprite2D_Off
|
||||
@onready var livetime_timer := $LivetimeTimer
|
||||
@onready var sprite_on_timer := $SpriteOnTimer
|
||||
@onready var sprite_off_timer := $SpriteOffTimer
|
||||
@onready var explosion_particles : ExplosionParticles = $ExplosionParticles
|
||||
|
||||
@@ -2,9 +2,9 @@ class_name Health
|
||||
extends Node
|
||||
|
||||
|
||||
signal shield_updated(value: int)
|
||||
signal armor_updated(value: int)
|
||||
signal hull_updated(value: int)
|
||||
signal shield_updated(value: int, max_value: int)
|
||||
signal armor_updated(value: int, max_value: int)
|
||||
signal hull_updated(value: int, max_value: int)
|
||||
|
||||
signal depleted
|
||||
|
||||
@@ -32,15 +32,15 @@ var hull: int:
|
||||
@onready var _shield := max_shield:
|
||||
set(value):
|
||||
_shield = value
|
||||
shield_updated.emit(_shield)
|
||||
shield_updated.emit(_shield, max_shield)
|
||||
@onready var _armor := max_armor:
|
||||
set(value):
|
||||
_armor = value
|
||||
armor_updated.emit(_armor)
|
||||
armor_updated.emit(_armor, max_armor)
|
||||
@onready var _hull := max_hull:
|
||||
set(value):
|
||||
_hull = value
|
||||
hull_updated.emit(_hull)
|
||||
hull_updated.emit(_hull, max_hull)
|
||||
|
||||
@onready var _shield_regen := floori(max_shield/30.0)
|
||||
|
||||
|
||||
@@ -33,18 +33,22 @@ func _ready() -> void:
|
||||
health.hull_updated.connect(_on_hull_updated)
|
||||
|
||||
|
||||
func _on_shield_updated(new_value: int) -> void:
|
||||
small_shield_part.set_value(new_value)
|
||||
large_shield_part.set_value(new_value)
|
||||
func _on_shield_updated(value: int, max_value: int) -> void:
|
||||
small_shield_part.set_value(value)
|
||||
large_shield_part.set_value(value)
|
||||
small_shield_part.set_max_value(max_value)
|
||||
large_shield_part.set_max_value(max_value)
|
||||
|
||||
|
||||
func _on_armor_updated(new_value: int) -> void:
|
||||
armor_part.set_value(new_value)
|
||||
_select_armor_part(new_value)
|
||||
func _on_armor_updated(value: int, max_value: int) -> void:
|
||||
armor_part.set_value(value)
|
||||
armor_part.set_max_value(max_value)
|
||||
_select_armor_part(value)
|
||||
|
||||
|
||||
func _on_hull_updated(new_value: int) -> void:
|
||||
hull_part.set_value(new_value)
|
||||
func _on_hull_updated(value: int, max_value: int) -> void:
|
||||
hull_part.set_value(value)
|
||||
hull_part.set_max_value(max_value)
|
||||
|
||||
|
||||
func _select_armor_part(armor_value: int) -> void:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user