spawn settings
This commit is contained in:
+51
-18
@@ -49,6 +49,12 @@ func _build_ui() -> void:
|
||||
_build_settings_panel()
|
||||
_build_difficulty_panel()
|
||||
|
||||
func _big_btn(text: String, width: float, cb: Callable) -> Button:
|
||||
var b := _btn(text, cb)
|
||||
b.custom_minimum_size = Vector2(width, 72)
|
||||
b.add_theme_font_size_override("font_size", 18)
|
||||
return b
|
||||
|
||||
func _btn(text: String, cb: Callable) -> Button:
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
@@ -153,10 +159,10 @@ func _build_difficulty_panel() -> void:
|
||||
difficulty_panel.anchor_right = 0.5
|
||||
difficulty_panel.anchor_top = 0.5
|
||||
difficulty_panel.anchor_bottom = 0.5
|
||||
difficulty_panel.offset_left = -230
|
||||
difficulty_panel.offset_right = 230
|
||||
difficulty_panel.offset_top = -160
|
||||
difficulty_panel.offset_bottom = 160
|
||||
difficulty_panel.offset_left = -310
|
||||
difficulty_panel.offset_right = 310
|
||||
difficulty_panel.offset_top = -240
|
||||
difficulty_panel.offset_bottom = 240
|
||||
add_child(difficulty_panel)
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
@@ -178,25 +184,52 @@ func _build_difficulty_panel() -> void:
|
||||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
vbox.add_child(title)
|
||||
|
||||
var immortal_btn := Button.new()
|
||||
immortal_btn.text = "Бессмертный\nНет урона · тир пинков от мелких врагов"
|
||||
immortal_btn.custom_minimum_size = Vector2(380, 72)
|
||||
immortal_btn.add_theme_font_size_override("font_size", 18)
|
||||
immortal_btn.connect("pressed", func() -> void:
|
||||
vbox.add_child(_big_btn("Бессмертный\nНет урона · тир пинков от мелких врагов", 540, func() -> void:
|
||||
GameSettings.difficulty = "immortal"
|
||||
get_tree().change_scene_to_file("res://scenes/Main.tscn")
|
||||
)
|
||||
vbox.add_child(immortal_btn)
|
||||
))
|
||||
|
||||
var survival_btn := Button.new()
|
||||
survival_btn.text = "Выживание\nПолучаешь урон · фиксированная сила пинка"
|
||||
survival_btn.custom_minimum_size = Vector2(380, 72)
|
||||
survival_btn.add_theme_font_size_override("font_size", 18)
|
||||
survival_btn.connect("pressed", func() -> void:
|
||||
vbox.add_child(_big_btn("Выживание\nПолучаешь урон · фиксированная сила пинка", 540, func() -> void:
|
||||
GameSettings.difficulty = "survival"
|
||||
get_tree().change_scene_to_file("res://scenes/Main.tscn")
|
||||
)
|
||||
vbox.add_child(survival_btn)
|
||||
))
|
||||
|
||||
# Spawn speed row
|
||||
var spawn_lbl := Label.new()
|
||||
spawn_lbl.text = "Скорость спавна:"
|
||||
spawn_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
spawn_lbl.add_theme_font_size_override("font_size", 16)
|
||||
spawn_lbl.add_theme_color_override("font_color", Color(0.85, 0.78, 1.0))
|
||||
vbox.add_child(spawn_lbl)
|
||||
|
||||
var hbox := HBoxContainer.new()
|
||||
hbox.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
hbox.add_theme_constant_override("separation", 10)
|
||||
vbox.add_child(hbox)
|
||||
|
||||
var spawn_options := [
|
||||
["Медленно", 15.0, 35.0],
|
||||
["Нормально", 10.0, 20.0],
|
||||
["Быстро", 5.0, 8.0],
|
||||
]
|
||||
var spawn_btns: Array[Button] = []
|
||||
for opt in spawn_options:
|
||||
var sb_btn := _btn(opt[0] as String, Callable())
|
||||
sb_btn.custom_minimum_size = Vector2(110, 40)
|
||||
sb_btn.add_theme_font_size_override("font_size", 15)
|
||||
var enemy_iv: float = opt[1]
|
||||
var item_iv: float = opt[2]
|
||||
sb_btn.connect("pressed", func() -> void:
|
||||
GameSettings.enemy_spawn_interval = enemy_iv
|
||||
GameSettings.item_respawn_delay = item_iv
|
||||
for b in spawn_btns:
|
||||
b.modulate = Color(1, 1, 1)
|
||||
sb_btn.modulate = Color(0.7, 1.0, 0.5)
|
||||
)
|
||||
hbox.add_child(sb_btn)
|
||||
spawn_btns.append(sb_btn)
|
||||
# default: normal
|
||||
spawn_btns[1].modulate = Color(0.7, 1.0, 0.5)
|
||||
|
||||
vbox.add_child(_btn("Назад", func(): difficulty_panel.visible = false))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user