test stats anche achievements
This commit is contained in:
@@ -1,25 +1,26 @@
|
||||
extends Node
|
||||
|
||||
#Achievement e statistiche devono essere pubblicati live nel backend
|
||||
#Steamworks anche se il gioco non è ancora uscito altrimenti le chiamate ritornano errore
|
||||
#Achievements and stats must be published on Steam even if game is not yet released
|
||||
#if you have an error setting achievements or stats in debug mode remember to open your steam client
|
||||
#with jmp games account or another account who bought this game. If error persist try to clos and reopen steam client.
|
||||
const KNOWN := [
|
||||
"ACH_FIRST_WIN",
|
||||
"ACH_PLAY_10_GAMES",
|
||||
"ACH_REACH_LEVEL_5",
|
||||
"ACH_DISTANCE_100",
|
||||
"ACH_DISTANCE_200",
|
||||
"ACH_10_PHOTOS",
|
||||
]
|
||||
|
||||
#how it works:
|
||||
#func _on_player_won() -> void:
|
||||
# Achievements.unlock("ACH_FIRST_WIN") #unlock the achievement at first win
|
||||
# Achievements.unlock("ACH_DISTANCE_100") #unlock the achievement at first win
|
||||
|
||||
#func _on_match_finished(coins_collected: int) -> void:
|
||||
#update stats
|
||||
#...
|
||||
#check thresholds and unlock achievements
|
||||
# if Stats.get_int("stat_games_played") >= 10:
|
||||
# Achievements.unlock("ACH_PLAY_10_GAMES")
|
||||
# if Stats.get_int("stat_total_coins") >= 100:
|
||||
# Achievements.unlock("ACH_COLLECT_100_COINS")
|
||||
# if Stats.get_int("stat_distance_km") >= 100:
|
||||
# Achievements.unlock("ACH_DISTANCE_100")
|
||||
# if Stats.get_int("stat_distance_km") >= 200:
|
||||
# Achievements.unlock("ACH_DISTANCE_200")
|
||||
|
||||
signal unlocked(api_name: String)
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
extends Node
|
||||
|
||||
#Achievement e statistiche devono essere pubblicati live nel backend
|
||||
#Steamworks anche se il gioco non è ancora uscito altrimenti le chiamate ritornano errore
|
||||
### SISETMARE SU RAILS IL FATTORE DI CONVERSIONE DA UNITA' A KM!!!
|
||||
### ORA HO LASCIATO 1:1 PER TEST
|
||||
|
||||
#Achievements and stats must be published on Steam even if game is not yet released
|
||||
#if you have an error setting achievements or stats in debug mode remember to open your steam client
|
||||
#with jmp games account or another account who bought this game. If error persist try to clos and reopen steam client.
|
||||
const KNOWN := [
|
||||
"stat_games_played",
|
||||
"stat_total_score",
|
||||
"stat_distance_km",
|
||||
"stat_stop_number",
|
||||
"stat_photo_number",
|
||||
"stat_toottoot_number",
|
||||
]
|
||||
|
||||
#how it works:
|
||||
@@ -16,6 +22,7 @@ const KNOWN := [
|
||||
# if Stats.get_int("stat_games_played") >= 10:
|
||||
# Achievements.unlock("ACH_PLAY_10_GAMES") #it call storeStats()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
@@ -32,6 +39,7 @@ func set_int(stat: String, value: int) -> void:
|
||||
if not KNOWN.has(stat):
|
||||
push_warning("Stat not found: %s" % stat)
|
||||
return
|
||||
|
||||
if not Steam.setStatInt(stat, value):
|
||||
push_error("setStatInt failed (incremental with value less than current value? is published on steam?): %s" % stat)
|
||||
|
||||
@@ -39,6 +47,7 @@ func set_float(stat: String, value: float) -> void:
|
||||
if not KNOWN.has(stat):
|
||||
push_warning("Stat not found: %s" % stat)
|
||||
return
|
||||
|
||||
if not Steam.setStatFloat(stat, value):
|
||||
push_error("setStatFloat failed: %s" % stat)
|
||||
|
||||
@@ -59,4 +68,5 @@ func reset_all(include_achievements: bool = false) -> void:
|
||||
Steam.storeStats()
|
||||
|
||||
func _on_stats_stored(_game: int, result: int) -> void:
|
||||
print("Stats save on server, result=%d" % result)
|
||||
if !result:
|
||||
print("stats not ready: (result %d)" % [result])
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
extends Node
|
||||
|
||||
#if you have an error setting achievements or stats in debug mode remember to open your steam client
|
||||
#with jmp games account or another account who bought this game. If error persist try to clos and reopen steam client.
|
||||
|
||||
const APP_ID: int = 4809260 #Train Goes Choo Choo
|
||||
|
||||
var is_on_steam: bool = false
|
||||
@@ -21,7 +24,7 @@ func _ready() -> void:
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if is_on_steam:
|
||||
Steam.run_callbacks() # every frame, always
|
||||
Steam.run_callbacks() #every frame, forever
|
||||
|
||||
func _on_overlay_toggled(active: bool, _user_initiated: bool, _app_id: int) -> void:
|
||||
get_tree().paused = active
|
||||
|
||||
Reference in New Issue
Block a user