xiandie/scene/ground/scene/c03/s11_胖子游戏2.gd

88 lines
2.5 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@tool
extends AnimationRoot
# 覆盖该方法
func _default_data() -> Dictionary:
return {"has_entered": false}
func _ready() -> void:
super._ready()
if Engine.is_editor_hint():
return
#region node_reference
var meat_hill: Node2D
var player: MainPlayer
#endregion
# 读取设置变量名
func _setup_node_reference() -> void:
meat_hill = $"../DeployLayer/肉山" as Node2D
player = SceneManager.get_player() as MainPlayer
func _on_ground_ready() -> void:
_check_first_enter()
func _check_first_enter() -> void:
if not data["has_entered"]:
var x = $"../DeployLayer/portal_left".global_position.x
SceneManager.get_player().global_position.x = x
SceneManager.get_player().set_facing_direction(Vector2.RIGHT)
SceneManager.lock_player(0, 6, true)
set_data("has_entered", true)
await SceneManager.pause_and_hide_player_sprite(1.5)
await SceneManager.get_player().animation_finished
SceneManager.unlock_player()
func talk_with_npc() -> void:
$"../DeployLayer/Ambush对话探子".enabled = false
SceneManager.lock_player()
$"../DeployLayer/Pro探子".flip_h = false
var camera = SceneManager.get_camera_marker()
DialogueManager.show_dialogue_balloon(GlobalConfig.DIALOG_C03, "c03_胖子游戏对白")
var tween = create_tween()
tween.tween_property(camera, "force_offset:x", 100.0, 2.0)
await DialogueManager.dialogue_ended
tween = create_tween()
tween.tween_property(camera, "force_offset:x", 0.0, 1.5)
await Util.wait(1.0)
SceneManager.unlock_player()
await Util.wait(2.0)
# 天上掉肉
tween = create_tween()
meat_hill.global_position.x = player.global_position.x
var start_y = meat_hill.global_position.y
var target_y = player.global_position.y
# 伪自由落体2.0 s从 start_y tween 到 target_y
tween.tween_method(_drop_meat.bind(start_y, target_y), 0.0, 1.0, 1.0)
await tween.finished
camera.shake_camera()
SceneManager.lock_player()
# TODO
SceneManager.pop_debug_dialog_info("音效", "肉山掉落")
$"Sfx肉山掉落".play()
await Util.wait(3.0)
# 转场
SceneManager.unlock_player()
SceneManager.get_ground_loader().transition_to_scene("c03_s12", "left")
func _drop_meat(progress: float, start_y: float, target_y: float) -> void:
# 伪自由落体2.0 s从 start_y tween 到 target_y
# progress 先慢后快
progress = progress * progress * progress
var y = start_y + (target_y - start_y) * progress
meat_hill.global_position.y = y
meat_hill.global_position.x = player.global_position.x
func _on_timer_lightning_timeout() -> void:
# 打雷循环
var wait = randf_range(5, 30)
$"Timer打雷".start(wait)