2020-07-18 15:58:23 -05:00
|
|
|
extends CanvasLayer
|
|
|
|
|
|
|
|
var open = false setget set_open
|
|
|
|
|
|
|
|
onready var parent = get_parent()
|
|
|
|
|
|
|
|
var active_conduit = null
|
|
|
|
var active_projectile = null
|
|
|
|
var active_effect = null
|
|
|
|
|
|
|
|
onready var Anim = $AnimationPlayer
|
2020-07-20 14:59:31 -05:00
|
|
|
onready var ConduitSelect = $Inventory/ConduitSelect
|
|
|
|
onready var ProjectileSelect = $Inventory/ProjectileSelect
|
2020-07-18 15:58:23 -05:00
|
|
|
|
|
|
|
###
|
|
|
|
onready var Conduits = $Conduits
|
|
|
|
onready var Conduit1 = $Inventory/Conduits/Conduit1
|
|
|
|
onready var Conduit2 = $Inventory/Conduits/Conduit2
|
|
|
|
onready var Conduit3 = $Inventory/Conduits/Conduit3
|
|
|
|
onready var Conduit4 = $Inventory/Conduits/Conduit4
|
|
|
|
|
2020-07-20 14:59:31 -05:00
|
|
|
onready var Conduit1Position = $Inventory/Conduits/Conduit1/Position2D
|
|
|
|
onready var Conduit2Position = $Inventory/Conduits/Conduit2/Position2D
|
|
|
|
onready var Conduit3Position = $Inventory/Conduits/Conduit3/Position2D
|
|
|
|
onready var Conduit4Position = $Inventory/Conduits/Conduit4/Position2D
|
|
|
|
|
2020-07-18 15:58:23 -05:00
|
|
|
onready var Projectiles = $Inventory/Projectiles
|
|
|
|
onready var Projectile1 = $Inventory/Projectiles/Projectile1
|
|
|
|
onready var Projectile2 = $Inventory/Projectiles/Projectile2
|
|
|
|
onready var Projectile3 = $Inventory/Projectiles/Projectile3
|
|
|
|
onready var Projectile4 = $Inventory/Projectiles/Projectile4
|
|
|
|
|
2020-07-20 14:59:31 -05:00
|
|
|
onready var Projectile1Position = $Inventory/Projectiles/Projectile1/Position2D
|
|
|
|
onready var Projectile2Position = $Inventory/Projectiles/Projectile2/Position2D
|
|
|
|
onready var Projectile3Position = $Inventory/Projectiles/Projectile3/Position2D
|
|
|
|
onready var Projectile4Position = $Inventory/Projectiles/Projectile4/Position2D
|
|
|
|
|
2020-07-18 15:58:23 -05:00
|
|
|
onready var Effects = $Inventory/Effects
|
|
|
|
onready var Effect1 = $Inventory/Effects/Effect1
|
|
|
|
onready var Effect2 = $Inventory/Effects/Effect2
|
|
|
|
onready var Effect3 = $Inventory/Effects/Effect3
|
|
|
|
onready var Effect4 = $Inventory/Effects/Effect4
|
|
|
|
###
|
|
|
|
|
2020-07-20 23:24:09 -05:00
|
|
|
func _ready():
|
|
|
|
for id in Player.unlocked:
|
|
|
|
add_item(id)
|
2020-07-23 00:18:46 -05:00
|
|
|
if Player.current_wand != -1:
|
|
|
|
active_conduit = Globals.Magic[Player.current_wand]
|
2020-07-23 01:27:37 -05:00
|
|
|
yield(get_tree(), "idle_frame")
|
2020-07-23 00:18:46 -05:00
|
|
|
parent.WandPosition.set_current_conduit(active_conduit)
|
|
|
|
match Player.current_wand:
|
2020-07-23 01:27:37 -05:00
|
|
|
Globals.Conduit1:
|
2020-07-23 00:18:46 -05:00
|
|
|
ConduitSelect.global_position = Conduit1Position.global_position
|
2020-07-23 01:27:37 -05:00
|
|
|
Globals.Conduit2:
|
2020-07-23 00:18:46 -05:00
|
|
|
ConduitSelect.global_position = Conduit2Position.global_position
|
2020-07-23 01:27:37 -05:00
|
|
|
Globals.Conduit3:
|
2020-07-23 00:18:46 -05:00
|
|
|
ConduitSelect.global_position = Conduit3Position.global_position
|
2020-07-23 01:27:37 -05:00
|
|
|
Globals.Conduit4:
|
2020-07-23 00:18:46 -05:00
|
|
|
ConduitSelect.global_position = Conduit4Position.global_position
|
|
|
|
|
|
|
|
if Player.current_spell != -1:
|
2020-07-23 01:27:37 -05:00
|
|
|
active_projectile = Globals.Magic[Player.current_spell]
|
2020-07-23 00:18:46 -05:00
|
|
|
match Player.current_spell:
|
2020-07-23 01:27:37 -05:00
|
|
|
Globals.Projectile1:
|
2020-07-23 00:18:46 -05:00
|
|
|
ProjectileSelect.global_position = Projectile1Position.global_position
|
2020-07-23 01:27:37 -05:00
|
|
|
Globals.Projectile2:
|
2020-07-23 00:18:46 -05:00
|
|
|
ProjectileSelect.global_position = Projectile2Position.global_position
|
2020-07-23 01:27:37 -05:00
|
|
|
Globals.Projectile3:
|
2020-07-23 00:18:46 -05:00
|
|
|
ProjectileSelect.global_position = Projectile3Position.global_position
|
2020-07-23 01:27:37 -05:00
|
|
|
Globals.Projectile4:
|
2020-07-23 00:18:46 -05:00
|
|
|
ProjectileSelect.global_position = Projectile3Position.global_position
|
2020-07-20 23:24:09 -05:00
|
|
|
|
2020-07-18 15:58:23 -05:00
|
|
|
func _process(delta):
|
|
|
|
if Input.is_action_just_pressed("inventory"):
|
|
|
|
set_open(!open)
|
|
|
|
|
2020-07-20 14:59:31 -05:00
|
|
|
if active_conduit == null:
|
|
|
|
ConduitSelect.visible = false
|
|
|
|
else:
|
|
|
|
ConduitSelect.visible = true
|
|
|
|
|
|
|
|
if active_projectile == null:
|
|
|
|
ProjectileSelect.visible = false
|
|
|
|
else:
|
|
|
|
ProjectileSelect.visible = true
|
|
|
|
|
2020-07-20 01:18:45 -05:00
|
|
|
func _input(event):
|
|
|
|
if event.is_action_pressed("ui_end"):
|
|
|
|
set_open(false)
|
|
|
|
|
2020-07-18 15:58:23 -05:00
|
|
|
func set_open(new):
|
|
|
|
if open != new:
|
|
|
|
if new == true:
|
|
|
|
Anim.play("SlideIn")
|
|
|
|
if new == false:
|
|
|
|
Anim.play("SlideOut")
|
|
|
|
open = new
|
|
|
|
|
|
|
|
func add_item(index):
|
|
|
|
match index:
|
|
|
|
Globals.Conduit1:
|
|
|
|
Conduit1.visible = true
|
|
|
|
Globals.Conduit2:
|
|
|
|
Conduit2.visible = true
|
|
|
|
Globals.Conduit3:
|
|
|
|
Conduit3.visible = true
|
|
|
|
Globals.Conduit4:
|
|
|
|
Conduit4.visible = true
|
|
|
|
|
|
|
|
Globals.Projectile1:
|
|
|
|
Projectile1.visible = true
|
|
|
|
Globals.Projectile2:
|
|
|
|
Projectile2.visible = true
|
|
|
|
Globals.Projectile3:
|
|
|
|
Projectile3.visible = true
|
|
|
|
Globals.Projectile4:
|
|
|
|
Projectile4.visible = true
|
|
|
|
|
|
|
|
Globals.Effect1:
|
|
|
|
Effect1.visible = true
|
|
|
|
Globals.Effect2:
|
|
|
|
Effect2.visible = true
|
|
|
|
Globals.Conduit3:
|
|
|
|
Effect3.visible = true
|
|
|
|
Globals.Conduit4:
|
|
|
|
Effect4.visible = true
|
|
|
|
|
2020-07-18 19:50:16 -05:00
|
|
|
func _on_Conduit1_toggled():
|
2020-07-19 16:11:22 -05:00
|
|
|
if Conduit1.is_visible() and active_conduit != Globals.Magic[Globals.Conduit1]:
|
2020-07-23 01:27:37 -05:00
|
|
|
Player.current_wand = Globals.Conduit1
|
2020-07-18 15:58:23 -05:00
|
|
|
active_conduit = Globals.Magic[Globals.Conduit1]
|
2020-07-19 18:36:36 -05:00
|
|
|
parent.WandPosition.set_current_conduit(active_conduit)
|
2020-07-20 14:59:31 -05:00
|
|
|
ConduitSelect.global_position = Conduit1Position.global_position
|
2020-07-18 16:13:45 -05:00
|
|
|
|
2020-07-18 19:50:16 -05:00
|
|
|
func _on_Conduit2_toggled():
|
2020-07-19 16:11:22 -05:00
|
|
|
if Conduit2.is_visible() and active_conduit != Globals.Magic[Globals.Conduit2]:
|
2020-07-23 01:27:37 -05:00
|
|
|
Player.current_wand = Globals.Conduit2
|
2020-07-18 16:13:45 -05:00
|
|
|
active_conduit = Globals.Magic[Globals.Conduit2]
|
2020-07-19 18:36:36 -05:00
|
|
|
parent.WandPosition.set_current_conduit(active_conduit)
|
2020-07-20 14:59:31 -05:00
|
|
|
ConduitSelect.global_position = Conduit2Position.global_position
|
2020-07-18 19:50:16 -05:00
|
|
|
|
|
|
|
func _on_Conduit3_toggled():
|
2020-07-19 16:11:22 -05:00
|
|
|
if Conduit3.is_visible() and active_conduit != Globals.Magic[Globals.Conduit3]:
|
2020-07-23 01:27:37 -05:00
|
|
|
Player.current_wand = Globals.Conduit3
|
2020-07-18 19:50:16 -05:00
|
|
|
active_conduit = Globals.Magic[Globals.Conduit3]
|
2020-07-19 18:36:36 -05:00
|
|
|
parent.WandPosition.set_current_conduit(active_conduit)
|
2020-07-20 14:59:31 -05:00
|
|
|
ConduitSelect.global_position = Conduit3Position.global_position
|
2020-07-18 19:50:16 -05:00
|
|
|
|
|
|
|
func _on_Conduit4_toggled():
|
2020-07-19 16:11:22 -05:00
|
|
|
if Conduit4.is_visible() and active_conduit != Globals.Magic[Globals.Conduit4]:
|
2020-07-23 01:27:37 -05:00
|
|
|
Player.current_wand = Globals.Conduit4
|
2020-07-18 19:50:16 -05:00
|
|
|
active_conduit = Globals.Magic[Globals.Conduit4]
|
2020-07-19 18:36:36 -05:00
|
|
|
parent.WandPosition.set_current_conduit(active_conduit)
|
2020-07-20 14:59:31 -05:00
|
|
|
ConduitSelect.global_position = Conduit4Position.global_position
|
2020-07-19 18:36:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Projectile1_pressed():
|
|
|
|
if Projectile1.is_visible() and active_projectile != Globals.Magic[Globals.Projectile1]:
|
2020-07-23 01:27:37 -05:00
|
|
|
Player.current_spell = Globals.Projectile1
|
2020-07-19 18:36:36 -05:00
|
|
|
active_projectile = Globals.Magic[Globals.Projectile1]
|
2020-07-20 14:59:31 -05:00
|
|
|
ProjectileSelect.global_position = Projectile1Position.global_position
|
2020-07-19 18:36:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Projectile2_pressed():
|
|
|
|
if Projectile2.is_visible() and active_projectile != Globals.Magic[Globals.Projectile2]:
|
2020-07-23 01:27:37 -05:00
|
|
|
Player.current_spell = Globals.Projectile2
|
2020-07-19 18:36:36 -05:00
|
|
|
active_projectile = Globals.Magic[Globals.Projectile2]
|
2020-07-20 14:59:31 -05:00
|
|
|
ProjectileSelect.global_position = Projectile2Position.global_position
|
2020-07-19 18:36:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Projectile3_pressed():
|
|
|
|
if Projectile3.is_visible() and active_projectile != Globals.Magic[Globals.Projectile3]:
|
2020-07-23 01:27:37 -05:00
|
|
|
Player.current_spell = Globals.Projectile3
|
2020-07-19 18:36:36 -05:00
|
|
|
active_projectile = Globals.Magic[Globals.Projectile3]
|
2020-07-20 14:59:31 -05:00
|
|
|
ProjectileSelect.global_position = Projectile3Position.global_position
|
2020-07-19 18:36:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Projectile4_pressed():
|
|
|
|
if Projectile4.is_visible() and active_projectile != Globals.Magic[Globals.Projectile4]:
|
2020-07-23 01:59:43 -05:00
|
|
|
Player.current_spell = Globals.Projectile4
|
2020-07-19 18:36:36 -05:00
|
|
|
active_projectile = Globals.Magic[Globals.Projectile4]
|
2020-07-20 14:59:31 -05:00
|
|
|
ProjectileSelect.global_position = Projectile4Position.global_position
|