diff --git a/art_collector.gd b/art_collector.gd index 53357a3..4c1a593 100644 --- a/art_collector.gd +++ b/art_collector.gd @@ -1,12 +1,16 @@ class_name ArtCollector extends Node2D + +var painting_pile: PaintingPile + + func _ready() -> void: $ArtCollectorAnimations.set_frame(randi_range(0, 16)) - #$ArtCollectorAnimations.animation_finished.connect(_handle_anim_finish) + func idle(): $ArtCollectorAnimations.play("Idle") - + func normal_paddle(): $ArtCollectorAnimations.play("NormalPaddle") $NormalPaddleSound.play() @@ -18,5 +22,3 @@ func critical_paddle(): $ArtCollectorAnimations.play("CriticalPaddle") await $ArtCollectorAnimations.animation_finished $ArtCollectorAnimations.play("Shiny") - -#func _handle_anim_finish diff --git a/audience_manager.gd b/audience_manager.gd index 9e81a0b..7a1244a 100644 --- a/audience_manager.gd +++ b/audience_manager.gd @@ -26,6 +26,7 @@ var currently_animated_collector = null @export var think_max_time := 5.0 var current_ask: int +var latest_bidder: ArtCollector func _ready() -> void: desk.numpad.ask_proposed.connect(_handle_ask_proposed) @@ -41,15 +42,16 @@ func raise_paddle(): game_manager.current_bid = desk.numpad.proposed_ask var collectors: Array[Node] = get_tree().get_nodes_in_group("ArtCollectors") collectors.shuffle() - + try_clear_currently_animated_collector() - currently_animated_collector = collectors[0] - + currently_animated_collector = collectors[0] + + latest_bidder = collectors[0] if bark_critical: - collectors[0].critical_paddle() + latest_bidder.critical_paddle() print("play crit paddle") else: - collectors[0].normal_paddle() + latest_bidder.normal_paddle() print("play norm paddle") bark_critical = false ask_accepted.emit() @@ -58,7 +60,7 @@ func try_clear_currently_animated_collector(): if currently_animated_collector: currently_animated_collector.idle() currently_animated_collector = null - + func _handle_auctioneer_bark(): if timer.time_left >= think_min_time: bark_critical = true diff --git a/bark_buttons.gd b/bark_buttons.gd index ee2fe36..6f645f2 100644 --- a/bark_buttons.gd +++ b/bark_buttons.gd @@ -7,22 +7,22 @@ signal auctioneer_bark func _on_great_buy_button_down() -> void: auctioneer_bark.emit() $GreatBuy.mouse_default_cursor_shape = Control.CURSOR_DRAG - DisplayServer.tts_speak("Great buy!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch, bark_speed) + turn_manager.speak("Great buy!", bark_speed) func _on_investment_piece_button_down() -> void: auctioneer_bark.emit() $InvestmentPiece.mouse_default_cursor_shape = Control.CURSOR_DRAG - DisplayServer.tts_speak("Investment piece!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch, bark_speed) + turn_manager.speak("Investment piece!", bark_speed) func _on_stunning_message_button_down() -> void: auctioneer_bark.emit() $StunningMessage.mouse_default_cursor_shape = Control.CURSOR_DRAG - DisplayServer.tts_speak("Stunning message!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch, bark_speed) + turn_manager.speak("Stunning message!", bark_speed) func _on_innovative_artist_button_down() -> void: auctioneer_bark.emit() $InnovativeArtist.mouse_default_cursor_shape = Control.CURSOR_DRAG - DisplayServer.tts_speak("Innovative artist!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch, bark_speed) + turn_manager.speak("Innovative artist!", bark_speed) func _on_great_buy_button_release() -> void: diff --git a/captions.gd b/captions.gd new file mode 100644 index 0000000..7e256b5 --- /dev/null +++ b/captions.gd @@ -0,0 +1,15 @@ +extends Label +class_name CaptionLabel + + +var _tween: Tween + + +func display_caption(msg: String) -> void: + text = msg + modulate = Color.WHITE + if _tween: _tween.kill() + _tween = create_tween() + _tween.tween_interval(30.0) + _tween.tween_property(self, ^'modulate', Color.TRANSPARENT, 3.0) + _tween.tween_callback(func(): _tween = null) diff --git a/captions.gd.uid b/captions.gd.uid new file mode 100644 index 0000000..d58b2a9 --- /dev/null +++ b/captions.gd.uid @@ -0,0 +1 @@ +uid://sfhg7pkumnwa diff --git a/game_manager.gd b/game_manager.gd index 06d8e7b..75cac42 100644 --- a/game_manager.gd +++ b/game_manager.gd @@ -4,58 +4,55 @@ class_name GameManager extends Node2D @export var desk: Desk @export var turn_manager: TurnManager +enum bidding_state {CLOSED, READY, ASKING, BID} + signal lost signal won -var paintings_sold = 0 -@export var paintings_total = 7 +var paintings_sold := 0 +const PAINTINGS_TOTAL := 7 -var paintings: Array = Array() -var current_painting = 0 +var paintings: Array[PaintingInfo] = [] +var current_painting_idx := 0 # tracker variables for bid markers, proposing bids happens between numpad and audience -var current_bid = 0 -var starting_price = 0 -var final_bid = 0 +var current_bid := 0 +var starting_price := 0 +var final_bid := 0 @export var current_bid_display: RichTextLabel -var target_sales: int = 0 -var total_sales: int = 0 -@export var sales_magnitude = 100000 -@export var single_painting_magnitude = 1000 -@export var initial_value_reduction: float = 0.6 +var target_sales := 0 +#var total_sales: int = 0 +@export var sales_magnitude := 100000 +@export var single_painting_magnitude := 1000 +@export var initial_value_reduction := 0.6 # state tracker for a given painting's auction -var bidding_open: bool = false -enum bidding_state {CLOSED, READY, ASKING, BID} -var state: int = bidding_state.CLOSED -signal new_painting_displayed +var bidding_open := false +var state := bidding_state.CLOSED func _ready() -> void: audience_manager.ask_accepted.connect(_handle_ask_accepted) desk.gavel.gavel_hit.connect(_handle_gavel_hit) - #paintings_total = randi_range(7,10) - target_sales = randi_range(2,5) * sales_magnitude + # Associate collectors with their collections + var collectors: Array[Node] = get_tree().get_nodes_in_group("ArtCollectors") + assert(%PaintingPiles.get_child_count() == collectors.size()) + for idx in collectors.size(): collectors[idx].painting_pile = %PaintingPiles.get_child(idx) - var new_painting = 0 - var new_painting_value: int - while new_painting < paintings_total: - new_painting_value = (target_sales/randf_range(paintings_total - 2, paintings_total + 2)) - new_painting_value = snappedi(new_painting_value, single_painting_magnitude) - print(str(new_painting_value)) - paintings.append(new_painting_value) - new_painting += 1 + randomize_auction() + for idx in PAINTINGS_TOTAL: + var pd: PaintingDisplay = %Paintings.get_child(idx) + pd.configure_painting(paintings[idx].id) - print(paintings) - print("You have " + str(paintings_total) + " paintings. Sell them for at least $" + str(target_sales) + " or face the consequences!") - print("Hit the gavel and input the starting price to begin!") - DisplayServer.tts_speak("You have " + str(paintings_total) + " paintings. Sell them fast for at least $" + str(target_sales) + " or face the consequences!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch) - DisplayServer.tts_speak("Hit the gavel and input the starting price to begin!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch) + next_painting() + + var intro_msg := "You have %s paintings. Sell them fast for at least $%s or face the consequences!" % [PAINTINGS_TOTAL, target_sales] + intro_msg += "\nHit the gavel and input the starting price to begin!" + turn_manager.speak(intro_msg) - next_painting(0) #build out the initialization process, which should: # -- generate paintings and assign values # -- start the turn timer/auction timer @@ -63,70 +60,118 @@ func _ready() -> void: # -- have tts announcement of starting bid and start of auction - - func _handle_gavel_hit(): - if state == bidding_state.CLOSED: - state = bidding_state.READY - print(str(state)) - current_bid_display.set_text("Starting price: $" + str(starting_price)) - elif state == bidding_state.ASKING: - if current_bid != 0: - state = bidding_state.CLOSED - desk.numpad.reminder_timer.stop() - current_bid_display.set_text("Sold for $" + str(current_bid) + "!") - sell_painting() - print("Congrats on selling your painting for $" + str(current_bid) + "! You have made $" + str(total_sales) + " so far.") - current_painting += 1 - if current_painting <= paintings_total - 1: - next_painting((current_painting)) - print("The next painting is valued at $" + str(starting_price) + " (should be $" + str(paintings[current_painting]) + ")") - (print(str(state))) - else: - end_auction() + match state: + bidding_state.CLOSED: + state = bidding_state.READY + current_bid_display.set_text("Starting price: $%s" % [starting_price]) + bidding_state.ASKING: + if current_bid != 0: + sell_painting() + if next_painting(): + print("The next painting is valued at $%s (should be $%s)" % [starting_price, paintings[current_painting_idx].value]) + else: + end_auction() - else: - pass func destroy_painting(): - # Painting destruction animation/particle effect $FailedPainting.play() - current_painting += 1 - DisplayServer.tts_speak("Oh nooooooo! Took too long!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch) - DisplayServer.tts_speak("Try to make it up on the next painting!", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch) - desk.numpad.reminder_timer.stop() - if current_painting <= paintings_total - 1: - next_painting((current_painting)) - print("The next painting is valued at $" + str(starting_price) + " (should be $" + str(paintings[current_painting]) + ")") - (print(str(state))) + if get_painting_display().damage_deal(): + cancel_bidding() + get_painting_display().move_painting_to_pile(%PaintingPileDiscard) + next_painting() + turn_manager.speak("Oh nooooooo! Took too long!\nTry to make it up on the next painting!") else: - end_auction() + turn_manager.restart_turn() + turn_manager.speak("Oops! Took too long! Quickly, try again!") + func sell_painting(): - total_sales = total_sales + current_bid + cancel_bidding() + move_painting_to_bidders_pile() + paintings[current_painting_idx].sold_for = current_bid + current_bid_display.set_text("Sold for $%s!" % [current_bid]) + turn_manager.speak("Sold for $%s!" % [current_bid]) + print("Congrats on selling your painting for $%s! You have made $%s so far." % [current_bid, get_total_sales()]) -func next_painting(a: int): - $NextPainting.play() - starting_price = paintings[a] + +func move_painting_to_bidders_pile() -> void: + get_painting_display().move_painting_to_pile(audience_manager.latest_bidder.painting_pile) + + +func get_painting_display() -> PaintingDisplay: + return %Paintings.get_child(current_painting_idx) + + +func next_painting() -> bool: + current_painting_idx += 1 + if current_painting_idx >= PAINTINGS_TOTAL: return false + var info := paintings[current_painting_idx] + starting_price = info.value current_bid = 0 + $NextPainting.play() + get_painting_display().animate_show_painting() + return true - # will need to add animation/image swap - new_painting_displayed.emit() func _handle_ask_accepted(): current_bid_display.set_text("Current bid: $" + str(current_bid)) + func end_auction(): #add in logic for displaying/transitioning to score screen - if total_sales >= target_sales: + if get_total_sales() >= target_sales: #add context specific score text? - DisplayServer.tts_speak("Congratulations! The auction house will run another day.", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch) + turn_manager.speak("Congratulations! The auction house will run another day.") emit_signal("won") else: #add context specific score text? - DisplayServer.tts_speak("You have failed. We must find a new auctioneer.", turn_manager.voice_id, turn_manager.tts_volume, turn_manager.tts_pitch) + turn_manager.speak("You have failed. We must find a new auctioneer.") emit_signal("lost") + +func sum_total_sales(acculator: int, info: PaintingInfo) -> int: + return acculator + info.sold_for + + +func get_total_sales() -> int: + return paintings.reduce(sum_total_sales, 0) + + +func randomize_auction() -> void: + #paintings_total = randi_range(7,10) + target_sales = randi_range(2, 5) * sales_magnitude + var custom_ids: Array[int] = %PaintingDisplay1.get_n_unique_custom_paintings(3) + for idx in PAINTINGS_TOTAL: + var info := PaintingInfo.new() + info.id = custom_ids.pop_back() if not custom_ids.is_empty() else -absi(randi()) + @warning_ignore('integer_division') + info.value = target_sales / randi_range(PAINTINGS_TOTAL - 2, PAINTINGS_TOTAL + 2) + info.value = snappedi(info.value, single_painting_magnitude) + paintings.append(info) + paintings.shuffle() + + +class PaintingInfo: + var id := 0 + var value := 0 + var sold_for := 0 + var is_sold: bool: + get(): return sold_for > 0 + +>> >> >> > wip_astra137 + # OTHER THINGS TO ADD: # UI elements for score # Bark manager + + +func _on_turn_manager_timer_timeout() -> void: + destroy_painting() + + +func cancel_bidding() -> void: + if not (state == bidding_state.ASKING or state == bidding_state.BID): + push_error('bidding state should not be ', state) + state = bidding_state.CLOSED + desk.numpad.reminder_timer.stop() diff --git a/main.tscn b/main.tscn index e6f3293..d968ebd 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=24 format=3 uid="uid://dt4nq0nkmjiit"] +[gd_scene load_steps=27 format=3 uid="uid://dt4nq0nkmjiit"] [ext_resource type="Script" uid="uid://b5tcsve1oo5ht" path="res://game_manager.gd" id="1_ig7tw"] [ext_resource type="Texture2D" uid="uid://cvqsf1nlfqwpr" path="res://assets/background/background.png" id="1_lquwl"] @@ -6,13 +6,15 @@ [ext_resource type="FontFile" uid="uid://cm28kqtqj3a6n" path="res://assets/amiga4ever pro.ttf" id="2_5vw27"] [ext_resource type="Texture2D" uid="uid://cpj3xw8js3h3" path="res://assets/chairs/chairs_back.png" id="2_7mycd"] [ext_resource type="Texture2D" uid="uid://d03ot1f34pyhu" path="res://assets/chairs/chairs_front.png" id="3_272bh"] +[ext_resource type="PackedScene" uid="uid://dpcsom2ps588j" path="res://paintings/layout/painting_pile.tscn" id="4_1u8w0"] +[ext_resource type="PackedScene" uid="uid://csugksrssibrp" path="res://paintings/layout/painting_display.tscn" id="4_d13ii"] [ext_resource type="AudioStream" uid="uid://db67ob7kkhsc0" path="res://assets/game sfx/failed-round.wav" id="5_cegan"] [ext_resource type="AudioStream" uid="uid://cicodo74wnevu" path="res://assets/game sfx/next-round.wav" id="6_82xsv"] [ext_resource type="PackedScene" uid="uid://c1acpop6amvcl" path="res://audience_manager.tscn" id="6_272bh"] [ext_resource type="PackedScene" uid="uid://b8key4hjaldui" path="res://turn_manager.tscn" id="7_272bh"] [ext_resource type="Texture2D" uid="uid://d2142cf22t1lv" path="res://assets/buttons/button1.png" id="9_2cqfq"] -[ext_resource type="PackedScene" uid="uid://donkfeu1x888o" path="res://paintings/painting.tscn" id="9_kek77"] [ext_resource type="Script" uid="uid://bg1vk1o2eq3fg" path="res://bark_buttons.gd" id="9_yaehf"] +[ext_resource type="Script" uid="uid://sfhg7pkumnwa" path="res://captions.gd" id="10_ryguw"] [ext_resource type="Texture2D" uid="uid://ut655l8y8xmi" path="res://assets/buttons/button1pressed.png" id="10_yaehf"] [ext_resource type="Texture2D" uid="uid://c0iad21xtnjdd" path="res://assets/buttons/button3.png" id="11_074og"] [ext_resource type="Texture2D" uid="uid://dx4dadmb37khl" path="res://assets/buttons/button3pressed.png" id="12_cegan"] @@ -27,6 +29,11 @@ default_font = ExtResource("2_5vw27") default_font_size = 12 +[sub_resource type="LabelSettings" id="LabelSettings_ryguw"] +font = ExtResource("2_5vw27") +shadow_size = 5 +shadow_color = Color(0, 0, 0, 0.416) + [node name="Main" type="Node"] [node name="Background" type="Sprite2D" parent="."] @@ -44,8 +51,30 @@ texture = ExtResource("2_7mycd") position = Vector2(640, 360) texture = ExtResource("3_272bh") -[node name="Painting" parent="." instance=ExtResource("9_kek77")] -position = Vector2(1075, 130) +[node name="Paintings" type="Node2D" parent="."] +unique_name_in_owner = true + +[node name="PaintingDisplay7" parent="Paintings" instance=ExtResource("4_d13ii")] +position = Vector2(1074, 136) + +[node name="PaintingDisplay6" parent="Paintings" instance=ExtResource("4_d13ii")] +position = Vector2(1074, 136) + +[node name="PaintingDisplay5" parent="Paintings" instance=ExtResource("4_d13ii")] +position = Vector2(1074, 136) + +[node name="PaintingDisplay4" parent="Paintings" instance=ExtResource("4_d13ii")] +position = Vector2(1074, 136) + +[node name="PaintingDisplay3" parent="Paintings" instance=ExtResource("4_d13ii")] +position = Vector2(1074, 136) + +[node name="PaintingDisplay2" parent="Paintings" instance=ExtResource("4_d13ii")] +position = Vector2(1074, 136) + +[node name="PaintingDisplay1" parent="Paintings" instance=ExtResource("4_d13ii")] +unique_name_in_owner = true +position = Vector2(1074, 136) [node name="GameManager" type="Node2D" parent="." node_paths=PackedStringArray("audience_manager", "desk", "turn_manager", "current_bid_display")] unique_name_in_owner = true @@ -86,15 +115,26 @@ text = "Current Bid: $0" horizontal_alignment = 1 vertical_alignment = 1 +[node name="Captions" type="Label" parent="UI"] +layout_mode = 0 +offset_top = 352.0 +offset_right = 1280.0 +offset_bottom = 392.0 +text = "PLACEHOLDER" +label_settings = SubResource("LabelSettings_ryguw") +horizontal_alignment = 1 +vertical_alignment = 1 +script = ExtResource("10_ryguw") + [node name="AudienceManager" parent="." node_paths=PackedStringArray("desk", "game_manager", "bark_buttons") instance=ExtResource("6_272bh")] desk = NodePath("../Desk") game_manager = NodePath("../GameManager") bark_buttons = NodePath("../BarkButtons") -[node name="TurnManager" parent="." node_paths=PackedStringArray("desk", "game_manager", "audience_manager") instance=ExtResource("7_272bh")] +[node name="TurnManager" parent="." node_paths=PackedStringArray("desk", "captions", "audience_manager") instance=ExtResource("7_272bh")] tts_sentence_speed = 4.5 desk = NodePath("../Desk") -game_manager = NodePath("../GameManager") +captions = NodePath("../UI/Captions") audience_manager = NodePath("../AudienceManager") [node name="BarkButtons" type="Node2D" parent="." node_paths=PackedStringArray("turn_manager")] @@ -145,6 +185,44 @@ stream = ExtResource("22_ryguw") volume_db = -14.0 autoplay = true +[node name="PaintingPileDiscard" parent="." instance=ExtResource("4_1u8w0")] +unique_name_in_owner = true +offset_left = 1159.0 +offset_top = 377.0 +offset_right = 1260.0 +offset_bottom = 442.1613 +size_flags_horizontal = 3 + +[node name="PaintingPiles" type="HBoxContainer" parent="."] +unique_name_in_owner = true +offset_left = 142.0 +offset_top = 242.0 +offset_right = 759.0 +offset_bottom = 310.0 +theme_override_constants/separation = 24 +metadata/_edit_group_ = true + +[node name="PaintingPile1" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile2" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile3" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile4" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile5" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[connection signal="timer_timeout" from="TurnManager" to="GameManager" method="_on_turn_manager_timer_timeout"] [connection signal="button_down" from="BarkButtons/GreatBuy" to="BarkButtons" method="_on_great_buy_button_down"] [connection signal="button_up" from="BarkButtons/GreatBuy" to="BarkButtons" method="_on_great_buy_button_release"] [connection signal="button_down" from="BarkButtons/InvestmentPiece" to="BarkButtons" method="_on_investment_piece_button_down"] diff --git a/numpad.gd b/numpad.gd index 09fc2f5..5d0478f 100644 --- a/numpad.gd +++ b/numpad.gd @@ -17,7 +17,8 @@ var turn_manager: TurnManager func _ready() -> void: progress_bar.max_value = reminder_timer.wait_time -func _process(delta: float) -> void: + +func _process(_delta: float) -> void: progress_bar.value = reminder_timer.time_left # number entry function called by numbered button children @@ -31,9 +32,9 @@ func keypad_backspace(): func keypad_submit(): var keypad_output: String = "".join(numpad_buffer) proposed_ask = int(keypad_output) * 1000 - + if proposed_ask == 0: return - + match game_manager.state: game_manager.bidding_state.READY: if proposed_ask == game_manager.starting_price: @@ -63,7 +64,7 @@ func keypad_submit(): error_audio_player.play() _: error_audio_player.play() - + # need to avoid starting the reminder timer before # the auction starts numpad_buffer.clear() diff --git a/paintings/dmg.png b/paintings/dmg.png new file mode 100644 index 0000000..09b2315 Binary files /dev/null and b/paintings/dmg.png differ diff --git a/paintings/dmg.png.import b/paintings/dmg.png.import new file mode 100644 index 0000000..1a4bbf5 --- /dev/null +++ b/paintings/dmg.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d02jhn3d0pwir" +path="res://.godot/imported/dmg.png-847f37e3df3d5bea8849f4f38fa49482.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/dmg.png" +dest_files=["res://.godot/imported/dmg.png-847f37e3df3d5bea8849f4f38fa49482.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/layout/painting_display.gd b/paintings/layout/painting_display.gd new file mode 100644 index 0000000..5851dc1 --- /dev/null +++ b/paintings/layout/painting_display.gd @@ -0,0 +1,114 @@ +@tool +extends Node2D +class_name PaintingDisplay + + +const PAINTING_SIZE := Vector2(310, 200) + +@export var custom_paintings: Array[Texture2D] + +@export_tool_button('Next Custom') var next_custom_action = func next_custom(): + configure_painting(absi(%Painting.painting_id + 1) % custom_paintings.size()) + animate_show_painting() + +@export_tool_button('Random Procedual') var random_procedual_action = func random_procedual(): + configure_painting(-absi(randi())) + animate_show_painting() + + +@export var shake_distance := 12.0 +@export var shake_duration := 0.3 +@export var shake_step_count := 5 +@export_tool_button('damage_deal') var damage_deal_action = damage_deal +@export_tool_button('damage_undo') var damage_undo_action = damage_undo + + +func get_n_unique_custom_paintings(count: int) -> Array[int]: + var list: Array[int] = [] + for idx in custom_paintings.size(): list.push_back(idx) + list.shuffle() + list.resize(count) + return list + + +var _shake_tween: Tween + +func animate_shake(): + if _shake_tween: _shake_tween.kill() + var shake_step := shake_duration / shake_step_count + _shake_tween = create_tween() + for i in shake_step_count: + var pos := Vector2(randf_range(-shake_distance, shake_distance), randf_range(-shake_distance, shake_distance)) + _shake_tween.set_ease(Tween.EASE_OUT_IN) + _shake_tween.set_trans(Tween.TRANS_ELASTIC) + _shake_tween.tween_property(%Shaker, ^'position', pos, shake_step) + _shake_tween.set_ease(Tween.EASE_OUT) + _shake_tween.set_trans(Tween.TRANS_ELASTIC) + _shake_tween.tween_property(%Shaker, ^'position', Vector2.ZERO, shake_duration) + _shake_tween.tween_callback(func(): _shake_tween = null) + + +func damage_deal() -> bool: + animate_shake() + %Painting.damage += 1 + if %Painting.damage > 3: + $AnimationPlayer.play(&'broke') + return true + else: + return false + + +func damage_undo(): + %Painting.damage = 0 + $AnimationPlayer.play_backwards(&'broke') + + +#var _has_loaded_painting := false +#var _loaded_painting_id: int + +#func animate_prev_painting() -> void: + #if _has_loaded_painting: + #$AnimationPlayer.play_backwards(&'slide') + #await $AnimationPlayer.animation_finished + #$AnimationPlayer.play_backwards(&'broke') + #await $AnimationPlayer.animation_finished + #_has_loaded_painting = false + +#func animate_next_painting(id: int) -> void: + #_has_loaded_painting = true + #_loaded_painting_id = id + #%Painting.damage = 0 + #%Painting.painting_id = id + #%Painting.overwrite_texture = custom_paintings[id] if id >= 0 and id < custom_paintings.size() else null + #$AnimationPlayer.play(&'slide') + #await $AnimationPlayer.animation_finished + + +func configure_painting(id: int) -> void: + %Painting.damage = 0 + %Painting.painting_id = id + %Painting.overwrite_texture = custom_paintings[id] if id >= 0 and id < custom_paintings.size() else null + $AnimationPlayer.play(&'RESET') + + +func animate_show_painting() -> void: + $AnimationPlayer.play(&'slide') + await $AnimationPlayer.animation_finished + + +var _painting_pile: PaintingPile +var _pile_tween: Tween + + +func move_painting_to_pile(pile: PaintingPile) -> void: + assert(not _painting_pile) + _painting_pile = pile + animate_move(pile.push_tracking(self)) + + +func animate_move(rect: Rect2) -> void: + if _pile_tween: _pile_tween.kill() + _pile_tween = create_tween() + _pile_tween.parallel().tween_property($Root, ^'global_position', rect.get_center(), 1.2) + _pile_tween.parallel().tween_property($Root, ^'scale', rect.size / PAINTING_SIZE, 1.2) + _pile_tween.tween_callback(func(): _pile_tween = null) diff --git a/paintings/layout/painting_display.gd.uid b/paintings/layout/painting_display.gd.uid new file mode 100644 index 0000000..866e4f4 --- /dev/null +++ b/paintings/layout/painting_display.gd.uid @@ -0,0 +1 @@ +uid://cy636hseq5fo4 diff --git a/paintings/layout/painting_display.tscn b/paintings/layout/painting_display.tscn new file mode 100644 index 0000000..98efed0 --- /dev/null +++ b/paintings/layout/painting_display.tscn @@ -0,0 +1,170 @@ +[gd_scene load_steps=27 format=3 uid="uid://csugksrssibrp"] + +[ext_resource type="Script" uid="uid://cy636hseq5fo4" path="res://paintings/layout/painting_display.gd" id="1_gy870"] +[ext_resource type="PackedScene" uid="uid://donkfeu1x888o" path="res://paintings/painting.tscn" id="2_5v8dq"] +[ext_resource type="Texture2D" uid="uid://dj7wj38a447jn" path="res://paintings/veryart/1/F0.png" id="2_7o3cd"] +[ext_resource type="Texture2D" uid="uid://drlta7bv52utw" path="res://paintings/veryart/2/F0.png" id="3_t05i8"] +[ext_resource type="Texture2D" uid="uid://crih6jm2ms4kt" path="res://paintings/veryart/3/F0.png" id="4_k2el0"] +[ext_resource type="Texture2D" uid="uid://byvh75dt6j3tv" path="res://paintings/veryart/4/F0.png" id="5_238kw"] +[ext_resource type="Texture2D" uid="uid://dchq2odvlum6i" path="res://paintings/veryart/5/F0.png" id="6_ugvm4"] +[ext_resource type="Texture2D" uid="uid://b0588wdutp328" path="res://paintings/veryart/6/F0.png" id="7_aqt5w"] +[ext_resource type="Texture2D" uid="uid://cse035uvcnob5" path="res://paintings/veryart/7/F0.png" id="8_dng8e"] +[ext_resource type="Texture2D" uid="uid://cco31jtejtaex" path="res://paintings/veryart/8/F0.png" id="9_mtyqy"] +[ext_resource type="Texture2D" uid="uid://b57h2svvximny" path="res://paintings/veryart/9/F0.png" id="10_ybjp4"] +[ext_resource type="Texture2D" uid="uid://b7dbha8x4c0tj" path="res://paintings/veryart/10/F0.png" id="11_q2yjp"] +[ext_resource type="Texture2D" uid="uid://bb6aiffvsc8mr" path="res://paintings/veryart/11/F0.png" id="12_r4wn3"] +[ext_resource type="Texture2D" uid="uid://b5tlr6nxy8vft" path="res://paintings/veryart/12.png" id="13_v614m"] +[ext_resource type="Texture2D" uid="uid://dps241gwu1flx" path="res://paintings/veryart/notart.png" id="14_5sb26"] + +[sub_resource type="Animation" id="Animation_a2c10"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Root/Shaker:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [0.0] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Root/Shaker/GPUParticles2D:emitting") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Root:position") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(600, 0)] +} + +[sub_resource type="Animation" id="Animation_7o3cd"] +resource_name = "broke" +length = 0.3 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Root/Shaker:rotation") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.3), +"transitions": PackedFloat32Array(0.5, 1), +"update": 0, +"values": [0.0, 0.2617993877991494] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Root/Shaker/GPUParticles2D:emitting") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.1), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [false, true] +} + +[sub_resource type="Animation" id="Animation_t05i8"] +resource_name = "slide" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Root:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(0.2, 1), +"update": 0, +"values": [Vector2(800, 0), Vector2(0, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_a2c10"] +_data = { +&"RESET": SubResource("Animation_a2c10"), +&"broke": SubResource("Animation_7o3cd"), +&"slide": SubResource("Animation_t05i8") +} + +[sub_resource type="Gradient" id="Gradient_7o3cd"] +offsets = PackedFloat32Array(0.92493296, 1) +colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_t05i8"] +gradient = SubResource("Gradient_7o3cd") +width = 12 +height = 12 +fill = 1 +fill_from = Vector2(0.5, 0.5) +fill_to = Vector2(1, 0.5) + +[sub_resource type="Gradient" id="Gradient_t05i8"] +offsets = PackedFloat32Array(0, 0.2327044, 1) +colors = PackedColorArray(0.99999994, 0.57875466, 0.3272594, 1, 0.26293245, 0.26293245, 0.26293245, 1, 0, 0, 0, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_k2el0"] +gradient = SubResource("Gradient_t05i8") + +[sub_resource type="Curve" id="Curve_238kw"] +_limits = [0.0, 4.0, 0.0, 1.0] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.08689458, 4), 0.0, 0.0, 0, 0, Vector2(1, 0.11427331), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_ugvm4"] +curve = SubResource("Curve_238kw") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_t05i8"] +particle_flag_disable_z = true +emission_shape = 3 +emission_box_extents = Vector3(150, 100, 1) +gravity = Vector3(0, -50, 0) +scale_min = 0.79999995 +scale_curve = SubResource("CurveTexture_ugvm4") +color_ramp = SubResource("GradientTexture1D_k2el0") +hue_variation_min = -2.2351742e-08 +hue_variation_max = 0.09999997 + +[node name="PaintingDisplay" type="Node2D"] +script = ExtResource("1_gy870") +custom_paintings = Array[Texture2D]([ExtResource("2_7o3cd"), ExtResource("3_t05i8"), ExtResource("4_k2el0"), ExtResource("5_238kw"), ExtResource("6_ugvm4"), ExtResource("7_aqt5w"), ExtResource("8_dng8e"), ExtResource("9_mtyqy"), ExtResource("10_ybjp4"), ExtResource("11_q2yjp"), ExtResource("12_r4wn3"), ExtResource("13_v614m"), ExtResource("14_5sb26")]) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +&"": SubResource("AnimationLibrary_a2c10") +} + +[node name="Root" type="Node2D" parent="."] +position = Vector2(600, 0) + +[node name="Shaker" type="Node2D" parent="Root"] +unique_name_in_owner = true + +[node name="Painting" parent="Root/Shaker" instance=ExtResource("2_5v8dq")] +unique_name_in_owner = true + +[node name="GPUParticles2D" type="GPUParticles2D" parent="Root/Shaker"] +emitting = false +amount = 32 +texture = SubResource("GradientTexture2D_t05i8") +lifetime = 2.0 +one_shot = true +process_material = SubResource("ParticleProcessMaterial_t05i8") diff --git a/paintings/layout/painting_pile.gd b/paintings/layout/painting_pile.gd new file mode 100644 index 0000000..692ce3e --- /dev/null +++ b/paintings/layout/painting_pile.gd @@ -0,0 +1,28 @@ +@tool +extends ReferenceRect +class_name PaintingPile + + +func _get_minimum_size() -> Vector2: + return Vector2(0, size.x * 20. / 31.) + + +func _set_height_from_width(): + size.y = size.x * 20. / 31. + update_minimum_size() + + +func _ready() -> void: + resized.connect(_set_height_from_width) + + +var tracking: Array[Node] + +func push_tracking(node: Node) -> Rect2: + tracking.push_back(node) + var rect := get_global_rect() + rect.position += Vector2(8, 4) * (tracking.size() - 1) + return rect + +func pop_tracking() -> Node: + return tracking.pop_back() diff --git a/paintings/layout/painting_pile.gd.uid b/paintings/layout/painting_pile.gd.uid new file mode 100644 index 0000000..7bed55e --- /dev/null +++ b/paintings/layout/painting_pile.gd.uid @@ -0,0 +1 @@ +uid://dcocb7413ofm3 diff --git a/paintings/layout/painting_pile.tscn b/paintings/layout/painting_pile.tscn new file mode 100644 index 0000000..7ad2941 --- /dev/null +++ b/paintings/layout/painting_pile.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://dpcsom2ps588j"] + +[ext_resource type="Script" uid="uid://dcocb7413ofm3" path="res://paintings/layout/painting_pile.gd" id="1_frs4q"] + +[node name="PaintingPile" type="ReferenceRect"] +custom_minimum_size = Vector2(31, 20) +offset_right = 310.0 +offset_bottom = 200.0 +mouse_filter = 2 +script = ExtResource("1_frs4q") diff --git a/paintings/noise.tscn b/paintings/noise.tscn deleted file mode 100644 index 0af8ed7..0000000 --- a/paintings/noise.tscn +++ /dev/null @@ -1,35 +0,0 @@ -[gd_scene load_steps=6 format=3 uid="uid://bjpharjtpysre"] - -[ext_resource type="Shader" uid="uid://b6jkek1qotcnf" path="res://paintings/noise.gdshader" id="1_2lnyf"] -[ext_resource type="Script" uid="uid://2jt34o1v7gbo" path="res://paintings/noise.gd" id="1_o4civ"] - -[sub_resource type="FastNoiseLite" id="FastNoiseLite_o4civ"] -resource_local_to_scene = true -seed = 1 -frequency = 0.0028707401 -offset = Vector3(1460.7504, 943.2602, 0) -fractal_type = 2 -fractal_octaves = 3 - -[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_2lnyf"] -width = 320 -height = 240 -noise = SubResource("FastNoiseLite_o4civ") - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_0uljq"] -shader = ExtResource("1_2lnyf") -shader_parameter/noise = SubResource("NoiseTexture2D_2lnyf") -shader_parameter/steps = 8.0 -shader_parameter/gradient_start = Color(0.56780183, 0.45513594, 0.630845, 1) -shader_parameter/gradient_end = Color(0.5222837, 0.45749915, 0.35617962, 1) - -[node name="Noise" type="ColorRect"] -material = SubResource("ShaderMaterial_0uljq") -custom_minimum_size = Vector2(32, 24) -offset_right = 320.0 -offset_bottom = 240.0 -script = ExtResource("1_o4civ") -noise = SubResource("FastNoiseLite_o4civ") -steps = 8 -gradient_start = Color(0.56780183, 0.45513594, 0.630845, 1) -gradient_end = Color(0.5222837, 0.45749915, 0.35617962, 1) diff --git a/paintings/painting.gd b/paintings/painting.gd index c0e5e80..62f9720 100644 --- a/paintings/painting.gd +++ b/paintings/painting.gd @@ -3,8 +3,27 @@ extends Node2D class_name Painting -@export_tool_button('Randomize', 'RandomNumberGenerator') var randomize_action = randomize +@export var painting_id: int: + set(x): + painting_id = x + queue_redraw() -func randomize(rng_seed := randi()) -> void: - %Noise.rng_seed = rng_seed +@export var overwrite_texture: Texture2D: + set(x): + overwrite_texture = x + queue_redraw() + + +@export_range(0, 4) var damage: int: + set(x): + damage = x + queue_redraw() + + +func _draw() -> void: + %Fail.visible = damage > 3 + %Dmg.visible = damage > 0 + %Dmg.frame = clampi(damage - 1, 0, 2) if damage > 0 else 0 + %Noise.rng_seed = painting_id + %TextureRect.texture = overwrite_texture diff --git a/paintings/painting.tscn b/paintings/painting.tscn index 8c389ed..c87de3b 100644 --- a/paintings/painting.tscn +++ b/paintings/painting.tscn @@ -1,15 +1,15 @@ -[gd_scene load_steps=5 format=3 uid="uid://donkfeu1x888o"] +[gd_scene load_steps=7 format=3 uid="uid://donkfeu1x888o"] [ext_resource type="Texture2D" uid="uid://b142kv367vbw7" path="res://paintings/frame.png" id="1_6chac"] [ext_resource type="Script" uid="uid://tqu2ms43fhis" path="res://paintings/painting.gd" id="1_465no"] -[ext_resource type="PackedScene" uid="uid://bjpharjtpysre" path="res://paintings/noise.tscn" id="2_oqt1c"] +[ext_resource type="PackedScene" uid="uid://bjpharjtpysre" path="res://paintings/procedual/noise.tscn" id="2_oqt1c"] +[ext_resource type="Texture2D" uid="uid://d02jhn3d0pwir" path="res://paintings/dmg.png" id="4_t4wwa"] +[ext_resource type="FontFile" uid="uid://cm28kqtqj3a6n" path="res://assets/amiga4ever pro.ttf" id="5_l5l5f"] -[sub_resource type="FastNoiseLite" id="FastNoiseLite_465no"] -resource_local_to_scene = true -seed = 1262753571 -frequency = 0.0024024888 -offset = Vector3(1460.7504, 943.2602, 0) -fractal_type = 0 +[sub_resource type="LabelSettings" id="LabelSettings_1sxlm"] +font = ExtResource("5_l5l5f") +font_size = 64 +font_color = Color(1, 0, 0, 1) [node name="Painting" type="Node2D"] texture_filter = 1 @@ -18,22 +18,35 @@ script = ExtResource("1_465no") [node name="Frame" type="Sprite2D" parent="."] texture = ExtResource("1_6chac") -[node name="SubViewportContainer" type="SubViewportContainer" parent="."] +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 offset_left = -146.0 offset_top = -91.0 offset_right = 146.0 offset_bottom = 91.0 + +[node name="SubViewportContainer" type="SubViewportContainer" parent="Control"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 stretch = true stretch_shrink = 4 -[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"] +[node name="SubViewport" type="SubViewport" parent="Control/SubViewportContainer"] +transparent_bg = true handle_input_locally = false +snap_2d_transforms_to_pixel = true +snap_2d_vertices_to_pixel = true size = Vector2i(73, 45) -size_2d_override = Vector2i(480, 360) +size_2d_override = Vector2i(310, 200) size_2d_override_stretch = true render_target_update_mode = 4 -[node name="Noise" parent="SubViewportContainer/SubViewport" instance=ExtResource("2_oqt1c")] +[node name="Noise" parent="Control/SubViewportContainer/SubViewport" instance=ExtResource("2_oqt1c")] unique_name_in_owner = true anchors_preset = 15 anchor_right = 1.0 @@ -42,8 +55,44 @@ offset_right = 0.0 offset_bottom = 0.0 grow_horizontal = 2 grow_vertical = 2 -noise = SubResource("FastNoiseLite_465no") -steps = 5 -gradient_start = Color(0.31606108, 0.20250309, 0.17190823, 1) -gradient_end = Color(0.48729545, 0.5426228, 0.2567169, 1) -rng_seed = 1262753571 +steps = 24 +gradient_start = Color(0.605822, 0.410077, 0.7508662, 1) +gradient_end = Color(0.1471889, 0.25502726, 0.39230567, 1) +rng_seed = 0 + +[node name="TextureRect" type="TextureRect" parent="Control"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +expand_mode = 1 + +[node name="Dmg" type="Sprite2D" parent="."] +unique_name_in_owner = true +visible = false +texture = ExtResource("4_t4wwa") +hframes = 3 + +[node name="Fail" type="Label" parent="."] +unique_name_in_owner = true +visible = false +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -145.99998 +offset_top = -29.0 +offset_right = 124.000015 +offset_bottom = 102.0 +grow_horizontal = 2 +grow_vertical = 2 +rotation = -0.25212684 +text = "NOT +SOLD" +label_settings = SubResource("LabelSettings_1sxlm") +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/paintings/fractal.gd b/paintings/procedual/fractal.gd similarity index 100% rename from paintings/fractal.gd rename to paintings/procedual/fractal.gd diff --git a/paintings/fractal.gd.uid b/paintings/procedual/fractal.gd.uid similarity index 100% rename from paintings/fractal.gd.uid rename to paintings/procedual/fractal.gd.uid diff --git a/paintings/fractal.gdshader b/paintings/procedual/fractal.gdshader similarity index 100% rename from paintings/fractal.gdshader rename to paintings/procedual/fractal.gdshader diff --git a/paintings/fractal.gdshader.uid b/paintings/procedual/fractal.gdshader.uid similarity index 100% rename from paintings/fractal.gdshader.uid rename to paintings/procedual/fractal.gdshader.uid diff --git a/paintings/fractal.tscn b/paintings/procedual/fractal.tscn similarity index 93% rename from paintings/fractal.tscn rename to paintings/procedual/fractal.tscn index 9a1347c..a2cf595 100644 --- a/paintings/fractal.tscn +++ b/paintings/procedual/fractal.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://bx4upo2n66wke"] -[ext_resource type="Shader" uid="uid://b8yiyjkjgvful" path="res://paintings/fractal.gdshader" id="1_4re67"] -[ext_resource type="Script" uid="uid://bnmc3t0wxeayv" path="res://paintings/fractal.gd" id="2_o3htp"] +[ext_resource type="Shader" uid="uid://b8yiyjkjgvful" path="res://paintings/procedual/fractal.gdshader" id="1_4re67"] +[ext_resource type="Script" uid="uid://bnmc3t0wxeayv" path="res://paintings/procedual/fractal.gd" id="2_o3htp"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_o3htp"] resource_local_to_scene = true diff --git a/paintings/noise.gd b/paintings/procedual/noise.gd similarity index 77% rename from paintings/noise.gd rename to paintings/procedual/noise.gd index ed8ed7e..f2fe933 100644 --- a/paintings/noise.gd +++ b/paintings/procedual/noise.gd @@ -1,16 +1,8 @@ @tool extends ColorRect - @export_tool_button('Randomize', 'RandomNumberGenerator') var randomize_action = randomize - -@export var noise: FastNoiseLite: - set(x): - if noise: noise.changed.disconnect(_changed_noise) - noise = x - if noise: noise.changed.connect(_changed_noise) - @export var steps := 12: set(x): material.set_shader_parameter('steps', x) get(): return material.get_shader_parameter('steps') @@ -25,35 +17,24 @@ extends ColorRect @export var rng_seed := 0: set(x): + if rng_seed == x: return rng_seed = x _regenerate() - -var _noise_texture := NoiseTexture2D.new(): - set(x): - _noise_texture = x - _changed_noise() - - -func _changed_noise() -> void: - _noise_texture.noise = noise - material.set_shader_parameter('noise', _noise_texture) - - func _resized() -> void: - _noise_texture.width = ceili(size.x) - _noise_texture.height = ceili(size.y) - _changed_noise() - + var tex: NoiseTexture2D = material.get_shader_parameter('noise') + tex.width = ceili(size.x) + tex.height = ceili(size.y) + material.set_shader_parameter('noise', tex) func _ready() -> void: _resized() resized.connect(_resized) - func _regenerate() -> void: var rng := RandomNumberGenerator.new() rng.seed = rng_seed + var noise := FastNoiseLite.new() noise.fractal_type = rng.randi_range(0, 3) as FastNoiseLite.FractalType match noise.fractal_type: 3: noise.fractal_octaves = 2 @@ -61,6 +42,12 @@ func _regenerate() -> void: _: noise.fractal_octaves = 5 noise.frequency = rng.randf_range(0.002, 0.004) noise.seed = rng.seed + var tex := NoiseTexture2D.new() + tex.generate_mipmaps = false + tex.width = ceili(size.x) + tex.height = ceili(size.y) + tex.noise = noise + material.set_shader_parameter('noise', tex) match rng.randi_range(1, 5): 1: steps = 2 2: steps = 5 diff --git a/paintings/noise.gd.uid b/paintings/procedual/noise.gd.uid similarity index 100% rename from paintings/noise.gd.uid rename to paintings/procedual/noise.gd.uid diff --git a/paintings/noise.gdshader b/paintings/procedual/noise.gdshader similarity index 100% rename from paintings/noise.gdshader rename to paintings/procedual/noise.gdshader diff --git a/paintings/noise.gdshader.uid b/paintings/procedual/noise.gdshader.uid similarity index 100% rename from paintings/noise.gdshader.uid rename to paintings/procedual/noise.gdshader.uid diff --git a/paintings/procedual/noise.tscn b/paintings/procedual/noise.tscn new file mode 100644 index 0000000..4dc920c --- /dev/null +++ b/paintings/procedual/noise.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=6 format=3 uid="uid://bjpharjtpysre"] + +[ext_resource type="Shader" uid="uid://b6jkek1qotcnf" path="res://paintings/procedual/noise.gdshader" id="1_2lnyf"] +[ext_resource type="Script" uid="uid://2jt34o1v7gbo" path="res://paintings/procedual/noise.gd" id="1_o4civ"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_ula8d"] +seed = 573944325 +frequency = 0.0020331522 +fractal_type = 2 +fractal_octaves = 3 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_8rnnf"] +width = 310 +height = 200 +generate_mipmaps = false +noise = SubResource("FastNoiseLite_ula8d") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_0uljq"] +resource_local_to_scene = true +shader = ExtResource("1_2lnyf") +shader_parameter/noise = SubResource("NoiseTexture2D_8rnnf") +shader_parameter/steps = 8.0 +shader_parameter/gradient_start = Color(0.9170881, 0.52674425, 0.57822865, 1) +shader_parameter/gradient_end = Color(0.18847808, 0.004581891, 0.12525481, 1) + +[node name="Noise" type="ColorRect"] +material = SubResource("ShaderMaterial_0uljq") +custom_minimum_size = Vector2(31, 20) +offset_right = 310.0 +offset_bottom = 200.0 +script = ExtResource("1_o4civ") +gradient_start = Color(0.9170881, 0.52674425, 0.57822865, 1) +gradient_end = Color(0.18847808, 0.004581891, 0.12525481, 1) +rng_seed = 573944325 diff --git a/paintings/veryart/1/F0.png b/paintings/veryart/1/F0.png new file mode 100644 index 0000000..a624ad8 Binary files /dev/null and b/paintings/veryart/1/F0.png differ diff --git a/paintings/veryart/1/F0.png.import b/paintings/veryart/1/F0.png.import new file mode 100644 index 0000000..5842a4a --- /dev/null +++ b/paintings/veryart/1/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dj7wj38a447jn" +path="res://.godot/imported/F0.png-3f6b68480ef4c52f836001c865a6fecc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/1/F0.png" +dest_files=["res://.godot/imported/F0.png-3f6b68480ef4c52f836001c865a6fecc.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/10/F0.png b/paintings/veryart/10/F0.png new file mode 100644 index 0000000..7a98d9e Binary files /dev/null and b/paintings/veryart/10/F0.png differ diff --git a/paintings/veryart/10/F0.png.import b/paintings/veryart/10/F0.png.import new file mode 100644 index 0000000..22d2c35 --- /dev/null +++ b/paintings/veryart/10/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b7dbha8x4c0tj" +path="res://.godot/imported/F0.png-33e844b1a0c64e2887780dc13544887c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/10/F0.png" +dest_files=["res://.godot/imported/F0.png-33e844b1a0c64e2887780dc13544887c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/11/F0.png b/paintings/veryart/11/F0.png new file mode 100644 index 0000000..e68583c Binary files /dev/null and b/paintings/veryart/11/F0.png differ diff --git a/paintings/veryart/11/F0.png.import b/paintings/veryart/11/F0.png.import new file mode 100644 index 0000000..e63d324 --- /dev/null +++ b/paintings/veryart/11/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bb6aiffvsc8mr" +path="res://.godot/imported/F0.png-1444aa60a3e120bd4da66237f3749f52.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/11/F0.png" +dest_files=["res://.godot/imported/F0.png-1444aa60a3e120bd4da66237f3749f52.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/12.png b/paintings/veryart/12.png new file mode 100644 index 0000000..535df67 Binary files /dev/null and b/paintings/veryart/12.png differ diff --git a/paintings/veryart/12.png.import b/paintings/veryart/12.png.import new file mode 100644 index 0000000..018c143 --- /dev/null +++ b/paintings/veryart/12.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b5tlr6nxy8vft" +path="res://.godot/imported/12.png-e8e67405f3c930c2885b1f046715bb7f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/12.png" +dest_files=["res://.godot/imported/12.png-e8e67405f3c930c2885b1f046715bb7f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/2/F0.png b/paintings/veryart/2/F0.png new file mode 100644 index 0000000..3e54fc5 Binary files /dev/null and b/paintings/veryart/2/F0.png differ diff --git a/paintings/veryart/2/F0.png.import b/paintings/veryart/2/F0.png.import new file mode 100644 index 0000000..c347b48 --- /dev/null +++ b/paintings/veryart/2/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://drlta7bv52utw" +path="res://.godot/imported/F0.png-2c22cf6ea53abfe36632fbfdce7746c1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/2/F0.png" +dest_files=["res://.godot/imported/F0.png-2c22cf6ea53abfe36632fbfdce7746c1.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/3/F0.png b/paintings/veryart/3/F0.png new file mode 100644 index 0000000..fc51918 Binary files /dev/null and b/paintings/veryart/3/F0.png differ diff --git a/paintings/veryart/3/F0.png.import b/paintings/veryart/3/F0.png.import new file mode 100644 index 0000000..5d4071c --- /dev/null +++ b/paintings/veryart/3/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://crih6jm2ms4kt" +path="res://.godot/imported/F0.png-165d06b886172fca9ebd15c1adbb6fe0.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/3/F0.png" +dest_files=["res://.godot/imported/F0.png-165d06b886172fca9ebd15c1adbb6fe0.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/4/F0.png b/paintings/veryart/4/F0.png new file mode 100644 index 0000000..2bcff6a Binary files /dev/null and b/paintings/veryart/4/F0.png differ diff --git a/paintings/veryart/4/F0.png.import b/paintings/veryart/4/F0.png.import new file mode 100644 index 0000000..11db825 --- /dev/null +++ b/paintings/veryart/4/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://byvh75dt6j3tv" +path="res://.godot/imported/F0.png-4d834c40ee4090c4a5342f52ebdbd563.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/4/F0.png" +dest_files=["res://.godot/imported/F0.png-4d834c40ee4090c4a5342f52ebdbd563.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/5/F0.png b/paintings/veryart/5/F0.png new file mode 100644 index 0000000..781cfec Binary files /dev/null and b/paintings/veryart/5/F0.png differ diff --git a/paintings/veryart/5/F0.png.import b/paintings/veryart/5/F0.png.import new file mode 100644 index 0000000..a95abb5 --- /dev/null +++ b/paintings/veryart/5/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dchq2odvlum6i" +path="res://.godot/imported/F0.png-7036c0b280684bb45b138d78df2a7e8b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/5/F0.png" +dest_files=["res://.godot/imported/F0.png-7036c0b280684bb45b138d78df2a7e8b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/6/F0.png b/paintings/veryart/6/F0.png new file mode 100644 index 0000000..2e6467f Binary files /dev/null and b/paintings/veryart/6/F0.png differ diff --git a/paintings/veryart/6/F0.png.import b/paintings/veryart/6/F0.png.import new file mode 100644 index 0000000..4436c3b --- /dev/null +++ b/paintings/veryart/6/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0588wdutp328" +path="res://.godot/imported/F0.png-c522a6fdeb6ce1758fa70550a9c7825a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/6/F0.png" +dest_files=["res://.godot/imported/F0.png-c522a6fdeb6ce1758fa70550a9c7825a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/7/F0.png b/paintings/veryart/7/F0.png new file mode 100644 index 0000000..62b8009 Binary files /dev/null and b/paintings/veryart/7/F0.png differ diff --git a/paintings/veryart/7/F0.png.import b/paintings/veryart/7/F0.png.import new file mode 100644 index 0000000..a474616 --- /dev/null +++ b/paintings/veryart/7/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cse035uvcnob5" +path="res://.godot/imported/F0.png-a1113c585a4e342a285f57f8bb47ede6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/7/F0.png" +dest_files=["res://.godot/imported/F0.png-a1113c585a4e342a285f57f8bb47ede6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/8/F0.png b/paintings/veryart/8/F0.png new file mode 100644 index 0000000..125f7e6 Binary files /dev/null and b/paintings/veryart/8/F0.png differ diff --git a/paintings/veryart/8/F0.png.import b/paintings/veryart/8/F0.png.import new file mode 100644 index 0000000..6144d03 --- /dev/null +++ b/paintings/veryart/8/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cco31jtejtaex" +path="res://.godot/imported/F0.png-5bd7ff51a5d1990f6c2fc33af7cbe5f3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/8/F0.png" +dest_files=["res://.godot/imported/F0.png-5bd7ff51a5d1990f6c2fc33af7cbe5f3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/9/F0.png b/paintings/veryart/9/F0.png new file mode 100644 index 0000000..8e62643 Binary files /dev/null and b/paintings/veryart/9/F0.png differ diff --git a/paintings/veryart/9/F0.png.import b/paintings/veryart/9/F0.png.import new file mode 100644 index 0000000..1382325 --- /dev/null +++ b/paintings/veryart/9/F0.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b57h2svvximny" +path="res://.godot/imported/F0.png-562f4f5cc0d48f32d431eb2434176ea6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/9/F0.png" +dest_files=["res://.godot/imported/F0.png-562f4f5cc0d48f32d431eb2434176ea6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/paintings/veryart/notart.png b/paintings/veryart/notart.png new file mode 100644 index 0000000..e7be331 Binary files /dev/null and b/paintings/veryart/notart.png differ diff --git a/paintings/veryart/notart.png.import b/paintings/veryart/notart.png.import new file mode 100644 index 0000000..8b719e8 --- /dev/null +++ b/paintings/veryart/notart.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dps241gwu1flx" +path="res://.godot/imported/notart.png-28a9d556b2a938d9ca01861b2729395c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://paintings/veryart/notart.png" +dest_files=["res://.godot/imported/notart.png-28a9d556b2a938d9ca01861b2729395c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/turn_manager.gd b/turn_manager.gd index f3da378..356e2a3 100644 --- a/turn_manager.gd +++ b/turn_manager.gd @@ -1,5 +1,7 @@ class_name TurnManager extends Node2D +signal timer_timeout + @export var turn_timer := 7.0 @export var tts_number_speed = 7.0 @export var tts_sentence_speed = 5.0 @@ -7,12 +9,13 @@ class_name TurnManager extends Node2D @export var tts_pitch = 1.0 @export var desk: Desk +@export var captions: CaptionLabel var timer: Timer -@export var game_manager: GameManager @export var audience_manager: AudienceManager -var voices = DisplayServer.tts_get_voices_for_language("en") -var voice_id = voices[0] + +var _voices := DisplayServer.tts_get_voices_for_language("en") + func _ready() -> void: audience_manager.ask_accepted.connect(_handle_ask_accepted) @@ -20,26 +23,39 @@ func _ready() -> void: timer = desk.numpad.reminder_timer timer.wait_time = turn_timer desk.numpad.reminder_timer.timeout.connect(_handle_reminder_timer_timeout) + print('voices available: ', _voices.size()) + + +func speak(text: String, speed := tts_number_speed) -> void: + print('tts: ', text) + captions.display_caption(text) + if not _voices.is_empty(): + DisplayServer.tts_speak(text, _voices[0], tts_volume, tts_pitch, speed) -func turn_timer_animation(): - pass func _speak_ask_proposed(amount): var speech_variance = randf() if speech_variance < 0.45: - DisplayServer.tts_speak(str(amount), voice_id, tts_volume, tts_pitch, tts_number_speed) + speak('%s' % [amount]) elif speech_variance > 0.45 and speech_variance < 0.65: - DisplayServer.tts_speak("Do I hear" + str(amount), voice_id, tts_volume, tts_pitch, tts_sentence_speed) + speak('Do I hear %s?' % [amount]) elif speech_variance > 0.65 and speech_variance < 0.8: - DisplayServer.tts_speak(str(amount) + ", anybody?", voice_id, tts_volume, tts_pitch, tts_sentence_speed) + speak('%s, anybody?' % [amount]) else: - DisplayServer.tts_speak("Can I get a" + str(amount), voice_id, tts_volume, tts_pitch, tts_sentence_speed) + speak('Can I get a %s?' % [amount]) + func _handle_ask_accepted(): timer.start() - turn_timer_animation() + func _handle_reminder_timer_timeout() -> void: - if game_manager.state == game_manager.bidding_state.ASKING or game_manager.state == game_manager.bidding_state.BID: - game_manager.state = game_manager.bidding_state.CLOSED - game_manager.destroy_painting() + timer_timeout.emit() + + +func end_turn() -> void: + timer.stop() + + +func restart_turn() -> void: + timer.start()