add ai, photo_mode and radio #11

Merged
m.cirafisi merged 9 commits from ai_and_photo_mode into main 2026-05-05 20:33:01 +00:00
6 changed files with 20 additions and 16 deletions
Showing only changes of commit 08c283d76a - Show all commits

View File

@@ -1,13 +1,17 @@
class_name SaveGameData
extends Resource
var unlocked_collectibles_ids: Array[String] = []
var unlocked_collectibles_ids: Array[StringName] = []
var saved_photos: Array[String] = []
var audio_bus_volumes: Dictionary[String, float] = {}
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 {
"unlocked_collectibles_ids": unlocked_collectibles_ids,
"unlocked_collectibles_ids": serialized_collectible_ids,
"saved_photos": saved_photos,
"audio_bus_volumes": audio_bus_volumes,
}
@@ -17,7 +21,7 @@ static func from_dictionary(data: Dictionary) -> SaveGameData:
if data.has("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"):
for photo_path in data["saved_photos"]:

View File

@@ -6,21 +6,21 @@
[sub_resource type="Resource" id="Resource_3cgvf"]
script = ExtResource("1_3cgvf")
id = "cane"
id = &"cane"
title = "Cane"
image = ExtResource("2_pxmdy")
metadata/_custom_type_script = "uid://bj34o0org55ei"
[sub_resource type="Resource" id="Resource_ggu10"]
script = ExtResource("1_3cgvf")
id = "gatto"
id = &"gatto"
title = "Gatto"
image = ExtResource("2_pxmdy")
metadata/_custom_type_script = "uid://bj34o0org55ei"
[sub_resource type="Resource" id="Resource_pxmdy"]
script = ExtResource("1_3cgvf")
id = "farfalla"
id = &"farfalla"
title = "Farfalla"
image = ExtResource("2_pxmdy")
metadata/_custom_type_script = "uid://bj34o0org55ei"

View File

@@ -1,6 +1,6 @@
class_name CollectibleResource
extends Resource
@export var id: String
@export var id: StringName
@export var title: String
@export var image: Texture2D

View File

@@ -1,17 +1,17 @@
extends Node
signal on_collectible_unlocked(collectible_id: String)
signal on_collectible_unlocked(collectible_id: StringName)
signal on_photo_saved(filePath: String)
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] = []
func _ready() -> void:
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:
var new_collectible = get_collectible_by_id(collectible_id)
if new_collectible:
@@ -19,7 +19,7 @@ func unlock_collectible(collectible_id: String) -> void:
sync_save_data()
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:
if collectible.id == id:
return collectible
@@ -28,7 +28,7 @@ func get_collectible_by_id(id: String) -> CollectibleResource:
func get_all_collectibles() -> Array[CollectibleResource]:
return collectibles_library.collectibles
func get_unlocked_collectible_ids() -> Array[String]:
func get_unlocked_collectible_ids() -> Array[StringName]:
return unlocked_collectibles_ids
func save_photo_to_disk_async() -> void:
@@ -55,6 +55,6 @@ func load_save_data() -> void:
saved_photos = GameState.save_data.saved_photos.duplicate()
if unlocked_collectibles_ids.is_empty() and saved_photos.is_empty():
unlocked_collectibles_ids.append("cane")
unlocked_collectibles_ids.append(&"cane")
sync_save_data()

View File

@@ -20,7 +20,7 @@ func setup() -> void:
if unlocked_collectible_ids.has(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)
func _add_collectible(collectible: CollectibleResource) -> void:
@@ -28,7 +28,7 @@ func _add_collectible(collectible: CollectibleResource) -> void:
collectible_ui.setup(collectible)
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():
if collectible_ui.collectible_resource.id == collectible_id:
collectible_ui.unlock()

View File

@@ -17,7 +17,7 @@ size = Vector3(1.9942131, 0.09710693, 1.984024)
[sub_resource type="Resource" id="Resource_ynvi2"]
script = ExtResource("3_hh1ka")
id = "gatto"
id = &"gatto"
title = "Gatto"
image = ExtResource("4_fan5s")
metadata/_custom_type_script = "uid://bj34o0org55ei"