* modification de certains assets * optimisation de chunks * ajout d'un SceneManager * ajout d'un premier dialogue avec Demeter * changement des jour en charge * mise en place d'un système de run * etc...
101 lines
3.2 KiB
GDScript
101 lines
3.2 KiB
GDScript
extends Resource
|
|
class_name GameData
|
|
|
|
signal current_planet_data_updated(p : PlanetData)
|
|
|
|
func _init():
|
|
set_default_unlocked()
|
|
|
|
@export var tutorial_done = false
|
|
|
|
@export var settings : SettingsData = SettingsData.new()
|
|
|
|
@export var current_run : RunData = RunData.new()
|
|
|
|
@export var current_planet_data : PlanetData : get = get_current_planet_data
|
|
|
|
@export var player_data : PlayerData = PlayerData.new()
|
|
|
|
@export var unlocked_plant_types : Array[PlantType] = []
|
|
@export var unlocked_plant_mutations : Array[PlantMutation] = []
|
|
@export var unlocked_machines : Array[MachineType] = []
|
|
|
|
@export var truck_data : TruckData = TruckData.new()
|
|
|
|
func _ready():
|
|
current_run.run_point_changed.connect(
|
|
func(): current_planet_data_updated.emit(get_current_planet_data)
|
|
)
|
|
|
|
func set_default_unlocked():
|
|
unlocked_plant_types = all_plant_types()
|
|
unlocked_plant_mutations = all_plant_mutations()
|
|
unlocked_machines = all_machines()
|
|
|
|
func reset_run():
|
|
current_run = RunData.new()
|
|
current_planet_data_updated.emit()
|
|
|
|
func reset_player():
|
|
player_data = PlayerData.new()
|
|
|
|
func reset_truck():
|
|
truck_data = TruckData.new()
|
|
|
|
func reset_all():
|
|
reset_run()
|
|
reset_player()
|
|
reset_truck()
|
|
|
|
unlocked_plant_types = []
|
|
|
|
func unlock_plant_type(new_plant_type : PlantType):
|
|
if not is_plant_type_unlocked(new_plant_type):
|
|
unlocked_plant_types.append(new_plant_type.duplicate_deep())
|
|
|
|
func get_locked_plant_types() -> Array[PlantType]:
|
|
var locked_plant_type : Array[PlantType] = []
|
|
|
|
for pt in GameInfo.game_data.all_plant_types():
|
|
if not is_plant_type_unlocked(pt):
|
|
locked_plant_type.append(pt)
|
|
|
|
return locked_plant_type
|
|
|
|
func get_current_planet_data():
|
|
return current_run.get_current_planet_data()
|
|
|
|
func is_plant_type_unlocked(new_plant_type : PlantType):
|
|
return unlocked_plant_types.find_custom(
|
|
func (upt : PlantType): return new_plant_type.name == upt.name
|
|
) != -1
|
|
|
|
|
|
func all_plant_types() -> Array[PlantType]:
|
|
return [
|
|
preload("res://entities/plants/resources/plant_types/champ.tres"),
|
|
preload("res://entities/plants/resources/plant_types/chardi.tres"),
|
|
preload("res://entities/plants/resources/plant_types/ferno.tres"),
|
|
preload("res://entities/plants/resources/plant_types/maias.tres"),
|
|
preload("res://entities/plants/resources/plant_types/philea.tres"),
|
|
preload("res://entities/plants/resources/plant_types/pili.tres"),
|
|
preload("res://entities/plants/resources/plant_types/solita.tres"),
|
|
]
|
|
|
|
func all_machines() -> Array[MachineType]:
|
|
return [
|
|
preload("res://entities/interactables/machines/solar_pannel/solar_pannel.tres"),
|
|
]
|
|
|
|
func all_plant_mutations() -> Array[PlantMutation]:
|
|
return [
|
|
preload("res://entities/plants/resources/plant_mutations/ancient_mutation.tres"),
|
|
preload("res://entities/plants/resources/plant_mutations/elitist_mutation.tres"),
|
|
preload("res://entities/plants/resources/plant_mutations/ermit_mutation.tres"),
|
|
preload("res://entities/plants/resources/plant_mutations/precocious_mutation.tres"),
|
|
preload("res://entities/plants/resources/plant_mutations/quality_mutation.tres"),
|
|
preload("res://entities/plants/resources/plant_mutations/quick_mutation.tres"),
|
|
preload("res://entities/plants/resources/plant_mutations/sociable_mutation.tres"),
|
|
preload("res://entities/plants/resources/plant_mutations/strong_mutation.tres"),
|
|
]
|