chests are saved to playlist
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=3 uid="uid://dpootbr7qgac1"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://dpootbr7qgac1"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bxo70raytpm81" path="res://scripts/playlist_generator.gd" id="1_qvqs2"]
|
||||
[ext_resource type="Script" uid="uid://cd1g0y1aav5a3" path="res://level_resource.gd" id="2_3l62y"]
|
||||
@@ -7,6 +7,7 @@
|
||||
[ext_resource type="Resource" uid="uid://bs8yvpq65yh3w" path="res://GameModes/cookie_mode.tres" id="3_t0mxh"]
|
||||
[ext_resource type="Resource" uid="uid://cwwvseoidm6ha" path="res://GameModes/DoNotGetHit.tres" id="4_8wht4"]
|
||||
[ext_resource type="Resource" uid="uid://u32xafejp3rq" path="res://GameModes/standard_stam_regen.tres" id="6_vu1w7"]
|
||||
[ext_resource type="PackedScene" uid="uid://dyu46bns8mesv" path="res://assets/mac10_pickup.tscn" id="8_hewbh"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_3w5k4"]
|
||||
script = ExtResource("2_3l62y")
|
||||
@@ -38,5 +39,7 @@ grow_vertical = 2
|
||||
script = ExtResource("1_qvqs2")
|
||||
maps_in_rotation = Array[ExtResource("2_3l62y")]([SubResource("Resource_3w5k4"), SubResource("Resource_t5q6w"), SubResource("Resource_2pkld"), SubResource("Resource_13n7k")])
|
||||
gamemodes_in_rotation = Array[ExtResource("2_hoyqc")]([ExtResource("2_85uje"), ExtResource("3_t0mxh"), ExtResource("4_8wht4"), ExtResource("6_vu1w7")])
|
||||
chest_drops = Array[Resource]([ExtResource("8_hewbh")])
|
||||
chests_per_match = null
|
||||
|
||||
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -12,7 +12,7 @@ config_version=5
|
||||
|
||||
config/name="First Person Test"
|
||||
config/tags=PackedStringArray("fps")
|
||||
run/main_scene="uid://otkecr0hcyon"
|
||||
run/main_scene="uid://f7e0v1r6ra6c"
|
||||
config/features=PackedStringArray("4.4", "Forward Plus")
|
||||
config/icon="uid://6svuq1l83al5"
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0169516, 0.0284452, -0.008
|
||||
[node name="LEVEL UTILS" type="Node" parent="."]
|
||||
|
||||
[node name="Playlist Generator" parent="LEVEL UTILS" instance=ExtResource("3_udqcb")]
|
||||
checksum_test = null
|
||||
load_playlist_from_file = null
|
||||
chest_drops = null
|
||||
chests_per_match = null
|
||||
|
||||
[node name="PlaylistLoader" type="Node" parent="LEVEL UTILS"]
|
||||
script = ExtResource("3_2u2e7")
|
||||
|
||||
@@ -93,7 +93,7 @@ func _ready():
|
||||
var chest_loc = chest_spawners.pick_random()
|
||||
var instance_chest = CHEST_1.instantiate()
|
||||
print("SPAWNING CHEST AT : ",chest_loc.name)
|
||||
get_tree().current_scene.add_child(instance_chest)
|
||||
add_child(instance_chest)
|
||||
instance_chest.basis = chest_loc.basis
|
||||
instance_chest.global_position = chest_loc.global_position
|
||||
instance_chest.global_rotation = chest_loc.global_rotation
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
@tool
|
||||
extends Node
|
||||
|
||||
@export_tool_button("Generate Playlist")
|
||||
var playlist_action : Callable = func(): generate_test_playlist()
|
||||
|
||||
@export var checksum_test = false
|
||||
@export var load_playlist_from_file = false
|
||||
@export var hub_world : level_resource
|
||||
@export var maps_in_rotation : Array[level_resource] = []
|
||||
@export var gamemodes_in_rotation : Array[gamemode]= []
|
||||
@export var chest_drops : Array[Resource]
|
||||
@export var levels_per_round : int = 5
|
||||
@export var rounds_per_match : int = 3
|
||||
@export var chests_per_match : int = 100
|
||||
@export var matches_per_year : int = 52
|
||||
|
||||
func generate_playlist() -> void:
|
||||
var playlist_name = only_valid_chars(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id])
|
||||
var playlist = []
|
||||
print("PLAYLIST CREATED FOR THE : ",playlist_name)
|
||||
|
||||
set_seed(playlist_name)
|
||||
|
||||
for h in matches_per_year:
|
||||
var matches = []
|
||||
var chests = []
|
||||
var round = []
|
||||
for i in rounds_per_match:
|
||||
var round = []
|
||||
for x in levels_per_round:
|
||||
var gamemode_path = gamemodes_in_rotation.pick_random().resource_path
|
||||
var level_selection = maps_in_rotation.pick_random()
|
||||
@@ -30,40 +31,26 @@ func generate_playlist() -> void:
|
||||
"gamemode_path" : gamemode_path
|
||||
}
|
||||
round.append(level_details)
|
||||
matches.append(round)
|
||||
playlist.append(matches)
|
||||
|
||||
save_playlist(playlist)
|
||||
|
||||
func generate_test_playlist():
|
||||
var playlist_name = "TEST2"
|
||||
var playlist = []
|
||||
var seed_to_use
|
||||
|
||||
if playlist_name:
|
||||
seed_to_use = hash(playlist_name)
|
||||
else:
|
||||
seed_to_use = randi()
|
||||
|
||||
seed(seed_to_use)
|
||||
|
||||
var chest_serial_no : int = 1
|
||||
|
||||
for y in chests_per_match:
|
||||
var drop = chest_drops.pick_random()
|
||||
|
||||
var chest_details = {
|
||||
"serial" : chest_serial_no,
|
||||
"drop" : drop
|
||||
}
|
||||
chests.append(chest_details)
|
||||
chest_serial_no += 1
|
||||
|
||||
var match_details = {"round" : round,"chests" : chests}
|
||||
|
||||
matches.append(match_details)
|
||||
|
||||
for h in matches_per_year:
|
||||
var matches = []
|
||||
for i in rounds_per_match:
|
||||
var round = []
|
||||
for x in levels_per_round:
|
||||
var gamemode_path = gamemodes_in_rotation.pick_random().resource_path
|
||||
var level_selection = maps_in_rotation.pick_random()
|
||||
var level_details = {
|
||||
"level_path" : level_selection.level_path,
|
||||
"level_name" : level_selection.level_name,
|
||||
"gamemode_path" : gamemode_path
|
||||
}
|
||||
round.append(level_details)
|
||||
matches.append(round)
|
||||
playlist.append(matches)
|
||||
|
||||
print(playlist[0][0]["round"][0])
|
||||
print(playlist[0][0]["chests"][3])
|
||||
GameGlobals.playlist = playlist
|
||||
|
||||
func only_valid_chars(input_string: String) -> String:
|
||||
@@ -86,20 +73,19 @@ func save_playlist(playlist):
|
||||
file.close()
|
||||
|
||||
func load_playlist():
|
||||
var playlist_path : String = "user://" + str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]) + "_playlist.save"
|
||||
if FileAccess.file_exists(playlist_path):
|
||||
var file = FileAccess.open(playlist_path, FileAccess.READ)
|
||||
var key = file.get_var()
|
||||
var playlist = file.get_var()
|
||||
print("KEY : ",key)
|
||||
GameGlobals.playlist_test = playlist
|
||||
GameGlobals.current_match = playlist[0]
|
||||
file.close()
|
||||
else:
|
||||
print("no data saved, generating new playlist...")
|
||||
generate_playlist()
|
||||
generate_playlist()
|
||||
GameGlobals.current_match = GameGlobals.playlist[0]
|
||||
|
||||
|
||||
func set_seed(playlist_name):
|
||||
var seed_to_use
|
||||
|
||||
if playlist_name:
|
||||
seed_to_use = hash(playlist_name)
|
||||
else:
|
||||
seed_to_use = randi()
|
||||
|
||||
seed(seed_to_use)
|
||||
|
||||
func _on_gui_input(event: InputEvent) -> void:
|
||||
generate_playlist()
|
||||
|
||||
@@ -91,7 +91,6 @@ func check_user_data_exists():
|
||||
return false
|
||||
|
||||
func load_user_data():
|
||||
print("ALL LEADERBOARDS: ",GameGlobals.all_user_leaderboards[0][0])
|
||||
var user_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_data.save")
|
||||
if FileAccess.file_exists(user_save_path):
|
||||
var file = FileAccess.open(user_save_path, FileAccess.READ)
|
||||
@@ -127,10 +126,7 @@ func load_user_data():
|
||||
get_tree().current_scene.gun_spawn(GameGlobals.current_gun_index)
|
||||
|
||||
var checksum = file.get_var()
|
||||
print("Checksum : ",checksum)
|
||||
var check_data = [user_save_path,file_leaderboard_name,money,deposited_money,health,high_score,player_deaths,shots_fired]
|
||||
print("CHECK DATA : ",check_data)
|
||||
print("CHECKSUM CALC : ",HelperFuncs.checksum(check_data))
|
||||
file.close()
|
||||
await !file.is_open()
|
||||
if checksum == HelperFuncs.checksum(check_data):
|
||||
|
||||
Reference in New Issue
Block a user