diff --git a/#Scenes/Events/shop/0.tscn b/#Scenes/Events/shop/0.tscn index 56bd4e34..cfd29024 100644 --- a/#Scenes/Events/shop/0.tscn +++ b/#Scenes/Events/shop/0.tscn @@ -1,8 +1,12 @@ -[gd_scene load_steps=4 format=3 uid="uid://b8hbst1klk5ng"] +[gd_scene load_steps=8 format=3 uid="uid://b8hbst1klk5ng"] [ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="1_7gwvp"] [ext_resource type="Script" path="res://#Scenes/SceneScripts/ShopScene.gd" id="1_u1m6k"] -[ext_resource type="Script" path="res://#Scenes/Events/skipEventButton.gd" id="2_owx5q"] +[ext_resource type="PackedScene" uid="uid://cdt4k2reymt2i" path="res://Shop/shop_item_card.tscn" id="4_bbct0"] +[ext_resource type="Texture2D" uid="uid://c6fmkrnbs4mf6" path="res://Art/Background/0-0.test.CatTree.png" id="6_ppjdl"] +[ext_resource type="PackedScene" uid="uid://tfeo4epmhse0" path="res://Shop/shop_item_torch.tscn" id="11_3t8vb"] +[ext_resource type="Script" path="res://#Scenes/SceneScripts/CardRemoval.gd" id="12_1uxnd"] +[ext_resource type="Texture2D" uid="uid://dd06ocktximw7" path="res://Art/Menus/Trash-1.png" id="12_yofyg"] [node name="Control" type="Control"] layout_mode = 3 @@ -13,32 +17,98 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_u1m6k") -[node name="TextEdit" type="TextEdit" parent="."] -layout_mode = 0 -offset_right = 1276.0 -offset_bottom = 715.0 -theme_override_font_sizes/font_size = 100 -placeholder_text = "This is a placeholder -shop event" - [node name="TopBarOverlay" parent="." instance=ExtResource("1_7gwvp")] layout_mode = 1 -[node name="SkipEventButton" type="Button" parent="."] +[node name="ShopItems" type="Control" parent="."] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="ShopItemTorch" parent="ShopItems" instance=ExtResource("11_3t8vb")] +offset_left = 835.0 +offset_top = 116.0 +offset_right = 835.0 +offset_bottom = 116.0 +amount = 5 + +[node name="Card" type="Control" parent="ShopItems"] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="ShopItemCard" parent="ShopItems/Card" instance=ExtResource("4_bbct0")] +offset_left = 1111.0 +offset_top = 496.0 +offset_right = 1111.0 +offset_bottom = 496.0 +scale = Vector2(0.5, 0.5) + +[node name="ShopItem" parent="ShopItems/Card" instance=ExtResource("4_bbct0")] +offset_left = 648.0 +offset_top = 476.0 +offset_right = 648.0 +offset_bottom = 476.0 +scale = Vector2(0.5, 0.5) + +[node name="ShopItem2" parent="ShopItems/Card" instance=ExtResource("4_bbct0")] +offset_left = 891.0 +offset_top = 486.0 +offset_right = 891.0 +offset_bottom = 486.0 +scale = Vector2(0.5, 0.5) + +[node name="CardRemoval" type="TextureButton" parent="ShopItems"] layout_mode = 1 -anchors_preset = 3 -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = -280.0 -offset_top = -220.0 -offset_right = -80.0 -offset_bottom = -140.0 -grow_horizontal = 0 -grow_vertical = 0 -theme_override_font_sizes/font_size = 26 -text = "Skip this event" -script = ExtResource("2_owx5q") - -[connection signal="pressed" from="SkipEventButton" to="SkipEventButton" method="_on_pressed"] +anchors_preset = -1 +anchor_left = 1.00078 +anchor_right = 1.00078 +offset_left = 731.966 +offset_top = 769.0 +offset_right = 791.966 +offset_bottom = 829.0 +scale = Vector2(2.92, 2.92) +texture_normal = ExtResource("12_yofyg") +texture_pressed = ExtResource("12_yofyg") +texture_hover = ExtResource("12_yofyg") +texture_disabled = ExtResource("12_yofyg") +texture_focused = ExtResource("12_yofyg") +stretch_mode = 0 +script = ExtResource("12_1uxnd") + +[node name="CardRemoval" type="Control" parent="ShopItems/CardRemoval"] +anchors_preset = 0 +offset_left = -27.0 +offset_top = -11.0 +offset_right = -27.0 +offset_bottom = -11.0 + +[node name="ColorRect" type="ColorRect" parent="ShopItems/CardRemoval/CardRemoval"] +layout_mode = 0 +offset_left = 23.5753 +offset_top = 76.7534 +offset_right = 86.5753 +offset_bottom = 100.753 + +[node name="Label" type="Label" parent="ShopItems/CardRemoval/CardRemoval/ColorRect"] +layout_mode = 0 +offset_left = -0.109672 +offset_top = 0.602746 +offset_right = 61.8903 +offset_bottom = 23.6027 +scale = Vector2(0.998719, 1.01696) +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "100" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="BackGround" type="TextureRect" parent="."] +z_index = -1 +layout_mode = 0 +offset_left = -53.0 +offset_top = 10.0 +offset_right = 1960.0 +offset_bottom = 1111.0 +mouse_filter = 2 +texture = ExtResource("6_ppjdl") +expand_mode = 1 diff --git a/#Scenes/SceneScripts/CardRemoval.gd b/#Scenes/SceneScripts/CardRemoval.gd new file mode 100644 index 00000000..f682041f --- /dev/null +++ b/#Scenes/SceneScripts/CardRemoval.gd @@ -0,0 +1,23 @@ +extends CardPileUISetter + +@onready var priceText : Label = $CardRemoval/ColorRect/Label +@onready var sceneRoot : Node = $"../.." + +func _ready() -> void: + priceText.text = str(ShopManager.card_removal_price) + super() + +func _pressed() -> void: + if(!InventoryManager.gold_component.can_afford(ShopManager.card_removal_price)): + return + + + var uiPile: Control = cardUI.instantiate() + + uiPile.populate(get_name()) + sceneRoot.add_child(uiPile) + queue_free() + +func _on_button_pressed() -> void: + + pass diff --git a/#Scenes/SceneScripts/ShopScene.gd b/#Scenes/SceneScripts/ShopScene.gd index 219c0d12..dd5b6385 100644 --- a/#Scenes/SceneScripts/ShopScene.gd +++ b/#Scenes/SceneScripts/ShopScene.gd @@ -1,4 +1,21 @@ extends Control +class_name ShopScene func _ready() -> void: + + # This code has to happen after the map has done '.on_event_started' [br] + # so I just put a .1 delay on it + var timer : SceneTreeTimer = get_tree().create_timer(0.1) + timer.timeout.connect(_on_start_with_delay) + + +## This code has to happen after the map has done '.on_event_started' [br] +## so I just put a .1 delay on it +func _on_start_with_delay() -> void: SaveManager.execute_save() + + if(PlayerManager.player_room != null): + PlayerManager.player_room.room_event.on_event_ended() + +func _stock_shop() -> void: + pass diff --git a/#Scenes/TestingScene.tscn b/#Scenes/TestingScene.tscn index 2ced87a5..1cd2bdfa 100644 --- a/#Scenes/TestingScene.tscn +++ b/#Scenes/TestingScene.tscn @@ -11,9 +11,9 @@ [ext_resource type="Texture2D" uid="uid://caemucaya30wh" path="res://Art/Card_layout/draw_pile.png" id="11_pw70x"] [ext_resource type="Texture2D" uid="uid://d4muqvs3etnr8" path="res://Art/Card_layout/discard_pile.png" id="12_kxw48"] [ext_resource type="Script" path="res://UI/EndTurnButton.gd" id="14_dpe64"] -[ext_resource type="PackedScene" path="res://#Scenes/TopBarOverlay.tscn" id="14_e54tj"] +[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="14_e54tj"] [ext_resource type="Script" path="res://UI/EnergyLabel.gd" id="14_nckre"] -[ext_resource type="Resource" path="res://Items/test_relic.tres" id="19_prw12"] +[ext_resource type="Resource" uid="uid://c5fh7bnfh3l4u" path="res://Items/test_relic.tres" id="19_prw12"] [ext_resource type="Texture2D" uid="uid://bl5v3bgnntoc5" path="res://Art/Card_layout/energy_count.png" id="19_spyxg"] [sub_resource type="GDScript" id="GDScript_g5yv1"] diff --git a/Art/Background/0-0.test.CatTree.png b/Art/Background/0-0.test.CatTree.png new file mode 100644 index 00000000..772c6550 Binary files /dev/null and b/Art/Background/0-0.test.CatTree.png differ diff --git a/Art/Background/0-0.test.CatTree.png.import b/Art/Background/0-0.test.CatTree.png.import new file mode 100644 index 00000000..b1c72614 --- /dev/null +++ b/Art/Background/0-0.test.CatTree.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c6fmkrnbs4mf6" +path="res://.godot/imported/0-0.test.CatTree.png-85c2a2ddf3b5a611c2c6d4f74b8e8a51.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Art/Background/0-0.test.CatTree.png" +dest_files=["res://.godot/imported/0-0.test.CatTree.png-85c2a2ddf3b5a611c2c6d4f74b8e8a51.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Art/Menus/Torch-1.png b/Art/Menus/Torch-1.png new file mode 100644 index 00000000..28e99aef Binary files /dev/null and b/Art/Menus/Torch-1.png differ diff --git a/Art/Menus/Torch-1.png.import b/Art/Menus/Torch-1.png.import new file mode 100644 index 00000000..2bd0e6a5 --- /dev/null +++ b/Art/Menus/Torch-1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://q8og304npj17" +path="res://.godot/imported/Torch-1.png-83e2f1112a740f117332d625f3e72da4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Art/Menus/Torch-1.png" +dest_files=["res://.godot/imported/Torch-1.png-83e2f1112a740f117332d625f3e72da4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Art/Menus/Trash-1.png b/Art/Menus/Trash-1.png new file mode 100644 index 00000000..207fa563 Binary files /dev/null and b/Art/Menus/Trash-1.png differ diff --git a/Art/Menus/Trash-1.png.import b/Art/Menus/Trash-1.png.import new file mode 100644 index 00000000..f46e93db --- /dev/null +++ b/Art/Menus/Trash-1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dd06ocktximw7" +path="res://.godot/imported/Trash-1.png-ce07c71134e16d0aecc8b7d0db00fb11.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Art/Menus/Trash-1.png" +dest_files=["res://.godot/imported/Trash-1.png-ce07c71134e16d0aecc8b7d0db00fb11.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Cards/CardWorld.gd b/Cards/CardWorld.gd index 4eca4e33..c799a6ea 100644 --- a/Cards/CardWorld.gd +++ b/Cards/CardWorld.gd @@ -22,6 +22,16 @@ func init_card(in_card_data: CardBase) -> void: card_cast_type = GlobalEnums.CardCastType.TARGET break +## takes money and increases price of shop removal, should only be used when this is wanted +func remove_this_from_player_deck_with_price() -> void: + if(!InventoryManager.gold_component.can_afford(ShopManager.card_removal_price)): + return + + ShopManager.remove_card_from_player_deck_with_price(card_data) + +## this should be used most of the time we want to take a card from the player +func remove_this_from_player_deck_without_price() -> void: + ShopManager.remove_card_from_player_deck_without_price(card_data) func _on_phase_changed(new_phase: GlobalEnums.CombatPhase, _old_phase: GlobalEnums.CombatPhase) -> void: # enable clicks on card only if player is in attack phase diff --git a/Cards/Resource/Test Cards/Card_Energy.tres b/Cards/Resource/Test Cards/Card_Energy.tres index 70240489..e7a9fc80 100644 --- a/Cards/Resource/Test Cards/Card_Energy.tres +++ b/Cards/Resource/Test Cards/Card_Energy.tres @@ -26,6 +26,8 @@ energy_cost = 2 script = ExtResource("3_opvsg") application_type = 0 card_title = "Gain 70 energy" +card_type = 0 card_description = "Gain 70 energy" +card_artist_name = "NULL" card_effects_data = Array[ExtResource("2_dr7f0")]([SubResource("Resource_6gvxm")]) energy_info = SubResource("Resource_1hn6q") diff --git a/Global/DEBUG_VAR.gd b/Global/DEBUG_VAR.gd index 6fcf0170..fc87fac9 100644 --- a/Global/DEBUG_VAR.gd +++ b/Global/DEBUG_VAR.gd @@ -20,6 +20,9 @@ const DEBUG_ACTIVE_INVENTORY_DEBUG_BUTTONS : bool = false ## TO BE REMOVED after implmentation const DEBUG_PRINT_EVENT_COUNT : bool = false +## Makes player start with a lot of gold +const DEBUG_START_WITH_A_LOT_OF_GOLD : bool = false + ## Used in tests to use the same enemy group all the time ## It can't be a const because we change it inside the tests var DEBUG_USE_TEST_ENEMY_GROUP: bool = false diff --git a/Items/test_consumable_2.tres b/Items/test_consumable_2.tres new file mode 100644 index 00000000..d87aa163 --- /dev/null +++ b/Items/test_consumable_2.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" script_class="Consumable" load_steps=2 format=3 uid="uid://qclftsxybsw"] + +[ext_resource type="Script" path="res://Items/Consumable.gd" id="1_5ygqd"] + +[resource] +resource_name = "Amoogus" +script = ExtResource("1_5ygqd") +name = "Golden apple" +description = "But she eated it" +image_path = "res://Art/Card_art/default_art.png" diff --git a/Items/test_relic.tres b/Items/test_relic.tres index c28199b7..7e7e25cc 100644 --- a/Items/test_relic.tres +++ b/Items/test_relic.tres @@ -6,4 +6,4 @@ script = ExtResource("1_pjxtd") name = "Defualt Icon" description = "test_desc" -sprite_path = "res://icon.svg" +sprite_path = "res://addons/gut/icon.png" diff --git a/Managers/InventoryManager.gd b/Managers/InventoryManager.gd index 26b866e9..e640d0b4 100644 --- a/Managers/InventoryManager.gd +++ b/Managers/InventoryManager.gd @@ -15,6 +15,10 @@ var relic_component : InventoryRelicComponent = InventoryRelicComponent.new() var inventory_HUD : PackedScene = preload("res://InventoryComponents/InventoryHUD/inventory_hud.tscn") var instanced_inventory_HUD : Node +func _ready() -> void: + if(DebugVar.DEBUG_START_WITH_A_LOT_OF_GOLD): + gold_component.add_gold(999999999) + func instance_inventory_HUD() -> void: instanced_inventory_HUD = inventory_HUD.instantiate() get_tree().current_scene.add_child(instanced_inventory_HUD) @@ -43,6 +47,10 @@ func subtract_torch() -> void: func init_data() -> void: close_inventory_HUD() gold_component = InventoryGoldComponent.new() + + if(DebugVar.DEBUG_START_WITH_A_LOT_OF_GOLD): + gold_component.add_gold(999999999) + torch_component = InventoryTorchComponent.new() consumable_component = InventoryConsumablesComponent.new() relic_component = InventoryRelicComponent.new() diff --git a/Managers/RandomGenerator.gd b/Managers/RandomGenerator.gd index 4d421be3..417c6f46 100644 --- a/Managers/RandomGenerator.gd +++ b/Managers/RandomGenerator.gd @@ -5,10 +5,12 @@ extends Node # Set this to a value other than -1 to have deterministic randomness. # Make sure to set back to -1 when done testing! const GAME_SEED = -1 - +var randomNumberGenerator : RandomNumberGenerator func _ready() -> void: set_game_seed(GAME_SEED) + randomNumberGenerator = RandomNumberGenerator.new() + randomNumberGenerator.seed = GAME_SEED func set_game_seed(given_seed: int = -1) -> void: @@ -18,3 +20,6 @@ func set_game_seed(given_seed: int = -1) -> void: seed(set_seed) print("Seed set to: " + str(set_seed)) + +func get_random_int(min: int, max: int) -> int: + return randomNumberGenerator.randi_range(min, max) diff --git a/Managers/ShopManager.gd b/Managers/ShopManager.gd new file mode 100644 index 00000000..7dda971b --- /dev/null +++ b/Managers/ShopManager.gd @@ -0,0 +1,28 @@ +extends Node +## Manager class for the shop + +## price for card removal at the shop events +var card_removal_price : int = 50 +var card_remocal_price_increase : int = 25 + +## the item pools for the various things provided in the shop[br] +@export var shop_card_pool : Array +@export var shop_relic_pool : Array +@export var shop_consumable_pool : Array + +func increase_removal_price() -> void: + card_removal_price += card_remocal_price_increase + +## Removes given card, takes money, and increases shop prices. Should only be used by the shop removal[br] +## or potentionaly a specific event +func remove_card_from_player_deck_with_price(card : CardBase) -> void: + if(!InventoryManager.gold_component.can_afford(ShopManager.card_removal_price)): + return + + CardManager.current_deck.erase(card) + InventoryManager.gold_component.lose_gold(card_removal_price) + increase_removal_price() + +## Should be used any time card should be removed from deck +func remove_card_from_player_deck_without_price(card : CardBase) -> void: + CardManager.current_deck.erase(card) diff --git a/Shop/ShopItem.gd b/Shop/ShopItem.gd new file mode 100644 index 00000000..e022c5c0 --- /dev/null +++ b/Shop/ShopItem.gd @@ -0,0 +1,23 @@ +extends Control +class_name ShopItem + +## base class for all items sold in the shop +## The classes deriving from this are named shopitem[item which is sold] + +@export var cost : int +@export var priceLabel : Label + +func _ready() -> void: + priceLabel.text = str(cost) + +func on_shop_item_clicked() ->void: + if(InventoryManager.gold_component.can_afford(cost)): + queue_free() + InventoryManager.gold_component.lose_gold(cost) + _give_player_item() + else: + print("can't afford") + +## this is an abstract class where each of the derived classes change to give the player their item +func _give_player_item() -> void: + pass diff --git a/Shop/ShopItemCard.gd b/Shop/ShopItemCard.gd new file mode 100644 index 00000000..4188b7c9 --- /dev/null +++ b/Shop/ShopItemCard.gd @@ -0,0 +1,15 @@ +extends ShopItem + +@export var cardWorld : CardWorld +var card : CardBase + +func _ready() -> void: + card = ShopManager.shop_card_pool[RandomGenerator.get_random_int(0, ShopManager.shop_card_pool.size() - 1)] + + cardWorld.init_card(card) + cardWorld.get_click_handler().on_click.connect(on_shop_item_clicked) + super() + + +func _give_player_item() -> void: + CardManager.current_deck.append(card) diff --git a/Shop/ShopManager.tscn b/Shop/ShopManager.tscn new file mode 100644 index 00000000..7e5a18d4 --- /dev/null +++ b/Shop/ShopManager.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=10 format=3 uid="uid://cunr4wwabqn1u"] + +[ext_resource type="Script" path="res://Managers/ShopManager.gd" id="1_rqenh"] +[ext_resource type="Resource" uid="uid://ckaua56xmrxib" path="res://Cards/Resource/Card_Energy.tres" id="2_bi5vb"] +[ext_resource type="Resource" uid="uid://bdjkrhy06ijb7" path="res://Cards/Resource/Card_PoisonRandom.tres" id="3_m7u3s"] +[ext_resource type="Resource" uid="uid://btj36bhn3n2tr" path="res://Cards/Resource/Card_Strength.tres" id="4_0e1wy"] +[ext_resource type="Resource" uid="uid://b4kmg3lm0e45q" path="res://Cards/Resource/Card_Vulnerability.tres" id="5_hech8"] +[ext_resource type="Resource" uid="uid://c5fh7bnfh3l4u" path="res://Items/test_relic.tres" id="6_whv6x"] +[ext_resource type="Resource" uid="uid://cu4gaxrv2jn81" path="res://Items/test_relic_2.tres" id="7_5msik"] +[ext_resource type="Resource" uid="uid://m8lhbvw2gawd" path="res://Items/test_consumable.tres" id="8_8fhko"] +[ext_resource type="Resource" uid="uid://qclftsxybsw" path="res://Items/test_consumable_2.tres" id="9_j2l7g"] + +[node name="ShopManager" type="Node"] +script = ExtResource("1_rqenh") +shop_card_pool = [ExtResource("2_bi5vb"), ExtResource("3_m7u3s"), ExtResource("4_0e1wy"), ExtResource("5_hech8")] +shop_relic_pool = [ExtResource("6_whv6x"), ExtResource("7_5msik")] +shop_consumable_pool = [ExtResource("8_8fhko"), ExtResource("9_j2l7g")] diff --git a/Shop/shop_item_card.tscn b/Shop/shop_item_card.tscn new file mode 100644 index 00000000..07bb2698 --- /dev/null +++ b/Shop/shop_item_card.tscn @@ -0,0 +1,42 @@ +[gd_scene load_steps=3 format=3 uid="uid://cdt4k2reymt2i"] + +[ext_resource type="Script" path="res://Shop/ShopItemCard.gd" id="1_4ryor"] +[ext_resource type="PackedScene" uid="uid://caxbd2ppk3ans" path="res://Cards/Card.tscn" id="2_2bk7m"] + +[node name="ShopItemCard" type="Control" node_paths=PackedStringArray("cardWorld", "priceLabel")] +layout_mode = 3 +anchors_preset = 0 +offset_left = -1.0 +offset_right = -1.0 +script = ExtResource("1_4ryor") +cardWorld = NodePath("Card") +cost = 25 +priceLabel = NodePath("PriceLabel/Label") + +[node name="Card" parent="." instance=ExtResource("2_2bk7m")] +offset_left = -178.0 +offset_top = -362.0 +offset_right = 172.0 +offset_bottom = 108.0 + +[node name="PriceLabel" type="ColorRect" parent="."] +layout_mode = 0 +offset_left = -163.0 +offset_top = 124.0 +offset_right = 180.0 +offset_bottom = 213.0 + +[node name="Label" type="Label" parent="PriceLabel"] +layout_mode = 0 +offset_left = 4.0 +offset_top = 2.0 +offset_right = 342.0 +offset_bottom = 86.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 56 +text = "dfdsfds +" +horizontal_alignment = 1 +vertical_alignment = 1 + +[editable path="Card"] diff --git a/Shop/shop_item_consumable.gd b/Shop/shop_item_consumable.gd new file mode 100644 index 00000000..9576f090 --- /dev/null +++ b/Shop/shop_item_consumable.gd @@ -0,0 +1,18 @@ +extends ShopItem + +var consumable : Consumable +@export var consumableImage : TextureButton +@export var clickHandler : ClickHandler + + +func _ready() -> void: + consumable = ShopManager.shop_consumable_pool[RandomGenerator.get_random_int(0, ShopManager.shop_consumable_pool.size() - 1)] + + + consumableImage.texture_normal = load(consumable.image_path) + clickHandler.on_click.connect(on_shop_item_clicked) + super() + + +func _give_player_item() -> void: + InventoryManager.consumable_component.add_consumable(consumable) diff --git a/Shop/shop_item_consumable.tscn b/Shop/shop_item_consumable.tscn new file mode 100644 index 00000000..bb1609cb --- /dev/null +++ b/Shop/shop_item_consumable.tscn @@ -0,0 +1,50 @@ +[gd_scene load_steps=3 format=3 uid="uid://c4bsmddaua2ye"] + +[ext_resource type="Script" path="res://Shop/shop_item_consumable.gd" id="1_m5rmx"] +[ext_resource type="Script" path="res://Input/ClickHandler.gd" id="3_h2ml3"] + +[node name="ShopItemConsumable" type="Control" node_paths=PackedStringArray("consumableImage", "clickHandler", "priceLabel")] +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_m5rmx") +consumableImage = NodePath("TextureRect") +clickHandler = NodePath("ClickHandler") +cost = 5 +priceLabel = NodePath("PriceLabel/Label") + +[node name="PriceLabel" type="ColorRect" parent="."] +layout_mode = 0 +offset_left = -80.0 +offset_top = 55.0 +offset_right = 74.0 +offset_bottom = 95.0 + +[node name="Label" type="Label" parent="PriceLabel"] +layout_mode = 0 +offset_left = 4.0 +offset_top = 2.0 +offset_right = 152.0 +offset_bottom = 40.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "dfdsfds +" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="TextureRect" type="TextureButton" parent="."] +layout_mode = 0 +offset_left = -33.0 +offset_top = -23.0 +offset_right = -4.0 +offset_bottom = 6.0 +scale = Vector2(2.32, 2.32) +ignore_texture_size = true +stretch_mode = 0 + +[node name="ClickHandler" type="Node" parent="."] +script = ExtResource("3_h2ml3") +time_to_lock_hover = 0.3 + +[connection signal="gui_input" from="TextureRect" to="ClickHandler" method="_on_gui_input_event"] +[connection signal="mouse_entered" from="TextureRect" to="ClickHandler" method="_on_mouse_entered"] +[connection signal="mouse_exited" from="TextureRect" to="ClickHandler" method="_on_mouse_exited"] diff --git a/Shop/shop_item_relic.gd b/Shop/shop_item_relic.gd new file mode 100644 index 00000000..8827b16c --- /dev/null +++ b/Shop/shop_item_relic.gd @@ -0,0 +1,15 @@ +extends ShopItem + +var relic : Relic +@export var relicImage : TextureButton +@export var clickHandler : ClickHandler + +func _ready() -> void: + relic = ShopManager.shop_relic_pool[RandomGenerator.get_random_int(0, ShopManager.shop_relic_pool.size() - 1)] + + relicImage.texture_normal = load(relic.sprite_path) + clickHandler.on_click.connect(on_shop_item_clicked) + super() + +func _give_player_item() -> void: + InventoryManager.relic_component.add_relic(relic) diff --git a/Shop/shop_item_relic.tscn b/Shop/shop_item_relic.tscn new file mode 100644 index 00000000..23ce4f0a --- /dev/null +++ b/Shop/shop_item_relic.tscn @@ -0,0 +1,48 @@ +[gd_scene load_steps=3 format=3 uid="uid://bmklwr3ycyicn"] + +[ext_resource type="Script" path="res://Shop/shop_item_relic.gd" id="1_nhbl5"] +[ext_resource type="Script" path="res://Input/ClickHandler.gd" id="3_lb38f"] + +[node name="ShopItemRelic" type="Control" node_paths=PackedStringArray("relicImage", "clickHandler", "priceLabel")] +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_nhbl5") +relicImage = NodePath("TextureRect") +clickHandler = NodePath("ClickHandler") +cost = 20 +priceLabel = NodePath("PriceLabel/Label") + +[node name="PriceLabel" type="ColorRect" parent="."] +layout_mode = 0 +offset_left = -80.0 +offset_top = 55.0 +offset_right = 74.0 +offset_bottom = 95.0 + +[node name="Label" type="Label" parent="PriceLabel"] +layout_mode = 0 +offset_left = 4.0 +offset_top = 2.0 +offset_right = 152.0 +offset_bottom = 40.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "dfdsfds +" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="TextureRect" type="TextureButton" parent="."] +layout_mode = 0 +offset_left = -45.0 +offset_top = -42.0 +offset_right = -5.0 +offset_bottom = -2.0 +scale = Vector2(2.32, 2.32) + +[node name="ClickHandler" type="Node" parent="."] +script = ExtResource("3_lb38f") +time_to_lock_hover = 0.3 + +[connection signal="gui_input" from="TextureRect" to="ClickHandler" method="_on_gui_input_event"] +[connection signal="mouse_entered" from="TextureRect" to="ClickHandler" method="_on_mouse_entered"] +[connection signal="mouse_exited" from="TextureRect" to="ClickHandler" method="_on_mouse_exited"] diff --git a/Shop/shop_item_torch.gd b/Shop/shop_item_torch.gd new file mode 100644 index 00000000..a8fc3782 --- /dev/null +++ b/Shop/shop_item_torch.gd @@ -0,0 +1,38 @@ +extends ShopItem + +@export var clickHandler : ClickHandler +var torchTexture : PackedScene = preload("res://Shop/tourchDisplay.tscn") +@export var amount : int +@export var startPosTransform : Node2D +var heldTorches : Array[TextureRect] + +func _ready() -> void: + clickHandler.on_click.connect(on_shop_item_clicked) + + var startPos : Vector2 = startPosTransform.position + + ## Instansiates the amount of torches held in this item. [br] + ## Each torch is moved a set distance away from the last + for i in amount: + var instance : TextureRect = torchTexture.instantiate() + heldTorches.append(instance) + instance.position = startPos + + var torch_distance : float = 5 + + startPos += Vector2.RIGHT * torch_distance + add_child(instance) + + super() + +func on_shop_item_clicked() ->void: + if(InventoryManager.gold_component.can_afford(cost)): + InventoryManager.gold_component.lose_gold(cost) + _give_player_item() + else: + print("can't afford") + + +func _give_player_item() -> void: + heldTorches.pop_back().queue_free() + InventoryManager.torch_component.add_torches(1) diff --git a/Shop/shop_item_torch.tscn b/Shop/shop_item_torch.tscn new file mode 100644 index 00000000..020bcb03 --- /dev/null +++ b/Shop/shop_item_torch.tscn @@ -0,0 +1,56 @@ +[gd_scene load_steps=4 format=3 uid="uid://tfeo4epmhse0"] + +[ext_resource type="Script" path="res://Shop/shop_item_torch.gd" id="1_u2x56"] +[ext_resource type="Texture2D" uid="uid://nheutko3fha3" path="res://Art/Card_layout/card_border.png" id="2_h1g3t"] +[ext_resource type="Script" path="res://Input/ClickHandler.gd" id="3_4xu5k"] + +[node name="ShopItemTorch" type="Control" node_paths=PackedStringArray("clickHandler", "startPosTransform", "priceLabel")] +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_u2x56") +clickHandler = NodePath("ClickHandler") +amount = 110 +startPosTransform = NodePath("StartPos") +cost = 80 +priceLabel = NodePath("PriceLabel/Label") + +[node name="PriceLabel" type="ColorRect" parent="."] +layout_mode = 0 +offset_left = -80.0 +offset_top = 55.0 +offset_right = 74.0 +offset_bottom = 95.0 + +[node name="Label" type="Label" parent="PriceLabel"] +layout_mode = 0 +offset_left = 4.0 +offset_top = 2.0 +offset_right = 152.0 +offset_bottom = 40.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "dfdsfds +" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="TextureRect" type="TextureButton" parent="."] +layout_mode = 0 +offset_left = -79.0 +offset_top = -23.0 +offset_right = -12.0 +offset_bottom = 3.0 +scale = Vector2(2.32, 2.32) +texture_normal = ExtResource("2_h1g3t") +ignore_texture_size = true +stretch_mode = 0 + +[node name="ClickHandler" type="Node" parent="."] +script = ExtResource("3_4xu5k") +time_to_lock_hover = 0.3 + +[node name="StartPos" type="Node2D" parent="."] +position = Vector2(-95, -33) + +[connection signal="gui_input" from="TextureRect" to="ClickHandler" method="_on_gui_input_event"] +[connection signal="mouse_entered" from="TextureRect" to="ClickHandler" method="_on_mouse_entered"] +[connection signal="mouse_exited" from="TextureRect" to="ClickHandler" method="_on_mouse_exited"] diff --git a/Shop/torchDisplay.tscn b/Shop/torchDisplay.tscn new file mode 100644 index 00000000..a96e7a01 --- /dev/null +++ b/Shop/torchDisplay.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://cfi6n74tteqoa"] + +[ext_resource type="Texture2D" uid="uid://q8og304npj17" path="res://Art/Menus/Torch-1.png" id="1_ibery"] + +[node name="Tourch" type="TextureRect"] +offset_right = 64.0 +offset_bottom = 64.0 +texture = ExtResource("1_ibery") diff --git a/Shop/tourchDisplay.tscn b/Shop/tourchDisplay.tscn new file mode 100644 index 00000000..1be0046b --- /dev/null +++ b/Shop/tourchDisplay.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://bk6mqnadig71r"] + +[ext_resource type="Texture2D" uid="uid://q8og304npj17" path="res://Art/Menus/Torch-1.png" id="1_4ar2h"] + +[node name="Tourch" type="TextureRect"] +offset_right = 64.0 +offset_bottom = 64.0 +texture = ExtResource("1_4ar2h") diff --git a/UI/CardScrollUI.gd b/UI/CardScrollUI.gd index 74112208..c22a0eaf 100644 --- a/UI/CardScrollUI.gd +++ b/UI/CardScrollUI.gd @@ -8,6 +8,8 @@ var cardworld: CardWorld = null var cardui: Control = null var key_art: Control = null +@onready var button : Button = $Button + const KEY_ART_SCALE: Vector2 = Vector2(1, 1) const CARD_SCALE: Vector2 = Vector2(1, 1) const CARDUI_INDEX: int = 2 @@ -29,6 +31,8 @@ func _input(_inputevent: InputEvent) -> void: func populate(parent_name: String) -> void: + var cardRemoval : bool = false + match parent_name: "DiscardPile": cards_to_display = CardManager.card_container.discard_pile @@ -39,7 +43,10 @@ func populate(parent_name: String) -> void: "DeckPile": cards_to_display = CardManager.current_deck $Label.text = "Showing the deck pile" - + "CardRemoval": + cards_to_display = CardManager.current_deck + $Label.text = "Pick a card to remove" + cardRemoval = true cards_to_display.sort_custom(card_sort_by_title) for card: CardBase in cards_to_display: @@ -47,11 +54,26 @@ func populate(parent_name: String) -> void: cardworld = card_scene.instantiate() cardui = cardworld.get_node("CardUI") key_art = cardworld.get_node("KeyArt") + + cardui = cardworld.get_child(CARDUI_INDEX) + + cardworld.custom_minimum_size = (cardui.size * CARD_SCALE) + SIZE_OFFSET + cardui.scale = CARD_SCALE + cardui.anchors_preset = CORNER_TOP_LEFT + cardui.position = CARDUI_POS + + if(cardRemoval): + cardworld.get_click_handler().on_click.connect(close_card_scroll) + cardworld.get_click_handler().on_click.connect(cardworld.remove_this_from_player_deck_with_price) + $ScrollContainer/GridContainer.add_child(cardworld) cardworld.init_card(card) +func close_card_scroll() -> void: + queue_free() + func card_sort_by_title(card_A: CardBase, card_B: CardBase) -> bool: if card_A.card_title.to_lower() < card_B.card_title.to_lower(): return true diff --git a/project.godot b/project.godot index bb6ec744..00697f93 100644 --- a/project.godot +++ b/project.godot @@ -34,6 +34,7 @@ MapManager="*res://Managers/MapManager.gd" InventoryManager="*res://Managers/InventoryManager.gd" DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd" XpManager="*res://Managers/XpManager.gd" +ShopManager="*res://Shop/ShopManager.tscn" [debug]