Technically a game

This commit is contained in:
2020-05-16 20:35:08 -04:00
parent bea02afbc5
commit 8b93f60aa0
30 changed files with 390 additions and 6 deletions

View File

@ -0,0 +1,14 @@
extends "res://Scripts/Component/Interactable.gd"
export var item : String
export var tip : String = ""
func _ready():
connect("interacted", self, "_on_interact")
func _on_interact():
player.add_item(item)
if len(tip) >= 1:
var gui = get_tree().root.get_node("World").get_node("GUI")
gui.display_tip(tip)
queue_free()

View File

@ -0,0 +1,12 @@
extends Area2D
export var tip = ""
func _ready():
connect("body_entered", self, "_on_body_enter")
func _on_body_enter(body):
if body.has_method("add_interactable"):
var gui = get_tree().root.get_node("World").get_node("GUI")
gui.display_tip(tip)
queue_free()

View File

@ -0,0 +1,19 @@
extends Node2D
# 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.
func _process(delta):
var rot = global_position.angle_to_point(get_global_mouse_position())
rotation = rot + PI - get_parent().global_rotation
if Input.is_action_just_pressed("toggle_flashlight"):
$Light2D.enabled = !$Light2D.enabled
$Glow.enabled = !$Glow.enabled

View File

@ -0,0 +1,45 @@
extends Area2D
var state = 0
var timer : Timer
func _ready():
$Speaker.speaker_name = "Aura"
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"):
state = 1
$Speaker.start_dialog("aura_meeting")
func _process(delta):
if state == 1 and not $Speaker.gui.is_in_dialog():
$Sprite.frame = 0
$Speaker.start_dialog("aura_meeting_gun")
state = 2
elif state == 2 and not $Speaker.gui.is_in_dialog():
$"/root/MusicManager".stop()
if not timer:
timer = Timer.new()
add_child(timer)
timer.connect("timeout", self, "shoot_scene")
timer.start(0.5)
func shoot_scene():
$AudioStreamPlayer.play()
$CanvasLayer/Blood.show()
timer.disconnect("timeout", self, "shoot_scene")
timer.stop()
timer.connect("timeout", self, "start_fade")
timer.start(0.5)
func start_fade():
timer.stop()
var fader = get_tree().root.get_node("World").get_node("Fader").get_child(0)
fader.connect("fade_complete", self, "go_to_credits")
fader.fade(2, false)
func go_to_credits():
get_tree().change_scene("res://Scenes/Credits.scn")

View File

@ -19,3 +19,4 @@ func _on_interact():
func _on_dialog_exit():
if state == 0:
state = 1
$Speaker.gui.display_tip("Press S and then SPACE\nto go down platforms")

View File

@ -4,8 +4,12 @@ func _ready():
connect("interacted", self, "_on_interact")
$Speaker.speaker = "fast_talker"
$Speaker.speaker_name = "Dr.Thadd"
$Speaker.connect("dialog_exited", self, "give_tip")
$Speaker.start_dialog("intro_science")
func _on_interact():
$Speaker.start_dialog("intro_science_followup")
func give_tip():
$Speaker.gui.display_tip("Used A & D to move\nleft and right")
$Speaker.disconnect("dialog_exited", self, "give_tip")

View File

@ -17,6 +17,20 @@ var motion : Vector2 = Vector2(0,0) # Player's current velocity
var gui
var interactables = []
var items = []
var equiped = null
func add_item(item):
items.append(item)
equip_item(item)
func equip_item(item):
var node = get_node_or_null("Torso/RightArm/RightForearm/LeftHand/Node2D/" + item)
if node:
equiped = item
node.show()
else:
print("Tried to equip: " + item + " but item was missing!")
func add_interactable(interactable):
interactables.append(interactable)
@ -49,7 +63,7 @@ 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():
if Input.is_action_just_pressed("interact") 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"):

View File

@ -1,8 +1,14 @@
extends Node2D
export var display_name = "Untitled"
export var load_on_start = false
export var music : AudioStream
var loaded = false
func is_loaded():
return loaded
func _ready():
if load_on_start:
load_zone()
@ -13,7 +19,9 @@ func load_zone():
if $"/root/MusicManager".stream != music:
$"/root/MusicManager".play_stream(music)
show()
loaded = true
func unload_zone():
hide()
loaded = false

View File

@ -12,6 +12,9 @@ func _on_body_entered(body):
var child = parent.get_child(i)
if child.has_method("load_zone"):
if child.name == load_zone + "Zone":
child.load_zone()
if not child.is_loaded():
child.load_zone()
var gui = get_tree().root.get_node("World").get_node("GUI")
gui.display_zone(child.display_name)
else:
child.unload_zone()

View File

@ -14,4 +14,4 @@ func _ready():
func play_sound(audio_stream):
audio_player.stream = audio_stream
audio_player.play()
#audio_player.play()

View File

@ -1,10 +1,23 @@
extends CanvasLayer
var in_dialog = false
var tip_timer : Timer
var zone_timer : Timer
const TIP_FADE_RATE = 0.1
const SHOW_TIP_TIME = 3
const ZONE_FADE_RATE = 0.05
const SHOW_ZONE_TIME = 3
func _ready():
$Dialog.hide()
$Tip.hide()
$ZoneLabel.hide()
func is_in_dialog():
return in_dialog or $Dialog.is_visible_in_tree()
var in_dialog = false
func current_dialog():
return $Dialog/Textbox/Body.text
@ -32,3 +45,65 @@ func add_choice(speaker : Node, choice_id : int, choice_text : String):
func show_choices():
$Dialog/Choices.show()
func display_tip(tip):
$Tip.modulate.a = 0
$Tip.text = tip
$Tip.show()
if not tip_timer:
tip_timer = Timer.new()
add_child(tip_timer)
tip_timer.disconnect("timeout", self, "fade_tip_out")
tip_timer.disconnect("timeout", self, "start_fade_tip_out")
tip_timer.connect("timeout", self, "fade_tip_in")
tip_timer.start(TIP_FADE_RATE)
func start_fade_tip_out():
tip_timer.disconnect("timeout", self, "fade_tip_in")
tip_timer.disconnect("timeout", self, "start_fade_tip_out")
tip_timer.connect("timeout", self, "fade_tip_out")
tip_timer.start(TIP_FADE_RATE)
func fade_tip_in():
$Tip.modulate.a = clamp($Tip.modulate.a + 0.1, 0, 1)
if $Tip.modulate.a == 1:
tip_timer.disconnect("timeout", self, "fade_tip_out")
tip_timer.disconnect("timeout", self, "fade_tip_in")
tip_timer.connect("timeout", self, "start_fade_tip_out")
tip_timer.start(SHOW_TIP_TIME)
func fade_tip_out():
$Tip.modulate.a = clamp($Tip.modulate.a - 0.1, 0, 1)
if $Tip.modulate.a == 0:
tip_timer.stop()
func display_zone(zone):
$ZoneLabel.modulate.a = 0
$ZoneLabel.text = "Entering: " + zone
$ZoneLabel.show()
if not zone_timer:
zone_timer = Timer.new()
add_child(zone_timer)
zone_timer.disconnect("timeout", self, "fade_zone_out")
zone_timer.disconnect("timeout", self, "start_fade_zone_out")
zone_timer.connect("timeout", self, "fade_zone_in")
zone_timer.start(ZONE_FADE_RATE)
func start_fade_zone_out():
zone_timer.disconnect("timeout", self, "fade_zone_in")
zone_timer.disconnect("timeout", self, "start_fade_zone_out")
zone_timer.connect("timeout", self, "fade_zone_out")
zone_timer.start(ZONE_FADE_RATE)
func fade_zone_in():
$ZoneLabel.modulate.a = clamp($ZoneLabel.modulate.a + 0.1, 0, 1)
if $ZoneLabel.modulate.a == 1:
zone_timer.disconnect("timeout", self, "fade_zone_out")
zone_timer.disconnect("timeout", self, "fade_zone_in")
zone_timer.connect("timeout", self, "start_fade_zone_out")
zone_timer.start(SHOW_ZONE_TIME)
func fade_zone_out():
$ZoneLabel.modulate.a = clamp($ZoneLabel.modulate.a - 0.1, 0, 1)
if $ZoneLabel.modulate.a == 0:
zone_timer.stop()