Added Grant Blevins
This commit is contained in:
18
client/Scripts/Component/Interactable.gd
Normal file
18
client/Scripts/Component/Interactable.gd
Normal file
@ -0,0 +1,18 @@
|
||||
extends Area2D
|
||||
|
||||
signal interacted
|
||||
|
||||
func _ready():
|
||||
connect("body_entered", self, "_on_body_enter")
|
||||
connect("body_exited", self, "_on_body_exit")
|
||||
|
||||
func _on_body_enter(body):
|
||||
if body.has_method("add_interactable"):
|
||||
body.add_interactable(self)
|
||||
|
||||
func _on_body_exit(body):
|
||||
if body.has_method("remove_interactable"):
|
||||
body.remove_interactable(self)
|
||||
|
||||
func interact():
|
||||
emit_signal("interacted")
|
@ -30,11 +30,11 @@ func start_dialog(record : String):
|
||||
|
||||
func start_dialog_did(dialog_id : int):
|
||||
gui = get_node("/root/World/GUI")
|
||||
|
||||
nid = 1
|
||||
did = dialog_id
|
||||
|
||||
process_message(story_reader.get_text(did, nid))
|
||||
if not gui.is_in_dialog():
|
||||
nid = 1
|
||||
did = dialog_id
|
||||
|
||||
process_message(story_reader.get_text(did, nid))
|
||||
|
||||
func has_next_node():
|
||||
return story_reader.has_slot(did, nid, 0)
|
||||
|
11
client/Scripts/Entities/MusicZone.gd
Normal file
11
client/Scripts/Entities/MusicZone.gd
Normal file
@ -0,0 +1,11 @@
|
||||
extends Area2D
|
||||
|
||||
export var music : AudioStream
|
||||
|
||||
func _ready():
|
||||
connect("body_entered", self, "_on_body_entered")
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body.has_method("user_input"):
|
||||
if $"/root/MusicManager".stream != music:
|
||||
$"/root/MusicManager".play_stream(music)
|
9
client/Scripts/Entities/NPCs/CEO.gd
Normal file
9
client/Scripts/Entities/NPCs/CEO.gd
Normal file
@ -0,0 +1,9 @@
|
||||
extends "res://Scripts/Component/Interactable.gd"
|
||||
|
||||
func _ready():
|
||||
connect("interacted", self, "_on_interact")
|
||||
$Speaker.speaker_name = "CEO Grant Blevins"
|
||||
#$Speaker.start_dialog("intro_science")
|
||||
|
||||
func _on_interact():
|
||||
$Speaker.start_dialog("intro_meet_ceo")
|
@ -1,7 +1,10 @@
|
||||
extends "res://Scripts/Component/StorySpeaker.gd"
|
||||
extends "res://Scripts/Component/Interactable.gd"
|
||||
|
||||
func _ready():
|
||||
start_dialog("intro_science")
|
||||
connect("interacted", self, "_on_interact")
|
||||
$Speaker.speaker_name = "Dr.Thadd"
|
||||
$Speaker.start_dialog("intro_science")
|
||||
|
||||
func _on_interact():
|
||||
start_dialog("intro_science_followup")
|
||||
$Speaker.start_dialog("intro_science_followup")
|
||||
|
||||
|
@ -12,6 +12,20 @@ export var jumpVelocity : float = -150
|
||||
var moveMotion : float = 0 # Player Input ( <- & -> )
|
||||
var motion : Vector2 = Vector2(0,0) # Player's current velocity
|
||||
|
||||
var gui
|
||||
|
||||
var interactables = []
|
||||
|
||||
func add_interactable(interactable):
|
||||
interactables.append(interactable)
|
||||
func remove_interactable(interactable):
|
||||
var loc = interactables.find(interactable)
|
||||
if loc >= 0:
|
||||
interactables.remove(loc)
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_just_pressed("ui_accept") and len(interactables) > 0:
|
||||
interactables[0].interact()
|
||||
|
||||
func _physics_process(delta):
|
||||
|
||||
@ -20,7 +34,10 @@ func _physics_process(delta):
|
||||
if is_on_floor():
|
||||
motion.y = 0
|
||||
|
||||
user_input()
|
||||
if not gui:
|
||||
gui = get_node("/root/World/GUI")
|
||||
elif not gui.is_in_dialog():
|
||||
user_input()
|
||||
|
||||
# Apply velocity limits
|
||||
moveMotion = clamp(moveMotion, -maxMoveVelocity, maxMoveVelocity)
|
||||
@ -32,6 +49,10 @@ func _physics_process(delta):
|
||||
|
||||
|
||||
func user_input():
|
||||
if is_on_floor() and Input.is_action_just_pressed("ui_up") and Input.is_action_pressed("ui_down"):
|
||||
position.y = position.y + 2
|
||||
return
|
||||
|
||||
if(Input.is_action_pressed("ui_left")):
|
||||
moveMotion -= moveAcceleration
|
||||
if(Input.is_action_pressed("ui_right")):
|
||||
|
@ -14,5 +14,11 @@ func play_music(song, loop=true):
|
||||
main_player.stream = track
|
||||
main_player.play()
|
||||
|
||||
func play_stream(track, loop = true):
|
||||
looping = loop
|
||||
main_player.stream = track
|
||||
main_player.play()
|
||||
|
||||
func stop_music():
|
||||
main_player.stop()
|
||||
|
||||
|
@ -1,21 +1,18 @@
|
||||
extends CanvasLayer
|
||||
|
||||
func is_in_dialog():
|
||||
return in_dialog
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
var in_dialog = false
|
||||
|
||||
func set_dialog(message, speaker=""):
|
||||
$Dialog.show()
|
||||
in_dialog = true
|
||||
$Dialog/Textbox/Speaker.text = speaker
|
||||
$Dialog/Textbox/Body.text = message
|
||||
|
||||
func finish_dialog():
|
||||
in_dialog = false
|
||||
$Dialog.hide()
|
||||
|
||||
func clear_choices():
|
||||
|
Reference in New Issue
Block a user