added sounds to ui and game, prepared interaction with character

This commit is contained in:
Luca 2024-10-12 14:30:39 +02:00
parent b5ace17da9
commit 21d7cf417a
42 changed files with 450 additions and 155 deletions

View file

@ -2,6 +2,14 @@ extends Control
@onready var battle_moves_menu: VBoxContainer = %BattleMovesMenu
@onready var party_fighter_level: Label = %PartyFighterLevel
@onready var party_fighter_name: Label = %PartyFighterName
@onready var party_fighter_healthbar: ProgressBar = %PartyFighterHealthbar
@onready var enemy_monster_level: Label = %EnemyMonsterLevel
@onready var enemy_monster_name: Label = %EnemyMonsterName
@onready var enemy_monster_healthbar: ProgressBar = %EnemyMonsterHealthbar
var move_button: PackedScene = preload("res://ui/battle_ui/battle_move_button.tscn")
# Called when the node enters the scene tree for the first time.
@ -15,15 +23,15 @@ func update() -> void:
var player: Node3D = Utils.get_player()
var player_fighter: MonsterData = SaveManager.current_save.party[0] as MonsterData
%PartyFighterLevel.text = "Lv. %s" % str(player_fighter.level)
%PartyFighterName.text = player_fighter.nickname if not player_fighter.nickname.is_empty() else player_fighter.name
%PartyFighterHealthbar.max_value = player_fighter.health
%PartyFighterHealthbar.value = player_fighter.current_health
party_fighter_level.text = "Lv. %s" % str(player_fighter.level)
party_fighter_name.text = player_fighter.nickname if not player_fighter.nickname.is_empty() else player_fighter.name
party_fighter_healthbar.max_value = player_fighter.health
party_fighter_healthbar.value = player_fighter.current_health
%EnemyMonsterLevel.text = "Lv. %s" % player.enemy.data.level
%EnemyMonsterName.text = player.enemy.data.name
%EnemyMonsterHealthbar.max_value = player.enemy.data.health
%EnemyMonsterHealthbar.value = player.enemy.data.current_health
enemy_monster_level.text = "Lv. %s" % player.enemy.data.level
enemy_monster_name.text = player.enemy.data.name
enemy_monster_healthbar.max_value = player.enemy.data.health
enemy_monster_healthbar.value = player.enemy.data.current_health
func _on_battle_button_pressed() -> void:
print("attacking enemy")

View file

@ -1,12 +1,10 @@
[gd_scene load_steps=21 format=3 uid="uid://dyroahq85mhws"]
[gd_scene load_steps=13 format=3 uid="uid://dyroahq85mhws"]
[ext_resource type="Script" path="res://ui/battle_ui/battle_ui.gd" id="1_jyqir"]
[ext_resource type="Texture2D" uid="uid://ve2k0qrfpwxw" path="res://assets/textures/Generic/Vector/generic_button_circle_fill.svg" id="2_keyyt"]
[ext_resource type="Texture2D" uid="uid://4t8cotroofge" path="res://assets/textures/Game Icons/Vector/2x/upRight.png" id="3_fa6tk"]
[ext_resource type="StyleBox" uid="uid://ddtjhp2lob6to" path="res://ui/styles/battle_ui_normal_button.tres" id="4_r2q1k"]
[ext_resource type="Texture2D" uid="uid://cxry7h4q17lir" path="res://assets/textures/Game Icons/Vector/2x/star.png" id="4_saqy8"]
[ext_resource type="Texture2D" uid="uid://c1dlsfah0ioi5" path="res://assets/textures/Game Icons/Vector/2x/massiveMultiplayer.png" id="5_pnobx"]
[ext_resource type="StyleBox" uid="uid://cv8ispcxuwjn5" path="res://ui/styles/battle_ui_pressed_button.tres" id="5_w48y1"]
[ext_resource type="Texture2D" uid="uid://dbycrn4i3wkhu" path="res://assets/textures/Game Icons/Vector/2x/menuList.png" id="6_ikm1n"]
[ext_resource type="Texture2D" uid="uid://cs84avwwjbn5q" path="res://assets/textures/Game Icons/Vector/2x/exitRight.png" id="7_tihhr"]
@ -56,28 +54,6 @@ expand_margin_top = 1.0
expand_margin_right = 1.0
expand_margin_bottom = 1.0
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jwbwi"]
bg_color = Color(0, 0, 0, 1)
border_width_left = 3
border_width_top = 3
border_width_right = 3
border_width_bottom = 3
border_color = Color(1, 1, 1, 1)
corner_radius_top_left = 6
corner_radius_top_right = 6
corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
[sub_resource type="LabelSettings" id="LabelSettings_5e62u"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_eqgks"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_4ki2k"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_cabkl"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_g6kqv"]
[node name="BattleUI" type="Control"]
layout_mode = 3
anchors_preset = 15
@ -219,7 +195,6 @@ size_flags_vertical = 3
[node name="PanelContainer" type="PanelContainer" parent="BottomMarginContainer/VBoxContainer/MessageContainer"]
custom_minimum_size = Vector2(0, 100)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_jwbwi")
[node name="MarginContainer" type="MarginContainer" parent="BottomMarginContainer/VBoxContainer/MessageContainer/PanelContainer"]
layout_mode = 2
@ -232,8 +207,8 @@ theme_override_constants/margin_bottom = 8
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 1
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "A wild monster appeared!"
label_settings = SubResource("LabelSettings_5e62u")
[node name="HBoxContainer" type="HBoxContainer" parent="BottomMarginContainer/VBoxContainer"]
layout_mode = 2
@ -349,18 +324,6 @@ unique_name_in_owner = true
layout_mode = 2
theme_override_constants/h_separation = 18
theme_override_constants/icon_max_width = 20
theme_override_font_sizes/font_size = 26
theme_override_styles/focus = SubResource("StyleBoxEmpty_eqgks")
theme_override_styles/disabled_mirrored = ExtResource("4_r2q1k")
theme_override_styles/disabled = ExtResource("4_r2q1k")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_r2q1k")
theme_override_styles/hover_pressed = ExtResource("4_r2q1k")
theme_override_styles/hover_mirrored = ExtResource("4_r2q1k")
theme_override_styles/hover = ExtResource("4_r2q1k")
theme_override_styles/pressed_mirrored = ExtResource("5_w48y1")
theme_override_styles/pressed = ExtResource("5_w48y1")
theme_override_styles/normal_mirrored = ExtResource("4_r2q1k")
theme_override_styles/normal = ExtResource("4_r2q1k")
text = "Attack"
icon = ExtResource("4_saqy8")
alignment = 0
@ -370,18 +333,6 @@ unique_name_in_owner = true
layout_mode = 2
theme_override_constants/h_separation = 18
theme_override_constants/icon_max_width = 20
theme_override_font_sizes/font_size = 26
theme_override_styles/focus = SubResource("StyleBoxEmpty_4ki2k")
theme_override_styles/disabled_mirrored = ExtResource("4_r2q1k")
theme_override_styles/disabled = ExtResource("4_r2q1k")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_r2q1k")
theme_override_styles/hover_pressed = ExtResource("4_r2q1k")
theme_override_styles/hover_mirrored = ExtResource("4_r2q1k")
theme_override_styles/hover = ExtResource("4_r2q1k")
theme_override_styles/pressed_mirrored = ExtResource("5_w48y1")
theme_override_styles/pressed = ExtResource("5_w48y1")
theme_override_styles/normal_mirrored = ExtResource("4_r2q1k")
theme_override_styles/normal = ExtResource("4_r2q1k")
text = "Party"
icon = ExtResource("5_pnobx")
alignment = 0
@ -391,18 +342,6 @@ unique_name_in_owner = true
layout_mode = 2
theme_override_constants/h_separation = 18
theme_override_constants/icon_max_width = 20
theme_override_font_sizes/font_size = 26
theme_override_styles/focus = SubResource("StyleBoxEmpty_cabkl")
theme_override_styles/disabled_mirrored = ExtResource("4_r2q1k")
theme_override_styles/disabled = ExtResource("4_r2q1k")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_r2q1k")
theme_override_styles/hover_pressed = ExtResource("4_r2q1k")
theme_override_styles/hover_mirrored = ExtResource("4_r2q1k")
theme_override_styles/hover = ExtResource("4_r2q1k")
theme_override_styles/pressed_mirrored = ExtResource("5_w48y1")
theme_override_styles/pressed = ExtResource("5_w48y1")
theme_override_styles/normal_mirrored = ExtResource("4_r2q1k")
theme_override_styles/normal = ExtResource("4_r2q1k")
text = "Items"
icon = ExtResource("6_ikm1n")
alignment = 0
@ -412,18 +351,6 @@ unique_name_in_owner = true
layout_mode = 2
theme_override_constants/h_separation = 18
theme_override_constants/icon_max_width = 20
theme_override_font_sizes/font_size = 26
theme_override_styles/focus = SubResource("StyleBoxEmpty_g6kqv")
theme_override_styles/disabled_mirrored = ExtResource("4_r2q1k")
theme_override_styles/disabled = ExtResource("4_r2q1k")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_r2q1k")
theme_override_styles/hover_pressed = ExtResource("4_r2q1k")
theme_override_styles/hover_mirrored = ExtResource("4_r2q1k")
theme_override_styles/hover = ExtResource("4_r2q1k")
theme_override_styles/pressed_mirrored = ExtResource("5_w48y1")
theme_override_styles/pressed = ExtResource("5_w48y1")
theme_override_styles/normal_mirrored = ExtResource("4_r2q1k")
theme_override_styles/normal = ExtResource("4_r2q1k")
text = "Run"
icon = ExtResource("7_tihhr")
alignment = 0

View file

@ -27,9 +27,11 @@ func _process(delta: float) -> void:
save_timer += delta
func _on_menu_button_pressed() -> void:
SoundManager.play_sound_effect("ui_click", "UI")
menu_button_clicked.emit()
func _on_settings_button_pressed() -> void:
SoundManager.play_sound_effect("ui_click", "UI")
settings_button_clicked.emit()
# the save function should work as follows:
@ -38,10 +40,12 @@ func _on_settings_button_pressed() -> void:
# during holding down, the percentage increases until 100%
# a finishing animation plays, the game is saved and the countdown disappears again
func _on_save_button_button_down() -> void:
SoundManager.play_sound_effect("ui_click", "UI")
save_button_held_down = true
save_button_clicked.emit()
func _on_save_button_button_up() -> void:
SoundManager.play_sound_effect("ui_click", "UI")
save_button_held_down = false
save_button_released.emit()
save_timer = 0.0

View file

@ -1,5 +1,7 @@
extends Panel
signal on_interact
@onready var talk_a_texture: CompressedTexture2D = preload("res://assets/textures/Xbox Series/Vector/xbox_button_a.svg")
@onready var drag_texture: CompressedTexture2D = preload("res://assets/textures/Generic/Vector/generic_button_circle.svg")
@onready var thumbstick: TextureRect = %Thumbstick
@ -30,7 +32,8 @@ func _on_gui_input(event: InputEvent) -> void:
thumbstick.texture = talk_a_texture
if event is InputEventScreenTouch and pressed == true:
Input.action_press("ui_select")
SoundManager.play_sound_effect("ui_click", "UI")
on_interact.emit()
pressed = false
if event is InputEventScreenTouch and event.is_pressed():
@ -46,8 +49,10 @@ func _on_gui_input(event: InputEvent) -> void:
# visual thumbstick movement
var thumbstick_position: Vector2 = touch_position - thumbstick.size / 2.0
#var clamped_thumbstick_position = thumbstick_position.clampf(-40.0, 40.0)
thumbstick.position = thumbstick_position
var thumbstick_center: Vector2 = middle - thumbstick.size / 2.0
var clamped_thumbstick_position: Vector2 = thumbstick_position.clamp(thumbstick_center - Vector2(50.0, 50.0), thumbstick_center + Vector2(50.0, 50.0))
thumbstick.position = clamped_thumbstick_position
# actual value
var _delta: Vector2 = middle - touch_position

View file

@ -1,12 +1,9 @@
[gd_scene load_steps=6 format=3 uid="uid://bbvbnrcjatkrb"]
[gd_scene load_steps=4 format=3 uid="uid://bbvbnrcjatkrb"]
[ext_resource type="Script" path="res://ui/ingame_menu/ingame_menu.gd" id="1_beinb"]
[ext_resource type="Texture2D" uid="uid://bhh31i3wgww43" path="res://assets/textures/Game Icons/Vector/2x/singleplayer.png" id="2_c2ia0"]
[ext_resource type="Texture2D" uid="uid://c737p2osplq2o" path="res://assets/textures/Xbox Series/Vector/xbox_button_x_outline.svg" id="3_kgfth"]
[ext_resource type="Texture2D" uid="uid://cxry7h4q17lir" path="res://assets/textures/Game Icons/Vector/2x/star.png" id="3_oo4iu"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_flvbu"]
[node name="IngameMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
@ -109,20 +106,19 @@ theme_override_constants/margin_right = 20
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/MonsterListEntryContainer"]
layout_mode = 2
theme_override_constants/separation = 20
[node name="CloseButtonContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 32
theme_override_constants/margin_bottom = 32
[node name="CloseButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/CloseButtonContainer"]
unique_name_in_owner = true
self_modulate = Color(0, 0, 0, 1)
custom_minimum_size = Vector2(120, 120)
layout_mode = 2
size_flags_horizontal = 4
theme_override_styles/focus = SubResource("StyleBoxEmpty_flvbu")
icon = ExtResource("3_kgfth")
flat = true
theme_type_variation = &"RedButton"
text = "Close"
icon_alignment = 1
expand_icon = true

View file

@ -1,25 +1,23 @@
[gd_scene load_steps=9 format=3 uid="uid://brp2sljqnkuhe"]
[gd_scene load_steps=8 format=3 uid="uid://brp2sljqnkuhe"]
[ext_resource type="Script" path="res://ui/ingame_menu/party_list_entry.gd" id="1_gdhy7"]
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="2_rogma"]
[ext_resource type="Texture2D" uid="uid://2vxx2waofxpw" path="res://assets/textures/Xbox Series/Vector/xbox_button_menu_outline.svg" id="3_etjt6"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s3mod"]
content_margin_top = 24.0
content_margin_top = 12.0
bg_color = Color(0.4, 0.5, 0.455, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nb1sm"]
bg_color = Color(0, 0.843137, 0.466667, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fkb5g"]
content_margin_top = 12.0
content_margin_top = 4.0
bg_color = Color(0.4, 0.466667, 0.5, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b4pov"]
bg_color = Color(0, 0.56, 0.84, 1)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_x2rfb"]
[node name="PartyListEntry" type="PanelContainer"]
anchors_preset = 10
anchor_right = 1.0
@ -32,10 +30,12 @@ layout_mode = 2
[node name="Thumbnail" type="TextureRect" parent="HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(70, 70)
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
size_flags_vertical = 4
texture = ExtResource("2_rogma")
expand_mode = 3
expand_mode = 1
stretch_mode = 5
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
layout_mode = 2
@ -100,11 +100,11 @@ show_percentage = false
[node name="SwapPositionButton" type="Button" parent="HBoxContainer"]
unique_name_in_owner = true
self_modulate = Color(0, 0, 0, 1)
custom_minimum_size = Vector2(100, 100)
custom_minimum_size = Vector2(30, 30)
layout_mode = 2
size_flags_horizontal = 8
theme_override_styles/focus = SubResource("StyleBoxEmpty_x2rfb")
size_flags_vertical = 4
theme_override_constants/icon_max_width = 32
icon = ExtResource("3_etjt6")
flat = true
icon_alignment = 1
expand_icon = true

View file

@ -8,6 +8,8 @@ signal on_game_continued
# On ready, check which buttons to show
func _ready() -> void:
SoundManager.play_background_music("Unexplored Fields")
if SaveManager.save_exists():
continue_game_button.visible = true
new_game_button.visible = false