Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions entities/game/memory_game/scenes/MemoryGame.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ memory_game = NodePath("../..")
debug_functions = Array[ExtResource("34_4hsit")]([SubResource("Resource_8rpam")])

[connection signal="announce_deck" from="." to="World/CardBoard" method="set_deck"]
[connection signal="announce_deck" from="." to="UI/PlayersOverlay" method="set_deck"]
[connection signal="game_paused" from="." to="Systems/PlayerInputSystem" method="game_paused"]
[connection signal="game_paused" from="." to="World/Camera2D" method="game_paused"]
[connection signal="load_game" from="." to="World/CardBoard/CardInteractionField" method="set_board_information"]
Expand Down
14 changes: 14 additions & 0 deletions entities/game/player_name_overlay/scenes/PlayerNameOverlay.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
[ext_resource type="Script" uid="uid://cpx0qtreblopk" path="res://entities/game/player_name_overlay/scripts/PlayerScoreInformation.gd" id="8_4u670"]
[ext_resource type="Resource" uid="uid://85njf66kd3s1" path="res://shared/resources/colors/assets/PlayerDefaultColor.tres" id="9_2q0hc"]
[ext_resource type="Shader" uid="uid://u0duqjndk87c" path="res://assets/shaders/ColorReplaceAndShine.gdshader" id="11_2q0hc"]
[ext_resource type="PackedScene" uid="uid://darv1wt1dlt1s" path="res://entities/game/player_overlay_score_board/scenes/PlayerOverlayScoreBoard.tscn" id="11_4vlvt"]

[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_qprtf"]
texture = ExtResource("2_blt2s")
Expand Down Expand Up @@ -83,6 +84,7 @@ inactive_color = ExtResource("9_2q0hc")
active_color = ExtResource("4_e0a06")

[node name="LeftBracket" type="Label" parent="PanelContainer/HBoxContainer/ScoreAndName" unique_id=672300167]
visible = false
layout_mode = 2
size_flags_horizontal = 8
text = "("
Expand All @@ -91,6 +93,7 @@ inactive_color = ExtResource("9_2q0hc")
active_color = ExtResource("4_e0a06")

[node name="Score" type="Label" parent="PanelContainer/HBoxContainer/ScoreAndName" unique_id=52366694]
visible = false
layout_mode = 2
size_flags_horizontal = 4
theme_override_font_sizes/font_size = 25
Expand All @@ -100,13 +103,20 @@ inactive_color = ExtResource("9_2q0hc")
active_color = ExtResource("4_e0a06")

[node name="RightBracket" type="Label" parent="PanelContainer/HBoxContainer/ScoreAndName" unique_id=1282868630]
visible = false
layout_mode = 2
size_flags_horizontal = 0
text = ")"
script = ExtResource("8_4u670")
inactive_color = ExtResource("9_2q0hc")
active_color = ExtResource("4_e0a06")

[node name="PlayerScoreBoard" parent="PanelContainer/HBoxContainer/ScoreAndName" unique_id=574098440 instance=ExtResource("11_4vlvt")]
layout_mode = 2
size_flags_horizontal = 0
offset_transform_enabled = true
offset_transform_position = Vector2(25, 0)

[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/HBoxContainer" unique_id=919225589]
layout_mode = 2
size_flags_horizontal = 8
Expand All @@ -125,11 +135,15 @@ script = ExtResource("7_4mda4")
default_color = ExtResource("9_2q0hc")
highlight_color = ExtResource("4_e0a06")

[connection signal="player_did_score" from="." to="PanelContainer/HBoxContainer/ScoreAndName/PlayerScoreBoard" method="add_score"]
[connection signal="player_is_active" from="." to="PanelContainer" method="is_active"]
[connection signal="player_is_active" from="." to="PanelContainer/HBoxContainer/ScoreAndName" method="is_now_active"]
[connection signal="player_is_active" from="." to="PanelContainer/HBoxContainer/ScoreAndName/PlayerScoreBoard" method="player_is_active"]
[connection signal="player_is_active" from="." to="PanelContainer/HBoxContainer/MarginContainer/TextureRect" method="set_highlight_color"]
[connection signal="player_is_inactive" from="." to="PanelContainer" method="is_inactive"]
[connection signal="player_is_inactive" from="." to="PanelContainer/HBoxContainer/ScoreAndName" method="is_now_inactive"]
[connection signal="player_is_inactive" from="." to="PanelContainer/HBoxContainer/ScoreAndName/PlayerScoreBoard" method="player_is_inactive"]
[connection signal="player_is_inactive" from="." to="PanelContainer/HBoxContainer/MarginContainer/TextureRect" method="set_default_color"]
[connection signal="player_name_changed" from="." to="PanelContainer/HBoxContainer/ScoreAndName/Name" method="set_text"]
[connection signal="player_score_changed" from="." to="PanelContainer/HBoxContainer/ScoreAndName/Score" method="set_new_score"]
[connection signal="texture_changed" from="." to="PanelContainer/HBoxContainer/ScoreAndName/PlayerScoreBoard" method="set_texture"]
10 changes: 9 additions & 1 deletion entities/game/player_name_overlay/scripts/PlayerGameLabel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ signal player_is_active()
signal player_is_inactive()
signal player_score_changed(new_value: int)
signal player_name_changed(new_player_name: String)
signal player_did_score()
signal texture_changed(texture: Texture2D)

@export var player_type_icon_box: TextureRect
@export var human_player_icon: Texture
Expand All @@ -17,11 +19,14 @@ var contained_player: PlayerResource

func _ready() -> void:
var icon: Texture = human_player_icon
if contained_player.is_ai():
if contained_player != null and contained_player.is_ai():
icon = ai_player_icon
player_type_icon_box.texture = icon
round_end()

func set_texture(texture: Texture2D) -> void:
texture_changed.emit(texture)

func set_player(current_player: PlayerResource) -> void:
contained_player = current_player

Expand All @@ -32,9 +37,12 @@ func player_turn(player_id: int) -> void:
func player_scored(player_id: int, score: int) -> void:
if contained_player.id == player_id:
player_score_changed.emit(score)
player_did_score.emit()
set_player_name()

func set_player_name() -> void:
if contained_player == null:
return
player_name_changed.emit(contained_player.get_display_name())
if contained_player.id == active_id:
player_is_active.emit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ func is_now_active() -> void:

func is_now_inactive() -> void:
var tween_animation: Tween = create_tween()
tween_animation.tween_property(self, "theme_override_colors/font_color", inactive_color.color, animation_duration)
tween_animation.tween_property(self, "theme_override_colors/font_color", inactive_color.color, animation_duration)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[gd_scene format=3 uid="uid://darv1wt1dlt1s"]

[ext_resource type="Script" uid="uid://djok43i733l62" path="res://entities/game/player_overlay_score_board/scripts/PlayerOverlayScoreBoard.gd" id="1_2cdvp"]
[ext_resource type="Texture2D" uid="uid://b0lfebra6adhv" path="res://assets/sprites/Axuree/back_card_1.png" id="2_t84dm"]
[ext_resource type="Resource" uid="uid://c0eqsic62hvl0" path="res://shared/resources/colors/assets/PlayerHighlightColor.tres" id="3_wurbt"]
[ext_resource type="Resource" uid="uid://85njf66kd3s1" path="res://shared/resources/colors/assets/PlayerDefaultColor.tres" id="4_ptxw8"]

[node name="PlayerScoreBoard" type="Control" unique_id=574098440]
layout_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_2cdvp")
fallback_texture = ExtResource("2_t84dm")
active_color = ExtResource("3_wurbt")
inactive_color = ExtResource("4_ptxw8")
metadata/_custom_type_script = "uid://djok43i733l62"
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
class_name PlayerOverlayScoreBoard extends Control

signal _card_animation_done()

@export_group("Visuals")
@export var fallback_texture: Texture2D
@export var max_size: float = 40
@export var rotation_limit_degree: float = 8
@export var min_separation: float = 5
@export var max_separation: float = 12
@export var max_visualized_cards: int = 5
@export var inactive_visibility: float = 0.7

@export_group("Label")
@export var active_color: ColorResource
@export var inactive_color: ColorResource

@export_group("Animation")
## Animation time for the first card
@export var animation_time: float = 0.5

## Additional animation time for the second card
@export var animation_time_difference: float = 0.0

var _current_spawn_position_x: float = 0
var _current_card_count: int = 0
var _texture: Texture2D = null
var _card_templates: Array[TextureRect] = []
var _is_active: bool = true

var _label: PlayerScoreCounter = null

func _ready() -> void:
_label = PlayerScoreCounter.new()
_label.inactive_color = inactive_color
_label.active_color = active_color
_label.custom_minimum_size = Vector2(max_size, max_size)
_label.custom_maximum_size = Vector2(max_size, max_size)
_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
_label.z_index = 2
add_child(_label)

func player_is_active() -> void:
_label.is_now_active()
_is_active = true
change_visibility(_is_active)

func player_is_inactive() -> void:
_label.is_now_inactive()
_is_active = false
change_visibility(_is_active)

func change_visibility(visible: bool) -> void:
var target: float = inactive_visibility
if visible:
target = 1.0
for card: TextureRect in _card_templates:
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_IN)
tween.set_trans(Tween.TRANS_SINE)
tween.tween_property(card, "modulate", Color(1.0, 1.0, 1.0, target), animation_time)

func _get_texture() -> Texture2D:
if _texture != null:
return _texture
return fallback_texture

func set_texture(new_texture: Texture2D) -> void:
_texture = new_texture

func add_score() -> void:
_create_card_stack()
_configure_label()

func _configure_label() -> void:
_label.set_new_score(_current_card_count)
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.tween_property(_label, "offset_left", _current_spawn_position_x + max_size / 2, animation_time)

func _create_card_stack() -> void:
_current_card_count += 1
if _current_card_count >= max_visualized_cards:
return
print("spawn card")
var cards: Array[TextureRect] = [
_create_new_card(),
_create_new_card()
]
var index: int = 0
for card: TextureRect in cards:
_card_templates.append(card)
add_child(card)
card.offset_top = -150
var tween: Tween = create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_BACK)

var time: float = animation_time
if index > 0:
time += animation_time_difference
tween.tween_property(card, "offset_top", 0, time)
tween.finished.connect(func() -> void: _card_animation_done.emit())
index += 1



_current_spawn_position_x += randf_range(min_separation, max_separation)
pass

func _create_new_card() -> TextureRect:
var card_template: TextureRect = TextureRect.new()
card_template.custom_maximum_size = Vector2(max_size, max_size)
card_template.offset_transform_enabled = true
card_template.texture = _get_texture()
card_template.offset_transform_rotation = deg_to_rad(randf_range(-rotation_limit_degree, rotation_limit_degree))
card_template.offset_left = _current_spawn_position_x
var target_modulate: Color = Color.WHITE
if not _is_active:
target_modulate.a = inactive_visibility
return card_template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://djok43i733l62
1 change: 1 addition & 0 deletions entities/game/players_overlay/scenes/PlayersOverlay.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[ext_resource type="PackedScene" uid="uid://cynb8xjpxqa6w" path="res://entities/game/player_name_overlay/scenes/PlayerNameOverlay.tscn" id="2_ehytq"]

[node name="MarginContainer" type="MarginContainer" unique_id=1095593491 node_paths=PackedStringArray("player_target_control")]
custom_minimum_size = Vector2(500, 0)
offset_right = 40.0
offset_bottom = 40.0
theme_override_constants/margin_left = 50
Expand Down
6 changes: 6 additions & 0 deletions entities/game/players_overlay/scripts/PlayerGameOverlay.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class_name PlayerGameOverlay extends Control

signal set_card_texture(texture: Texture2D)

@export var player_template: PackedScene
@export var player_target_control: Control

Expand All @@ -19,12 +21,16 @@ func _ready() -> void:
break
_ui_information_system.register_ui_element(name, self)

func set_texture(deck: MemoryDeckResource) -> void:
set_card_texture.emit(deck.get_back_image())

func add_player(player: PlayerResource) -> void:
var node: PlayerGameLabel = player_template.instantiate() as PlayerGameLabel
if node == null:
return
node.set_player(player)
player_target_control.add_child(node)
set_card_texture.connect(node.set_texture)

func player_changed(player_id: int) -> void:
_current_player = player_id
Expand Down
2 changes: 1 addition & 1 deletion shared/resources/colors/assets/PlayerDefaultColor.tres
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="ColorResource" load_steps=2 format=3 uid="uid://85njf66kd3s1"]
[gd_resource type="Resource" script_class="ColorResource" format=3 uid="uid://85njf66kd3s1"]

[ext_resource type="Script" uid="uid://crr4r8hbc4d1l" path="res://shared/resources/colors/ColorResource.gd" id="1_d0tol"]

Expand Down
Loading