Added player hull saving. Multiple fixes
This commit is contained in:
@@ -107,12 +107,16 @@ func _add_weapon(weapon: AbstractWeapon, weapon_position: Vector2) -> void:
|
||||
|
||||
|
||||
func _on_shield_updated(value: int, max_value: int) -> void:
|
||||
if shield_sprite == null: return
|
||||
|
||||
shield_sprite.visible = value != 0
|
||||
var intensity := value/float(max_value) if value != 0 else 0.0
|
||||
shield_sprite.material.set(SHADER_INTENSITY, intensity)
|
||||
|
||||
|
||||
func _on_armor_updated(value: int, max_value: int) -> void:
|
||||
if armor_sprite == null: return
|
||||
|
||||
armor_sprite.visible = value != 0
|
||||
var intensity := value/float(max_value) if value != 0 else 0.0
|
||||
armor_sprite.material.set(SHADER_INTENSITY, intensity)
|
||||
|
||||
@@ -69,6 +69,9 @@ func _set_player_data(new_data: PlayerData) -> void:
|
||||
_weapons.clear()
|
||||
_add_weapon_by_id(player_data.first_weapon_id, weapon_positions[0])
|
||||
_add_weapon_by_id(player_data.second_weapon_id, weapon_positions[1])
|
||||
|
||||
if player_data.hull > 0:
|
||||
health.hull = mini(player_data.hull, health.max_hull)
|
||||
|
||||
|
||||
func _add_weapon_by_id(weapon_id: String, weapon_position: Vector2) -> void:
|
||||
@@ -77,3 +80,11 @@ func _add_weapon_by_id(weapon_id: String, weapon_position: Vector2) -> void:
|
||||
var weapon_scene : PackedScene = load(WEAPON_SCENES[weapon_id])
|
||||
var weapon : AbstractWeapon = weapon_scene.instantiate()
|
||||
_add_weapon(weapon, weapon_position)
|
||||
|
||||
|
||||
func _on_hull_updated(value: int, max_value: int) -> void:
|
||||
super._on_hull_updated(value, max_value)
|
||||
|
||||
if player_data == null: return
|
||||
|
||||
player_data.hull = value
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://br074cqcnul3d"]
|
||||
[gd_scene load_steps=14 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"]
|
||||
[ext_resource type="PackedScene" uid="uid://dh1oj1w5wx4je" path="res://game/controllers/player_controller.tscn" id="3_4mjo1"]
|
||||
[ext_resource type="Texture2D" uid="uid://y2yfli24n51v" path="res://images/ships/player.png" id="3_uf2n1"]
|
||||
[ext_resource type="Shader" uid="uid://dwh22f35u5qqi" path="res://game/entities/ships/shield.gdshader" id="4_ui1ht"]
|
||||
[ext_resource type="PackedScene" uid="uid://d20nvskf38vpo" path="res://game/entities/ships/player/blink_charge_indicator.tscn" id="5_uf2n1"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4mjo1"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 0, 48, 32)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_waejo"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("4_ui1ht")
|
||||
shader_parameter/speed = 0.0
|
||||
shader_parameter/scale = 20.0
|
||||
shader_parameter/intensity = 1.0
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uf2n1"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 32, 48, 32)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_5xifi"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("4_ui1ht")
|
||||
shader_parameter/speed = 5.0
|
||||
shader_parameter/scale = 20.0
|
||||
shader_parameter/intensity = 1.0
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ui1ht"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 64, 48, 32)
|
||||
@@ -34,6 +49,7 @@ collision_layer = 3
|
||||
collision_mask = 5
|
||||
script = ExtResource("2_625ti")
|
||||
blink_range = 75
|
||||
player_data = null
|
||||
acceleration = 92
|
||||
deceleration = 46
|
||||
max_speed = 92
|
||||
@@ -43,9 +59,11 @@ mass = 250
|
||||
texture = SubResource("AtlasTexture_4mjo1")
|
||||
|
||||
[node name="ArmorSprite" parent="." index="1"]
|
||||
material = SubResource("ShaderMaterial_waejo")
|
||||
texture = SubResource("AtlasTexture_uf2n1")
|
||||
|
||||
[node name="ShieldSprite" parent="." index="2"]
|
||||
material = SubResource("ShaderMaterial_5xifi")
|
||||
texture = SubResource("AtlasTexture_ui1ht")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="3"]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_4b2nh"]
|
||||
|
||||
[node name="AbstrastProjectile" type="Area2D"]
|
||||
[node name="AbstrastProjectile" type="Area2D" groups=["projectiles"]]
|
||||
z_index = 1
|
||||
script = ExtResource("1_4b2nh")
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ fixed_fps = 10
|
||||
process_material = SubResource("ParticleProcessMaterial_ifsj2")
|
||||
|
||||
[node name="CooldownTimer" type="Timer" parent="." index="2"]
|
||||
wait_time = 1.3
|
||||
wait_time = 2.0
|
||||
one_shot = true
|
||||
|
||||
[connection signal="timeout" from="CooldownTimer" to="." method="_on_cooldown_timer_timeout"]
|
||||
|
||||
Reference in New Issue
Block a user