-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShopGui.gd
76 lines (57 loc) · 1.83 KB
/
ShopGui.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
extends Control
@onready var ContainerSkins= $ContainerSkins
var ruta = "res://sprites/"
var cont = 1
var coins
func _ready():
setSkins(cont)
coins = Global.player_data.coins
$TextureCoinsRect/coins.text = str(coins)
func setSkins(cont):
var skinsName = Global.skins.keys()
var skinsArray = Global.skins.values()
ContainerSkins.get_node("nameSkin").text = skinsName[cont]
ContainerSkins.get_node("ImageSkin").texture = load(ruta + skinsName[cont] + "/Portada.png")
ContainerSkins.get_node("ContainerPrices/PriceSkin").text = str(skinsArray[cont].price)
setButtons($ButtonBuy, skinsArray[cont], skinsName[cont])
func setButtons(butom: TextureButton, skin, skinName):
if(skinName == Global.player_data.skin):
butom.texture_normal = load("res://GUI/Buttons/inUse.png")
butom.texture_hover = load("")
else:
if(skin.blocked):
butom.texture_normal = load("res://GUI/Buttons/BuyBoton.png")
butom.texture_hover = load("res://GUI/pressed/buyPresed.png")
else:
butom.texture_normal = load("res://GUI/Buttons/equip.png")
butom.texture_hover = load("res://GUI/pressed/equip.png")
func buySkin(skin, skinname):
if(skin.blocked):
if(Global.player_data.coins >= skin.price):
Global.player_data.coins -= skin.price
skin.blocked = false
print("skin Comprada " + skinname)
setSkins(cont)
else:
Global.player_data.skin = skinname
print("skin equipada " + skinname)
setSkins(cont)
func _on_button_atras_pressed():
get_tree().change_scene_to_file("res://ui.tscn")
func _on_button_left_pressed():
if(cont >0):
cont -= 1
else:
cont = 0
setSkins(cont)
func _on_button_rigth_pressed():
if(cont < 3):
cont += 1
else:
cont = 3
setSkins(cont)
func _on_button_buy_pressed():
var skinsName = Global.skins.keys()
var skinsArray = Global.skins.values()
buySkin(skinsArray[cont], skinsName[cont])
Global.save_Data()