add ai, photo_mode and radio #11
@@ -1,13 +1,17 @@
|
|||||||
class_name SaveGameData
|
class_name SaveGameData
|
||||||
extends Resource
|
extends Resource
|
||||||
|
|
||||||
var unlocked_collectibles_ids: Array[String] = []
|
var unlocked_collectibles_ids: Array[StringName] = []
|
||||||
var saved_photos: Array[String] = []
|
var saved_photos: Array[String] = []
|
||||||
var audio_bus_volumes: Dictionary[String, float] = {}
|
var audio_bus_volumes: Dictionary[String, float] = {}
|
||||||
|
|
||||||
func to_dictionary() -> Dictionary:
|
func to_dictionary() -> Dictionary:
|
||||||
|
var serialized_collectible_ids: Array[String] = []
|
||||||
|
for collectible_id in unlocked_collectibles_ids:
|
||||||
|
serialized_collectible_ids.append(str(collectible_id))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"unlocked_collectibles_ids": unlocked_collectibles_ids,
|
"unlocked_collectibles_ids": serialized_collectible_ids,
|
||||||
"saved_photos": saved_photos,
|
"saved_photos": saved_photos,
|
||||||
"audio_bus_volumes": audio_bus_volumes,
|
"audio_bus_volumes": audio_bus_volumes,
|
||||||
}
|
}
|
||||||
@@ -17,7 +21,7 @@ static func from_dictionary(data: Dictionary) -> SaveGameData:
|
|||||||
|
|
||||||
if data.has("unlocked_collectibles_ids"):
|
if data.has("unlocked_collectibles_ids"):
|
||||||
for collectible_id in data["unlocked_collectibles_ids"]:
|
for collectible_id in data["unlocked_collectibles_ids"]:
|
||||||
save_game_data.unlocked_collectibles_ids.append(str(collectible_id))
|
save_game_data.unlocked_collectibles_ids.append(StringName(str(collectible_id)))
|
||||||
|
|
||||||
if data.has("saved_photos"):
|
if data.has("saved_photos"):
|
||||||
for photo_path in data["saved_photos"]:
|
for photo_path in data["saved_photos"]:
|
||||||
|
|||||||
@@ -6,21 +6,21 @@
|
|||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_3cgvf"]
|
[sub_resource type="Resource" id="Resource_3cgvf"]
|
||||||
script = ExtResource("1_3cgvf")
|
script = ExtResource("1_3cgvf")
|
||||||
id = "cane"
|
id = &"cane"
|
||||||
title = "Cane"
|
title = "Cane"
|
||||||
image = ExtResource("2_pxmdy")
|
image = ExtResource("2_pxmdy")
|
||||||
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_ggu10"]
|
[sub_resource type="Resource" id="Resource_ggu10"]
|
||||||
script = ExtResource("1_3cgvf")
|
script = ExtResource("1_3cgvf")
|
||||||
id = "gatto"
|
id = &"gatto"
|
||||||
title = "Gatto"
|
title = "Gatto"
|
||||||
image = ExtResource("2_pxmdy")
|
image = ExtResource("2_pxmdy")
|
||||||
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_pxmdy"]
|
[sub_resource type="Resource" id="Resource_pxmdy"]
|
||||||
script = ExtResource("1_3cgvf")
|
script = ExtResource("1_3cgvf")
|
||||||
id = "farfalla"
|
id = &"farfalla"
|
||||||
title = "Farfalla"
|
title = "Farfalla"
|
||||||
image = ExtResource("2_pxmdy")
|
image = ExtResource("2_pxmdy")
|
||||||
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class_name CollectibleResource
|
class_name CollectibleResource
|
||||||
extends Resource
|
extends Resource
|
||||||
|
|
||||||
@export var id: String
|
@export var id: StringName
|
||||||
@export var title: String
|
@export var title: String
|
||||||
@export var image: Texture2D
|
@export var image: Texture2D
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
signal on_collectible_unlocked(collectible_id: String)
|
signal on_collectible_unlocked(collectible_id: StringName)
|
||||||
signal on_photo_saved(filePath: String)
|
signal on_photo_saved(filePath: String)
|
||||||
|
|
||||||
var collectibles_library: CollectibleLibrary = preload("res://core/photo_mode/data/collectible_library.tres")
|
var collectibles_library: CollectibleLibrary = preload("res://core/photo_mode/data/collectible_library.tres")
|
||||||
|
|
||||||
var unlocked_collectibles_ids: Array[String] = []
|
var unlocked_collectibles_ids: Array[StringName] = []
|
||||||
var saved_photos: Array[String] = []
|
var saved_photos: Array[String] = []
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
load_save_data()
|
load_save_data()
|
||||||
|
|
||||||
func unlock_collectible(collectible_id: String) -> void:
|
func unlock_collectible(collectible_id: StringName) -> void:
|
||||||
if not collectible_id in unlocked_collectibles_ids:
|
if not collectible_id in unlocked_collectibles_ids:
|
||||||
var new_collectible = get_collectible_by_id(collectible_id)
|
var new_collectible = get_collectible_by_id(collectible_id)
|
||||||
if new_collectible:
|
if new_collectible:
|
||||||
@@ -19,7 +19,7 @@ func unlock_collectible(collectible_id: String) -> void:
|
|||||||
sync_save_data()
|
sync_save_data()
|
||||||
on_collectible_unlocked.emit(collectible_id)
|
on_collectible_unlocked.emit(collectible_id)
|
||||||
|
|
||||||
func get_collectible_by_id(id: String) -> CollectibleResource:
|
func get_collectible_by_id(id: StringName) -> CollectibleResource:
|
||||||
for collectible in collectibles_library.collectibles:
|
for collectible in collectibles_library.collectibles:
|
||||||
if collectible.id == id:
|
if collectible.id == id:
|
||||||
return collectible
|
return collectible
|
||||||
@@ -28,7 +28,7 @@ func get_collectible_by_id(id: String) -> CollectibleResource:
|
|||||||
func get_all_collectibles() -> Array[CollectibleResource]:
|
func get_all_collectibles() -> Array[CollectibleResource]:
|
||||||
return collectibles_library.collectibles
|
return collectibles_library.collectibles
|
||||||
|
|
||||||
func get_unlocked_collectible_ids() -> Array[String]:
|
func get_unlocked_collectible_ids() -> Array[StringName]:
|
||||||
return unlocked_collectibles_ids
|
return unlocked_collectibles_ids
|
||||||
|
|
||||||
func save_photo_to_disk_async() -> void:
|
func save_photo_to_disk_async() -> void:
|
||||||
@@ -55,6 +55,6 @@ func load_save_data() -> void:
|
|||||||
saved_photos = GameState.save_data.saved_photos.duplicate()
|
saved_photos = GameState.save_data.saved_photos.duplicate()
|
||||||
|
|
||||||
if unlocked_collectibles_ids.is_empty() and saved_photos.is_empty():
|
if unlocked_collectibles_ids.is_empty() and saved_photos.is_empty():
|
||||||
unlocked_collectibles_ids.append("cane")
|
unlocked_collectibles_ids.append(&"cane")
|
||||||
|
|
||||||
sync_save_data()
|
sync_save_data()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func setup() -> void:
|
|||||||
if unlocked_collectible_ids.has(collectible.id):
|
if unlocked_collectible_ids.has(collectible.id):
|
||||||
_unlock_collectible(collectible.id)
|
_unlock_collectible(collectible.id)
|
||||||
|
|
||||||
func on_collectible_unlocked(collectible_id: String) -> void:
|
func on_collectible_unlocked(collectible_id: StringName) -> void:
|
||||||
_unlock_collectible(collectible_id)
|
_unlock_collectible(collectible_id)
|
||||||
|
|
||||||
func _add_collectible(collectible: CollectibleResource) -> void:
|
func _add_collectible(collectible: CollectibleResource) -> void:
|
||||||
@@ -28,7 +28,7 @@ func _add_collectible(collectible: CollectibleResource) -> void:
|
|||||||
collectible_ui.setup(collectible)
|
collectible_ui.setup(collectible)
|
||||||
grid_container.add_child(collectible_ui)
|
grid_container.add_child(collectible_ui)
|
||||||
|
|
||||||
func _unlock_collectible(collectible_id: String) -> void:
|
func _unlock_collectible(collectible_id: StringName) -> void:
|
||||||
for collectible_ui in grid_container.get_children():
|
for collectible_ui in grid_container.get_children():
|
||||||
if collectible_ui.collectible_resource.id == collectible_id:
|
if collectible_ui.collectible_resource.id == collectible_id:
|
||||||
collectible_ui.unlock()
|
collectible_ui.unlock()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ size = Vector3(1.9942131, 0.09710693, 1.984024)
|
|||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_ynvi2"]
|
[sub_resource type="Resource" id="Resource_ynvi2"]
|
||||||
script = ExtResource("3_hh1ka")
|
script = ExtResource("3_hh1ka")
|
||||||
id = "gatto"
|
id = &"gatto"
|
||||||
title = "Gatto"
|
title = "Gatto"
|
||||||
image = ExtResource("4_fan5s")
|
image = ExtResource("4_fan5s")
|
||||||
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
||||||
|
|||||||
Reference in New Issue
Block a user