added different spells based on cauldron input and moved functions no cauldron
parent
e89b80a825
commit
832d2dbd70
|
|
@ -9,9 +9,12 @@ var slots: Array[TextureRect] = []
|
||||||
var colors: Array[AtlasTexture] = []
|
var colors: Array[AtlasTexture] = []
|
||||||
var burning_colors: Array[AtlasTexture] = []
|
var burning_colors: Array[AtlasTexture] = []
|
||||||
var slot_states = [0, 0, 0]
|
var slot_states = [0, 0, 0]
|
||||||
|
var progres_index = 0
|
||||||
|
var is_brewing
|
||||||
|
@onready var witch = get_parent()
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
print(witch)
|
||||||
base.atlas = preload("res://assets/Cauldron's Brew/Equiptment.png")
|
base.atlas = preload("res://assets/Cauldron's Brew/Equiptment.png")
|
||||||
base.region = Rect2(96, 96, 96, 96)
|
base.region = Rect2(96, 96, 96, 96)
|
||||||
yellow.atlas = preload("res://assets/Cauldron's Brew/Cauldron and Powder.png")
|
yellow.atlas = preload("res://assets/Cauldron's Brew/Cauldron and Powder.png")
|
||||||
|
|
@ -55,10 +58,36 @@ func enrich_burning_colors():
|
||||||
burning.region = Rect2(color.region.position.x, color.region.position.y + 96, 96, 96)
|
burning.region = Rect2(color.region.position.x, color.region.position.y + 96, 96, 96)
|
||||||
burning_colors.append(burning)
|
burning_colors.append(burning)
|
||||||
|
|
||||||
func progres_bar(fruit, progress):
|
func progres_bar(fruit):
|
||||||
|
if is_brewing:
|
||||||
|
return
|
||||||
if fruit is Apple:
|
if fruit is Apple:
|
||||||
change_texture(progress,3)
|
change_texture(progres_index,2)
|
||||||
if fruit is Grape:
|
if fruit is Grape:
|
||||||
change_texture(progress, 4)
|
change_texture(progres_index, 4)
|
||||||
|
progres_index += 1
|
||||||
|
if progres_index == 3:
|
||||||
|
brew(slot_states)
|
||||||
|
progres_index = 0
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func brew(fruits):
|
||||||
|
is_brewing = true
|
||||||
|
var unique = get_unique_fruits()
|
||||||
|
await ignite_cauldrons()
|
||||||
|
if unique.has(2) and unique.size() == 1:
|
||||||
|
witch.shoot_fireballs()
|
||||||
|
elif unique.has(4) and unique.size() == 1:
|
||||||
|
witch.shoot_shuriken()
|
||||||
|
elif unique.has(2) and unique.has(4) and unique.size() == 2:
|
||||||
|
witch.shoot_fireballs()
|
||||||
|
witch.shoot_shuriken()
|
||||||
|
reset_texture()
|
||||||
|
is_brewing = false
|
||||||
|
|
||||||
|
func get_unique_fruits() -> Array:
|
||||||
|
var unique = []
|
||||||
|
for fruit in slot_states:
|
||||||
|
if fruit != null and not fruit in unique:
|
||||||
|
unique.append(fruit)
|
||||||
|
return unique
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
var camera
|
var camera
|
||||||
var bar_progress = 0
|
|
||||||
var is_casting = false
|
var is_casting = false
|
||||||
var fireball = preload("res://scenes/fireball.tscn")
|
var fireball = preload("res://scenes/fireball.tscn")
|
||||||
var shuriken = preload("res://scenes/shuriken.tscn")
|
var shuriken = preload("res://scenes/shuriken.tscn")
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
$CauldronBar.witch = self
|
||||||
camera = get_node("/root/Game/Camera2D")
|
camera = get_node("/root/Game/Camera2D")
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
|
@ -16,16 +16,8 @@ func _physics_process(delta: float) -> void:
|
||||||
func _on_collect(DropsBase):
|
func _on_collect(DropsBase):
|
||||||
if is_casting:
|
if is_casting:
|
||||||
return
|
return
|
||||||
$CauldronBar.progres_bar(DropsBase, bar_progress)
|
$CauldronBar.progres_bar(DropsBase)
|
||||||
bar_progress += 1
|
|
||||||
if bar_progress == 3:
|
|
||||||
bar_progress = 0
|
|
||||||
is_casting = true
|
|
||||||
await $CauldronBar.ignite_cauldrons()
|
|
||||||
shoot_shuriken()
|
|
||||||
camera.shake(0.3,0.8)
|
|
||||||
$CauldronBar.reset_texture()
|
|
||||||
is_casting = false
|
|
||||||
|
|
||||||
func shoot_fireballs():
|
func shoot_fireballs():
|
||||||
var enemies = get_tree().get_nodes_in_group("enemies")
|
var enemies = get_tree().get_nodes_in_group("enemies")
|
||||||
|
|
@ -34,6 +26,7 @@ func shoot_fireballs():
|
||||||
fb.global_position = global_position
|
fb.global_position = global_position
|
||||||
get_parent().add_child(fb)
|
get_parent().add_child(fb)
|
||||||
fb.launch(enemy.global_position)
|
fb.launch(enemy.global_position)
|
||||||
|
camera.shake(0.3,0.8)
|
||||||
|
|
||||||
func shoot_shuriken():
|
func shoot_shuriken():
|
||||||
var sh = shuriken.instantiate()
|
var sh = shuriken.instantiate()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue