Workers, lighting, and loading
This commit is contained in:
65
client/Scripts/Entities/Door.gd
Normal file
65
client/Scripts/Entities/Door.gd
Normal 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
|
@ -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")
|
||||
|
||||
|
@ -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")
|
||||
|
||||
|
@ -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
|
||||
|
7
client/Scripts/Entities/Wall Light.gd
Normal file
7
client/Scripts/Entities/Wall Light.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends Sprite
|
||||
|
||||
export var shadows : bool = false
|
||||
|
||||
func _ready():
|
||||
$Light2D.show()
|
||||
$Light2D.shadow_enabled = shadows
|
19
client/Scripts/Entities/Zone.gd
Normal file
19
client/Scripts/Entities/Zone.gd
Normal 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()
|
||||
|
17
client/Scripts/Entities/ZoneLoader.gd
Normal file
17
client/Scripts/Entities/ZoneLoader.gd
Normal 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()
|
Reference in New Issue
Block a user