Raise-Your-Wand/Scripts/RoundFinishedIndicator.gd
2024-05-30 22:55:48 -04:00

50 lines
1.5 KiB
GDScript

extends Control
@onready var backdrop: ColorRect = $ColorRect
@onready var result: RichTextLabel = $Result
@onready var animationPlayer: AnimationPlayer = $AnimationPlayer
@onready var data: Data = $/root/Root/Data
@onready var icon = $NewSpell/Icon
@onready var nam = $NewSpell/Name
@onready var rarity = $NewSpell/Rarity
@onready var description = $NewSpell/Description
var timer: float = 0
var won: bool
# Called when the node enters the scene tree for the first time.
func _ready():
data.player.connect("died", displayResult)
data.opponent.connect("died", displayResult)
func displayResult(victory: bool):
won = victory
if (victory):
result.text = "[center]Victory[/center]"
else:
result.text = "[center]Defeat[/center]"
animationPlayer.play("show")
func animFinished(s: String):
if (won):
won = false
var spell: Spell = data.getNewSpell()
if (spell != null):
icon.texture = spell.icon
nam.text = "[center]%s[/center]" % spell.name
rarity.text = "[center]%s[/center]" % data.Rarity.find_key(spell.rarity)
description.text = "[center]%s[/center]" % spell.description
animationPlayer.play("newSpell")
else:
animationPlayer.play("continue")
elif (s != "continue" && s != "RESET"):
animationPlayer.play("continue")
func _on_continue_pressed():
await data.transitioner.hideScreen()
var t: Tavern = load(data.locations[data.Location.TAVERN]).instantiate()
$/root/Root.add_child(t)
data.musicPlayer.setLoc(Data.Location.TAVERN)
data.loc = data.Location.TAVERN
$/root/Root/Arena.queue_free()