feat: choice system
This commit is contained in:
@ -43,6 +43,6 @@ one_shot = true
|
||||
ignore_time_scale = true
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
|
||||
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]
|
||||
[connection signal="timeout" from="KillAfter" to="." method="_on_kill_after_timeout"]
|
||||
|
90
dialogues/choice.gd
Normal file
90
dialogues/choice.gd
Normal file
@ -0,0 +1,90 @@
|
||||
extends Node
|
||||
|
||||
@onready var bubbles: HBoxContainer = %Bubbles
|
||||
@onready var bubbles_back: TileMapLayer = %BubblesBack
|
||||
@onready var bubbles_interior: TileMapLayer = %BubblesInterior
|
||||
@onready var bubble_label: RichTextLabel = %BubbleLabel
|
||||
|
||||
@onready var ui_flicker_timer: Timer = $UIFlickerTimer
|
||||
@onready var e_ui_button: TextureRect = %E
|
||||
@onready var next_label: Label = %NextLabel
|
||||
|
||||
@onready var choices_container: MarginContainer = %ChoicesContainer
|
||||
@onready var accept_indicator: ColorRect = %AcceptIndicator
|
||||
@onready var accept_label: Label = %AcceptLabel
|
||||
@onready var reject_indicator: ColorRect = %RejectIndicator
|
||||
@onready var reject_label: Label = %RejectLabel
|
||||
|
||||
@export_multiline var choice = ""
|
||||
@export var accept_option = ""
|
||||
@export var reject_option = ""
|
||||
|
||||
@onready var wait_a_sec: Timer = $WaitASec
|
||||
|
||||
signal accepted
|
||||
signal rejected
|
||||
|
||||
var is_accept_selected = true
|
||||
var is_choice_happening = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not is_choice_happening:
|
||||
return
|
||||
|
||||
if Input.is_action_just_pressed("move_right"):
|
||||
is_accept_selected = false
|
||||
update_ui()
|
||||
|
||||
if Input.is_action_just_pressed("move_left"):
|
||||
is_accept_selected = true
|
||||
update_ui()
|
||||
|
||||
if Input.is_action_just_pressed("interact"):
|
||||
stop_choice()
|
||||
|
||||
|
||||
func update_ui():
|
||||
accept_indicator.visible = is_accept_selected
|
||||
reject_indicator.visible = not is_accept_selected
|
||||
|
||||
func toggle_ui():
|
||||
e_ui_button.visible = not e_ui_button.visible
|
||||
|
||||
func start_choice():
|
||||
bubbles.visible = true
|
||||
bubbles_back.visible = true
|
||||
bubbles_interior.visible = true
|
||||
bubble_label.visible = true
|
||||
e_ui_button.visible = true
|
||||
next_label.visible = true
|
||||
choices_container.visible = true
|
||||
|
||||
accept_label.text = accept_option
|
||||
reject_label.text = reject_option
|
||||
|
||||
is_accept_selected = true
|
||||
update_ui()
|
||||
|
||||
wait_a_sec.start()
|
||||
|
||||
func stop_choice():
|
||||
is_choice_happening = false
|
||||
|
||||
ui_flicker_timer.stop()
|
||||
|
||||
bubbles.visible = false
|
||||
bubbles_back.visible = false
|
||||
bubbles_interior.visible = false
|
||||
bubble_label.visible = false
|
||||
e_ui_button.visible = false
|
||||
next_label.visible = false
|
||||
choices_container.visible = false
|
||||
|
||||
if is_accept_selected:
|
||||
accepted.emit()
|
||||
else:
|
||||
rejected.emit()
|
||||
|
||||
func _on_wait_a_sec_timeout() -> void:
|
||||
is_choice_happening = true
|
||||
ui_flicker_timer.start()
|
1
dialogues/choice.gd.uid
Normal file
1
dialogues/choice.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b65dvbdgyplnm
|
17
dialogues/choice.tscn
Normal file
17
dialogues/choice.tscn
Normal file
@ -0,0 +1,17 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c2axd06m2g28y"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b65dvbdgyplnm" path="res://dialogues/choice.gd" id="1_ht8c8"]
|
||||
|
||||
[node name="Choice" type="Node"]
|
||||
script = ExtResource("1_ht8c8")
|
||||
|
||||
[node name="UIFlickerTimer" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
ignore_time_scale = true
|
||||
|
||||
[node name="WaitASec" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
|
||||
[connection signal="timeout" from="UIFlickerTimer" to="." method="toggle_ui"]
|
||||
[connection signal="timeout" from="WaitASec" to="." method="_on_wait_a_sec_timeout"]
|
@ -13,7 +13,6 @@ extends Node
|
||||
@onready var e_ui_button: TextureRect = %E
|
||||
@onready var next_label: Label = %NextLabel
|
||||
|
||||
|
||||
@export_multiline var dialogue = ""
|
||||
@export var start_with_left = false
|
||||
@export var left_picture: Texture2D
|
||||
@ -31,7 +30,6 @@ func _ready() -> void:
|
||||
is_left_speaking = start_with_left
|
||||
left_speaker.texture = left_picture
|
||||
right_speaker.texture = right_picture
|
||||
display_profiles()
|
||||
|
||||
e_ui_button.visible = false
|
||||
next_label.visible = false
|
||||
@ -70,15 +68,18 @@ func load_next_dialogue():
|
||||
|
||||
func on_dialogue_started():
|
||||
bubbles.visible = true
|
||||
bubble_label.visible = true
|
||||
bubbles_back.visible = true
|
||||
bubbles_interior.visible = true
|
||||
|
||||
display_profiles()
|
||||
is_dialogue_ongoing = true
|
||||
time_between_letters.start()
|
||||
load_next_dialogue()
|
||||
|
||||
func end_dialogue():
|
||||
bubbles.visible = false
|
||||
bubble_label.visible = false
|
||||
bubbles_back.visible = false
|
||||
bubbles_interior.visible = false
|
||||
e_ui_button.visible = false
|
||||
|
24
main.gd
24
main.gd
@ -8,6 +8,7 @@ var active_camera: SuperCamera
|
||||
@onready var opening_fade_to_black: ColorRect = $OpeningFadeToBlack
|
||||
|
||||
@onready var opening_cutscene: AnimationPlayer = $OpeningCutscene
|
||||
@onready var dance_cutscene: AnimationPlayer = $DanceCutscene
|
||||
|
||||
@onready var background_far: TileMapLayer = $BackgroundFar
|
||||
@onready var background_middle: TileMapLayer = $BackgroundMiddle
|
||||
@ -15,10 +16,12 @@ var active_camera: SuperCamera
|
||||
@onready var foreground_far: TileMapLayer = $ForegroundFar
|
||||
|
||||
@export_group("Parallax")
|
||||
@export var parallax_far = 0.1
|
||||
@export var parallax_middle = 0.3
|
||||
@export var parallax_close = 0.5
|
||||
@export var foreground = 0.8
|
||||
@export var parallax_far = 0.5
|
||||
@export var parallax_middle = 0.4
|
||||
@export var parallax_close = 0.3
|
||||
@export var foreground = 0.2
|
||||
|
||||
@onready var choices_container: MarginContainer = %ChoicesContainer
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
@ -39,9 +42,22 @@ func _process(delta: float) -> void:
|
||||
next_dialogue.global_position.x = active_camera.global_position.x + 133.0
|
||||
bubbles_back.global_position.x = active_camera.global_position.x
|
||||
bubbles_interior.global_position.x = active_camera.global_position.x
|
||||
choices_container.global_position.x = active_camera.global_position.x - 100
|
||||
|
||||
background_far.global_position.x = active_camera.global_position.x * parallax_far
|
||||
background_middle.global_position.x = active_camera.global_position.x * parallax_middle
|
||||
background_close.global_position.x = active_camera.global_position.x * parallax_close
|
||||
foreground_far.global_position.x = active_camera.global_position.x * foreground
|
||||
|
||||
|
||||
func _on_start_dancing() -> void:
|
||||
dance_cutscene.play("dance")
|
||||
|
||||
func restart_at_first_scene():
|
||||
pass
|
||||
|
||||
func to_main_menu():
|
||||
pass
|
||||
|
||||
func quit_game():
|
||||
pass
|
||||
|
BIN
player/assets/Danse.png
(Stored with Git LFS)
Normal file
BIN
player/assets/Danse.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
player/assets/Danse.png.import
Normal file
34
player/assets/Danse.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dv7jhtoptk12r"
|
||||
path="res://.godot/imported/Danse.png-360f9d75971dc28cdb901fbcce9ab403.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://player/assets/Danse.png"
|
||||
dest_files=["res://.godot/imported/Danse.png-360f9d75971dc28cdb901fbcce9ab403.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
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/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
|
BIN
player/assets/RunArmeEpee.png
(Stored with Git LFS)
Normal file
BIN
player/assets/RunArmeEpee.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
player/assets/RunArmeEpee.png.import
Normal file
34
player/assets/RunArmeEpee.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dxsbbcagqkiid"
|
||||
path="res://.godot/imported/RunArmeEpee.png-53c014bb63270f9d7b7a1a264ad4311e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://player/assets/RunArmeEpee.png"
|
||||
dest_files=["res://.godot/imported/RunArmeEpee.png-53c014bb63270f9d7b7a1a264ad4311e.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
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/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
|
@ -11,17 +11,14 @@ var jump_velocity = 400.0
|
||||
@export_range(0, 10, 0.1, "or_greater")
|
||||
var gravity_modifier = 1
|
||||
|
||||
@onready var knight: AnimatedSprite2D = $Knight
|
||||
@onready var base: AnimatedSprite2D = $Base
|
||||
|
||||
var animated_sprites = []
|
||||
var current_sprite: AnimatedSprite2D
|
||||
|
||||
var is_in_cutscene = false # back to true on build
|
||||
var current_animation = "idle"
|
||||
|
||||
func play_anim():
|
||||
for sprite: AnimatedSprite2D in animated_sprites:
|
||||
sprite.play(current_animation)
|
||||
current_sprite.play(current_animation)
|
||||
|
||||
func play_anim_run():
|
||||
current_animation = "run"
|
||||
@ -31,31 +28,29 @@ func play_anim_idle():
|
||||
|
||||
func play_anim_jump():
|
||||
current_animation = "jump"
|
||||
|
||||
func play_anim_dance():
|
||||
current_animation = "dance"
|
||||
|
||||
func set_in_cutscene():
|
||||
is_in_cutscene = true
|
||||
play_anim_idle()
|
||||
|
||||
func set_in_play():
|
||||
is_in_cutscene = false
|
||||
|
||||
func look_left():
|
||||
for sprite in animated_sprites:
|
||||
sprite.flip_h = true
|
||||
current_sprite.flip_h = true
|
||||
|
||||
func look_right():
|
||||
for sprite in animated_sprites:
|
||||
sprite.flip_h = false
|
||||
current_sprite.flip_h = false
|
||||
|
||||
func _ready() -> void:
|
||||
animated_sprites = [
|
||||
knight,
|
||||
base
|
||||
]
|
||||
current_sprite = base
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
play_anim()
|
||||
if is_in_cutscene:
|
||||
play_anim_idle()
|
||||
velocity.x = move_toward(velocity.x, 0, speed)
|
||||
move_and_slide()
|
||||
return
|
||||
@ -70,7 +65,6 @@ func _physics_process(delta: float) -> void:
|
||||
if direction < 0 and is_on_floor():
|
||||
look_left()
|
||||
|
||||
|
||||
if not is_on_floor():
|
||||
current_animation = "got_hit"
|
||||
else:
|
||||
@ -94,3 +88,11 @@ func _on_dialogue_manager_dialogue_ended() -> void:
|
||||
|
||||
func _on_trigger_dialogue_body_entered(body: Node2D) -> void:
|
||||
set_in_cutscene()
|
||||
|
||||
func _on_start_dancing() -> void:
|
||||
play_anim_dance()
|
||||
|
||||
func _on_npc_shield_dialogue_dialogue_ended() -> void:
|
||||
set_in_play()
|
||||
print("jget shield")
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=30 format=3 uid="uid://yvp44oauis4n"]
|
||||
[gd_scene load_steps=45 format=3 uid="uid://yvp44oauis4n"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c1fqj3lba7wik" path="res://player/player.gd" id="1_yw30f"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://i6035vm5ited" path="res://player/armored_spritesheet.tres" id="2_qjkh3"]
|
||||
[ext_resource type="Texture2D" uid="uid://dv7jhtoptk12r" path="res://player/assets/Danse.png" id="3_hg6s5"]
|
||||
[ext_resource type="Texture2D" uid="uid://dwn548x0n4bpd" path="res://player/assets/Outch.png" id="3_rgyib"]
|
||||
[ext_resource type="Texture2D" uid="uid://dr5ypp4q8n2xm" path="res://player/assets/DebutIdle.png" id="4_rgyib"]
|
||||
[ext_resource type="Texture2D" uid="uid://dsxvqsh3umw01" path="res://player/assets/RunCycle.png" id="5_boad6"]
|
||||
@ -9,6 +10,62 @@
|
||||
[ext_resource type="Shape2D" uid="uid://6rhdwj5jxbxn" path="res://player/player_collision.tres" id="5_qjkh3"]
|
||||
[ext_resource type="Texture2D" uid="uid://dw6tn0grt2ajc" path="res://player/assets/WalkCycle.png" id="5_rgyib"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tqiix"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e7oew"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(32, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_c35mf"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(64, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_65viv"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(96, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_x7c3f"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(128, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bjvpn"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(160, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_s7qer"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(192, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ge24q"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(224, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pnw6m"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(256, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1so5t"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(288, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_55jnj"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(320, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dx5ib"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(352, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a2xo5"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(384, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_art4l"]
|
||||
atlas = ExtResource("3_hg6s5")
|
||||
region = Rect2(416, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hg6s5"]
|
||||
atlas = ExtResource("3_rgyib")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
@ -93,6 +150,53 @@ region = Rect2(352, 0, 32, 32)
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tqiix")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_e7oew")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_c35mf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_65viv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_x7c3f")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bjvpn")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_s7qer")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ge24q")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pnw6m")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1so5t")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_55jnj")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dx5ib")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_a2xo5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_art4l")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"dance",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_hg6s5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
@ -191,9 +295,9 @@ autoplay = "idle"
|
||||
[node name="Base" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(0, -16)
|
||||
sprite_frames = SubResource("SpriteFrames_mmwog")
|
||||
animation = &"got_hit"
|
||||
animation = &"dance"
|
||||
autoplay = "idle"
|
||||
frame_progress = 0.993718
|
||||
frame_progress = 0.0683317
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
|
BIN
world_assets/Armoire.png
(Stored with Git LFS)
Normal file
BIN
world_assets/Armoire.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
world_assets/Armoire.png.import
Normal file
34
world_assets/Armoire.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://rbj0av8dvm2e"
|
||||
path="res://.godot/imported/Armoire.png-62a56be0dd5d8aab64da1c1f213a9e8a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://world_assets/Armoire.png"
|
||||
dest_files=["res://.godot/imported/Armoire.png-62a56be0dd5d8aab64da1c1f213a9e8a.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
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/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
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user