diff --git a/scenes/game.tscn b/scenes/game.tscn index 4415611..f695968 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -40,7 +40,7 @@ shader = ExtResource("12_kvuet") shader_parameter/shake = 0.002000000095 shader_parameter/noiseQuality = 250.0 shader_parameter/noiseIntensity = 0.0010000000475 -shader_parameter/offsetIntensity = 0.0045 +shader_parameter/offsetIntensity = 0.0 shader_parameter/colorOffsetIntensity = 0.10000000149012 shader_parameter/pixelSize = 1024.0 shader_parameter/grainIntensity = 0.04 diff --git a/scenes/ground.tscn b/scenes/ground.tscn index 192ded5..ace20e4 100644 --- a/scenes/ground.tscn +++ b/scenes/ground.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=45 format=4 uid="uid://by43ihcec8e8q"] +[gd_scene load_steps=46 format=4 uid="uid://by43ihcec8e8q"] [ext_resource type="Script" uid="uid://b2sw6ymaf4t0s" path="res://scripts/game_ground.gd" id="1_6ra5r"] [ext_resource type="AudioStream" uid="uid://dgv01wy8r7ej2" path="res://sounds/uglyburger.mp3" id="2_5vwr8"] [ext_resource type="Script" uid="uid://dowu512otgyyf" path="res://scripts/player_ground.gd" id="3_8gbjj"] +[ext_resource type="AudioStream" uid="uid://cdl70q0x28717" path="res://sounds/dialogue.mp3" id="3_rncil"] [ext_resource type="Texture2D" uid="uid://c0cyhybh30ogt" path="res://textures/player-ground-sheet.png" id="4_2c1ag"] [ext_resource type="Texture2D" uid="uid://xs6tjca62pw1" path="res://textures/wall_side_tile.png" id="4_8gbjj"] [ext_resource type="Texture2D" uid="uid://ddfp7u4a7llnr" path="res://textures/wall_side_tile_left.png" id="5_176r3"] @@ -154,20 +155,20 @@ animations = [{ }, { "frames": [{ "duration": 1.0, -"texture": SubResource("AtlasTexture_jo68p") -}, { -"duration": 1.0, "texture": SubResource("AtlasTexture_6gpfv") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_yqhs4") +"texture": SubResource("AtlasTexture_jo68p") }, { "duration": 1.0, "texture": SubResource("AtlasTexture_fd1o3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yqhs4") }], "loop": true, "name": &"walk", -"speed": 6.0 +"speed": 7.0 }] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_176r3"] @@ -200,7 +201,7 @@ shader = ExtResource("9_257nh") shader_parameter/shake = 0.002000000095 shader_parameter/noiseQuality = 250.0 shader_parameter/noiseIntensity = 0.0010000000475 -shader_parameter/offsetIntensity = 0.0045 +shader_parameter/offsetIntensity = 0.0 shader_parameter/colorOffsetIntensity = 0.10000000149012 shader_parameter/pixelSize = 1024.0 shader_parameter/grainIntensity = 0.04 @@ -220,6 +221,9 @@ autoplay = true bus = &"Music" parameters/looping = true +[node name="Dialogue" type="AudioStreamPlayer" parent="."] +stream = ExtResource("3_rncil") + [node name="Map" type="TileMapLayer" parent="."] modulate = Color(0.53333336, 0.53333336, 0.53333336, 1) material = SubResource("CanvasItemMaterial_gysiw") @@ -383,6 +387,7 @@ text = "TO INTERACT" label_settings = SubResource("LabelSettings_c2suo") [node name="DialogueOptions" type="VBoxContainer" parent="UI/Control"] +visible = false custom_minimum_size = Vector2(128, 0) layout_mode = 1 anchors_preset = -1 diff --git a/scripts/dialogue_select_button.gd b/scripts/dialogue_select_button.gd index c796868..e74b65b 100644 --- a/scripts/dialogue_select_button.gd +++ b/scripts/dialogue_select_button.gd @@ -2,9 +2,8 @@ extends Button var game = null - func _on_pressed() -> void: - get_tree().quit() + game.choice_made.emit(get_name()) func _input(event: InputEvent) -> void: if has_focus() and (event.is_action_pressed("interact") or event.is_action_pressed("dialogue_continue")): diff --git a/scripts/galactamart_worker.gd b/scripts/galactamart_worker.gd index c2ac373..eca3547 100644 --- a/scripts/galactamart_worker.gd +++ b/scripts/galactamart_worker.gd @@ -11,10 +11,62 @@ func _interact(player: Node2D) -> void: await game.dialogue("How may I help you?") - await game.make_choice({ + var option = await game.make_choice({ "refuel": "Refuel ship", "buy": "Buy items", "exit": "Exit" }) + if option == "refuel": + await game.dialogue("How much?") + + var price_per_percentage = 0.433 + var price_full = floori((100 - global.stats.fuel) * price_per_percentage) + var price_half = floori((50 - global.stats.fuel) * price_per_percentage) + var price_quarter = floori((25 - global.stats.fuel) * price_per_percentage) + + var options = { + "full": "Refuel Tank (" + str(price_full)+ "¤)" + } + + if price_half > 0: + options.half = "Refuel to 50% (" + str(price_half) + "¤)" + if price_quarter > 0: + options.quarter = "Refuel to 25% (" + str(price_quarter) + "¤)" + + options.exit = "Nevermind" + + var fuel_option = await game.make_choice(options) + + if fuel_option == "full": + if price_full <= global.stats.marks: + global.stats.fuel = 100 + global.stats.marks -= price_full + + await game.dialogue("Okay, your tank should be filled to 100%.") + else: + await game.dialogue("Sorry, but you don't have enough marks for that.") + elif fuel_option == "half": + if price_half <= global.stats.marks: + global.stats.fuel = 50 + global.stats.marks -= price_half + + await game.dialogue("Okay, your tank should be filled to 50%.") + else: + await game.dialogue("Sorry, but you don't have enough marks for that.") + elif fuel_option == "quarter": + if price_quarter <= global.stats.marks: + global.stats.fuel = 25 + global.stats.marks -= price_quarter + + await game.dialogue("Okay, your tank should be filled to 25%.") + else: + await game.dialogue("Sorry, but you don't have enough marks for that.") + + player.get_node("Camera").enabled = true + $Camera.enabled = false + $InteractArea.monitoring = true + + player.busy = false + return diff --git a/scripts/game_ground.gd b/scripts/game_ground.gd index 2515e18..44ad222 100644 --- a/scripts/game_ground.gd +++ b/scripts/game_ground.gd @@ -29,7 +29,9 @@ func dialogue(text: String) -> void: $UI/Control/Dialogue/Label.text = displayed_text - await get_tree().create_timer(0.05).timeout + $Dialogue.play() + + await get_tree().create_timer(0.03).timeout i += 1 @@ -41,11 +43,9 @@ func dialogue(text: String) -> void: return -func make_choice(options: Dictionary = {}) -> void: +func make_choice(options: Dictionary = {}) -> String: $UI/Control/DialogueOptions.visible = true - $UI/Control/DialogueOptions/Button.grab_focus() - var dialogue_select_button_scene = preload("res://scenes/dialogue_select_button.tscn") for n in $UI/Control/DialogueOptions.get_children(): if n.is_class("Button"): n.free() @@ -58,6 +58,7 @@ func make_choice(options: Dictionary = {}) -> void: dialogue_select_button.name = n dialogue_select_button.text = options[n] + dialogue_select_button.game = self $UI/Control/DialogueOptions.add_child(dialogue_select_button) @@ -70,9 +71,12 @@ func make_choice(options: Dictionary = {}) -> void: first_button.grab_focus() - await dialogue_continue + var response = await choice_made + + $UI/Control/DialogueOptions.visible = false + + return response - return func _input(event: InputEvent) -> void: if event.is_action_pressed("dialogue_continue"): diff --git a/scripts/global.gd b/scripts/global.gd index 5142c53..ff9a39b 100644 --- a/scripts/global.gd +++ b/scripts/global.gd @@ -22,3 +22,11 @@ var orbit_zones = [ }, ] + +var stats = { + "fuel": 12, + "fuel_tank_size": 1, + "speed": 512, + "boost_tank_size": 1, + "marks": 200, +} diff --git a/sounds/dialogue.mp3 b/sounds/dialogue.mp3 new file mode 100644 index 0000000..ba3cc51 Binary files /dev/null and b/sounds/dialogue.mp3 differ diff --git a/sounds/dialogue.mp3.import b/sounds/dialogue.mp3.import new file mode 100644 index 0000000..59f3e7c --- /dev/null +++ b/sounds/dialogue.mp3.import @@ -0,0 +1,19 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +uid="uid://cdl70q0x28717" +path="res://.godot/imported/dialogue.mp3-22f16b154a5459377efc48f8b6299007.mp3str" + +[deps] + +source_file="res://sounds/dialogue.mp3" +dest_files=["res://.godot/imported/dialogue.mp3-22f16b154a5459377efc48f8b6299007.mp3str"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4