diff --git a/scenes/HeroSelect.tscn b/scenes/hero_select.tscn similarity index 66% rename from scenes/HeroSelect.tscn rename to scenes/hero_select.tscn index d8e103c..c3e0e9b 100644 --- a/scenes/HeroSelect.tscn +++ b/scenes/hero_select.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] -[ext_resource path="res://scripts/hero_select.gd" type="Script" id=1] +[ext_resource path="res://scripts/hero_select_screen.gd" type="Script" id=1] +[ext_resource path="res://scripts/hero_select.gd" type="Script" id=2] [node name="HeroSelect" type="ColorRect" index="0"] @@ -15,6 +16,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 color = Color( 0.097229, 0.104696, 0.105469, 1 ) +script = ExtResource( 1 ) _sections_unfolded = [ "Anchor", "Margin", "Material", "Pause", "Visibility" ] [node name="Hero" type="OptionButton" parent="." index="0"] @@ -43,7 +45,7 @@ flat = false align = 0 selected = -1 items = [ ] -script = ExtResource( 1 ) +script = ExtResource( 2 ) [node name="Confirm" type="Button" parent="." index="1"] @@ -69,4 +71,32 @@ text = "Select Hero" flat = false align = 1 +[node name="HeroDescription" type="RichTextLabel" parent="." index="2"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -198.0 +margin_top = 105.0 +margin_right = 197.0 +margin_bottom = 240.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = true +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +bbcode_enabled = false +bbcode_text = "" +visible_characters = -1 +percent_visible = 1.0 +meta_underlined = true +tab_size = 4 +text = "" +scroll_active = true +scroll_following = false +selection_enabled = false +override_selected_font_color = false + diff --git a/scripts/hero_select.gd b/scripts/hero_select.gd index afd8fea..7624ee5 100644 --- a/scripts/hero_select.gd +++ b/scripts/hero_select.gd @@ -8,6 +8,15 @@ const hero_names = [ "PAZIENZA", ] +const hero_text = [ + "DILIGENCE.\n\nWallride by jumping on walls.\n\nYour speed builds immensely as your Switch Charge increases.", + "WRATH.\n\nPress E and click (or just click) to build a wall.\n\nRight click to destroy one.", + "LUST.\n\nYou attract nearby heroes.\n\nPress E to switch to repelling them.", + "GENEROSITY.\n\nMake contact with a friend to boost their speed.\n\nPress E to separate.", + "PATIENCE.\n\nHold left mouse button on an enemy to slow them down.", +] + func _ready(): for hero_index in range(hero_names.size()): add_item(hero_names[hero_index], hero_index) + diff --git a/scripts/hero_select_screen.gd b/scripts/hero_select_screen.gd new file mode 100644 index 0000000..61ba122 --- /dev/null +++ b/scripts/hero_select_screen.gd @@ -0,0 +1,10 @@ +extends ColorRect + +func _ready(): + get_node("Hero").connect("item_selected", self, "update_description") + update_description(0) + +func update_description(hero): + var description = get_node("Hero").hero_text[hero] + get_node("HeroDescription").set_text(description) + diff --git a/scripts/lobby.gd b/scripts/lobby.gd index 860fbd8..6d12735 100644 --- a/scripts/lobby.gd +++ b/scripts/lobby.gd @@ -36,15 +36,24 @@ func option_sel(button_name, option): func _ready(): + randomize() + + get_node("Server").connect("pressed", self, "_server_init") + get_node("ServerStart").connect("pressed", self, "start_game") + get_node("Client").connect("pressed", self, "_client_init") + get_node("Singleplayer").connect("pressed", self, "_singleplayer_init") + get_node("HeroSelect").connect("item_selected", self, "select_hero") + var o = setup_options() o.parse() - - randomize() if o.get_value("-silent-server"): SERVER_PLAYING = false # TODO: Uncaps :( if o.get_value("-hero"): - option_sel("HeroSelect", o.get_value("-hero")) + var hero = o.get_value("-hero") + option_sel("HeroSelect", hero) + # For some reason, calling option_sel doesn't trigger the actual selection + select_hero(get_node("HeroSelect").get_selected_id()) if o.get_value("-level"): option_sel("ServerStart/LevelSelect", o.get_value("-level")) if o.get_value("-server"): @@ -64,18 +73,9 @@ func _ready(): o.print_help() quit() - # Called every time the node is added to the scene. - # Initialization here - get_node("Server").connect("pressed", self, "_server_init") - get_node("ServerStart").connect("pressed", self, "start_game") - get_node("Client").connect("pressed", self, "_client_init") - get_node("Singleplayer").connect("pressed", self, "_singleplayer_init") - get_tree().connect("network_peer_connected", self, "_player_connected") get_tree().connect("network_peer_disconnected", self, "_player_disconnected") get_tree().connect("connected_to_server", self, "_connected_ok") - - get_node("HeroSelect").connect("item_selected", self, "select_hero") func _client_init(): collect_info() @@ -157,6 +157,8 @@ sync func unregister_player(peer): get_node("/root/Level/Players/%d" % peer).queue_free() func select_hero(hero): + var description = get_node("HeroSelect").hero_text[hero] + get_node("HeroDescription").set_text(description) rpc("set_hero", get_tree().get_network_unique_id(), hero) sync func set_hero(peer, hero): @@ -228,7 +230,3 @@ sync func post_configure_game(): for p in player_info: get_node("/root/Level/Players/%d" % p).begin() -#func _process(delta): -# # Called every frame. Delta is time since last frame. -# # Update game logic here. -# pass