
- Added more spells - Added plans for more spells - Added support for healing spells - Worked on getting enemy spellbook randomization implemented - Added some enemy animations - Tweaked healthbar size so that red doesn't poke over the top - Cleaned up some unused scripts
85 lines
3.6 KiB
GDScript
85 lines
3.6 KiB
GDScript
class_name Tavern extends Control
|
|
|
|
@onready var data: Data = $/root/Root/Data
|
|
@onready var selected: GridContainer = $NinePatchRect3/GridContainer
|
|
@onready var library: GridContainer = $NinePatchRect2/GridContainer
|
|
@onready var zone: Control = $NinePatchRect/zone
|
|
@onready var icon = $NinePatchRect/zone/Icon
|
|
@onready var nam = $NinePatchRect/zone/Name
|
|
@onready var rarity = $NinePatchRect/zone/Rarity
|
|
@onready var description = $NinePatchRect/zone/Description
|
|
@onready var damage = $NinePatchRect/zone/Damage
|
|
@onready var buttonBase: PackedScene = load("res://Scenes/UI/spellButton.tscn")
|
|
@onready var choice = $Choice
|
|
|
|
var selectedButton: SpellButton
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
var spells: Array[Spell] = data.unlockedSpells.duplicate()
|
|
for spell: Spell in data.spellbook.spells:
|
|
if (spell == null): continue
|
|
spells.erase(spell)
|
|
var button: SpellButton = buttonBase.instantiate()
|
|
button.spell = spell
|
|
button.connect("spellClicked", displaySpell)
|
|
selected.add_child(button)
|
|
for spell: Spell in spells:
|
|
var button: SpellButton = buttonBase.instantiate()
|
|
button.spell = spell
|
|
button.connect("spellClicked", displaySpell)
|
|
library.add_child(button)
|
|
|
|
func displaySpell(spellButton: SpellButton):
|
|
zone.show()
|
|
selectedButton = spellButton
|
|
icon.texture = selectedButton.spell.icon
|
|
nam.text = "[center]%s[/center]" % selectedButton.spell.name
|
|
rarity.text = "[center]%s[/center]" % data.Rarity.find_key(selectedButton.spell.rarity)
|
|
description.text = "[center]%s[/center]" % selectedButton.spell.description
|
|
var text: String = "Damage: %s\nBackfire Strength: %s\nFire Resistance: %s\nIce Resistance: %s\nPoison Resistance: %s\nStone Resistance: %s"
|
|
if (selectedButton.spell.damage < 0): text = "Healing: %s\nBackfire Strength: %s\nFire Resistance: %s\nIce Resistance: %s\nPoison Resistance: %s\nStone Resistance: %s"
|
|
var resistances: Dictionary = selectedButton.spell.blockStrength
|
|
damage.text = text % [selectedButton.spell.damage if selectedButton.spell.damage >= 0 else -selectedButton.spell.damage, selectedButton.spell.backfireStrength, 100 - resistances[Data.Element.FIRE] * 100, 100 - resistances[Data.Element.ICE] * 100, 100 - resistances[Data.Element.POISON] * 100, 100 - resistances[Data.Element.STONE] * 100]
|
|
if (selectedButton in selected.get_children()):
|
|
choice.get_child(0).text = "[center]Remove[/center]"
|
|
if (selected.get_child_count() == 1):
|
|
choice.disabled = true
|
|
choice.modulate = Color("fff8cf87")
|
|
else:
|
|
choice.disabled = false
|
|
choice.modulate = Color("fff8cf")
|
|
else:
|
|
choice.get_child(0).text = "[center]Select[/center]"
|
|
if (selected.get_child_count() >= 5):
|
|
choice.disabled = true
|
|
choice.modulate = Color("fff8cf87")
|
|
else:
|
|
choice.disabled = false
|
|
choice.modulate = Color("fff8cf")
|
|
|
|
func _on_choice_pressed():
|
|
if (selectedButton in selected.get_children()):
|
|
data.spellbook.spells.erase(selectedButton.spell)
|
|
selected.remove_child(selectedButton)
|
|
library.add_child(selectedButton)
|
|
else:
|
|
data.spellbook.spells.append(selectedButton.spell)
|
|
library.remove_child(selectedButton)
|
|
selected.add_child(selectedButton)
|
|
|
|
func _on_main_menu_pressed():
|
|
var m: Control = load(data.locations[data.Location.MAINMENU]).instantiate()
|
|
$/root/Root.add_child(m)
|
|
data.musicPlayer.setLoc(Data.Location.MAINMENU)
|
|
data.loc = data.Location.MAINMENU
|
|
self.queue_free()
|
|
|
|
func _on_continue_pressed():
|
|
var a: Node2D = load(data.locations[data.Location.ARENA]).instantiate()
|
|
$/root/Root.add_child(a)
|
|
data.musicPlayer.setLoc(Data.Location.ARENA)
|
|
data.loc = data.Location.ARENA
|
|
self.queue_free()
|
|
data.playing = true
|