diff --git a/src/dev-util/candle-prototype.tscn b/src/dev-util/candle-prototype.tscn index 5db4da6..dba48d3 100644 --- a/src/dev-util/candle-prototype.tscn +++ b/src/dev-util/candle-prototype.tscn @@ -1,16 +1,16 @@ -[gd_scene load_steps=11 format=3 uid="uid://de1jhrkfs5qc6"] +[gd_scene load_steps=10 format=3 uid="uid://de1jhrkfs5qc6"] [ext_resource type="Material" uid="uid://clfshh25jwfm1" path="res://logic-scenes/card_burner/card_fire.material" id="1_5xkf6"] [ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="2_wi77g"] [ext_resource type="SpriteFrames" uid="uid://j7e7me3hl6xt" path="res://logic-scenes/board/card-textures/card-sprites.tres" id="3_2ph0d"] -[ext_resource type="Material" uid="uid://0mocn41t2rq8" path="res://logic-scenes/card_burner/card_sut.material" id="3_5ktf7"] +[ext_resource type="PackedScene" uid="uid://bp6fd5lms3apa" path="res://logic-scenes/card_burner/card_sut.tscn" id="3_5xkf6"] [ext_resource type="PackedScene" uid="uid://uc6urpgv7n1y" path="res://logic-scenes/card_burner/cursor_candle.tscn" id="3_f606e"] -[sub_resource type="Gradient" id="Gradient_uu85p"] +[sub_resource type="Gradient" id="Gradient_pt3n6"] colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1) [sub_resource type="GradientTexture2D" id="GradientTexture2D_f606e"] -gradient = SubResource("Gradient_uu85p") +gradient = SubResource("Gradient_pt3n6") width = 407 height = 315 fill = 1 @@ -28,14 +28,6 @@ func _process(delta: float) -> void: $AnimatedSprite2D/Sprite2D.material.set_shader_parameter(\"fire_progression\", flame_progression) " -[sub_resource type="GradientTexture2D" id="GradientTexture2D_wi77g"] -gradient = SubResource("Gradient_uu85p") -width = 407 -height = 300 -fill = 1 -fill_from = Vector2(1, 0) -fill_to = Vector2(0, 1) - [sub_resource type="Environment" id="Environment_cfpbc"] background_mode = 3 ambient_light_source = 2 @@ -65,11 +57,9 @@ position = Vector2(-9.06201, -0.589877) scale = Vector2(0.647283, 0.589863) sprite_frames = ExtResource("3_2ph0d") -[node name="Sprite2D" type="Sprite2D" parent="Sprite2D2/AnimatedSprite2D"] -material = ExtResource("3_5ktf7") +[node name="Node2D" parent="Sprite2D2/AnimatedSprite2D" instance=ExtResource("3_5xkf6")] +material = null position = Vector2(6, -11) -scale = Vector2(1.54492, 1.69531) -texture = SubResource("GradientTexture2D_wi77g") [node name="CursorCandle" parent="." instance=ExtResource("3_f606e")] position = Vector2(1206, 675) diff --git a/src/dev-util/savegame.gd b/src/dev-util/savegame.gd index 7d83cb5..fd1abe3 100644 --- a/src/dev-util/savegame.gd +++ b/src/dev-util/savegame.gd @@ -21,10 +21,11 @@ var _is_initialised: bool = false set(value): mementos_complete = value if _is_initialised: changed.emit() -@export var board_state: Dictionary = {"cards": {}, "stickies": {}}: +@export var board_state: Dictionary = {"cards": {}, "stickies": {}, "randoms": []}: set(value): board_state = value if _is_initialised: changed.emit() +@export var is_childhood_board_complete: bool = false @export var thumbnail: Texture = preload("res://import/interface-elements/empty_save_slot.png"): set(value): thumbnail = value @@ -84,6 +85,7 @@ func read_save_file(): parsed["current_room"] is float and parsed["mementos_complete"] is float and parsed["board_state"] is Dictionary and + parsed["is_childhood_board_complete"] is bool and parsed["last_saved"] is float and parsed["demo"] is bool and last_saved != 0 ) @@ -100,15 +102,19 @@ func read_save_file(): var cards: Dictionary[StringName, Variant] var stickies: Dictionary[StringName, Variant] + var randoms: Array[StringName] for cardname:String in board_state["cards"]: cards[StringName(cardname)] = board_state["cards"][cardname] for sticky_name:String in board_state["stickies"]: stickies[StringName(sticky_name)] = board_state["stickies"][sticky_name] + for random_name:StringName in board_state["randoms"]: + randoms.append( board_state["randoms"][random_name] ) board_state = { "cards": cards, - "stickies": stickies + "stickies": stickies, + "randoms": randoms } is_valid = are_types_valid \ @@ -131,6 +137,7 @@ func _get_save_dict() -> Dictionary: "current_room": current_room, "mementos_complete": mementos_complete, "board_state": board_state, + "is_childhood_board_complete": is_childhood_board_complete, "last_saved": last_saved, "is_demo": is_demo } diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 133916c..8233b42 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -146,7 +146,7 @@ func _ready(): #last_save_dict = get_save_dict() -func reclaim_lost_focus(): +func reclaim_lost_focus(_thief): if has_stage: grab_focus() @@ -496,13 +496,13 @@ func get_save_dict() -> Dictionary: # Save position of Card. cards[child.name] = child.transform.origin if child.picked_random: - randoms.append(child) + randoms.append(child.name) if child.has_sticky_note_attached(): # Saves Card Name as position of it's children. stickies[child.get_attached_sticky_note().name] = child.name if child.get_attached_sticky_note().picked_random: - randoms.append(child.get_attached_sticky_note().card_id) + randoms.append(child.get_attached_sticky_note().name) elif child is StickyNote: # Save position of StickyNote. @@ -532,7 +532,7 @@ func rebuild_from_savedict(board_state:Dictionary): if board_state["stickies"] != {} : stickies = board_state["stickies"] var randoms: Array[StringName] - if board_state["randoms"] != {} : + if board_state["randoms"] != [] : randoms = board_state["randoms"] if cards == null and stickies == null: return diff --git a/src/logic-scenes/board/card.gd b/src/logic-scenes/board/card.gd index 335c08f..98a0c27 100644 --- a/src/logic-scenes/board/card.gd +++ b/src/logic-scenes/board/card.gd @@ -4,6 +4,13 @@ class_name Card var card_id +enum burned { + NOT, + SINGED, + BURNING, + TORCHED +} + #FIXME remove this legacy stuff without loosing the evil notes ... var compatible_sticky_notes: Array[StickyNote] = [] @export var evil_sticky_notes: Array[StickyNote] = [] @@ -65,7 +72,57 @@ var background_sprite: AnimatedSprite2D @export var voice_line: AudioStream = null @export var is_dragable: bool = false @export var diameter = 336.0 +@export_range(0, 2) var burn_progress: float = 0: + set(burn): + if is_node_ready(): + if burn > 0 and background_sprite.material == null: + if background_sprite != null: + background_sprite.material = crumble_material.duplicate() + add_child(card_fire, false, Node.INTERNAL_MODE_FRONT) + card_fire.material = card_fire.material.duplicate() + elif burn_progress > 0 and burn <= 0: + background_sprite.material.set_shader_parameter("fire_progression", 0) + card_fire.material.set_shader_parameter("fire_progression", 0) + background_sprite.material = null + remove_child(card_fire) + + burn_progress = burn + if background_sprite != null and card_fire != null and burn_progress > 0: + background_sprite.material.set_shader_parameter("fire_progression", burn_progress) + card_fire.material.set_shader_parameter("fire_progression", burn_progress) + background_sprite.visible = burn_progress < 2 + card_fire.visible = burn_progress < 2 + label.modulate = Color.WHITE.lerp(Color(0,0,0,0), clampf(burn_progress*3-3, 0, 1)) +var burn_tween: Tween +signal has_burned +@export var burn_state: burned = burned.NOT: + set(burning): + if burning != burn_state: + if burn_tween != null: + burn_tween.kill() + match burning: + burned.NOT: + burn_tween = get_tree().create_tween() + burn_tween.tween_property(self, "burn_progress", 0, 0.5) + burned.SINGED: + burn_tween = get_tree().create_tween() + burn_tween.set_ease(Tween.EASE_OUT) + burn_tween.set_trans(Tween.TRANS_SINE) + burn_tween.tween_property(self, "burn_progress", 0.5, 2) + burned.BURNING: + burn_tween = get_tree().create_tween() + burn_tween.tween_property(self, "burn_progress", 2.0, 2) + burn_tween.tween_callback(_torch).set_delay(1.0) + burned.TORCHED: + has_burned.emit() + burn_state = burning + +func _torch(): + burn_state = burned.TORCHED + +var crumble_material: ShaderMaterial = preload("res://logic-scenes/card_burner/card_crumble.material") +var card_fire: Sprite2D = preload("res://logic-scenes/card_burner/card_fire.tscn").instantiate() var sticky_note_position: Vector2 = Vector2(-66, 83) var collider: Shape2D @@ -92,6 +149,7 @@ func _ready(): background_sprite = AnimatedSprite2D.new() background_sprite.sprite_frames = preload("res://logic-scenes/board/card-textures/card-sprites.tres") + background_sprite.clip_children = CanvasItem.CLIP_CHILDREN_AND_DRAW label = Label.new() label.theme_type_variation = "card_text" @@ -124,7 +182,6 @@ func _on_text_updated(): if text == "": if background_sprite.get_child_count() == 0: background_sprite.add_child(load("res://logic-scenes/board/void_stuff.tscn").instantiate(), false, Node.INTERNAL_MODE_DISABLED) - background_sprite.clip_children = CanvasItem.CLIP_CHILDREN_AND_DRAW else: if background_sprite.get_child_count() > 0: background_sprite.get_child(0).queue_free() @@ -136,6 +193,8 @@ func _on_text_updated(): label.rotation = deg_to_rad(transfor_arr[curr_frame].get_rotation()) label.position = transfor_arr[curr_frame].origin + burn_progress = burn_progress + if not Engine.is_editor_hint(): _handle_wiggle(0) @@ -186,6 +245,8 @@ func _on_mouse_entered(): func _on_mouse_exited(): highlighted = false is_mouse_entered = false + if burn_state == burned.SINGED: + burn_state = burned.NOT func _on_input_event(_viewport, event, _shape_idx): diff --git a/src/logic-scenes/board/physics-board.tscn b/src/logic-scenes/board/physics-board.tscn index 6cc95c6..4c16f7c 100644 --- a/src/logic-scenes/board/physics-board.tscn +++ b/src/logic-scenes/board/physics-board.tscn @@ -22,6 +22,9 @@ size = Vector2(4262, 766.5) [sub_resource type="RectangleShape2D" id="RectangleShape2D_ivo5o"] size = Vector2(4249, 766.5) +[sub_resource type="Animation" id="Animation_qjqy3"] +length = 0.001 + [sub_resource type="Animation" id="Animation_2qppy"] resource_name = "complete" length = 14.5 @@ -79,9 +82,6 @@ tracks/0/keys = { } tracks/0/use_blend = true -[sub_resource type="Animation" id="Animation_qjqy3"] -length = 0.001 - [sub_resource type="AnimationLibrary" id="AnimationLibrary_htay1"] _data = { &"RESET": SubResource("Animation_qjqy3"), diff --git a/src/logic-scenes/card_burner/card_burner.gd b/src/logic-scenes/card_burner/card_burner.gd index 11abff2..8672220 100644 --- a/src/logic-scenes/card_burner/card_burner.gd +++ b/src/logic-scenes/card_burner/card_burner.gd @@ -6,7 +6,7 @@ var has_stage = false: if focus: process_mode = Node.PROCESS_MODE_INHERIT self.show() - self.mouse_filter = Control.MOUSE_FILTER_STOP + self.mouse_filter = Control.MOUSE_FILTER_PASS else: self.mouse_filter = Control.MOUSE_FILTER_IGNORE self.hide() @@ -14,13 +14,42 @@ var has_stage = false: has_stage = focus func _ready(): - Scenes.sign_up_for_sequence(burn_cards, Scenes.id.TRANSITION, 0) + Scenes.sign_up_for_sequence(burn_cards, Scenes.id.TRANSITION, 1) + %SkipButton.pressed.connect(card_burned.emit) -func burn_cards(): - var random_card_names: Array[StringName] = State.active_save_game.board_state["randoms"] +func burn_cards(_id, _repeat): + var random_card_names: Array = State.active_save_game.board_state["randoms"] for card_name in random_card_names: - if card_name.begins_with("c"): + if card_name.begins_with("p"): random_card_names.erase(card_name) - var random_cards: Array[Card] = HardCards.get_cards_by_name_array(random_card_names)["cards"] + var random_cards: Array = HardCards.get_cards_by_name_array(random_card_names)["cards"] + + random_cards.shuffle() + + for ancor:Control in [%Ancor1, %Ancor2, %Ancor3, %Ancor4]: + if random_cards.size() > 0: + ancor.get_child(0).queue_free() + var new_child: Card = random_cards.pop_front() + ancor.add_child(new_child) + new_child.owner = self + new_child.has_burned.connect(card_burned.emit) + + await card_burned + $AnimationPlayer.play("vanish") + await $AnimationPlayer.animation_finished + + + Scenes.continue_sequence(self) + +signal card_burned + +func handle_hover(to_handle: Area2D): + if to_handle is Card: + if to_handle.burn_state == Card.burned.NOT: + to_handle.burn_state = Card.burned.SINGED + +func handle_mouse_button(event: InputEventMouseButton, card: Card): + if event.button_index == MOUSE_BUTTON_MASK_LEFT and event.is_pressed() and not event.is_echo(): + card.burn_state = Card.burned.BURNING diff --git a/src/logic-scenes/card_burner/card_burner.tscn b/src/logic-scenes/card_burner/card_burner.tscn index 3bb1d47..7a26457 100644 --- a/src/logic-scenes/card_burner/card_burner.tscn +++ b/src/logic-scenes/card_burner/card_burner.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://g2a27jwdapai"] +[gd_scene load_steps=13 format=3 uid="uid://g2a27jwdapai"] [ext_resource type="Script" uid="uid://bbia2hcdwctyn" path="res://logic-scenes/card_burner/card_burner.gd" id="1_copuj"] [ext_resource type="Script" uid="uid://2loic2eeec5b" path="res://logic-scenes/board/card.gd" id="2_l4ogr"] @@ -6,16 +6,60 @@ [ext_resource type="PackedScene" uid="uid://uc6urpgv7n1y" path="res://logic-scenes/card_burner/cursor_candle.tscn" id="3_l4ogr"] [ext_resource type="Script" uid="uid://bbs1u7ojno7xo" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="4_x6cxt"] -[sub_resource type="InputEventKey" id="InputEventKey_23lqb"] +[sub_resource type="InputEventKey" id="InputEventKey_ckmi5"] device = -1 physical_keycode = 88 unicode = 120 -[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_57mhv"] +[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_x6cxt"] device = -1 button_index = 2 pressed = true +[sub_resource type="Gradient" id="Gradient_ckmi5"] +colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_x6cxt"] +gradient = SubResource("Gradient_ckmi5") +width = 100 +height = 100 + +[sub_resource type="Animation" id="Animation_23lqb"] +resource_name = "vanish" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:self_modulate") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] +} + +[sub_resource type="Animation" id="Animation_57mhv"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("../Sprite2D:self_modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_kaqqi"] +_data = { +&"RESET": SubResource("Animation_57mhv"), +&"vanish": SubResource("Animation_23lqb") +} + [node name="CardBurner" type="CenterContainer"] anchors_preset = 15 anchor_right = 1.0 @@ -46,6 +90,7 @@ You may try to burn one." horizontal_alignment = 1 [node name="Ancor1" type="Control" parent="Control"] +unique_name_in_owner = true layout_mode = 2 anchors_preset = 0 offset_left = -518.0 @@ -57,10 +102,10 @@ rotation = -0.0352522 [node name="Card" type="Area2D" parent="Control/Ancor1"] script = ExtResource("2_l4ogr") text = "card" -picked_random = null metadata/_custom_type_script = "uid://2loic2eeec5b" [node name="Ancor2" type="Control" parent="Control"] +unique_name_in_owner = true layout_mode = 2 anchors_preset = 0 offset_left = -183.0 @@ -72,10 +117,10 @@ rotation = 0.0120591 [node name="card" type="Area2D" parent="Control/Ancor2"] script = ExtResource("2_l4ogr") text = "card" -picked_random = null metadata/_custom_type_script = "uid://2loic2eeec5b" [node name="Ancor3" type="Control" parent="Control"] +unique_name_in_owner = true layout_mode = 2 anchors_preset = 0 offset_left = 153.0 @@ -87,10 +132,10 @@ rotation = -0.0139755 [node name="card" type="Area2D" parent="Control/Ancor3"] script = ExtResource("2_l4ogr") text = "card" -picked_random = null metadata/_custom_type_script = "uid://2loic2eeec5b" [node name="Ancor4" type="Control" parent="Control"] +unique_name_in_owner = true layout_mode = 2 anchors_preset = 0 offset_left = 495.0 @@ -102,7 +147,6 @@ rotation = 0.0245775 [node name="card" type="Area2D" parent="Control/Ancor4"] script = ExtResource("2_l4ogr") text = "card" -picked_random = null metadata/_custom_type_script = "uid://2loic2eeec5b" [node name="HSplitContainer" type="HSplitContainer" parent="Control"] @@ -121,15 +165,27 @@ layout_mode = 2 size_flags_horizontal = 3 texture = ExtResource("3_ckmi5") expand_mode = 2 -stretch_mode = 4 +stretch_mode = 5 script = ExtResource("4_x6cxt") action = "skip" icon = 0 -events = Array[InputEvent]([null, SubResource("InputEventKey_23lqb"), SubResource("InputEventJoypadButton_57mhv")]) +events = Array[InputEvent]([null, SubResource("InputEventKey_ckmi5"), SubResource("InputEventJoypadButton_x6cxt")]) metadata/_custom_type_script = "uid://bbs1u7ojno7xo" -[node name="Button" type="Button" parent="Control/HSplitContainer"] +[node name="SkipButton" type="Button" parent="Control/HSplitContainer"] +unique_name_in_owner = true layout_mode = 2 text = "Keep all thoughts" +[node name="Sprite2D" type="Sprite2D" parent="Control"] +self_modulate = Color(1, 1, 1, 0) +scale = Vector2(100, 100) +texture = SubResource("GradientTexture2D_x6cxt") + [node name="CursorCandle" parent="." instance=ExtResource("3_l4ogr")] + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +root_node = NodePath("../Control/HSplitContainer") +libraries = { +&"": SubResource("AnimationLibrary_kaqqi") +} diff --git a/src/logic-scenes/card_burner/card_crumble.gdshader b/src/logic-scenes/card_burner/card_crumble.gdshader new file mode 100644 index 0000000..385a37a --- /dev/null +++ b/src/logic-scenes/card_burner/card_crumble.gdshader @@ -0,0 +1,59 @@ +shader_type canvas_item; + +uniform float fire_progression = 0; +uniform sampler2D disp_noise: repeat_enable; +uniform sampler2D crackle_noise: repeat_enable; +uniform sampler2D ash_gradient: repeat_disable; + + +vec3 RNGV3(vec3 p) { + vec3 a = fract(sin(vec3(p.x, p.y, p.z)) * vec3(111.11,333.33,444.44)); + a += dot(a, a+33.51); + return fract(vec3(a.x*a.y, a.y*a.z, a.z*a.x)); //outputs a random vec2 between 0 and 1 +} + +vec4 voronoy(vec3 loc, float scale){ + loc = loc*scale; + vec4 output = vec4(0., 0., 0., 10.); + for(float y=-1.; y<=1.; y++){ + for(float x=-1.; x<=1.; x++){ + for(float z=-1.; z<=1.; z++){ + vec3 offs = vec3(x,y,z); + vec3 n = RNGV3(floor(loc)+offs)*2.0-1.0; + vec3 p = offs+sin(n) * .5; + float d = length((fract(loc)-0.5)-p); + if(d void: position = get_viewport().get_mouse_position() + noise_offset rotation = lerp(rotation, clamp(-PI/3, diff.x *.05, PI/3), delta*20.0) - lifetime = lerp(lifetime, .25 * (1.0/(1.0+diff.length()*.1) - noise_offset.length()*.02), 0.2) + lifetime = max(0.01, lerp(lifetime, .25 * (1.0/(1.0+diff.length()*.1) - noise_offset.length()*.02), 0.2)) " [node name="CursorCandle" type="CPUParticles2D"]