88 lines
2.2 KiB
GDScript
88 lines
2.2 KiB
GDScript
extends Node
|
|
|
|
enum VIBE {
|
|
NORAML,
|
|
MYSTERY,
|
|
DANGEROUS,
|
|
TOUCHING,
|
|
}
|
|
|
|
|
|
func get_camera() -> MainCamera:
|
|
return get_node_or_null("/root/Main/MainPlayer/CameraFocusMarker/MainCamera") as MainCamera
|
|
|
|
|
|
func get_player() -> MainPlayer:
|
|
return get_node_or_null("/root/Main/MainPlayer") as MainPlayer
|
|
|
|
|
|
# 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, animation := ""):
|
|
var player = get_player()
|
|
if player:
|
|
player.freeze_player(lock_time, animation)
|
|
|
|
|
|
func set_camera_boundary(size: Vector2) -> void:
|
|
var camera = get_camera()
|
|
if camera:
|
|
camera.limit_left = 0
|
|
camera.limit_right = size.x
|
|
if GlobalConfig.DEBUG:
|
|
print("set camera boundary:", size)
|
|
# camera.limit_top = -size.y / 2
|
|
# camera.limit_bottom = size.y / 2
|
|
else:
|
|
printerr("Camera node not found")
|
|
|
|
|
|
func set_player_boundary(size: Vector2) -> void:
|
|
var player = get_player()
|
|
if player:
|
|
size.x = size.x - 30
|
|
var rect = Rect2(Vector2(15, -size.y / 2), size)
|
|
player.player_movement_rect = rect
|
|
if GlobalConfig.DEBUG:
|
|
print("set player boundary:", rect)
|
|
else:
|
|
printerr("Player node not found")
|
|
|
|
|
|
func get_ground_loader() -> GroundLoader:
|
|
return get_node_or_null("/root/Main/GroundLoader") as GroundLoader
|
|
|
|
|
|
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:
|
|
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")
|
|
|
|
|
|
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")
|
|
|
|
|
|
func get_inspector() -> PropInspector:
|
|
return get_node_or_null("/root/Main/PropInspector") as PropInspector
|
|
|