added playlist generator

This commit is contained in:
derek
2025-02-26 09:13:00 -06:00
parent c87f22d9e8
commit 1c342ecda7
13 changed files with 257 additions and 3 deletions

View File

@@ -5,8 +5,12 @@
[resource]
script = ExtResource("1_8tp85")
gamemode_name = "Cookie Mode"
estimated_difficulty = 4
win_conditions = 0
survival_time = 160.0
money_lost_multiplier = 0.5
weapon_penalty = 0
weapon_drop_percentage = 0.5
walk_speed = 5.0
jump_velocity = 5
dash_speed = 5
@@ -17,7 +21,7 @@ max_stamina = 100.0
stamina_drain = 20.0
air_dash_max = 1
load_save = true
money = 0
money_multiplier = 3.0
start_health = 3
drop_chance_minimum = 0.1
random_drops = false

View File

@@ -5,6 +5,12 @@
[resource]
script = ExtResource("1_lcpua")
gamemode_name = "DO NOT GET HIT"
estimated_difficulty = 0
win_conditions = 2
survival_time = 160.0
money_lost_multiplier = 0.5
weapon_penalty = 0
weapon_drop_percentage = 0.5
walk_speed = 12.0
jump_velocity = 5
dash_speed = 40
@@ -15,7 +21,7 @@ max_stamina = 100.0
stamina_drain = 20.0
air_dash_max = 1
load_save = true
money = 250
money_multiplier = 1.0
start_health = 1
drop_chance_minimum = 0.1
random_drops = false

View File

@@ -5,6 +5,7 @@
[resource]
script = ExtResource("1_litni")
gamemode_name = "Standard"
estimated_difficulty = 2
win_conditions = 0
survival_time = 160.0
money_lost_multiplier = 0.5

View File

@@ -0,0 +1,38 @@
[gd_resource type="Resource" script_class="gamemode" load_steps=2 format=3 uid="uid://u32xafejp3rq"]
[ext_resource type="Script" path="res://gamemode.gd" id="1_2sia6"]
[resource]
script = ExtResource("1_2sia6")
gamemode_name = "Standard"
estimated_difficulty = 0
win_conditions = 0
survival_time = 160.0
money_lost_multiplier = 0.5
weapon_penalty = 0
weapon_drop_percentage = 0.5
walk_speed = 12.0
jump_velocity = 5
dash_speed = 40
gravity = -9.8
time_slowed_speed = 0.1
stamina_regen = false
max_stamina = 100.0
stamina_drain = 20.0
air_dash_max = 1
load_save = false
money_multiplier = 1.0
start_health = 10
drop_chance_minimum = 0.1
random_drops = false
ammo_drop_enabled = true
expected_ammo = {
"heavy": 25,
"light": 200,
"medium": 50,
"rocket": 3,
"shotgun": 20
}
stamina_drop_enabled = true
health_drop_enabled = true
money_drop_enabled = true

59
Mai48CD.tmp Normal file
View File

@@ -0,0 +1,59 @@
[gd_scene load_steps=5 format=3 uid="uid://sa1d1rftyn87"]
[ext_resource type="Script" path="res://scripts/main_menu.gd" id="1_haaol"]
[ext_resource type="Theme" uid="uid://clek42ofxr45f" path="res://DefaultTheme.tres" id="2_3fflq"]
[ext_resource type="FontFile" uid="uid://d2h2tjhxiv5wo" path="res://assets/fonts/White On Black.ttf" id="2_ac165"]
[ext_resource type="Script" path="res://scripts/playlist_generator.gd" id="4_pbhnf"]
[node name="MainMenu" type="Control" groups=["ui"]]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_haaol")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -277.018
offset_top = -174.68
offset_right = 277.018
offset_bottom = 174.68
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="leaderboard_name" type="TextEdit" parent="MarginContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 75)
layout_mode = 2
theme = ExtResource("2_3fflq")
theme_override_font_sizes/font_size = 51
placeholder_text = "Leaderboard name"
[node name="Continue" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_ac165")
theme_override_font_sizes/font_size = 150
text = "Continue"
[node name="Exit" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_ac165")
theme_override_font_sizes/font_size = 150
text = "exit"
[node name="PlaylistGenerator" type="Node" parent="."]
script = ExtResource("4_pbhnf")
[connection signal="pressed" from="MarginContainer/VBoxContainer/Continue" to="." method="_on_continue_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/Exit" to="." method="_on_exit_pressed"]

View File

@@ -1,6 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://sa1d1rftyn87"]
[gd_scene load_steps=5 format=3 uid="uid://sa1d1rftyn87"]
[ext_resource type="Script" path="res://scripts/main_menu.gd" id="1_haaol"]
[ext_resource type="PackedScene" uid="uid://dpootbr7qgac1" path="res://Tools/playlist_generator.tscn" id="2_2rg1o"]
[ext_resource type="Theme" uid="uid://clek42ofxr45f" path="res://DefaultTheme.tres" id="2_3fflq"]
[ext_resource type="FontFile" uid="uid://d2h2tjhxiv5wo" path="res://assets/fonts/White On Black.ttf" id="2_ac165"]
[node name="MainMenu" type="Control" groups=["ui"]]
@@ -12,6 +14,10 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_haaol")
[node name="PlaylistGenerator" parent="." instance=ExtResource("2_2rg1o")]
visible = false
layout_mode = 1
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 8
@@ -31,6 +37,13 @@ layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="leaderboard_name" type="TextEdit" parent="MarginContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 75)
layout_mode = 2
theme = ExtResource("2_3fflq")
theme_override_font_sizes/font_size = 51
placeholder_text = "Leaderboard name"
[node name="Continue" type="Button" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_ac165")

View File

@@ -0,0 +1,28 @@
[gd_scene load_steps=7 format=3 uid="uid://dpootbr7qgac1"]
[ext_resource type="Script" path="res://scripts/playlist_generator.gd" id="1_qvqs2"]
[ext_resource type="Resource" uid="uid://dn3t7wcoumlm3" path="res://GameModes/standard.tres" id="2_85uje"]
[ext_resource type="Script" path="res://gamemode.gd" id="2_hoyqc"]
[ext_resource type="Resource" uid="uid://bs8yvpq65yh3w" path="res://GameModes/cookie_mode.tres" id="3_t0mxh"]
[ext_resource type="Resource" uid="uid://dlvhtdmtln3bb" path="res://GameModes/do_not_get_hit.tres" id="4_8wht4"]
[ext_resource type="Resource" uid="uid://u32xafejp3rq" path="res://GameModes/standard_stam_regen.tres" id="6_vu1w7"]
[node name="Playlist Generator" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_qvqs2")
generate_playlist_now = null
maps_in_rotation = Array[String](["res://assets/blockout_2.tscn", "res://scenes/enemy_working_scene.tscn", "res://scenes/test_level_2v2.tscn", "res://scenes/Arena of Money.tscn"])
gamemodes_in_rotation = Array[ExtResource("2_hoyqc")]([ExtResource("2_85uje"), ExtResource("3_t0mxh"), ExtResource("4_8wht4"), ExtResource("6_vu1w7")])
[node name="Button" type="Button" parent="."]
layout_mode = 0
offset_right = 8.0
offset_bottom = 8.0
text = "Generate Random Playlist"
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]

View File

@@ -2,6 +2,7 @@ extends Resource
class_name gamemode
@export var gamemode_name : String = "My Custom Game Mode"
@export_range(1,5) var estimated_difficulty : int
@export_enum("Kill 'em All","Extraction","Survival_Time") var win_conditions
@export_group("Win Conditions")
@export var survival_time : float = 160 #in seconds

View File

@@ -1,3 +1,4 @@
@tool
extends Node
## ANGLES
@@ -34,3 +35,12 @@ func weighted_random(choices):
print("----------------------------------------------------------------")
return i
random_number -= choices[i]
func only_valid_chars(input_string: String) -> String:
var valid_chars = ""
for char in input_string:
if char.is_valid_identifier():
valid_chars += char
return valid_chars

View File

@@ -13,6 +13,10 @@ var loading_gamemode
var current_level
var current_gamemode
#Leaderboard
var leaderboard_name = "Test"
var playlist_test
#Player Stats

View File

@@ -2,14 +2,24 @@ extends Node
var last_scene
@onready var playlist_generator: Node = $PlaylistGenerator
@onready var leaderboard_name: TextEdit = $MarginContainer/VBoxContainer/leaderboard_name
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
SaveLoad.load_persistent_data()
leaderboard_name.text = GameGlobals.leaderboard_name
playlist_generator.load_playlist()
func _on_continue_pressed() -> void:
var level
var load_to_gamemode
if GameGlobals.leaderboard_name != leaderboard_name.text:
GameGlobals.leaderboard_name = leaderboard_name.text
playlist_generator.load_playlist()
if GameGlobals.current_level == null:
level = "res://scenes/HUBWORLD.tscn"
load_to_gamemode = "res://GameModes/hubworld.tres"

View File

@@ -0,0 +1,78 @@
@tool
extends Node
@export var generate_playlist_now = false
@export var load_playlist_from_file = false
@export var maps_in_rotation : Array[String] = []
@export var gamemodes_in_rotation : Array[gamemode]= []
@export var levels_per_round : int = 5
@export var rounds : int = 3
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if generate_playlist_now == true:
generate_playlist()
if load_playlist_from_file == true:
load_playlist()
func generate_playlist() -> void:
var playlist_name = only_valid_chars(GameGlobals.leaderboard_name)
var playlist = []
print("PLAYLIST CREATED FOR THE : ",playlist_name)
for i in rounds:
var round = []
for x in levels_per_round:
var level_details = {
"map" : maps_in_rotation.pick_random(),
"gamemode" : gamemodes_in_rotation.pick_random()
}
round.append(level_details)
playlist.append(round)
print("PLAYLIST : ", playlist[0][0])
save_playlist(playlist)
generate_playlist_now = false
func only_valid_chars(input_string: String) -> String:
var valid_chars = ""
for char in input_string:
if char.is_valid_identifier():
valid_chars += char
elif char == " ":
valid_chars += "_"
return valid_chars
func save_playlist(playlist):
var playlist_path : String = "user://" + str(only_valid_chars(GameGlobals.leaderboard_name)) + "_playlist.save"
var file = FileAccess.open(playlist_path, FileAccess.WRITE)
file.store_var(only_valid_chars(GameGlobals.leaderboard_name))
file.store_var(playlist)
file.close()
func load_playlist():
var playlist_path : String = "user://" + str(only_valid_chars(GameGlobals.leaderboard_name)) + "_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
file.close()
print("PLAYLIST: ")
print("------------------------------------------------------------------------------------")
print(playlist)
else:
print("no data saved, generating new playlist...")
generate_playlist()

View File

@@ -35,6 +35,7 @@ func save_persistent_data():
print("LAST HIT PATH " + str(last_hit_path))
file.store_var(last_hit_path)
file.store_var(player.velocity)
file.store_var(GameGlobals.leaderboard_name)
file.store_var(get_tree().current_scene.scene_file_path)
file.store_var(get_tree().current_scene.gamemode.resource_path)
file.store_var(GameGlobals.money)
@@ -59,6 +60,7 @@ func load_persistent_data():
var file = FileAccess.open(persistent_save_path, FileAccess.READ)
last_hit_path = file.get_var()
player_velocity_cache = file.get_var()
GameGlobals.leaderboard_name = file.get_var()
GameGlobals.current_level = str(file.get_var())
GameGlobals.current_gamemode = file.get_var()
GameGlobals.money = set_nulls_zero(file.get_var())