added the basic shop

This commit is contained in:
Lexi Quinn 2023-11-20 21:20:29 +11:00
parent edbb3261c6
commit f631654626
10 changed files with 328 additions and 19 deletions

View File

@ -22,7 +22,7 @@
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_jbu13"]
[sub_resource type="AtlasTexture" id="AtlasTexture_66cl7"]
[sub_resource type="AtlasTexture" id="AtlasTexture_a5vl4"]
resource_local_to_scene = true
atlas = ExtResource("6_yyp8i")
region = Rect2(0, 0, 96, 96)
@ -103,7 +103,7 @@ collision_mask = 24
[node name="EightDirectionSprite" parent="." instance=ExtResource("2_ib0t5")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0.915529, 0)
texture = SubResource("AtlasTexture_66cl7")
texture = SubResource("AtlasTexture_a5vl4")
[node name="Inventory" type="Node" parent="."]
script = ExtResource("6_cf5ap")
@ -394,13 +394,13 @@ horizontal_alignment = 1
vertical_alignment = 1
[node name="Currency" type="Label" parent="HUD"]
anchors_preset = 1
anchors_preset = -1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -99.0
offset_top = 298.0
offset_right = -57.0
offset_bottom = 352.0
offset_left = -101.0
offset_top = 300.0
offset_right = -40.0
offset_bottom = 54.0
grow_horizontal = 0
theme_override_colors/font_color = Color(0.988235, 0.909804, 0.65098, 1)
theme_override_font_sizes/font_size = 37
@ -430,7 +430,7 @@ horizontal_alignment = 1
vertical_alignment = 1
[node name="WaveCount" type="Label" parent="HUD"]
anchors_preset = -1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -30.0

View File

@ -54,7 +54,7 @@ offset_top = 270.0
offset_right = 21.0
offset_bottom = 31.0
grow_horizontal = 2
text = "Quit"
text = "Quit to main menu"
[connection signal="pressed" from="RestartButton" to="." method="_on_restart_button_pressed"]
[connection signal="pressed" from="QuitButton" to="." method="_on_quit_button_pressed"]

213
Scenes/shop_stand.tscn Normal file
View File

@ -0,0 +1,213 @@
[gd_scene load_steps=16 format=3 uid="uid://7g3jev3v6d3l"]
[ext_resource type="Script" path="res://Scripts/shop_stand.gd" id="1_4in53"]
[ext_resource type="Script" path="res://Scripts/interact_button.gd" id="1_x8sts"]
[ext_resource type="PackedScene" uid="uid://dsasunnk47n8o" path="res://Scenes/item_card.tscn" id="2_qh00w"]
[ext_resource type="PackedScene" uid="uid://dixtx38u4jhd7" path="res://Scenes/UI/card_hand.tscn" id="3_u7x2f"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lhc2g"]
albedo_color = Color(0.313726, 0.180392, 0.00392157, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tn6ej"]
albedo_color = Color(0.313726, 0.180392, 0.00392157, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4tjcf"]
albedo_color = Color(0.313726, 0.180392, 0.00392157, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_3a288"]
size = Vector3(2.95542, 2.01704, 1.92446)
[sub_resource type="BoxShape3D" id="BoxShape3D_3r1g8"]
size = Vector3(0.69, 0.665, 0.34)
[sub_resource type="ViewportTexture" id="ViewportTexture_5mbfv"]
viewport_path = NodePath("SubViewport")
[sub_resource type="ViewportTexture" id="ViewportTexture_cfv1i"]
viewport_path = NodePath("SubViewport2")
[sub_resource type="ViewportTexture" id="ViewportTexture_1rey7"]
viewport_path = NodePath("SubViewport3")
[sub_resource type="ViewportTexture" id="ViewportTexture_rlwso"]
viewport_path = NodePath("SubViewport4")
[sub_resource type="ViewportTexture" id="ViewportTexture_a6401"]
viewport_path = NodePath("SubViewport5")
[sub_resource type="ViewportTexture" id="ViewportTexture_rnm0u"]
viewport_path = NodePath("SubViewport6")
[node name="ShopStand" type="Node3D" node_paths=PackedStringArray("cards", "choice_colliders", "choice_buttons")]
script = ExtResource("1_4in53")
cards = [NodePath("SubViewport/Node2D"), NodePath("SubViewport2/Node2D"), NodePath("SubViewport3/Node2D"), NodePath("SubViewport4/Node2D"), NodePath("SubViewport5/Node2D"), NodePath("SubViewport6/Node2D")]
choice_colliders = [NodePath("InteractButton/CollisionShape3D"), NodePath("InteractButton2/CollisionShape3D2"), NodePath("InteractButton3/CollisionShape3D3"), NodePath("InteractButton6/CollisionShape3D6"), NodePath("InteractButton5/CollisionShape3D5"), NodePath("InteractButton4/CollisionShape3D4")]
choice_buttons = [NodePath("InteractButton"), NodePath("InteractButton2"), NodePath("InteractButton3"), NodePath("InteractButton6"), NodePath("InteractButton5"), NodePath("InteractButton4")]
item_card_scene = ExtResource("2_qh00w")
[node name="CSGBox3D" type="CSGBox3D" parent="."]
size = Vector3(2.95902, 1, 1)
material = SubResource("StandardMaterial3D_lhc2g")
[node name="CSGBox3D2" type="CSGBox3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.453776, -0.485039)
size = Vector3(2.95902, 1, 1)
material = SubResource("StandardMaterial3D_tn6ej")
[node name="CSGBox3D3" type="CSGBox3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.491623, -0.927363)
size = Vector3(2.95902, 1.96606, 1)
material = SubResource("StandardMaterial3D_4tjcf")
[node name="StaticBody3D" type="StaticBody3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.502094, -0.465026)
shape = SubResource("BoxShape3D_3a288")
[node name="InteractButton" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.08327, 0.835364, 0.235621)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_x8sts")
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractButton"]
shape = SubResource("BoxShape3D_3r1g8")
disabled = true
[node name="InteractButton2" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0897942, 0.854733, 0.276212)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_x8sts")
button_press_value = 1
[node name="CollisionShape3D2" type="CollisionShape3D" parent="InteractButton2"]
shape = SubResource("BoxShape3D_3r1g8")
disabled = true
[node name="InteractButton3" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.982556, 0.839111, 0.270489)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_x8sts")
button_press_value = 2
[node name="CollisionShape3D3" type="CollisionShape3D" parent="InteractButton3"]
shape = SubResource("BoxShape3D_3r1g8")
disabled = true
[node name="InteractButton4" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.964396, 1.2947, -0.222282)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_x8sts")
button_press_value = 5
[node name="CollisionShape3D4" type="CollisionShape3D" parent="InteractButton4"]
shape = SubResource("BoxShape3D_3r1g8")
disabled = true
[node name="InteractButton5" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0971891, 1.30596, -0.223896)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_x8sts")
button_press_value = 4
[node name="CollisionShape3D5" type="CollisionShape3D" parent="InteractButton5"]
shape = SubResource("BoxShape3D_3r1g8")
disabled = true
[node name="InteractButton6" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.01936, 1.30134, -0.249066)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_x8sts")
button_press_value = 3
[node name="CollisionShape3D6" type="CollisionShape3D" parent="InteractButton6"]
shape = SubResource("BoxShape3D_3r1g8")
disabled = true
[node name="SubViewport" type="SubViewport" parent="."]
transparent_bg = true
render_target_update_mode = 4
[node name="Node2D" parent="SubViewport" instance=ExtResource("3_u7x2f")]
[node name="SubViewport2" type="SubViewport" parent="."]
transparent_bg = true
render_target_update_mode = 4
[node name="Node2D" parent="SubViewport2" instance=ExtResource("3_u7x2f")]
[node name="SubViewport3" type="SubViewport" parent="."]
transparent_bg = true
render_target_update_mode = 4
[node name="Node2D" parent="SubViewport3" instance=ExtResource("3_u7x2f")]
[node name="SubViewport4" type="SubViewport" parent="."]
transparent_bg = true
render_target_update_mode = 4
[node name="Node2D" parent="SubViewport4" instance=ExtResource("3_u7x2f")]
[node name="SubViewport5" type="SubViewport" parent="."]
transparent_bg = true
render_target_update_mode = 4
[node name="Node2D" parent="SubViewport5" instance=ExtResource("3_u7x2f")]
[node name="SubViewport6" type="SubViewport" parent="."]
transparent_bg = true
render_target_update_mode = 4
[node name="Node2D" parent="SubViewport6" instance=ExtResource("3_u7x2f")]
[node name="Sprites" type="Node3D" parent="."]
visible = false
[node name="Sprite3D" type="Sprite3D" parent="Sprites"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.05174, 0.845052, 0.31035)
pixel_size = 0.0015
texture_filter = 0
texture = SubResource("ViewportTexture_5mbfv")
[node name="Sprite3D2" type="Sprite3D" parent="Sprites"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0552108, 0.842029, 0.32352)
pixel_size = 0.0015
texture_filter = 0
texture = SubResource("ViewportTexture_cfv1i")
[node name="Sprite3D3" type="Sprite3D" parent="Sprites"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.02516, 0.816916, 0.304008)
pixel_size = 0.0015
texture_filter = 0
texture = SubResource("ViewportTexture_1rey7")
[node name="Sprite3D4" type="Sprite3D" parent="Sprites"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.947595, 1.28234, -0.191499)
pixel_size = 0.0015
texture_filter = 0
texture = SubResource("ViewportTexture_rlwso")
[node name="Sprite3D5" type="Sprite3D" parent="Sprites"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0401761, 1.28234, -0.191499)
pixel_size = 0.0015
texture_filter = 0
texture = SubResource("ViewportTexture_a6401")
[node name="Sprite3D6" type="Sprite3D" parent="Sprites"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.0227, 1.28234, -0.191499)
pixel_size = 0.0015
texture_filter = 0
texture = SubResource("ViewportTexture_rnm0u")
[connection signal="button_interacted" from="InteractButton" to="." method="retrieve_card"]
[connection signal="button_interacted" from="InteractButton2" to="." method="retrieve_card"]
[connection signal="button_interacted" from="InteractButton3" to="." method="retrieve_card"]
[connection signal="button_interacted" from="InteractButton4" to="." method="retrieve_card"]
[connection signal="button_interacted" from="InteractButton5" to="." method="retrieve_card"]
[connection signal="button_interacted" from="InteractButton6" to="." method="retrieve_card"]

View File

@ -29,6 +29,7 @@ var UILayer : CanvasLayer
var chatbox : Chatbox
var wave_limit := 20
var starting_cash := 16
var shop_chance := 0.0
func _ready() -> void:
@ -61,6 +62,13 @@ func parse_command(text : String, peer_id : int):
networked_set_endless.rpc(false)
else:
chatbox.append_message("SERVER", Color.TOMATO, "Unable to edit gamemode")
if text.substr(1, 11) == "spawn_print":
level.printer._on_static_body_3d_button_interacted(0)
if text.substr(1, 10) == "spawn_shop":
level.shop.randomize_cards()
if text.substr(1, 7) == "prosper":
for id in connected_players_nodes:
connected_players_nodes[id].currency += 50
# if text.substr(1, 17) == "show tower ranges":
# pass
# if text.substr(1, 20) = "show gauntlet ranges":
@ -111,6 +119,7 @@ func ready_player(_value):
func spawn_enemy_wave():
level.shop.close()
wave += 1
level.a_star_graph_3d.find_path()
level.a_star_graph_3d.visualized_path.disable_visualization()
@ -182,10 +191,22 @@ func end_wave():
connected_players_nodes[peer_id].currency += ceili(pot / connected_players_nodes.size())
connected_players_nodes[peer_id].ready_state = false
level.a_star_graph_3d.visualized_path.enable_visualization()
if is_multiplayer_authority():
if randf() <= shop_chance:
networked_spawn_shop.rpc()
shop_chance = 0.0
else:
shop_chance += 0.05
wave_finished.emit(wave)
set_upcoming_wave()
@rpc("reliable", "call_local")
func networked_spawn_shop():
level.shop.randomize_cards()
chatbox.append_message("SERVER", Color.TOMATO, "A shopkeeper has arrived!")
func remove_player(peer_id):
if connected_players_nodes.has(peer_id):
connected_players_nodes[peer_id].queue_free()

View File

@ -7,3 +7,5 @@ class_name Level
@export var enemy_goals : Array[Node3D] = []
@export var a_star_graph_3d : AStarGraph3D
@export var cinematic_cam : CinematicCamManager
@export var printer : CardPrinter
@export var shop : ShopStand

View File

@ -2,7 +2,8 @@ extends Control
func _on_quit_button_pressed() -> void:
Game.quit_to_desktop()
Game.scene_switch_main_menu()
queue_free()
func _on_restart_button_pressed() -> void:

65
Scripts/shop_stand.gd Normal file
View File

@ -0,0 +1,65 @@
extends Node3D
class_name ShopStand
@export var cards : Array[CardInHand]
@export var choice_colliders : Array[CollisionShape3D]
@export var choice_buttons : Array[InteractButton]
@export var item_card_scene : PackedScene
var price_dict = {
Data.Rarity.UNCOMMON : 30,
Data.Rarity.RARE : 50,
Data.Rarity.EPIC : 75,
Data.Rarity.LEGENDARY : 100,
}
func close():
for x in choice_colliders:
x.disabled = true
$Sprites.set_visible(false)
func randomize_cards():
var cheap_cards = []
var medium_cards = []
var pricey_cards = []
for card in Data.cards:
if card.rarity == Data.Rarity.UNCOMMON or card.rarity == Data.Rarity.RARE:
cheap_cards.append(card)
if card.rarity == Data.Rarity.RARE or card.rarity == Data.Rarity.EPIC:
medium_cards.append(card)
if card.rarity == Data.Rarity.EPIC or card.rarity == Data.Rarity.LEGENDARY:
pricey_cards.append(card)
for x in 3:
var chosen_card = cheap_cards.pick_random()
cards[x].set_card(chosen_card)
cards[x].view_tower()
choice_buttons[x].press_cost = price_dict[chosen_card.rarity]
choice_buttons[x].hover_text = "Spend $" + str(choice_buttons[x].press_cost) + " to acquire " + chosen_card.title + "?"
for x in 2:
var chosen_card = medium_cards.pick_random()
cards[x+3].set_card(chosen_card)
cards[x+3].view_tower()
choice_buttons[x+3].press_cost = price_dict[chosen_card.rarity]
choice_buttons[x+3].hover_text = "Spend $" + str(choice_buttons[x+3].press_cost) + " to acquire " + chosen_card.title + "?"
for x in 1:
var chosen_card = pricey_cards.pick_random()
cards[x+5].set_card(chosen_card)
cards[x+5].view_tower()
choice_buttons[x+5].press_cost = price_dict[chosen_card.rarity]
choice_buttons[x+5].hover_text = "Spend $" + str(choice_buttons[x+5].press_cost) + " to acquire " + chosen_card.title + "?"
$Sprites.set_visible(true)
for x in choice_colliders:
x.disabled = false
func retrieve_card(i):
close()
var card = cards[i].stats
var item = item_card_scene.instantiate() as ItemCard
item.card = card
item.position = Vector3(2.128, 0, 0)
add_child(item)
#button_collider.disabled = false
#button_box.position = Vector3(0,0,0)

View File

@ -2,7 +2,8 @@ extends Control
func _on_quit_button_pressed() -> void:
Game.quit_to_desktop()
Game.scene_switch_main_menu()
queue_free()
func _on_play_button_pressed() -> void:

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=39 format=3 uid="uid://y1qa1g3ic8sp"]
[gd_scene load_steps=40 format=3 uid="uid://y1qa1g3ic8sp"]
[ext_resource type="Script" path="res://Scripts/level.gd" id="1_ws6nn"]
[ext_resource type="PackedScene" uid="uid://d2yv447trxkwt" path="res://Scenes/enemy_spawner.tscn" id="3_5imwp"]
@ -18,6 +18,7 @@
[ext_resource type="Texture2D" uid="uid://4gff4l03ibpm" path="res://Assets/Textures/scaffold.png" id="15_61y1c"]
[ext_resource type="PackedScene" uid="uid://d3h3lmlf3hljl" path="res://Worlds/GreenPlanet/Decorations/bush.tscn" id="16_lhsvw"]
[ext_resource type="Texture2D" uid="uid://cnvndwp3q7rke" path="res://Assets/Textures/dirt.png" id="17_oq0rj"]
[ext_resource type="PackedScene" uid="uid://7g3jev3v6d3l" path="res://Scenes/shop_stand.tscn" id="19_h6brl"]
[sub_resource type="Curve3D" id="Curve3D_3rdl2"]
_data = {
@ -112,7 +113,7 @@ texture_filter = 0
[sub_resource type="QuadMesh" id="QuadMesh_dyydf"]
material = SubResource("StandardMaterial3D_sugxr")
[node name="GridMap" type="GridMap" node_paths=PackedStringArray("player_spawns", "enemy_spawns", "enemy_goals", "a_star_graph_3d", "cinematic_cam")]
[node name="GridMap" type="GridMap" node_paths=PackedStringArray("player_spawns", "enemy_spawns", "enemy_goals", "a_star_graph_3d", "cinematic_cam", "printer", "shop")]
mesh_library = ExtResource("12_ywwug")
cell_size = Vector3(1, 1, 1)
cell_center_x = false
@ -127,6 +128,8 @@ enemy_spawns = [NodePath("GroundSpawn"), NodePath("AirSpawn")]
enemy_goals = [NodePath("EnemyGoal")]
a_star_graph_3d = NodePath("AStarGraph3D")
cinematic_cam = NodePath("CinemaCam")
printer = NodePath("CardPrinter")
shop = NodePath("ShopStand")
metadata/_editor_floor_ = Vector3(-15, 0, 0)
[node name="CinemaCam" type="Node3D" parent="." node_paths=PackedStringArray("path_follows", "cameras")]
@ -1088,4 +1091,7 @@ mesh = SubResource("QuadMesh_dyydf")
transform = Transform3D(-5.24537e-06, 30, 4.37114e-08, 0, -1.31134e-06, 1, 120, 1.31134e-06, 1.91069e-15, 0.297939, -9.5, 0)
mesh = SubResource("QuadMesh_dyydf")
[node name="ShopStand" parent="." instance=ExtResource("19_h6brl")]
transform = Transform3D(0.675552, 0, -0.737313, 0, 1, 0, 0.737313, 0, 0.675552, 21.8477, 0.5, -5.74175)
[connection signal="body_entered" from="EnemyGoal/Area3D" to="EnemyGoal" method="_on_area_3d_body_entered"]

File diff suppressed because one or more lines are too long