Skip to content

Commit

Permalink
Merge pull request #6 from the-dev-bin/tyler/ui_setup
Browse files Browse the repository at this point in the history
Mostly functional game loop setup
  • Loading branch information
tylercchase authored Jul 27, 2024
2 parents 6a96ec4 + 0b32c35 commit a993c91
Show file tree
Hide file tree
Showing 37 changed files with 629 additions and 52 deletions.
3 changes: 3 additions & 0 deletions godot/assets/one_block.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions godot/assets/one_block.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bpoxr5tkoi7k1"
path="res://.godot/imported/one_block.svg-cfc2e0ae5b1432e799327957c8f8a5aa.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/one_block.svg"
dest_files=["res://.godot/imported/one_block.svg-cfc2e0ae5b1432e799327957c8f8a5aa.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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target = 0
[resource]
script = ExtResource("1_dmw50")
ingredient_name = "Godot"
image = "res://icon.svg"
image = "res://assets/one_block.svg"
action = SubResource("Resource_8c46l")
base_structure = Array[Vector2]([Vector2(0, 0)])
right_structure = Array[Vector2]([Vector2(0, 0)])
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions godot/loot_tables/LootTableEntry.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class_name LootTableEntry
extends Resource


@export var ingredient: Ingredient
@export var likelihood: int
21 changes: 21 additions & 0 deletions godot/loot_tables/loot_table.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class_name LootTable
extends Resource

@export var loot: Array[LootTableEntry]
@export var money_range: Array[int] = [5,15] # might not use this yet, but eventually

func get_loot(quantity: int) -> Array[LootTableEntry]:
var temp: Array[LootTableEntry] = loot.duplicate()
var output: Array[LootTableEntry] = []
randomize()
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
for i in quantity:
var weights: Array = temp.map(get_weights)
var index: int = rng.rand_weighted(weights)
var item = temp.pop_at(index)
if item:
output.push_back(item)
return output

func get_weights(loot_entry: LootTableEntry) -> float:
return loot_entry.likelihood
26 changes: 26 additions & 0 deletions godot/loot_tables/resources/base_table.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[gd_resource type="Resource" script_class="LootTable" load_steps=8 format=3 uid="uid://b181mahpm5jwp"]

[ext_resource type="Script" path="res://loot_tables/LootTableEntry.gd" id="1_5p5ur"]
[ext_resource type="Script" path="res://loot_tables/loot_table.gd" id="1_pcdo4"]
[ext_resource type="Resource" uid="uid://bahbxo6wc30m4" path="res://ingredients/resources/godot_single.tres" id="2_0u5as"]
[ext_resource type="Resource" uid="uid://cyhd24hu3rkmq" path="res://ingredients/resources/l_block.tres" id="3_g1scy"]

[sub_resource type="Resource" id="Resource_rwm6v"]
script = ExtResource("1_5p5ur")
ingredient = ExtResource("2_0u5as")
likelihood = 1

[sub_resource type="Resource" id="Resource_mk8fk"]
script = ExtResource("1_5p5ur")
ingredient = ExtResource("3_g1scy")
likelihood = 1

[sub_resource type="Resource" id="Resource_p8m23"]
script = ExtResource("1_5p5ur")
ingredient = ExtResource("2_0u5as")
likelihood = 1

[resource]
script = ExtResource("1_pcdo4")
loot = Array[ExtResource("1_5p5ur")]([SubResource("Resource_rwm6v"), SubResource("Resource_mk8fk"), SubResource("Resource_p8m23")])
money_range = Array[int]([5, 15])
1 change: 1 addition & 0 deletions godot/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ rotate_right={
locale/translations=PackedStringArray("res://i18n/translation.de.translation", "res://i18n/translation.en.translation")

[rendering]

textures/vram_compression/import_etc2_astc=true
6 changes: 4 additions & 2 deletions godot/scenes/cauldron/cauldron.gd
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ func _drop_data(_at_position:Vector2, data:Variant)->void:
elif drag_data.source:
pieces_on_board.push_back(drag_data.item)
drag_data.source.removed_from_pouch.emit()
drag_data.destination.add_child(temp)
var other_temp = Node2D.new()
drag_data.destination.add_child(other_temp)
other_temp.add_child(temp)
drag_data.destination.block_rotation = drag_data.block_rotation
# temp.rotation_degrees = drag_data.block_rotation
temp.rotation_degrees = drag_data.block_rotation
toggle_availablity_block(drag_data.destination.board_position, drag_data.item.get_structure(drag_data.block_rotation), drag_data.item, drag_data.destination)


Expand Down
3 changes: 3 additions & 0 deletions godot/scenes/cauldron/cauldron.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ layout_mode = 2
[node name="CauldronSlot20" parent="CenterContainer/SlotContainer" instance=ExtResource("2_h1aey")]
layout_mode = 2

[node name="Node2D" type="Node2D" parent="CenterContainer/SlotContainer/CauldronSlot20"]
position = Vector2(16, 16)

[node name="CauldronSlot21" parent="CenterContainer/SlotContainer" instance=ExtResource("2_h1aey")]
layout_mode = 2

Expand Down
13 changes: 13 additions & 0 deletions godot/scenes/combat_arena/combat_arena.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ extends Node2D
@onready var ingredient_tooltip: IngredientTooltip = %IngredientTooltip
@onready var end_turn_button: Button = %EndTurnButton
@onready var player_node: Player = %Player
@onready var position_anchor: Control = %PositionAnchor


@export var combat_end_scene: PackedScene
@export var test_loot_table: LootTable

func _ready() -> void:
%BattleEndButton.pressed.connect(end_battle)
cauldron.toggle_tooltip.connect(_on_toggle_tooltip)
ingredient_pouch.toggle_tooltip.connect(_on_toggle_tooltip)
end_turn_button.pressed.connect(_on_end_turn_button_pressed)
Expand Down Expand Up @@ -57,3 +64,9 @@ func _on_end_turn_button_pressed():
ingredient_pouch.clear_hand()
ingredient_pouch.draw_hand()

func end_battle():
var thing: CombatEndScene = combat_end_scene.instantiate()
position_anchor.add_child(thing)
thing.setup(test_loot_table)
process_mode = PROCESS_MODE_DISABLED # pause background since we're done with battle and don't want interactions to work there
# the anchor control node is setup to process always and isn't affected by this
38 changes: 35 additions & 3 deletions godot/scenes/combat_arena/combat_arena.tscn
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
[gd_scene load_steps=7 format=3 uid="uid://b08icw3rhyjdm"]
[gd_scene load_steps=9 format=3 uid="uid://b08icw3rhyjdm"]

[ext_resource type="Script" path="res://scenes/combat_arena/combat_arena.gd" id="1_3j36f"]
[ext_resource type="PackedScene" uid="uid://sh2tec1kvvnv" path="res://scenes/cauldron/cauldron.tscn" id="1_ne5b2"]
[ext_resource type="PackedScene" uid="uid://bq4bpebcy5h4d" path="res://scenes/component_pouch/component_pouch.tscn" id="2_6n2cw"]
[ext_resource type="PackedScene" uid="uid://da05b17xnp2s1" path="res://ui/menues/combat_end/combat_end.tscn" id="2_a7uwy"]
[ext_resource type="PackedScene" uid="uid://dksentt5dji3p" path="res://scenes/tooltip/ingredient_tooltip.tscn" id="3_4gmlw"]
[ext_resource type="Resource" uid="uid://b181mahpm5jwp" path="res://loot_tables/resources/base_table.tres" id="3_g53h1"]
[ext_resource type="PackedScene" uid="uid://d0myqt3wxsrtt" path="res://scenes/enemy/enemy_spawn_point.tscn" id="5_gk7dw"]
[ext_resource type="PackedScene" uid="uid://dw74q47ldjy8w" path="res://scenes/player/player.tscn" id="6_ucnf1"]

[node name="CombatArena" type="Node2D"]
script = ExtResource("1_3j36f")
combat_end_scene = ExtResource("2_a7uwy")
test_loot_table = ExtResource("3_g53h1")

[node name="PanelContainer" type="PanelContainer" parent="."]
offset_right = 1831.0
offset_bottom = 859.0

[node name="Cauldron" parent="." instance=ExtResource("1_ne5b2")]
unique_name_in_owner = true
Expand All @@ -21,8 +29,8 @@ offset_bottom = 311.0
unique_name_in_owner = true
offset_left = 108.0
offset_top = 336.0
offset_right = 384.0
offset_bottom = 406.0
offset_right = 408.0
offset_bottom = 431.0

[node name="IngredientTooltip" parent="." instance=ExtResource("3_4gmlw")]
unique_name_in_owner = true
Expand All @@ -47,3 +55,27 @@ position = Vector2(844, 346)
[node name="Player" parent="." instance=ExtResource("6_ucnf1")]
unique_name_in_owner = true
position = Vector2(77, 225)

[node name="BattleEndButton" type="Button" parent="."]
unique_name_in_owner = true
offset_left = 249.0
offset_top = 511.0
offset_right = 401.0
offset_bottom = 542.0
text = "End Battle (Debug)"

[node name="PositionAnchor" type="Control" parent="."]
unique_name_in_owner = true
process_mode = 3
custom_minimum_size = Vector2(960, 640)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = 960.0
offset_bottom = 640.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
mouse_filter = 2
2 changes: 1 addition & 1 deletion godot/scenes/component_pouch/component_pouch.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var deck: Array[Ingredient] = []

var max_hand_size = 2
func _ready() -> void:
deck = State.player_deck
deck = State.player_deck.duplicate()
deck.shuffle()
# have some hand size variable here, for now this works tho
draw_hand()
Expand Down
9 changes: 3 additions & 6 deletions godot/scenes/component_pouch/component_pouch.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ grow_vertical = 2
script = ExtResource("1_u40qd")
ingredient_block_scene = ExtResource("2_njvai")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
alignment = 1

[node name="IngredientContainer" type="HBoxContainer" parent="VBoxContainer"]
[node name="IngredientContainer" type="HBoxContainer" parent="."]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 20
size_flags_vertical = 3
theme_override_constants/separation = 32
alignment = 1
6 changes: 5 additions & 1 deletion godot/scenes/ingredient_block/ingredient_block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ func setup(_block_data: Ingredient) -> void:
ingredient_resource = _block_data
parse_structure(ingredient_resource.base_structure)
var size_vector: Vector2 = Vector2(max_width * block_size + block_size, max_height * block_size + block_size )
size = size_vector
# size = size_vector
# print(size_vector)
# set_deferred('size', size_vector)
# pivot_offset = Vector2(16,16)
# set_deferred('size', size_vector)
$TextureRect.size = size_vector
$TextureRect.texture = ResourceLoader.load(ingredient_resource.image)
if on_board:
Expand Down
2 changes: 1 addition & 1 deletion godot/scenes/ingredient_block/ingredient_block.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ layout_mode = 3
anchors_preset = 0
offset_right = 32.0
offset_bottom = 32.0
pivot_offset = Vector2(16, 16)
script = ExtResource("1_pmisc")
preview_scene = ExtResource("2_uluk4")

Expand All @@ -19,4 +20,3 @@ layout_mode = 0
offset_right = 32.0
offset_bottom = 32.0
texture = ExtResource("3_ogvbt")
expand_mode = 1
Loading

0 comments on commit a993c91

Please sign in to comment.