From 5e2084109ea27c62b58110e808831c7b60eeec33 Mon Sep 17 00:00:00 2001 From: Fisch Date: Sat, 22 Mar 2025 18:33:11 +0100 Subject: [PATCH] override round setting for maps --- scenes/map_00.tscn | 4 +++- scenes/map_01.tscn | 4 +++- scenes/map_02.tscn | 4 +++- scenes/map_03.tscn | 4 +++- scenes/map_04.tscn | 4 +++- scenes/map_05.tscn | 4 +++- scenes/map_06.tscn | 41 ++++++---------------------------------- scenes/map_template.tscn | 4 +++- scenes/menu.tscn | 24 +++++++++++++++-------- scripts/game.gd | 15 ++++++++++++--- scripts/gamestate.gd | 3 +++ scripts/map_selection.gd | 27 ++++++++++++++++++++++---- scripts/map_settings.gd | 7 +++++++ scripts/menudisplay.gd | 2 +- 14 files changed, 89 insertions(+), 58 deletions(-) create mode 100644 scripts/map_settings.gd diff --git a/scenes/map_00.tscn b/scenes/map_00.tscn index 7ea4be8..7aeae98 100644 --- a/scenes/map_00.tscn +++ b/scenes/map_00.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=34 format=3 uid="uid://bu1m43nyf4ys8"] +[gd_scene load_steps=35 format=3 uid="uid://bu1m43nyf4ys8"] [ext_resource type="Texture2D" uid="uid://csknopg1cbqbq" path="res://sprites/background/green_gradient.png" id="1_01a82"] +[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_7xl02"] [ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="2_fr1tj"] [ext_resource type="Script" path="res://scripts/roadborder.gd" id="3_pbq8s"] [ext_resource type="Texture2D" uid="uid://gydxil7qf7jc" path="res://sprites/road/road_trim.png" id="4_s7foq"] @@ -43,6 +44,7 @@ size = Vector2(128, 64) size = Vector2(32, 128) [node name="Map" type="Node"] +script = ExtResource("1_7xl02") [node name="CanvasLayer" type="CanvasLayer" parent="."] layer = -1 diff --git a/scenes/map_01.tscn b/scenes/map_01.tscn index 99367cd..3708166 100644 --- a/scenes/map_01.tscn +++ b/scenes/map_01.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=34 format=3 uid="uid://cxj0xsy7clbrt"] +[gd_scene load_steps=35 format=3 uid="uid://cxj0xsy7clbrt"] [ext_resource type="Texture2D" uid="uid://dh437eqwliuu1" path="res://sprites/background/desert_gradient.png" id="1_hn21d"] +[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_rmyo5"] [ext_resource type="Texture2D" uid="uid://ba7g1ewwchn6c" path="res://sprites/smooth_fields/fields_animal_001.png" id="2_08by0"] [ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="2_r66hk"] [ext_resource type="Script" path="res://scripts/roadborder.gd" id="3_s3rd6"] @@ -43,6 +44,7 @@ size = Vector2(32, 96) size = Vector2(32, 128) [node name="Map" type="Node"] +script = ExtResource("1_rmyo5") [node name="CanvasLayer" type="CanvasLayer" parent="."] layer = -1 diff --git a/scenes/map_02.tscn b/scenes/map_02.tscn index 9ea9949..bff7441 100644 --- a/scenes/map_02.tscn +++ b/scenes/map_02.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=27 format=3 uid="uid://bwtvxy6hryc4u"] +[gd_scene load_steps=28 format=3 uid="uid://bwtvxy6hryc4u"] +[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_v25kt"] [ext_resource type="Texture2D" uid="uid://csknopg1cbqbq" path="res://sprites/background/green_gradient.png" id="1_y1cwa"] [ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="2_8k47d"] [ext_resource type="Texture2D" uid="uid://c0ss6dp7hba8j" path="res://sprites/smooth_fields/fields_flower_011.png" id="2_jpevj"] @@ -36,6 +37,7 @@ size = Vector2(32, 128) size = Vector2(32, 128) [node name="Map" type="Node"] +script = ExtResource("1_v25kt") [node name="CanvasLayer" type="CanvasLayer" parent="."] layer = -1 diff --git a/scenes/map_03.tscn b/scenes/map_03.tscn index 723c436..b8abb4f 100644 --- a/scenes/map_03.tscn +++ b/scenes/map_03.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=33 format=3 uid="uid://bp3hpwhldy2rn"] +[gd_scene load_steps=34 format=3 uid="uid://bp3hpwhldy2rn"] [ext_resource type="Texture2D" uid="uid://dh437eqwliuu1" path="res://sprites/background/desert_gradient.png" id="1_ck4s5"] +[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_kc7uh"] [ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="2_0ms3p"] [ext_resource type="Texture2D" uid="uid://gydxil7qf7jc" path="res://sprites/road/road_trim.png" id="4_kby5d"] [ext_resource type="Script" path="res://scripts/generate_road_polyon.gd" id="5_65xy1"] @@ -42,6 +43,7 @@ size = Vector2(32, 79) size = Vector2(32, 128) [node name="Map" type="Node"] +script = ExtResource("1_kc7uh") [node name="CanvasLayer" type="CanvasLayer" parent="."] layer = -1 diff --git a/scenes/map_04.tscn b/scenes/map_04.tscn index d1c1a37..3179a8d 100644 --- a/scenes/map_04.tscn +++ b/scenes/map_04.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=36 format=3 uid="uid://bilsj1h72s23a"] +[gd_scene load_steps=37 format=3 uid="uid://bilsj1h72s23a"] +[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_cg3k6"] [ext_resource type="Texture2D" uid="uid://csknopg1cbqbq" path="res://sprites/background/green_gradient.png" id="2_mev6t"] [ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="3_q2khr"] [ext_resource type="Texture2D" uid="uid://gydxil7qf7jc" path="res://sprites/road/road_trim.png" id="5_xsnl8"] @@ -45,6 +46,7 @@ size = Vector2(165, 34) size = Vector2(53, 68) [node name="Map" type="Node"] +script = ExtResource("1_cg3k6") [node name="CanvasLayer" type="CanvasLayer" parent="."] layer = -1 diff --git a/scenes/map_05.tscn b/scenes/map_05.tscn index 1960e29..970d73a 100644 --- a/scenes/map_05.tscn +++ b/scenes/map_05.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=35 format=3 uid="uid://c3bc2y1kqhboa"] +[gd_scene load_steps=36 format=3 uid="uid://c3bc2y1kqhboa"] +[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_cowj0"] [ext_resource type="Texture2D" uid="uid://dh437eqwliuu1" path="res://sprites/background/desert_gradient.png" id="1_un1r6"] [ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="3_mivmq"] [ext_resource type="Script" path="res://scripts/roadborder.gd" id="4_8hrwh"] @@ -44,6 +45,7 @@ size = Vector2(32, 90.1512) size = Vector2(32, 128) [node name="Map" type="Node"] +script = ExtResource("1_cowj0") [node name="CanvasLayer" type="CanvasLayer" parent="."] layer = -1 diff --git a/scenes/map_06.tscn b/scenes/map_06.tscn index d5fe79f..97be94a 100644 --- a/scenes/map_06.tscn +++ b/scenes/map_06.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=18 format=3 uid="uid://ccy3rfrd1jpg1"] +[gd_scene load_steps=19 format=3 uid="uid://ccy3rfrd1jpg1"] [ext_resource type="Texture2D" uid="uid://csknopg1cbqbq" path="res://sprites/background/green_gradient.png" id="1_wo3gb"] +[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_y50df"] [ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="2_2ey0t"] [ext_resource type="Script" path="res://scripts/roadborder.gd" id="3_yxc3j"] [ext_resource type="Texture2D" uid="uid://gydxil7qf7jc" path="res://sprites/road/road_trim.png" id="4_lutxb"] @@ -27,6 +28,8 @@ size = Vector2(128, 160) size = Vector2(384, 128) [node name="Map" type="Node"] +script = ExtResource("1_y50df") +override_rounds_number = 1 [node name="CanvasLayer" type="CanvasLayer" parent="."] layer = -1 @@ -39,7 +42,7 @@ texture = ExtResource("1_wo3gb") [node name="Line2D2_right" type="Line2D" parent="."] z_index = 1 -points = PackedVector2Array(-256, 64, 640, 64, 768, 96, 832, 160, 896, 256, 896, 416, 928, 512, 1024, 576, 1152, 608, 1280, 608, 1536, 608, 2048, 256, 2112, 160, 2144, 0, 2144, -128, 2176, -224, 2304, -256, 2432, -224, 2528, -128, 2560, 0, 2624, 64, 2816, 96, 2912, 96, 3328, 96, 3328, -256, 3168, -256, 3168, -352, 3456, -352, 3456, -480, 3584, -480, 3584, -256, 3392, -256, 3392, 96, 3360, 192, 3232, 224, 2944, 256, 2848, 288, 2784, 384, 2752, 512, 2752, 608, 2816, 704, 3040, 768, 3264, 736, 3488, 608, 3648, 416, 3712, 224, 3776, 64, 3872, 0, 4096, 0, 4352, 0, 4512, -128, 4768, 96, 5024, -96, 5248, 0, 5317, -36, 5632, 64, 5856, 160, 6080, 192, 6304, 192, 6560, 288, 6688, 448, 6880, 544, 7168, 544, 7424, 448, 7552, 288, 7712, 96, 8032, 64, 8256, 0, 8352, -160, 8352, -352, 8256, -512, 8064, -608, 7808, -640, 7520, -640, 7200, -672, 7104, -736, 7104, -832, 7136, -896, 7264, -928, 7712, -896, 8064, -768, 8352, -544, 8448, -320, 8576, -64, 8800, 32, 8992, 64, 8800, 160, 8704, 512, 8736, 704, 8864, 736, 9216, 704, 9472, 608, 9600, 448, 9664, 288, 9888, 256, 10016, 320, 10432, 288, 10688, 128, 10848, -224, 10816, -640, 10528, -896, 10528, -1344) +points = PackedVector2Array(-256, 64, 640, 64, 768, 96, 832, 160, 896, 256, 896, 416, 928, 512, 1024, 576, 1152, 608, 1280, 608, 1536, 608, 2048, 256, 2112, 160, 2144, 0, 2144, -128, 2176, -224, 2304, -256, 2432, -224, 2528, -128, 2560, 0, 2624, 64, 2816, 96, 2912, 96, 3328, 96, 3328, -256, 3168, -256, 3168, -352, 3456, -352, 3456, -480, 3584, -480, 3584, -256, 3392, -256, 3392, 96, 3360, 192, 3232, 224, 2944, 256, 2848, 288, 2784, 384, 2752, 512, 2752, 608, 2816, 704, 3040, 768, 3264, 736, 3488, 608, 3648, 416, 3712, 224, 3776, 64, 3872, 0, 4096, 0, 4352, 0, 4512, -128, 4768, 96, 5024, -96, 5248, 0, 5317, -36, 5632, 64, 5856, 160, 6080, 192, 6304, 192, 6560, 288, 6886, 394, 7148, 426, 7316, 414, 7441, 316, 7574, 119, 7750, 30, 8032, 64, 8256, 0, 8352, -160, 8352, -352, 8256, -512, 8064, -608, 7808, -640, 7520, -640, 7200, -672, 7104, -736, 7104, -832, 7136, -896, 7264, -928, 7712, -896, 8064, -768, 8352, -544, 8448, -320, 8576, -64, 8800, 32, 8995, 103, 8800, 160, 8704, 512, 8736, 704, 8864, 736, 9216, 704, 9472, 608, 9600, 448, 9664, 288, 9888, 256, 10200, 207, 10558, 10, 10619, -111, 10536, -422, 10536, -654, 10528, -896, 10528, -1344) width = 6.0 texture = ExtResource("2_2ey0t") texture_mode = 1 @@ -55,7 +58,7 @@ texture_mode = 1 [node name="Line2D2_left" type="Line2D" parent="."] z_index = 1 -points = PackedVector2Array(-256, -64, 640, -64, 800, -32, 928, 64, 1024, 224, 1024, 384, 1088, 480, 1280, 512, 1504, 512, 1952, 224, 2016, 96, 2048, -64, 2080, -224, 2144, -320, 2272, -352, 2432, -320, 2592, -224, 2624, -96, 2720, -32, 2880, -32, 3232, -32, 3232, -160, 3104, -160, 3104, -416, 3392, -416, 3392, -544, 3648, -544, 3680, -448, 3680, -192, 3648, -128, 3520, -128, 3488, -96, 3488, 96, 3456, 256, 3360, 320, 3168, 352, 2944, 352, 2880, 416, 2880, 512, 3040, 576, 3264, 544, 3520, 416, 3616, 224, 3648, 32, 3776, -64, 4032, -128, 4096, -128, 4320, -128, 4512, -224, 4768, -64, 5024, -192, 5216, -128, 5419, -136, 5632, -192, 5792, -288, 6048, -384, 6336, -384, 7232, -384, 7520, -320, 7712, -224, 8000, -160, 8160, -160, 8224, -256, 8160, -384, 7968, -480, 7616, -544, 7296, -544, 7040, -608, 6912, -736, 6944, -928, 7104, -1088, 7296, -1120, 7680, -1120, 7968, -1088, 8064, -992, 8160, -800, 8352, -640, 8480, -512, 8544, -320, 8640, -160, 8736, -96, 8928, -32, 9120, 0, 9248, 160, 9120, 288, 8896, 352, 8832, 512, 8864, 640, 9056, 608, 9472, 416, 9504, -64, 9984, 96, 10176, 0, 10400, -96, 10368, -416, 10144, -704, 10144, -1344) +points = PackedVector2Array(-256, -64, 640, -64, 800, -32, 928, 64, 1024, 224, 1024, 384, 1088, 480, 1280, 512, 1504, 512, 1952, 224, 2016, 96, 2048, -64, 2080, -224, 2144, -320, 2272, -352, 2432, -320, 2592, -224, 2624, -96, 2720, -32, 2880, -32, 3232, -32, 3232, -160, 3104, -160, 3104, -416, 3392, -416, 3392, -544, 3648, -544, 3680, -448, 3680, -192, 3648, -128, 3520, -128, 3488, -96, 3488, 96, 3456, 256, 3360, 320, 3168, 352, 2944, 352, 2880, 416, 2880, 512, 3040, 576, 3264, 544, 3520, 416, 3616, 224, 3648, 32, 3776, -64, 4032, -128, 4096, -128, 4320, -128, 4512, -224, 4768, -64, 5024, -192, 5216, -128, 5419, -136, 5682, -76, 6013, 11, 6496, 68, 6994, 168, 7379, -25, 7543, -127, 7782, -186, 8000, -160, 8160, -160, 8224, -256, 8160, -384, 7968, -480, 7616, -544, 7296, -544, 7040, -608, 6912, -736, 6944, -928, 7104, -1088, 7296, -1120, 7680, -1120, 7968, -1088, 8064, -992, 8160, -800, 8352, -640, 8480, -512, 8544, -320, 8640, -160, 8736, -96, 8928, -32, 9120, 0, 9248, 160, 9120, 288, 8896, 352, 8832, 512, 8864, 640, 9056, 608, 9472, 416, 9592, 170, 9984, 96, 10176, 0, 10400, -96, 10368, -416, 10144, -704, 10144, -1344) width = 6.0 texture = ExtResource("2_2ey0t") texture_mode = 1 @@ -69,38 +72,6 @@ width = 28.0 texture = ExtResource("4_lutxb") texture_mode = 1 -[node name="Line2D2_right2" type="Line2D" parent="."] -z_index = 1 -points = PackedVector2Array(5728, -64, 5984, -160, 6240, -192, 6688, -192, 7072, -192, 7264, -128, 7520, -64, 7648, -32) -width = 6.0 -texture = ExtResource("2_2ey0t") -texture_mode = 1 -script = ExtResource("3_yxc3j") - -[node name="road_r" type="StaticBody2D" parent="Line2D2_right2"] -collision_layer = 3 - -[node name="trim" type="Line2D" parent="Line2D2_right2"] -width = 28.0 -texture = ExtResource("4_lutxb") -texture_mode = 1 - -[node name="Line2D2_left2" type="Line2D" parent="."] -z_index = 1 -points = PackedVector2Array(5736, -64, 5952, 0, 6272, 64, 6464, 96, 6688, 192, 6816, 352, 7072, 384, 7296, 352, 7456, 192, 7640, -32) -width = 6.0 -texture = ExtResource("2_2ey0t") -texture_mode = 1 -script = ExtResource("3_yxc3j") - -[node name="road_l" type="StaticBody2D" parent="Line2D2_left2"] -collision_layer = 3 - -[node name="trim" type="Line2D" parent="Line2D2_left2"] -width = 28.0 -texture = ExtResource("4_lutxb") -texture_mode = 1 - [node name="Road" type="Polygon2D" parent="." node_paths=PackedStringArray("line_road_left", "line_road_right")] color = Color(0.314316, 0.314316, 0.314316, 1) script = ExtResource("5_weemp") diff --git a/scenes/map_template.tscn b/scenes/map_template.tscn index 0d91f06..c23b38a 100644 --- a/scenes/map_template.tscn +++ b/scenes/map_template.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=13 format=3 uid="uid://b8e6unjutl5bb"] +[gd_scene load_steps=14 format=3 uid="uid://b8e6unjutl5bb"] [ext_resource type="Texture2D" uid="uid://csknopg1cbqbq" path="res://sprites/background/green_gradient.png" id="1_1q1bt"] +[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_4kvv2"] [ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="2_3n7v7"] [ext_resource type="Script" path="res://scripts/roadborder.gd" id="3_i3pho"] [ext_resource type="Texture2D" uid="uid://gydxil7qf7jc" path="res://sprites/road/road_trim.png" id="4_1s1xa"] @@ -22,6 +23,7 @@ size = Vector2(32, 128) size = Vector2(32, 128) [node name="Map" type="Node"] +script = ExtResource("1_4kvv2") [node name="CanvasLayer" type="CanvasLayer" parent="."] layer = -1 diff --git a/scenes/menu.tscn b/scenes/menu.tscn index e4f0d32..194f6f3 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -81,9 +81,9 @@ texture = ExtResource("10_equk1") offset = Vector2(0.92, 14.62) [node name="countdown" type="Label" parent="MenuDisplay"] -offset_left = 114.0 +offset_left = 175.0 offset_top = 71.0 -offset_right = 171.0 +offset_right = 232.0 offset_bottom = 208.0 theme_override_font_sizes/font_size = 100 text = "5" @@ -190,18 +190,18 @@ scale_amount_curve = SubResource("Curve_kioen") [node name="btn_fullscreen" type="CheckButton" parent="MenuDisplay"] offset_left = 845.0 -offset_top = 540.0 +offset_top = 539.0 offset_right = 972.0 -offset_bottom = 571.0 +offset_bottom = 570.0 scale = Vector2(2, 2) theme_override_constants/outline_size = 10 text = "Fullscreen" [node name="btn_save_whitelist" type="Button" parent="MenuDisplay"] -offset_left = 862.0 -offset_top = 602.0 -offset_right = 1011.0 -offset_bottom = 633.0 +offset_left = 936.0 +offset_top = 605.0 +offset_right = 1085.0 +offset_bottom = 636.0 text = "Save Key Whitelist" [node name="map_container" type="HFlowContainer" parent="MenuDisplay"] @@ -279,6 +279,14 @@ libraries = { } autoplay = "menu_idle" +[node name="MapChangeInfo" type="Label" parent="MenuDisplay"] +offset_left = 168.0 +offset_top = 601.0 +offset_right = 329.0 +offset_bottom = 635.0 +theme_override_font_sizes/font_size = 24 +text = "Mapchange in " + [node name="Timer" type="Timer" parent="."] wait_time = 5.0 diff --git a/scripts/game.gd b/scripts/game.gd index b7f8eb7..5f03a89 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -35,11 +35,17 @@ var time_close_keypressed=1 #seconds to wait after key pressed at endscreen var game_ended=false +var map_rounds:int=1 + + # Called when the node enters the scene tree for the first time. func _ready() -> void: Gamestate.resetTimeElapsed() + map_rounds=Gamestate.getRounds() #load round number from menu + + #countdown.start() game_hud_animations.play("game_start") @@ -53,6 +59,9 @@ func _ready() -> void: for mapc in mapsceneinstance.get_children(): if mapc.name.begins_with("area_cp"): checkpoints.append(mapc.name) + + if (mapsceneinstance.override_rounds_number>0): #if set to 0, do not override + map_rounds=mapsceneinstance.override_rounds_number print(str(checkpoints.size())+" Checkpoints found") @@ -72,7 +81,7 @@ func _ready() -> void: #newcarinstance.setPosition(Vector2(0,ceil(i/2.0)*(fmod(i,2)-0.5)*2.0*caroffset)) #all in a row, alternating up/down newcarinstance.setPosition(Vector2(caroffset_rear*-1*i_position,(fmod(i_position,2)-0.5)*2.0*caroffset_side)) - newcarinstance.setCheckpoints(checkpoints,Gamestate.getRounds()) + newcarinstance.setCheckpoints(checkpoints,map_rounds) newcarinstance.getCharacterBody().car_finished.connect(_on_car_finished) newcarinstance.getCharacterBody().car_on_checkpoint.connect(_on_car_on_checkpoint) @@ -88,7 +97,7 @@ func _ready() -> void: print("i_position="+str(i_position)+" carpos is ="+str(newcarinstance.getPosition())+" instancepos="+str(newcarinstance.position)+" colori="+str(player.colori)+" color="+str(player.color)) i+=1 - highscorecheckpointtimes=HighscoreHandler.loadHighcoreCheckpoints(Gamestate.getSelectedMapName(),"normal",str(Gamestate.getRounds())) + highscorecheckpointtimes=HighscoreHandler.loadHighcoreCheckpoints(Gamestate.getSelectedMapName(),"normal",str(map_rounds)) func custom_array_sort_rank(a, b): @@ -276,7 +285,7 @@ func finishGame(): if Gamestate.getPlayers().size()==1: #was played in singleplayer - var timediff=HighscoreHandler.updateHighscore(Gamestate.getSelectedMapName(),"normal",str(Gamestate.getRounds()),getfinalTimeByPlayer(Gamestate.getPlayers()[0]),getcheckpointtimesByPlayer(Gamestate.getPlayers()[0])) + var timediff=HighscoreHandler.updateHighscore(Gamestate.getSelectedMapName(),"normal",str(map_rounds),getfinalTimeByPlayer(Gamestate.getPlayers()[0]),getcheckpointtimesByPlayer(Gamestate.getPlayers()[0])) print("Timediff="+str(timediff)) timediff=round(timediff*1000)/1000 highscore_label.visible=true diff --git a/scripts/gamestate.gd b/scripts/gamestate.gd index 42f56b0..d1bccca 100644 --- a/scripts/gamestate.gd +++ b/scripts/gamestate.gd @@ -16,6 +16,9 @@ var map_scene_name_postfix=".tscn" var rounds=3 +var automatic_map_change_in_start=5 +var automatic_map_change_in=automatic_map_change_in_start #change map when this reaches 0 + var colorwheelstep:float=0.3 func getRounds(): diff --git a/scripts/map_selection.gd b/scripts/map_selection.gd index 82ecdaa..869f69c 100644 --- a/scripts/map_selection.gd +++ b/scripts/map_selection.gd @@ -10,13 +10,31 @@ func _ready() -> void: for btn in get_children(): btn.pressed.connect(_on_btn_map.bind(btn)) + + + if len(Gamestate.getSelectedMap())<=0: #no map selected (ie on startup) get_children()[0].emit_signal("pressed") #preselect first map in list else: - for c in get_children(): - if c.name==button_prefix+Gamestate.getSelectedMap(): - c.emit_signal("pressed") - break + Gamestate.automatic_map_change_in-=1 + if Gamestate.automatic_map_change_in<=0: #do automatic mapchange + Gamestate.automatic_map_change_in=3 #reset + var next_map_pick=null + while next_map_pick==null: + next_map_pick=get_children().pick_random() + print("Selected random map="+str(next_map_pick.get_name())) + if next_map_pick.name==button_prefix+Gamestate.getSelectedMap(): #picked the last map + next_map_pick=null #force selecting another + var saved_automatic_map_change_in=Gamestate.automatic_map_change_in #save number, to restore after simulated map button press + next_map_pick.emit_signal("pressed") + Gamestate.automatic_map_change_in=saved_automatic_map_change_in + else: #no automatic mapchange mapchange + for c in get_children(): + if c.name==button_prefix+Gamestate.getSelectedMap(): + var saved_automatic_map_change_in=Gamestate.automatic_map_change_in #save number, to restore after simulated map button press + c.emit_signal("pressed") #select last map + Gamestate.automatic_map_change_in=saved_automatic_map_change_in + break @@ -29,3 +47,4 @@ func _on_btn_map(btn): var mapname=btn_name.erase(0,len(button_prefix)) print("Selected Map="+str(mapname)) Gamestate.setSelectedMap(mapname) + Gamestate.automatic_map_change_in=Gamestate.automatic_map_change_in_start #rest number if button pressed manually diff --git a/scripts/map_settings.gd b/scripts/map_settings.gd new file mode 100644 index 0000000..66c2065 --- /dev/null +++ b/scripts/map_settings.gd @@ -0,0 +1,7 @@ +extends Node + + +@export_range(0, 10, 1) var override_rounds_number: int #if set to 0, do not override + +func _ready() -> void: + pass diff --git a/scripts/menudisplay.gd b/scripts/menudisplay.gd index b8668c5..197f3bc 100644 --- a/scripts/menudisplay.gd +++ b/scripts/menudisplay.gd @@ -6,7 +6,7 @@ const MAX_OUTLINESIZE=60 # Called when the node enters the scene tree for the first time. func _ready() -> void: - pass # Replace with function body. + $MapChangeInfo.text="Mapchange in "+str(Gamestate.automatic_map_change_in) # Called every frame. 'delta' is the elapsed time since the previous frame.