fix tutorial
This commit is contained in:
@@ -59,6 +59,7 @@ const CONTACT_CD = 0.7
|
|||||||
const AIR_FRICTION = 0.86
|
const AIR_FRICTION = 0.86
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
process_mode = Node.PROCESS_MODE_PAUSABLE
|
||||||
add_to_group("enemies")
|
add_to_group("enemies")
|
||||||
mat = mesh_node.material_override.duplicate() as StandardMaterial3D
|
mat = mesh_node.material_override.duplicate() as StandardMaterial3D
|
||||||
mesh_node.material_override = mat
|
mesh_node.material_override = mat
|
||||||
|
|||||||
+30
-20
@@ -31,9 +31,8 @@ var upgrading: bool = false
|
|||||||
var tutorial_canvas: CanvasLayer
|
var tutorial_canvas: CanvasLayer
|
||||||
var tutorial_image: TextureRect
|
var tutorial_image: TextureRect
|
||||||
var tutorial_hint: Label
|
var tutorial_hint: Label
|
||||||
var tutorial_active: bool = false
|
|
||||||
var tutorial_hint_ready: bool = false
|
var tutorial_hint_ready: bool = false
|
||||||
var tutorial_timer: float = 0.0
|
var tutorial_active: bool = false
|
||||||
var tutorial_on_dismiss: Callable = Callable()
|
var tutorial_on_dismiss: Callable = Callable()
|
||||||
var shown_tutorials: Dictionary = {}
|
var shown_tutorials: Dictionary = {}
|
||||||
|
|
||||||
@@ -50,7 +49,6 @@ var upgrade_panel: Panel
|
|||||||
var gameover_panel: Panel
|
var gameover_panel: Panel
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
||||||
_spawn_level()
|
_spawn_level()
|
||||||
_create_camera()
|
_create_camera()
|
||||||
_create_ui()
|
_create_ui()
|
||||||
@@ -63,12 +61,8 @@ func _ready() -> void:
|
|||||||
show_tutorial("Tutorial_StartGame", _start_game)
|
show_tutorial("Tutorial_StartGame", _start_game)
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if tutorial_active and tutorial_hint_ready:
|
if tutorial_active:
|
||||||
var mb := event as InputEventMouseButton
|
return
|
||||||
if mb != null and mb.button_index == MOUSE_BUTTON_LEFT and mb.pressed:
|
|
||||||
_dismiss_tutorial()
|
|
||||||
return
|
|
||||||
|
|
||||||
var motion := event as InputEventMouseMotion
|
var motion := event as InputEventMouseMotion
|
||||||
if motion != null and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
if motion != null and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||||
cam_yaw -= motion.relative.x * MOUSE_SENS
|
cam_yaw -= motion.relative.x * MOUSE_SENS
|
||||||
@@ -98,12 +92,6 @@ func _create_camera() -> void:
|
|||||||
add_child(camera)
|
add_child(camera)
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if tutorial_active:
|
|
||||||
tutorial_timer -= delta
|
|
||||||
if tutorial_timer <= 0.0 and not tutorial_hint_ready:
|
|
||||||
tutorial_hint_ready = true
|
|
||||||
tutorial_hint.visible = true
|
|
||||||
return
|
|
||||||
if is_instance_valid(player):
|
if is_instance_valid(player):
|
||||||
var yaw_r: float = deg_to_rad(cam_yaw)
|
var yaw_r: float = deg_to_rad(cam_yaw)
|
||||||
var pitch_r: float = deg_to_rad(cam_pitch)
|
var pitch_r: float = deg_to_rad(cam_pitch)
|
||||||
@@ -397,6 +385,26 @@ func _create_tutorial_overlay() -> void:
|
|||||||
tutorial_hint.visible = false
|
tutorial_hint.visible = false
|
||||||
tutorial_canvas.add_child(tutorial_hint)
|
tutorial_canvas.add_child(tutorial_hint)
|
||||||
|
|
||||||
|
var click_cap := Control.new()
|
||||||
|
click_cap.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||||
|
click_cap.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||||
|
click_cap.process_mode = Node.PROCESS_MODE_ALWAYS
|
||||||
|
click_cap.connect("gui_input", _on_tutorial_input)
|
||||||
|
tutorial_canvas.add_child(click_cap)
|
||||||
|
|
||||||
|
func _on_tutorial_input(event: InputEvent) -> void:
|
||||||
|
if not tutorial_hint_ready:
|
||||||
|
return
|
||||||
|
var mb := event as InputEventMouseButton
|
||||||
|
if mb != null and mb.button_index == MOUSE_BUTTON_LEFT and mb.pressed:
|
||||||
|
_dismiss_tutorial()
|
||||||
|
|
||||||
|
func _set_enemies_paused(paused: bool) -> void:
|
||||||
|
var mode := Node.PROCESS_MODE_DISABLED if paused else Node.PROCESS_MODE_PAUSABLE
|
||||||
|
for e in get_tree().get_nodes_in_group("enemies"):
|
||||||
|
(e as Node).process_mode = mode
|
||||||
|
spawn_timer.paused = paused
|
||||||
|
|
||||||
func show_tutorial(key: String, on_dismiss: Callable = Callable()) -> void:
|
func show_tutorial(key: String, on_dismiss: Callable = Callable()) -> void:
|
||||||
if shown_tutorials.get(key, false):
|
if shown_tutorials.get(key, false):
|
||||||
if on_dismiss.is_valid():
|
if on_dismiss.is_valid():
|
||||||
@@ -406,17 +414,19 @@ func show_tutorial(key: String, on_dismiss: Callable = Callable()) -> void:
|
|||||||
var path := "res://assets/%s.jpeg" % key
|
var path := "res://assets/%s.jpeg" % key
|
||||||
tutorial_image.texture = load(path) if ResourceLoader.exists(path) else null
|
tutorial_image.texture = load(path) if ResourceLoader.exists(path) else null
|
||||||
tutorial_on_dismiss = on_dismiss
|
tutorial_on_dismiss = on_dismiss
|
||||||
tutorial_active = true
|
|
||||||
tutorial_hint_ready = false
|
tutorial_hint_ready = false
|
||||||
tutorial_timer = 3.0
|
|
||||||
tutorial_hint.visible = false
|
tutorial_hint.visible = false
|
||||||
tutorial_canvas.visible = true
|
tutorial_canvas.visible = true
|
||||||
get_tree().paused = true
|
tutorial_active = true
|
||||||
|
_set_enemies_paused(true)
|
||||||
|
await get_tree().create_timer(3.0).timeout
|
||||||
|
tutorial_hint.visible = true
|
||||||
|
tutorial_hint_ready = true
|
||||||
|
|
||||||
func _dismiss_tutorial() -> void:
|
func _dismiss_tutorial() -> void:
|
||||||
tutorial_active = false
|
|
||||||
tutorial_canvas.visible = false
|
tutorial_canvas.visible = false
|
||||||
get_tree().paused = false
|
tutorial_active = false
|
||||||
|
_set_enemies_paused(false)
|
||||||
if tutorial_on_dismiss.is_valid():
|
if tutorial_on_dismiss.is_valid():
|
||||||
tutorial_on_dismiss.call()
|
tutorial_on_dismiss.call()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user