way too many changes to list, oops. big rewrite.
This commit is contained in:
@ -1,14 +1,22 @@
|
||||
class_name CardPrinter extends StaticBody3D
|
||||
|
||||
@export var cards: Array[CardInHand]
|
||||
@export var item_card_scene: PackedScene
|
||||
@export var button_collider: CollisionShape3D
|
||||
@export var button_box: Node3D
|
||||
@export var choice_colliders: Array[CollisionShape3D]
|
||||
|
||||
#TODO: use faction enum
|
||||
var base_faction: int = 1
|
||||
var cards_generated: int = 0
|
||||
var card_available: bool = false
|
||||
var reply_player: Hero
|
||||
var spawned_cards: Array[CardItem] = []
|
||||
|
||||
|
||||
func get_faction_cards(faction: Card.Faction) -> Array[Card]:
|
||||
var valid_cards: Array[Card] = []
|
||||
for card: Card in Data.cards:
|
||||
if card.faction == faction:
|
||||
valid_cards.append(card)
|
||||
return valid_cards
|
||||
|
||||
|
||||
func generate_rarity() -> int:
|
||||
@ -28,42 +36,44 @@ func generate_rarity() -> int:
|
||||
return decided_rarity
|
||||
|
||||
|
||||
func randomize_cards() -> void:
|
||||
var decided_rarity: int = generate_rarity()
|
||||
var card_array: Array = []
|
||||
for x: Card in Data.cards:
|
||||
if x.rarity == decided_rarity:
|
||||
card_array.append(x)
|
||||
var card: Card
|
||||
for x: CardInHand in cards:
|
||||
func randomize_cards(faction: Card.Faction) -> void:
|
||||
#TODO: no magic numbers, asshole! 3 = cards to spawn
|
||||
for x: int in 3:
|
||||
var decided_rarity: int = generate_rarity()
|
||||
var card_choices: Array[Card] = get_faction_cards(faction)
|
||||
var card_array: Array = []
|
||||
var cards_chosen: bool = false
|
||||
while !cards_chosen:
|
||||
for card: Card in card_choices:
|
||||
if card.rarity == decided_rarity:
|
||||
card_array.append(card)
|
||||
cards_chosen = true
|
||||
decided_rarity -= 1
|
||||
if decided_rarity < 0:
|
||||
card_array.append(Data.cards[0])
|
||||
cards_chosen = true
|
||||
var card: Card
|
||||
if card_array.size() > 0:
|
||||
card = card_array[Game.randi_in_range(132 * cards_generated, 0, card_array.size() - 1)]
|
||||
cards_generated += 1
|
||||
card_array.erase(card)
|
||||
x.set_card(card)
|
||||
#TODO: in reality this should just show the icon and then hovering over it lets you see either side at the players own discretion
|
||||
x.view_tower()
|
||||
$Node3D.set_visible(true)
|
||||
for x: CollisionShape3D in choice_colliders:
|
||||
x.disabled = false
|
||||
card_available = true
|
||||
var item: CardItem = item_card_scene.instantiate() as CardItem
|
||||
item.set_card(card)
|
||||
item.position = Vector3(x, 1, 2)
|
||||
item.pressed.connect(card_picked_up)
|
||||
spawned_cards.append(item)
|
||||
add_child(item)
|
||||
|
||||
|
||||
func retrieve_card(i: int, _reply: Hero) -> void:
|
||||
$Node3D.set_visible(false)
|
||||
for x: CollisionShape3D in choice_colliders:
|
||||
x.disabled = true
|
||||
if card_available:
|
||||
var card: Card = cards[i].stats
|
||||
reply_player.add_card(card)
|
||||
#var item: ItemCard = item_card_scene.instantiate() as ItemCard
|
||||
#item.card = card
|
||||
#item.position = Vector3(1.683, 0, 0)
|
||||
#add_child(item)
|
||||
func card_picked_up(card_item: CardItem) -> void:
|
||||
reply_player.add_card(card_item.card)
|
||||
reply_player = null
|
||||
for spawned_card: CardItem in spawned_cards:
|
||||
spawned_card.queue_free()
|
||||
spawned_cards = []
|
||||
button_collider.disabled = false
|
||||
button_box.position = Vector3(0,0,0)
|
||||
$StaticBody3D/AudioStreamPlayer3D.play()
|
||||
reply_player = null
|
||||
|
||||
|
||||
func _on_static_body_3d_button_interacted(_value: int, reply: Hero) -> void:
|
||||
@ -71,4 +81,4 @@ func _on_static_body_3d_button_interacted(_value: int, reply: Hero) -> void:
|
||||
button_collider.disabled = true
|
||||
button_box.position = Vector3(0,0,-0.2)
|
||||
$StaticBody3D/AudioStreamPlayer3D.play()
|
||||
randomize_cards()
|
||||
randomize_cards(reply.hero_class.faction)
|
||||
|
1
Scenes/CardPrinter/card_printer.gd.uid
Normal file
1
Scenes/CardPrinter/card_printer.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bivtfdl3p1brv
|
@ -1,10 +1,9 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://1b2ikdanl66b"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://1b2ikdanl66b"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/CardPrinter/card_printer.gd" id="1_qft15"]
|
||||
[ext_resource type="PackedScene" uid="uid://dsasunnk47n8o" path="res://Scenes/item_card.tscn" id="2_hegq8"]
|
||||
[ext_resource type="PackedScene" uid="uid://dixtx38u4jhd7" path="res://Scenes/UI/card_hand.tscn" id="3_wygtg"]
|
||||
[ext_resource type="Script" path="res://Scripts/interact_button.gd" id="4_eavi1"]
|
||||
[ext_resource type="AudioStream" uid="uid://dknygn5eyuhxt" path="res://shot1.wav" id="5_m033a"]
|
||||
[ext_resource type="Script" uid="uid://bivtfdl3p1brv" path="res://Scenes/CardPrinter/card_printer.gd" id="1_qft15"]
|
||||
[ext_resource type="PackedScene" uid="uid://dq8v5e11rvyi6" path="res://plan.tscn" id="2_8jpsw"]
|
||||
[ext_resource type="Script" uid="uid://dkfswql8ui0bt" path="res://Scripts/interact_button.gd" id="4_eavi1"]
|
||||
[ext_resource type="AudioStream" uid="uid://dknygn5eyuhxt" path="res://Audio/shot1.wav" id="5_m033a"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_s02au"]
|
||||
albedo_color = Color(0.203922, 0.592157, 0.592157, 1)
|
||||
@ -12,15 +11,6 @@ albedo_color = Color(0.203922, 0.592157, 0.592157, 1)
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_0ebt5"]
|
||||
size = Vector3(2, 2.1, 1)
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_yf4je"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_3q3h0"]
|
||||
viewport_path = NodePath("SubViewport2")
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_vyyy4"]
|
||||
viewport_path = NodePath("SubViewport3")
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_ikdwj"]
|
||||
size = Vector3(1.29447, 0.342125, 0.277604)
|
||||
|
||||
@ -28,18 +18,12 @@ size = Vector3(1.29447, 0.342125, 0.277604)
|
||||
random_pitch = 1.1
|
||||
streams_count = 1
|
||||
stream_0/stream = ExtResource("5_m033a")
|
||||
stream_0/weight = 1.0
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_gv3t5"]
|
||||
size = Vector3(0.617184, 0.869944, 0.0570252)
|
||||
|
||||
[node name="CardPrinter" type="StaticBody3D" node_paths=PackedStringArray("cards", "button_collider", "button_box", "choice_colliders")]
|
||||
[node name="CardPrinter" type="StaticBody3D" node_paths=PackedStringArray("button_collider", "button_box")]
|
||||
script = ExtResource("1_qft15")
|
||||
cards = [NodePath("SubViewport/Node2D"), NodePath("SubViewport2/Node2D"), NodePath("SubViewport3/Node2D")]
|
||||
item_card_scene = ExtResource("2_hegq8")
|
||||
item_card_scene = ExtResource("2_8jpsw")
|
||||
button_collider = NodePath("StaticBody3D/CollisionShape3D2")
|
||||
button_box = NodePath("StaticBody3D/CollisionShape3D2/CSGBox3D")
|
||||
choice_colliders = [NodePath("StaticBody3D2/CollisionShape3D2"), NodePath("StaticBody3D3/CollisionShape3D2"), NodePath("StaticBody3D4/CollisionShape3D2")]
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.05, 0)
|
||||
@ -50,49 +34,6 @@ material = SubResource("StandardMaterial3D_s02au")
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.05, 0)
|
||||
shape = SubResource("BoxShape3D_0ebt5")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
transparent_bg = true
|
||||
size = Vector2i(352, 512)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Node2D" parent="SubViewport" instance=ExtResource("3_wygtg")]
|
||||
position = Vector2(-56, 0)
|
||||
|
||||
[node name="SubViewport2" type="SubViewport" parent="."]
|
||||
transparent_bg = true
|
||||
size = Vector2i(352, 512)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Node2D" parent="SubViewport2" instance=ExtResource("3_wygtg")]
|
||||
position = Vector2(-56, 0)
|
||||
|
||||
[node name="SubViewport3" type="SubViewport" parent="."]
|
||||
transparent_bg = true
|
||||
size = Vector2i(352, 512)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="Node2D" parent="SubViewport3" instance=ExtResource("3_wygtg")]
|
||||
position = Vector2(-56, 0)
|
||||
|
||||
[node name="Node3D" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.149617, 0)
|
||||
visible = false
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="Node3D"]
|
||||
transform = Transform3D(0.175, 0, 0, 0, 0.175, 0, 0, 0, 0.175, -0.65, 1.65, 0.506948)
|
||||
texture_filter = 0
|
||||
texture = SubResource("ViewportTexture_yf4je")
|
||||
|
||||
[node name="Sprite3D2" type="Sprite3D" parent="Node3D"]
|
||||
transform = Transform3D(0.175, 0, 0, 0, 0.175, 0, 0, 0, 0.175, 0, 1.65, 0.506948)
|
||||
texture_filter = 0
|
||||
texture = SubResource("ViewportTexture_3q3h0")
|
||||
|
||||
[node name="Sprite3D3" type="Sprite3D" parent="Node3D"]
|
||||
transform = Transform3D(0.175, 0, 0, 0, 0.175, 0, 0, 0, 0.175, 0.65, 1.65, 0.506948)
|
||||
texture_filter = 0
|
||||
texture = SubResource("ViewportTexture_vyyy4")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.847404, 0.610684)
|
||||
collision_layer = 16
|
||||
@ -112,42 +53,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.010989, -0.086501)
|
||||
stream = SubResource("AudioStreamRandomizer_73g2w")
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.650194, 1.50143, 0.528758)
|
||||
collision_layer = 16
|
||||
collision_mask = 0
|
||||
script = ExtResource("4_eavi1")
|
||||
hover_text = "Select card"
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D2"]
|
||||
shape = SubResource("BoxShape3D_gv3t5")
|
||||
disabled = true
|
||||
|
||||
[node name="StaticBody3D3" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000848182, 1.5001, 0.528758)
|
||||
collision_layer = 16
|
||||
collision_mask = 0
|
||||
script = ExtResource("4_eavi1")
|
||||
button_press_value = 1
|
||||
hover_text = "Select card"
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D3"]
|
||||
shape = SubResource("BoxShape3D_gv3t5")
|
||||
disabled = true
|
||||
|
||||
[node name="StaticBody3D4" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.648946, 1.49865, 0.528758)
|
||||
collision_layer = 16
|
||||
collision_mask = 0
|
||||
script = ExtResource("4_eavi1")
|
||||
button_press_value = 2
|
||||
hover_text = "Select card"
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D4"]
|
||||
shape = SubResource("BoxShape3D_gv3t5")
|
||||
disabled = true
|
||||
|
||||
[connection signal="button_interacted" from="StaticBody3D" to="." method="_on_static_body_3d_button_interacted"]
|
||||
[connection signal="button_interacted" from="StaticBody3D2" to="." method="retrieve_card"]
|
||||
[connection signal="button_interacted" from="StaticBody3D3" to="." method="retrieve_card"]
|
||||
[connection signal="button_interacted" from="StaticBody3D4" to="." method="retrieve_card"]
|
||||
|
Reference in New Issue
Block a user