Fixed debugger errors in many files and optimized some scenes/code

This commit is contained in:
VoidTwo
2021-12-12 23:55:59 -06:00
parent fc6dfdef4d
commit ef5ce684eb
39 changed files with 657 additions and 740 deletions

View File

@@ -1,38 +1,33 @@
extends AnimatedSprite
export(PackedScene) var object_scene: PackedScene = null
export var object_scene: PackedScene = null
var is_player_inside: bool = false
var is_opened: bool = false
var has_key: bool = false
onready var animation_player: AnimationPlayer = get_node("AnimationPlayer")
onready var tween: Tween = get_node("Key/Tween")
func _ready() -> void:
assert(object_scene!=null)
animation_player.play("closed")
assert(object_scene != null)
$AnimationPlayer.play('closed')
$Key/KeySprite.visible = false
func _input(event: InputEvent) -> void:
if is_player_inside and not is_opened:
is_opened = true
animation_player.play("open")
_drop_object()
return
func _on_area_body_entered(body: Node) -> void:
if body.is_in_group('player'):
$Area/CollisionShape2D.set_deferred('disabled', true)
$AnimationPlayer.play('open')
_drop_object()
return
func _drop_object() -> void:
#print($Key.position)
$Key/KeySprite.visible = true
tween.interpolate_property($Key, "position", Vector2(0,0), Vector2(0, -10), 1.0, Tween.TRANS_QUAD,
Tween.EASE_OUT)
tween.start()
yield(tween, "tween_completed")
$Key/KeySprite.visible = false
func _on_Area2D_player_entered(_player: KinematicBody2D) -> void:
is_player_inside = true
if not $Key/Tween.interpolate_property($Key, 'position', Vector2(0,0), Vector2(0, -10), 1.0,
Tween.TRANS_QUAD, Tween.EASE_OUT):
print('ERROR: Chest key animation has errors.')
if not $Key/Tween.start():
print('ERROR: Chest key animation failed to start.')
func _on_Area2D_player_exited(_player: KinematicBody2D) -> void:
is_player_inside = false
yield($Key/Tween, 'tween_completed')
$Key/KeySprite.visible = false
return

View File

@@ -174,5 +174,4 @@ animation = "closed"
[node name="AnimationPlayer" type="AnimationPlayer" parent="Entrance"]
anims/closed = SubResource( 6 )
[connection signal="body_entered" from="Area" to="." method="_on_Area2D_player_entered"]
[connection signal="body_exited" from="Area" to="." method="_on_Area2D_player_exited"]
[connection signal="body_entered" from="Area" to="." method="_on_area_body_entered"]

View File

@@ -1,63 +1,63 @@
extends ColorRect
export var dialogPath = ""
export(float) var textSpeed = 0.05
export var dialog_path: String = ''
export var text_speed: float = 0.05
var dialog
var phraseNum = 0
var dialog: Array
var phrase_num: int = 0
var finished = false
func _ready():
# self.visible = false
$Timer.wait_time = textSpeed
dialog = getDialog()
assert(dialog, "Dialong not found")
nextPhrase()
func _process(delta):
func _ready() -> void:
$Timer.wait_time = text_speed
dialog = get_dialog()
assert(dialog, 'Dialog not found')
next_phrase()
return
func _input(event: InputEvent) -> void:
$Indicator.visible = finished
if Input.is_action_just_pressed("ui_accept"):
if event.is_action_pressed('ui_accept'):
if finished:
nextPhrase()
next_phrase()
else:
$Text.visible_characters = len($Text.text)
func getDialog() -> Array:
return
func get_dialog() -> Array:
var f = File.new()
assert(f.file_exists(dialogPath), "File path does not exist")
f.open(dialogPath, File.READ)
assert(f.file_exists(dialog_path), 'File path does not exist')
f.open(dialog_path, File.READ)
var json = f.get_as_text()
var output = parse_json(json)
if typeof(output) == TYPE_ARRAY:
return output
else:
return []
func nextPhrase() -> void:
if phraseNum >= len(dialog):
func next_phrase() -> void:
if phrase_num >= len(dialog):
queue_free()
return
finished = false
$Name.bbcode_text = dialog[phraseNum]["Name"]
$Text.bbcode_text = dialog[phraseNum]["Text"]
$Name.bbcode_text = dialog[phrase_num]['Name']
$Text.bbcode_text = dialog[phrase_num]['Text']
$Text.visible_characters = 0
while $Text.visible_characters < len($Text.text):
$Text.visible_characters += 1
$Timer.start()
yield($Timer, "timeout")
yield($Timer, 'timeout')
finished = true
phraseNum += 1
phrase_num += 1
return

View File

@@ -28,7 +28,7 @@ tracks/0/keys = {
"values": [ NodePath("..") ]
}
[node name="Control" type="Control"]
[node name="Dialogue" type="Control"]
__meta__ = {
"_edit_use_anchors_": false
}
@@ -46,7 +46,7 @@ script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
dialogPath = "res://Levels/Objects/journalScrapDialog.json"
dialog_path = "res://Levels/Objects/journalScrapDialog.json"
[node name="Name" type="RichTextLabel" parent="DialogBox"]
anchor_bottom = 2.0

View File

@@ -1,24 +1,11 @@
extends Node2D
# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void:
# pass
func _on_AnimationPlayer_animation_finished(anim_name: String) -> void:
func _on_AnimationPlayer_animation_finished(_anim_name: String) -> void:
$IceKeySprite.visible = false
return
func _on_AnimationPlayer_animation_started(anim_name: String) -> void:
func _on_AnimationPlayer_animation_started(_anim_name: String) -> void:
$IceKeySprite.visible = true
return

View File

@@ -1,34 +1,20 @@
extends Sprite
signal ice_key_collected
var is_player_inside: bool = false
var is_opened: bool = false
var has_key: bool = true
signal ice_key_collected
# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void:
# pass
func _on_Player_Detector_area_entered(area: Area2D) -> void:
print(get_parent().get_parent().score)
if area.get_parent().name == 'Player' and get_parent().get_parent().score >= 5:
if is_opened == false:
$chestClosed.visible = false
$chestOpened.visible = true
$Key.visible = true
$Key/AnimationPlayer.play("rise")
$Key/AnimationPlayer.play('rise')
is_opened = true
has_key = false
emit_signal("ice_key_collected")
emit_signal('ice_key_collected')
return