2024-12-23 01:29:31 +00:00
|
|
|
|
extends Node
|
|
|
|
|
|
2024-12-30 13:19:10 +00:00
|
|
|
|
enum VIBE {
|
|
|
|
|
NORAML,
|
|
|
|
|
MYSTERY,
|
|
|
|
|
DANGEROUS,
|
|
|
|
|
TOUCHING,
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
@export var first_entered = true
|
|
|
|
|
|
|
|
|
|
#### Ground and Loader ####
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_ground_loader() -> GroundLoader:
|
|
|
|
|
return get_node_or_null("/root/Main/GroundLoader") as GroundLoader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_ground() -> Ground2D:
|
|
|
|
|
var loader = get_ground_loader()
|
|
|
|
|
if loader:
|
|
|
|
|
return loader.ground
|
|
|
|
|
return null
|
|
|
|
|
|
2024-12-30 13:19:10 +00:00
|
|
|
|
|
2025-01-02 11:01:44 +00:00
|
|
|
|
func get_camera_marker():
|
2025-01-16 12:24:21 +00:00
|
|
|
|
var ground = get_ground()
|
|
|
|
|
if ground:
|
|
|
|
|
return ground.camera_focus_marker
|
|
|
|
|
return null
|
2024-12-30 13:19:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_player() -> MainPlayer:
|
2025-01-16 12:24:21 +00:00
|
|
|
|
var ground = get_ground()
|
|
|
|
|
if ground:
|
|
|
|
|
return ground.player
|
|
|
|
|
return null
|
2024-12-30 13:19:10 +00:00
|
|
|
|
|
2025-01-03 13:29:22 +00:00
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
func focus_nodepath(node_path: NodePath) -> void:
|
|
|
|
|
if not node_path:
|
|
|
|
|
printerr("Node path is empty")
|
|
|
|
|
return
|
|
|
|
|
var node = get_node_or_null(node_path)
|
|
|
|
|
if node:
|
|
|
|
|
focus_node(node)
|
|
|
|
|
else:
|
|
|
|
|
printerr("Node not found:", node_path)
|
2025-01-13 08:09:57 +00:00
|
|
|
|
|
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
func focus_node(node: CanvasItem) -> void:
|
|
|
|
|
var ground = get_ground()
|
|
|
|
|
if ground:
|
|
|
|
|
ground.focus_node(node)
|
2024-12-30 13:19:10 +00:00
|
|
|
|
|
2025-01-03 13:29:22 +00:00
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
func focus_player() -> void:
|
|
|
|
|
var ground = get_ground()
|
|
|
|
|
if ground:
|
|
|
|
|
ground.focus_player()
|
2025-01-14 10:20:31 +00:00
|
|
|
|
|
|
|
|
|
|
2025-01-21 10:08:16 +00:00
|
|
|
|
func focus_player_and_reset_zoom(duration := 1) -> void:
|
2025-01-16 12:24:21 +00:00
|
|
|
|
var marker = get_camera_marker()
|
|
|
|
|
if marker:
|
|
|
|
|
marker.tween_zoom(1.0, duration).tween_callback(focus_player)
|
2025-01-14 10:20:31 +00:00
|
|
|
|
|
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
# action_locked 用于设置界面等强制锁定,action_freezed 用于查看物品等锁定
|
|
|
|
|
# action_locked 优先级高于 action_freezed
|
|
|
|
|
# action_locked 对应 lock 与 unlock 方法
|
|
|
|
|
func lock_player():
|
2025-01-12 06:02:00 +00:00
|
|
|
|
var player = get_player()
|
|
|
|
|
if player:
|
2025-01-16 12:24:21 +00:00
|
|
|
|
player.action_locked = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func unlock_player():
|
|
|
|
|
var player = get_player()
|
|
|
|
|
if player:
|
|
|
|
|
player.action_locked = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# action_freezed 对应 freeze 与 release 方法
|
|
|
|
|
# lock_time: the time to lock the player action. 0 means lock forever, thus the player will be locked until release_player is called.
|
|
|
|
|
func freeze_player(
|
|
|
|
|
lock_time: float, action := PlayerAnimationConfig.ACTION_NONE, auto_quit := false
|
|
|
|
|
) -> void:
|
|
|
|
|
var player = get_player()
|
|
|
|
|
if player:
|
|
|
|
|
player.freeze_player(lock_time, action, auto_quit)
|
2025-01-12 06:02:00 +00:00
|
|
|
|
else:
|
|
|
|
|
printerr("Player node not found")
|
|
|
|
|
|
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
func freeze_and_play(lock_time: float, animation := "", auto_quit := false) -> void:
|
2024-12-30 13:19:10 +00:00
|
|
|
|
var player = get_player()
|
|
|
|
|
if player:
|
2025-01-16 12:24:21 +00:00
|
|
|
|
player.freeze_and_play(lock_time, animation, auto_quit)
|
2025-01-08 00:51:09 +00:00
|
|
|
|
else:
|
|
|
|
|
printerr("Player node not found")
|
2024-12-27 13:32:12 +00:00
|
|
|
|
|
2025-01-12 06:02:00 +00:00
|
|
|
|
|
2025-01-10 07:43:55 +00:00
|
|
|
|
func release_player():
|
|
|
|
|
var player = get_player()
|
|
|
|
|
if player:
|
|
|
|
|
player.release_player()
|
|
|
|
|
else:
|
|
|
|
|
printerr("Player node not found")
|
2024-12-27 13:32:12 +00:00
|
|
|
|
|
2025-01-12 06:02:00 +00:00
|
|
|
|
|
2025-01-06 08:06:20 +00:00
|
|
|
|
func set_camera_boundary(rect: Rect2) -> void:
|
2025-01-16 12:24:21 +00:00
|
|
|
|
var camera_marker = get_camera_marker()
|
2025-01-06 08:06:20 +00:00
|
|
|
|
camera_marker.limit_left = rect.position.x
|
|
|
|
|
camera_marker.limit_right = rect.position.x + rect.size.x
|
|
|
|
|
camera_marker.limit_top = rect.position.y
|
|
|
|
|
camera_marker.limit_bottom = rect.position.y + rect.size.y
|
2024-12-27 13:32:12 +00:00
|
|
|
|
|
|
|
|
|
|
2025-01-06 08:06:20 +00:00
|
|
|
|
func set_player_boundary(rect: Rect2) -> void:
|
2024-12-30 13:19:10 +00:00
|
|
|
|
var player = get_player()
|
2024-12-27 13:32:12 +00:00
|
|
|
|
if player:
|
|
|
|
|
player.player_movement_rect = rect
|
|
|
|
|
else:
|
|
|
|
|
printerr("Player node not found")
|
|
|
|
|
|
2024-12-27 07:56:45 +00:00
|
|
|
|
|
2025-01-21 12:41:24 +00:00
|
|
|
|
var balloon_node
|
|
|
|
|
|
|
|
|
|
|
2025-01-20 13:45:47 +00:00
|
|
|
|
func pop_debug_dialog_info(character: String, content: String):
|
|
|
|
|
if GlobalConfig.DEBUG:
|
2025-01-21 12:41:24 +00:00
|
|
|
|
if not is_instance_valid(balloon_node):
|
|
|
|
|
balloon_node = preload("res://scene/dialog/balloon_debug.tscn").instantiate()
|
2025-01-20 13:45:47 +00:00
|
|
|
|
var title = "title"
|
|
|
|
|
var body = "~ " + title + "\n"
|
|
|
|
|
body += character + ": " + content + "\n"
|
|
|
|
|
body += "=> END"
|
|
|
|
|
var res = DialogueManager.create_resource_from_text(body)
|
2025-01-21 12:41:24 +00:00
|
|
|
|
DialogueManager.show_dialogue_balloon_scene(balloon_node, res, title)
|
2025-01-20 13:45:47 +00:00
|
|
|
|
|
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
#### Prop ####
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_prop_hud() -> PropHud:
|
2025-01-21 10:08:16 +00:00
|
|
|
|
return get_node_or_null("/root/Main/UILayer/PropHUD") as PropHud
|
2025-01-16 12:24:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_current_prop(must_selected: bool) -> String:
|
|
|
|
|
var prop_hud = get_prop_hud()
|
|
|
|
|
if prop_hud and (not must_selected or prop_hud.selected):
|
|
|
|
|
return prop_hud.inventory.current_item_key()
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func enable_prop_item(prop_key: String) -> void:
|
|
|
|
|
var prop_hud = get_prop_hud()
|
|
|
|
|
if prop_hud:
|
|
|
|
|
prop_hud.enable_prop_item(prop_key)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func disable_prop_item(prop_key: String) -> void:
|
|
|
|
|
var prop_hud = get_prop_hud()
|
|
|
|
|
if prop_hud:
|
|
|
|
|
prop_hud.disable_prop_item(prop_key)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func pop_os(lines := []):
|
|
|
|
|
var player = get_player()
|
|
|
|
|
if player:
|
|
|
|
|
player.pop_os(lines)
|
|
|
|
|
else:
|
|
|
|
|
printerr("Player node not found")
|
2024-12-27 07:56:45 +00:00
|
|
|
|
|
|
|
|
|
|
2024-12-23 01:29:31 +00:00
|
|
|
|
func pop_notification(msg: String, number := 1) -> void:
|
|
|
|
|
var notification_node = get_node_or_null("/root/Main/UILayer/Notification")
|
|
|
|
|
if notification_node:
|
|
|
|
|
notification_node.show_notification(msg, number)
|
|
|
|
|
else:
|
2024-12-27 07:56:45 +00:00
|
|
|
|
printerr("Notification node not found")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func pop_dialog(
|
|
|
|
|
character: String,
|
|
|
|
|
content: String,
|
|
|
|
|
character_color := "orange",
|
|
|
|
|
content_color := "white",
|
|
|
|
|
duration := 2.5
|
|
|
|
|
) -> void:
|
|
|
|
|
var dialog_node = get_node_or_null("/root/Main/UILayer/Dialog")
|
|
|
|
|
if dialog_node:
|
|
|
|
|
dialog_node.append_dialog(character, content, character_color, content_color, duration)
|
|
|
|
|
else:
|
|
|
|
|
printerr("Dialog node not found")
|
|
|
|
|
|
|
|
|
|
|
2025-01-10 07:43:55 +00:00
|
|
|
|
# func pop_note(note: String, note_color := "white", duration := 2.5) -> void:
|
|
|
|
|
# var dialog_node = get_node_or_null("/root/Main/UILayer/Dialog")
|
|
|
|
|
# if dialog_node:
|
|
|
|
|
# dialog_node.append_note(note, note_color, duration)
|
|
|
|
|
# else:
|
|
|
|
|
# printerr("Dialog node not found")
|
2024-12-30 13:19:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_inspector() -> PropInspector:
|
|
|
|
|
return get_node_or_null("/root/Main/PropInspector") as PropInspector
|
|
|
|
|
|
2025-01-02 11:01:44 +00:00
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
func checkout_index_page():
|
|
|
|
|
ArchiveManager.save_all()
|
|
|
|
|
# get_tree().change_scene_to_file("res://scene/index_page.tscn")
|
|
|
|
|
get_tree().change_scene_to_packed(preload("res://scene/index_page.tscn"))
|
2025-01-02 11:01:44 +00:00
|
|
|
|
|
|
|
|
|
|
2025-01-21 12:41:24 +00:00
|
|
|
|
var prop_bag = preload("res://scene/prop/prop_bag.tscn")
|
2025-01-02 11:01:44 +00:00
|
|
|
|
|
|
|
|
|
|
2025-01-21 12:41:24 +00:00
|
|
|
|
func show_bag():
|
|
|
|
|
get_node("/root/Main").add_child(prop_bag.instantiate())
|
2025-01-02 11:01:44 +00:00
|
|
|
|
|
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
func quit_game():
|
|
|
|
|
ArchiveManager.save_all()
|
|
|
|
|
get_tree().quit()
|
2025-01-03 13:29:22 +00:00
|
|
|
|
|
|
|
|
|
# func player_moved_delta_x(delta_x: float) -> void:
|
|
|
|
|
# # fog effect offset
|
|
|
|
|
# var fog = get_node_or_null("/root/Main/ShadingLayer/Fog")
|
|
|
|
|
# # if fog:
|
|
|
|
|
# # fog.texture.noise.offset.x += delta_x * 0.2
|