meowbay created and other things
This commit is contained in:
parent
09625d8285
commit
93cc1a8c59
35 changed files with 318 additions and 41 deletions
27
shop/listing.gd
Normal file
27
shop/listing.gd
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
extends HBoxContainer
|
||||
|
||||
@export var item_slot : ItemSlot
|
||||
@export var button : Button
|
||||
var item_cost : int
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
item_slot.block_taking = true
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if item_slot.item:
|
||||
button.disabled = PlayerInventory.money <= item_cost
|
||||
|
||||
func prepare(item : ItemData):
|
||||
item_slot.item = item
|
||||
button.text = "Buy $" + str(item.buy_value)
|
||||
item_cost = item.buy_value
|
||||
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
if PlayerInventory.money >= item_cost:
|
||||
PlayerInventory.money -= item_cost
|
||||
PlayerInventory.inventory_panel.add_item(item_slot.item)
|
||||
1
shop/listing.gd.uid
Normal file
1
shop/listing.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cplyptfsma786
|
||||
22
shop/listing.tscn
Normal file
22
shop/listing.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cluhvm32w5321"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cplyptfsma786" path="res://shop/listing.gd" id="1_ir6io"]
|
||||
[ext_resource type="PackedScene" uid="uid://dgqs20xf7l8c" path="res://inv_system/item_slot.tscn" id="1_uc81x"]
|
||||
|
||||
[node name="listing" type="HBoxContainer" node_paths=PackedStringArray("item_slot", "button")]
|
||||
size_flags_horizontal = 3
|
||||
alignment = 1
|
||||
script = ExtResource("1_ir6io")
|
||||
item_slot = NodePath("ItemSlot2")
|
||||
button = NodePath("Button")
|
||||
|
||||
[node name="ItemSlot2" parent="." instance=ExtResource("1_uc81x")]
|
||||
custom_minimum_size = Vector2(32, 32)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Buy $99999"
|
||||
|
||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||
22
shop/meowbay.gd
Normal file
22
shop/meowbay.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
extends PanelContainer
|
||||
|
||||
@export var listing_grid : GridContainer
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
#RecipeManager.recipes_loaded.connect(make_listings)
|
||||
make_listings()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func make_listings():
|
||||
print("building meowbay")
|
||||
for item in RecipeManager.items:
|
||||
if item.can_buy:
|
||||
var new_listing = load("res://shop/listing.tscn").instantiate()
|
||||
new_listing.prepare(item)
|
||||
listing_grid.add_child(new_listing)
|
||||
1
shop/meowbay.gd.uid
Normal file
1
shop/meowbay.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bxdc7rrd22mlr
|
||||
Loading…
Add table
Add a link
Reference in a new issue