Cutscene
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://b16ysbx7ah03u"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://b16ysbx7ah03u"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d3rtd0ln7l2gr" path="res://scenes/maps/tundra/MapTundra.tscn" id="1_2gju5"]
|
||||
[ext_resource type="PackedScene" uid="uid://2ch34sio36nv" path="res://scenes/entities/Player.tscn" id="2_rlkm5"]
|
||||
[ext_resource type="Script" uid="uid://csb0i132lcu0w" path="res://scripts/entities/MapCamera.gd" id="3_n77mx"]
|
||||
[ext_resource type="PackedScene" uid="uid://bng2mc7fu5aik" path="res://scenes/entities/NPC.tscn" id="4_nb1wl"]
|
||||
[ext_resource type="Script" uid="uid://chxpes3546yoj" path="res://scripts/cutscene/Cutscene.gd" id="5_m5dm6"]
|
||||
[ext_resource type="Script" uid="uid://8updtj1mctra" path="res://scripts/cutscene/item/CutsceneText.gd" id="6_fws1a"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_n77mx"]
|
||||
|
||||
@@ -37,10 +38,10 @@ point_count = 2
|
||||
[node name="Player" parent="." instance=ExtResource("2_rlkm5")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.06402, 1.54702, -2.35884)
|
||||
|
||||
[node name="NPC" parent="." instance=ExtResource("4_nb1wl")]
|
||||
[node name="NPC" parent="." node_paths=PackedStringArray("cutscene") instance=ExtResource("4_nb1wl")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.20455, 1.94676, -3.51349)
|
||||
interactType = 1
|
||||
interactTexts = Array[String](["Hello interact 1", "test interact 2"])
|
||||
interactType = 2
|
||||
cutscene = NodePath("../Cutscenes/TestCutscene")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." node_paths=PackedStringArray("targetFollow", "pathFollow", "pathMap")]
|
||||
transform = Transform3D(0.996991, 0.0418507, -0.0652558, 0, 0.841762, 0.539849, 0.0775229, -0.538225, 0.839228, 1.25757, 8.21861, 8.01254)
|
||||
@@ -69,3 +70,8 @@ curve = SubResource("Curve3D_nb1wl")
|
||||
|
||||
[node name="TestCutscene" type="Node" parent="Cutscenes"]
|
||||
script = ExtResource("5_m5dm6")
|
||||
|
||||
[node name="CutsceneText" type="Node" parent="Cutscenes/TestCutscene"]
|
||||
script = ExtResource("6_fws1a")
|
||||
interactTexts = Array[String](["test cutscene item 1", "tttt2"])
|
||||
metadata/_custom_type_script = "uid://8updtj1mctra"
|
||||
|
@@ -1,4 +1,31 @@
|
||||
class_name Cutscene extends Node
|
||||
|
||||
func start() -> void:
|
||||
var items:Array[CutsceneItem] = []
|
||||
var itemIndex:int = 0
|
||||
|
||||
func _enter_tree() -> void:
|
||||
# Get children
|
||||
var children = get_children()
|
||||
for child in children:
|
||||
if !(child is CutsceneItem):
|
||||
continue
|
||||
items.append(child)
|
||||
pass
|
||||
|
||||
func _exit_tree() -> void:
|
||||
items.clear()
|
||||
pass
|
||||
|
||||
func start() -> void:
|
||||
itemIndex = -1
|
||||
if items.size() == 0:
|
||||
return
|
||||
nextItem()
|
||||
|
||||
func nextItem() -> void:
|
||||
itemIndex += 1
|
||||
if itemIndex >= items.size():
|
||||
return
|
||||
|
||||
var item = items[itemIndex]
|
||||
item.start()
|
5
scripts/cutscene/item/CutsceneItem.gd
Normal file
5
scripts/cutscene/item/CutsceneItem.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
class_name CutsceneItem extends Node
|
||||
|
||||
func start() -> void:
|
||||
# This method should be overridden by subclasses
|
||||
pass
|
1
scripts/cutscene/item/CutsceneItem.gd.uid
Normal file
1
scripts/cutscene/item/CutsceneItem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dbjcrhunrugyb
|
23
scripts/cutscene/item/CutsceneText.gd
Normal file
23
scripts/cutscene/item/CutsceneText.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
class_name CutsceneText extends CutsceneItem
|
||||
|
||||
@export_multiline var interactTexts:Array[String] = []
|
||||
var nextTextIndex:int = 0
|
||||
|
||||
func _enter_tree() -> void:
|
||||
pass
|
||||
|
||||
func _exit_tree() -> void:
|
||||
UI.TEXTBOX.textboxClosing.disconnect(onTextboxClosing)
|
||||
|
||||
func start() -> void:
|
||||
nextTextIndex = 0
|
||||
UI.TEXTBOX.setText(interactTexts[nextTextIndex])
|
||||
UI.TEXTBOX.textboxClosing.connect(onTextboxClosing)
|
||||
|
||||
func onTextboxClosing() -> void:
|
||||
nextTextIndex += 1
|
||||
if nextTextIndex < interactTexts.size():
|
||||
UI.TEXTBOX.setText(interactTexts[nextTextIndex])
|
||||
else:
|
||||
UI.TEXTBOX.textboxClosing.disconnect(onTextboxClosing)
|
||||
UI.TEXTBOX.setText("")
|
1
scripts/cutscene/item/CutsceneText.gd.uid
Normal file
1
scripts/cutscene/item/CutsceneText.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://8updtj1mctra
|
@@ -31,11 +31,16 @@ func _on_interact() -> void:
|
||||
nextTextIndex = 0
|
||||
match interactType:
|
||||
InteractType.TEXTBOX:
|
||||
if interactTexts.size() == 0:
|
||||
return
|
||||
UI.TEXTBOX.setText(interactTexts[nextTextIndex])
|
||||
UI.TEXTBOX.textboxClosing.connect(onTextboxClosing)
|
||||
return
|
||||
|
||||
InteractType.CUTSCENE:
|
||||
if cutscene:
|
||||
cutscene.start()
|
||||
return
|
||||
_:
|
||||
return
|
||||
|
||||
|
Reference in New Issue
Block a user