2048-Shooter/Objects/Slot.gd

56 lines
1.1 KiB
GDScript3
Raw Permalink Normal View History

2022-11-27 20:47:03 +01:00
extends Panel
var PanzerType = preload("res://Objects/Panzer.tscn")
var Panzer = null
var level = 0
2022-11-27 20:47:03 +01:00
var start_panzer = 0
func _process(delta):
check_level()
2022-11-27 20:47:03 +01:00
if start_panzer > 0:
if randi() % 2 == 0:
Panzer = PanzerType.instance()
add_child(Panzer)
start_panzer -= 1
func pickFromSlot():
remove_child(Panzer)
var GameNode = find_parent("Game")
GameNode.add_child(Panzer)
Panzer = null
func putIntoSlot(new_panzer):
if level != 0 and new_panzer.old_slot == null:
if new_panzer.PanzerType != null:
new_panzer.PanzerType += 1
else:
new_panzer.PanzerType = 2
2022-11-27 20:47:03 +01:00
Panzer = new_panzer
Panzer.position = Vector2(64, 64)
var GameNode = find_parent("Game")
GameNode.remove_child(Panzer)
add_child(Panzer)
func upgradePanzerInSlot():
Panzer.hit_power *= 2
Panzer.PanzerType += 1
2022-11-27 20:47:03 +01:00
pass
func _set_start_panzer(value):
start_panzer += value
func _on_slotshape_area_entered(area):
if area.is_in_group("Panzer"):
var GameNode = find_parent("Game")
if GameNode.holding_item != null:
GameNode.hover = self
pass # Replace with function body.
func check_level():
if level == 1:
modulate = Color(1, 0.984375, 0)
pass