From 469590d195228da048c1bcb4e6f31eaea863dc56 Mon Sep 17 00:00:00 2001 From: Logan Date: Thu, 23 Jul 2020 00:18:46 -0500 Subject: [PATCH] Fixed door kinda not really --- Player/PlayerVariables.gd | 2 ++ levels/Campaign/Level0.tscn | 2 +- levels/other/Level 1.tscn | 2 ++ levels/other/Level 1a.tscn | 2 ++ objects/Door.gd | 3 ++- objects/torch.tscn | 2 +- script/Inventory.gd | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Player/PlayerVariables.gd b/Player/PlayerVariables.gd index 892edd9..9d8bb6b 100644 --- a/Player/PlayerVariables.gd +++ b/Player/PlayerVariables.gd @@ -5,6 +5,8 @@ var health = null var energy = null var unlocked: Array = [] var current_scene: String +var current_wand: int = -1 +var current_spell: int = -1 func respawn(): health = null diff --git a/levels/Campaign/Level0.tscn b/levels/Campaign/Level0.tscn index 8ae7452..16bdc64 100644 --- a/levels/Campaign/Level0.tscn +++ b/levels/Campaign/Level0.tscn @@ -16,7 +16,7 @@ autoplay = true [node name="Door" parent="." instance=ExtResource( 3 )] position = Vector2( 180, 128 ) -unlocked = false +next_scene = "\"res://levels/other/test.tscn\"" [node name="CanvasModulate" type="CanvasModulate" parent="."] color = Color( 0.564706, 0.564706, 0.564706, 1 ) diff --git a/levels/other/Level 1.tscn b/levels/other/Level 1.tscn index 3f1371e..d57d288 100644 --- a/levels/other/Level 1.tscn +++ b/levels/other/Level 1.tscn @@ -15,6 +15,8 @@ [ext_resource path="res://levels/other/Timer.gd" type="Script" id=13] + + [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 85, 8 ) diff --git a/levels/other/Level 1a.tscn b/levels/other/Level 1a.tscn index bc65969..7dfbebb 100644 --- a/levels/other/Level 1a.tscn +++ b/levels/other/Level 1a.tscn @@ -9,6 +9,8 @@ [ext_resource path="res://levels/other/Level 1a.gd" type="Script" id=7] + + [node name="Level 1a" type="Node"] script = ExtResource( 7 ) diff --git a/objects/Door.gd b/objects/Door.gd index e6b501d..0b6f15f 100644 --- a/objects/Door.gd +++ b/objects/Door.gd @@ -1,11 +1,12 @@ extends Sprite export var unlocked: bool = true -export var next_scene: String +export var next_scene: String = "" onready var door = get_node("AnimationPlayer") func _process(delta): + print(next_scene) if $Area2D.get_overlapping_bodies().size() != 0: if unlocked: $Label.text = "F to Open" diff --git a/objects/torch.tscn b/objects/torch.tscn index fbc5e2f..8b599b0 100644 --- a/objects/torch.tscn +++ b/objects/torch.tscn @@ -44,7 +44,7 @@ speed_scale = 0.25 process_material = SubResource( 5 ) [node name="Light2D" type="Light2D" parent="."] -position = Vector2( 0, -5 ) +position = Vector2( 0, -4 ) texture = ExtResource( 1 ) color = Color( 1, 0.4, 0, 1 ) range_layer_min = -5 diff --git a/script/Inventory.gd b/script/Inventory.gd index 857dade..4908981 100644 --- a/script/Inventory.gd +++ b/script/Inventory.gd @@ -45,6 +45,30 @@ onready var Effect4 = $Inventory/Effects/Effect4 func _ready(): for id in Player.unlocked: add_item(id) + if Player.current_wand != -1: + active_conduit = Globals.Magic[Player.current_wand] + parent.WandPosition.set_current_conduit(active_conduit) + match Player.current_wand: + 0: + ConduitSelect.global_position = Conduit1Position.global_position + 1: + ConduitSelect.global_position = Conduit2Position.global_position + 2: + ConduitSelect.global_position = Conduit3Position.global_position + 3: + ConduitSelect.global_position = Conduit4Position.global_position + + if Player.current_spell != -1: + active_projectile = Globals.Magic[Player.current_wand] + match Player.current_spell: + 4: + ProjectileSelect.global_position = Projectile1Position.global_position + 5: + ProjectileSelect.global_position = Projectile2Position.global_position + 6: + ProjectileSelect.global_position = Projectile3Position.global_position + 7: + ProjectileSelect.global_position = Projectile3Position.global_position func _process(delta): if Input.is_action_just_pressed("inventory"): @@ -103,24 +127,28 @@ func add_item(index): func _on_Conduit1_toggled(): if Conduit1.is_visible() and active_conduit != Globals.Magic[Globals.Conduit1]: + Player.current_wand = Globals.Magicp active_conduit = Globals.Magic[Globals.Conduit1] parent.WandPosition.set_current_conduit(active_conduit) ConduitSelect.global_position = Conduit1Position.global_position func _on_Conduit2_toggled(): if Conduit2.is_visible() and active_conduit != Globals.Magic[Globals.Conduit2]: + active_conduit = Globals.Magic[Globals.Conduit2] active_conduit = Globals.Magic[Globals.Conduit2] parent.WandPosition.set_current_conduit(active_conduit) ConduitSelect.global_position = Conduit2Position.global_position func _on_Conduit3_toggled(): if Conduit3.is_visible() and active_conduit != Globals.Magic[Globals.Conduit3]: + active_conduit = Globals.Magic[Globals.Conduit3] active_conduit = Globals.Magic[Globals.Conduit3] parent.WandPosition.set_current_conduit(active_conduit) ConduitSelect.global_position = Conduit3Position.global_position func _on_Conduit4_toggled(): if Conduit4.is_visible() and active_conduit != Globals.Magic[Globals.Conduit4]: + active_conduit = Globals.Magic[Globals.Conduit4] active_conduit = Globals.Magic[Globals.Conduit4] parent.WandPosition.set_current_conduit(active_conduit) ConduitSelect.global_position = Conduit4Position.global_position @@ -128,24 +156,28 @@ func _on_Conduit4_toggled(): func _on_Projectile1_pressed(): if Projectile1.is_visible() and active_projectile != Globals.Magic[Globals.Projectile1]: + Player.active_spell = Globals.Magic[Globals.Conduit1] active_projectile = Globals.Magic[Globals.Projectile1] ProjectileSelect.global_position = Projectile1Position.global_position func _on_Projectile2_pressed(): if Projectile2.is_visible() and active_projectile != Globals.Magic[Globals.Projectile2]: + Player.active_spell = Globals.Magic[Globals.Conduit2] active_projectile = Globals.Magic[Globals.Projectile2] ProjectileSelect.global_position = Projectile2Position.global_position func _on_Projectile3_pressed(): if Projectile3.is_visible() and active_projectile != Globals.Magic[Globals.Projectile3]: + Player.active_spell = Globals.Magic[Globals.Conduit3] active_projectile = Globals.Magic[Globals.Projectile3] ProjectileSelect.global_position = Projectile3Position.global_position func _on_Projectile4_pressed(): if Projectile4.is_visible() and active_projectile != Globals.Magic[Globals.Projectile4]: + Player.active_spell = Globals.Magic[Globals.Conduit4] active_projectile = Globals.Magic[Globals.Projectile4] ProjectileSelect.global_position = Projectile4Position.global_position