gae_wild_jam/scripts/cauldron_bar.gd

54 lines
1.7 KiB
GDScript

extends HBoxContainer
var base = AtlasTexture.new()
var yellow = AtlasTexture.new()
var orange = AtlasTexture.new()
var red = AtlasTexture.new()
var slots: Array[TextureRect] = []
var colors: Array[AtlasTexture] = []
var burning_colors: Array[AtlasTexture] = []
var slot_states = [0, 0, 0]
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
base.atlas = preload("res://assets/Cauldron's Brew/Equiptment.png")
base.region = Rect2(96, 96, 96, 96)
yellow.atlas = preload("res://assets/Cauldron's Brew/Cauldron and Powder.png")
yellow.region = Rect2(96, 96, 96, 96)
orange.atlas = preload("res://assets/Cauldron's Brew/Cauldron and Powder.png")
orange.region = Rect2(192, 96, 96, 96)
red.atlas = preload("res://assets/Cauldron's Brew/Cauldron and Powder.png")
red.region = Rect2(288, 96, 96, 96)
slots = [$Empty1, $Empty2, $Empty3]
colors = [base, yellow, red, orange]
enrich_burning_colors()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func change_texture(slot_index: int, color_index: int):
slots[slot_index].texture = colors[color_index]
slot_states[slot_index] = color_index
pass
func reset_texture():
for slot in slots:
slot.texture = colors[0]
slot_states = [0,0,0]
func ignite_cauldrons():
for i in slots.size():
slots[i].texture = burning_colors[slot_states[i]]
await get_tree().create_timer(0.4).timeout
pass
func enrich_burning_colors():
for color in colors:
var burning = AtlasTexture.new()
burning.atlas = color.atlas
burning.region = Rect2(color.region.position.x, color.region.position.y + 96, 96, 96)
burning_colors.append(burning)