Background color + Modules Save/Load WIP

This commit is contained in:
gotfishmakesticks 2024-01-13 15:24:04 +03:00
commit db34682cf9
3 changed files with 17 additions and 15 deletions

View file

@ -296,6 +296,7 @@ offset_bottom = 511.0
text = "Accept quest"
[node name="EquipmentMenu" type="NinePatchRect" parent="."]
visible = false
layout_mode = 0
offset_left = 320.0
offset_top = 40.0

View file

@ -1,15 +1,10 @@
extends Node2D
var can_target = []
var weapon_dict = {
"SingleRocketMk1" : "res://scenes/weapons/presets/SingleRocketMk1.tscn",
"DoubleLaserMk1" : "res://scenes/weapons/presets/DoubleLaserMk1.tscn",
"SingleLaserMk1" : "res://scenes/weapons/presets/SingleLaserMk1.tscn"
}
var bought_weapon : Dictionary = weapon_dict.duplicate()
var color_player
var color_base
var color_enemy
var color_background
@export var map_width = 8192
@export var map_height = 8192
@onready var ship = $MainShip
@ -21,9 +16,6 @@ signal scene_ready
func _ready():
randomize()
recolor()
for key in bought_weapon:
bought_weapon[key] = false
bought_weapon["SingleLaserMk1"] = true
ship.camera.limit_left = -map_width/2.0
ship.camera.limit_right = map_width/2.0
ship.camera.limit_top = -map_height/2.0
@ -38,12 +30,16 @@ func _ready():
ship.hull.fuel = save['fuel']
ship.hull.ammunition = save['ammo']
ship.hull.cargo = save['cargo']
ship.hulls = save['hulls'] as Array[String]
ship.engines = save['engines'] as Array[String]
ship.shields = save['shields'] as Array[String]
ship.weapons = save['weapons'] as Array[String]
if save.has('ship_equipment'):
var hull = Game.get_module(save['ship_equipment']['hull'], 'hull').instantiate()
var engine = Game.get_module(save['ship_equipment']['hull'], 'engine').instantiate()
var shield = Game.get_module(save['ship_equipment']['hull'], 'shield').instantiate()
var primary_weapon = Game.get_weapon(save['ship_equipment']['primary_weapon']).instantiate()
var secondary_weapon = Game.get_weapon(save['ship_equipment']['secondary_weapon']).instantiate()
var hull = save['ship_equipment']['hull']
var engine = save['ship_equipment']['engine']
var shield = save['ship_equipment']['shield']
var primary_weapon = save['ship_equipment']['primary_weapon']
var secondary_weapon = save['ship_equipment']['secondary_weapon']
ship.change_hull(hull)
ship.change_engine(engine)
ship.change_shield(shield)
@ -94,6 +90,7 @@ func recolor():
color_player = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1))
color_base = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1))
color_enemy = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1))
color_background = Color.from_hsv(randf(), randf_range(0.1765, 1), randf_range(0.0392, 0.0862))
ship.modulate = color_player
bases.modulate = color_base
enemy_faction.modulate = color_enemy

View file

@ -32,7 +32,11 @@ static func profile_save(scene : Node) -> void:
"hp" : scene.ship.hull.hp,
"fuel" : scene.ship.hull.fuel,
"money" : scene.ship.money,
"cargo" : scene.ship.hull.cargo
"cargo" : scene.ship.hull.cargo,
"hulls" : scene.ship.hulls,
"engines" : scene.ship.engines,
"shields" : scene.ship.shields,
"weapons" : scene.ship.weapons
}
if !scene.ship.quest.new or scene.ship.quest_completed:
profile.profile_meta['game']['quest'] = {