Cutscene
This commit is contained in:
@@ -1,4 +1,31 @@
|
||||
class_name Cutscene extends Node
|
||||
|
||||
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:
|
||||
pass
|
||||
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