87 lines
2.6 KiB
GDScript
87 lines
2.6 KiB
GDScript
extends CanvasLayer
|
|
|
|
@warning_ignore("unused_signal")
|
|
signal exit(arg)
|
|
|
|
@onready var wheel = $Wheel as Wheel2D
|
|
@onready var wheel_sfx = $"Sfx转盘齿轮"
|
|
@onready var sfx_success = $"Sfx转动完成"
|
|
@onready var wheel_sprite = $"转盘" as AnimatedSprite2D
|
|
@onready var hand_sprite = $"手" as Node2D
|
|
@onready var animation_player = $AnimationPlayer as AnimationPlayer
|
|
|
|
# c03_meat_grinder: 0:初始化 1:已装转盘 2:绞肉机演出 3:演出结束
|
|
var stage := 0
|
|
|
|
|
|
func _ready() -> void:
|
|
stage = EventManager.get_stage("c03_meat_grinder")
|
|
layer = GlobalConfig.CANVAS_LAYER_LITTLE_GAME
|
|
if stage == 0:
|
|
# 需要装转盘
|
|
SceneManager.pop_center_notification("ui_center_notify_c03绞肉机缺少转轮")
|
|
wheel_sprite.hide()
|
|
elif stage == 1:
|
|
# 演出并传送到胖子游戏
|
|
_wheel_placed_and_show()
|
|
elif stage == 2:
|
|
SceneManager.pop_center_notification("ui_center_notify_drag_to_rotate")
|
|
wheel_sprite.show()
|
|
# 需连接转动信号
|
|
wheel.rotated.connect(_on_wheel_rotated)
|
|
elif stage == 3:
|
|
# 无需转动
|
|
wheel_sprite.show()
|
|
|
|
|
|
var rotationg_steps := 0
|
|
const TOTAL_STEPS = 6 * 3 # 转 3 圈
|
|
|
|
|
|
func _on_wheel_rotated(_radiant: float) -> void:
|
|
if rotationg_steps >= TOTAL_STEPS:
|
|
return
|
|
if not wheel_sfx.playing:
|
|
wheel_sfx.play()
|
|
rotationg_steps += 1
|
|
wheel_sprite.frame = wrapi(wheel_sprite.frame + 1, 0, 3)
|
|
if rotationg_steps == TOTAL_STEPS:
|
|
# 成功
|
|
sfx_success.play()
|
|
animation_player.play("catch_fragments")
|
|
await animation_player.animation_finished
|
|
animation_player.play("hand_swinging")
|
|
var c03_mem = $"二章结尾回忆" as Node2D
|
|
c03_mem.exit.connect(exit.emit)
|
|
c03_mem.show()
|
|
c03_mem.modulate.a = 0.0
|
|
await Util.wait(2.0)
|
|
DialogueManager.show_dialogue_balloon(
|
|
GlobalConfig.DIALOG_C03, "c03_绞肉机回忆小蝶和小婵1", [GlobalConfig.DIALOG_IGNORE_INPUT]
|
|
)
|
|
var tween = create_tween()
|
|
tween.tween_interval(3.0)
|
|
tween.tween_property(c03_mem, "modulate:a", 1.0, 3.0)
|
|
await DialogueManager.dialogue_ended
|
|
if tween and tween.is_running():
|
|
await tween.finished
|
|
c03_mem.start_show()
|
|
|
|
|
|
func _wheel_placed_and_show() -> void:
|
|
wheel_sprite.show()
|
|
#TODO 演出,结束后传送到胖子游戏
|
|
SceneManager.get_ground_loader().transition_to_scene("c03_s10", "left")
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if stage == 0 and event.is_action_pressed("interact"):
|
|
get_viewport().set_input_as_handled()
|
|
var prop = SceneManager.get_current_prop()
|
|
if prop == "prop_转轮":
|
|
SceneManager.disable_prop_item("prop_转轮")
|
|
EventManager.set_stage("c03_meat_grinder", 1)
|
|
_wheel_placed_and_show()
|
|
else:
|
|
SceneManager.get_prop_hud().on_toggle_invalid_prop()
|