mirror of
https://github.com/Yadciel1/2048-Shooter.git
synced 2024-11-12 17:11:18 +01:00
66 lines
1.8 KiB
GDScript
66 lines
1.8 KiB
GDScript
extends Node2D
|
|
|
|
|
|
const SlotClass = preload("res://Slot.gd")
|
|
var Panzer_Temp = preload("res://Panzer.tscn")
|
|
onready var game_slots = $VBoxContainer/PanzerSlots
|
|
var holding_item = null
|
|
var buy_panzer_left = 0
|
|
|
|
signal speed_shoot
|
|
|
|
func _ready():
|
|
for gam_slot in game_slots.get_children():
|
|
gam_slot.connect("gui_input", self, "slot_gui_input", [gam_slot])
|
|
var pBars = get_tree().get_nodes_in_group("XP")
|
|
for pBar in pBars:
|
|
pBar.connect("full_bar", self, "_enable_Panzer")
|
|
|
|
|
|
func slot_gui_input(event: InputEvent, slot: SlotClass):
|
|
if event is InputEventMouseButton:
|
|
if event.button_index == BUTTON_LEFT && event.pressed:
|
|
if holding_item != null:
|
|
if!slot.Panzer:
|
|
slot.putIntoSlot(holding_item)
|
|
holding_item = null
|
|
else:
|
|
var temp_item = slot.Panzer
|
|
slot.pickFromSlot()
|
|
temp_item.global_position = event.global_position
|
|
slot.putIntoSlot(holding_item)
|
|
holding_item = temp_item
|
|
elif slot.Panzer:
|
|
holding_item = slot.Panzer
|
|
slot.pickFromSlot()
|
|
holding_item.global_position = get_global_mouse_position()
|
|
|
|
func _input(event):
|
|
if holding_item:
|
|
holding_item.global_position = get_global_mouse_position()
|
|
pass
|
|
|
|
|
|
func _on_Panzer_pressed():
|
|
buy_panzer_left -= 1
|
|
if buy_panzer_left == 0:
|
|
$VBoxContainer/ButtonGrid/Panzer.disabled = true
|
|
if holding_item == null:
|
|
var Panzer = null
|
|
Panzer = Panzer_Temp.instance()
|
|
add_child(Panzer)
|
|
holding_item = Panzer
|
|
holding_item.global_position = get_global_mouse_position()
|
|
pass # Replace with function body.
|
|
|
|
|
|
func _on_Speed_pressed():
|
|
var value = 0.5
|
|
emit_signal("speed_shoot", value)
|
|
$VBoxContainer/ButtonGrid/Speed.disabled = true
|
|
pass # Replace with function body.
|
|
|
|
func _enable_Panzer(value):
|
|
buy_panzer_left += 1
|
|
$VBoxContainer/ButtonGrid/Panzer.disabled = false
|