Workers, lighting, and loading

This commit is contained in:
2020-05-16 17:05:44 -04:00
parent 7528cba7d7
commit a26da07f43
61 changed files with 905 additions and 24 deletions

View File

@ -1,6 +1,7 @@
extends Area2D
signal interacted
var player
func _ready():
connect("body_entered", self, "_on_body_enter")
@ -8,6 +9,7 @@ func _ready():
func _on_body_enter(body):
if body.has_method("add_interactable"):
player = body
body.add_interactable(self)
func _on_body_exit(body):

View File

@ -0,0 +1,9 @@
extends "res://Scripts/Component/Interactable.gd"
export var dialog_name : String = "unconfigured"
func _ready():
connect("interacted", self, "_on_interact")
func _on_interact():
$Speaker.start_dialog(dialog_name)

View File

@ -0,0 +1,14 @@
extends Area2D
func _ready():
connect("body_entered", self, "_on_body_enter")
connect("body_exited", self, "_on_body_exit")
get_parent().get_node("Light2D").enabled = false
func _on_body_enter(body):
if body.has_method("add_interactable"):
get_parent().get_node("Light2D").enabled = true
func _on_body_exit(body):
if body.has_method("remove_interactable"):
get_parent().get_node("Light2D").enabled = false

View File

@ -83,5 +83,4 @@ func move_dialog_forward(decision = 0):
func _process(delta):
if(Input.is_action_just_pressed("ui_accept") and choices == 0 and final_display_message == gui.current_dialog()):
print("YEET")
move_dialog_forward(0)

View File

@ -0,0 +1,65 @@
extends Area2D
var opened = false
export var locked = false
export var security_level = 0
var player_level = -1
func lock():
locked = true
$Top/Color.modulate = Color.red
func unlock():
locked = false
set_color()
func set_color():
match(security_level):
0:
$Top/Color.modulate = Color.green
1:
$Top/Color.modulate = Color.blue
2:
$Top/Color.modulate = Color.yellow
3:
$Top/Color.modulate = Color.orange
4:
$Top/Color.modulate = Color.red
5:
$Top/Color.modulate = Color.purple
# Called when the node enters the scene tree for the first time.
func _ready():
connect("body_entered", self, "_on_body_enter")
connect("body_exited", self, "_on_body_exit")
if locked:
lock()
else:
unlock()
func _on_body_enter(body):
if body.has_method("add_interactable"):
if body.clearance_level >= security_level and not locked:
open()
func _on_body_exit(body):
if body.has_method("remove_interactable"):
close()
func open():
if not opened:
$AnimationPlayer.play("Open")
$AudioStreamPlayer2D.play()
$StaticBody2D.collision_layer = 0
$StaticBody2D.collision_mask = 0
opened = true
func close():
if opened:
$AnimationPlayer.play("Close")
$AudioStreamPlayer2D.play()
$StaticBody2D.collision_layer = 1
$StaticBody2D.collision_mask = 1
opened = false

View File

@ -5,11 +5,14 @@ var state : int = 0
func _ready():
connect("interacted", self, "_on_interact")
$Speaker.speaker_name = "CEO Grant Blevins"
$Speaker.speaker = "ceo"
$Speaker.connect("dialog_exited", self, "_on_dialog_exit")
func _on_interact():
if state == 0:
$Speaker.start_dialog("intro_meet_ceo")
if player:
player.clearance_level = 1
else:
$Speaker.start_dialog("into_speak_ceo")

View File

@ -2,6 +2,7 @@ extends "res://Scripts/Component/Interactable.gd"
func _ready():
connect("interacted", self, "_on_interact")
$Speaker.speaker = "fast_talker"
$Speaker.speaker_name = "Dr.Thadd"
#$Speaker.start_dialog("intro_science")

View File

@ -1,5 +1,7 @@
extends KinematicBody2D
export var clearance_level = 0
# Environment variables
export var baseGravity : float = 9.8
@ -23,10 +25,6 @@ func remove_interactable(interactable):
if loc >= 0:
interactables.remove(loc)
func _process(delta):
if Input.is_action_just_pressed("ui_accept") and len(interactables) > 0 and not gui.is_in_dialog():
interactables[0].interact()
func _physics_process(delta):
# Gravity
@ -38,6 +36,8 @@ func _physics_process(delta):
gui = get_node("/root/World/GUI")
elif not gui.is_in_dialog():
user_input()
else:
moveMotion = 0
# Apply velocity limits
moveMotion = clamp(moveMotion, -maxMoveVelocity, maxMoveVelocity)
@ -49,6 +49,9 @@ func _physics_process(delta):
func user_input():
if Input.is_action_just_pressed("ui_accept") and len(interactables) > 0 and not gui.is_in_dialog():
interactables[0].interact()
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

View File

@ -0,0 +1,7 @@
extends Sprite
export var shadows : bool = false
func _ready():
$Light2D.show()
$Light2D.shadow_enabled = shadows

View File

@ -0,0 +1,19 @@
extends Node2D
export var load_on_start = false
export var music : AudioStream
func _ready():
if load_on_start:
load_zone()
else:
unload_zone()
func load_zone():
if $"/root/MusicManager".stream != music:
$"/root/MusicManager".play_stream(music)
show()
func unload_zone():
hide()

View File

@ -0,0 +1,17 @@
extends Area2D
export var load_zone : String = ""
func _ready():
connect("body_entered", self, "_on_body_entered")
func _on_body_entered(body):
if body.has_method("user_input"):
var parent = get_parent()
for i in range(0, parent.get_child_count()):
var child = parent.get_child(i)
if child.has_method("load_zone"):
if child.name == load_zone + "Zone":
child.load_zone()
else:
child.unload_zone()

View File

@ -9,7 +9,7 @@ func _ready():
gui_manager = $GUI
audio_player = AudioStreamPlayer.new()
add_child(audio_player)
$CanvasLayer/ColorRect.show()
$Fader/ColorRect.show()
play_sound(preload("res://Assets/Sfx/intro/processed.wav"))
func play_sound(audio_stream):