Added basic build menu and placement
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
14
data/buildings/advanced/advanced_building_group.tres
Normal file
14
data/buildings/advanced/advanced_building_group.tres
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[gd_resource type="Resource" script_class="BuildingGroup" load_steps=4 format=3 uid="uid://cfeob1arfvw6p"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://data/buildings/building_group.gd" id="1_5u0lh"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_hpowi"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_24mqt"]
|
||||||
|
atlas = ExtResource("1_hpowi")
|
||||||
|
region = Rect2(1088, 576, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_5u0lh")
|
||||||
|
name = "Advanced"
|
||||||
|
atlas_texture = SubResource("AtlasTexture_24mqt")
|
||||||
|
buildings = Array[Resource("res://data/buildings/building.gd")]([])
|
||||||
16
data/buildings/basic/basic_building_group.tres
Normal file
16
data/buildings/basic/basic_building_group.tres
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[gd_resource type="Resource" script_class="BuildingGroup" load_steps=6 format=3 uid="uid://dqv53okb3evb7"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_p1crr"]
|
||||||
|
[ext_resource type="Script" path="res://data/buildings/building_group.gd" id="1_xphre"]
|
||||||
|
[ext_resource type="Resource" uid="uid://d38xgwstvtcm4" path="res://data/buildings/basic/harvester_building.tres" id="2_7d7fa"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cta6ngelbwo8b" path="res://data/buildings/basic/warehouse_building.tres" id="3_vxs34"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_nleix"]
|
||||||
|
atlas = ExtResource("1_p1crr")
|
||||||
|
region = Rect2(1024, 576, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_xphre")
|
||||||
|
name = "Basic"
|
||||||
|
atlas_texture = SubResource("AtlasTexture_nleix")
|
||||||
|
buildings = Array[Resource("res://data/buildings/building.gd")]([ExtResource("2_7d7fa"), ExtResource("3_vxs34")])
|
||||||
18
data/buildings/basic/harvester_building.tres
Normal file
18
data/buildings/basic/harvester_building.tres
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[gd_resource type="Resource" script_class="Building" load_steps=5 format=3 uid="uid://d38xgwstvtcm4"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_8uuv4"]
|
||||||
|
[ext_resource type="Script" path="res://data/buildings/building.gd" id="1_s0c8c"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="2_ppxqc"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_5nxx0"]
|
||||||
|
atlas = ExtResource("1_8uuv4")
|
||||||
|
region = Rect2(1088, 128, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_s0c8c")
|
||||||
|
atlas_texture = SubResource("AtlasTexture_5nxx0")
|
||||||
|
name = "Harvester"
|
||||||
|
description = "Harvests nearby"
|
||||||
|
cost = {
|
||||||
|
ExtResource("2_ppxqc"): 100
|
||||||
|
}
|
||||||
20
data/buildings/basic/warehouse_building.tres
Normal file
20
data/buildings/basic/warehouse_building.tres
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[gd_resource type="Resource" script_class="Building" load_steps=6 format=3 uid="uid://cta6ngelbwo8b"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_24f36"]
|
||||||
|
[ext_resource type="Script" path="res://data/buildings/building.gd" id="1_aylgh"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="2_s5ve8"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dr00rd4f42jqe" path="res://data/game_resources/gem/gem_resource.tres" id="3_y57vu"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_pbx2g"]
|
||||||
|
atlas = ExtResource("1_24f36")
|
||||||
|
region = Rect2(1024, 64, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_aylgh")
|
||||||
|
atlas_texture = SubResource("AtlasTexture_pbx2g")
|
||||||
|
name = "Warehouse"
|
||||||
|
description = "Allows storage of more materials"
|
||||||
|
cost = {
|
||||||
|
ExtResource("2_s5ve8"): 500,
|
||||||
|
ExtResource("3_y57vu"): 200
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
class_name Building
|
class_name Building
|
||||||
extends Resource
|
extends Resource
|
||||||
|
|
||||||
@export var corruption_pattern: ExpansionBase
|
@export var atlas_texture: AtlasTexture
|
||||||
@export var atlas_texture_region: Vector2i
|
|
||||||
@export var name: String
|
@export var name: String
|
||||||
@export var description: String
|
@export var description: String
|
||||||
@export var cost: Dictionary
|
@export var cost: Dictionary
|
||||||
13
data/buildings/building_base.gd
Normal file
13
data/buildings/building_base.gd
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
extends Node2D
|
||||||
|
class_name BuildingBase
|
||||||
|
|
||||||
|
var _building_data: Building
|
||||||
|
|
||||||
|
@onready var sprite_2d: Sprite2D = $Sprite2D
|
||||||
|
|
||||||
|
func initialize(data: Building, grid_location: Vector2i) -> void:
|
||||||
|
_building_data = data
|
||||||
|
position = Grid.grid_to_world_center(grid_location)
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
sprite_2d.texture = _building_data.atlas_texture
|
||||||
8
data/buildings/building_base.tscn
Normal file
8
data/buildings/building_base.tscn
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://kij6k2k1rmxb"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://data/buildings/building_base.gd" id="1_odhat"]
|
||||||
|
|
||||||
|
[node name="BuildingBase" type="Node2D"]
|
||||||
|
script = ExtResource("1_odhat")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
7
data/buildings/building_group.gd
Normal file
7
data/buildings/building_group.gd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
extends Resource
|
||||||
|
class_name BuildingGroup
|
||||||
|
|
||||||
|
@export var name: String
|
||||||
|
@export var atlas_texture: AtlasTexture
|
||||||
|
|
||||||
|
@export var buildings: Array[Building]
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
[gd_resource type="Resource" script_class="Building" load_steps=4 format=3 uid="uid://bgwoy0uh2cpvu"]
|
[gd_resource type="Resource" script_class="Building" load_steps=4 format=3 uid="uid://bgwoy0uh2cpvu"]
|
||||||
|
|
||||||
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="1_5s38g"]
|
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="1_5s38g"]
|
||||||
[ext_resource type="Script" path="res://scripts/building.gd" id="1_ssts7"]
|
|
||||||
[ext_resource type="Resource" uid="uid://dr00rd4f42jqe" path="res://data/game_resources/gem/gem_resource.tres" id="2_u1tpw"]
|
[ext_resource type="Resource" uid="uid://dr00rd4f42jqe" path="res://data/game_resources/gem/gem_resource.tres" id="2_u1tpw"]
|
||||||
|
[ext_resource type="Script" path="res://data/buildings/building.gd" id="3_bd7jk"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_ssts7")
|
script = ExtResource("3_bd7jk")
|
||||||
atlas_texture_region = Vector2i(14, 7)
|
|
||||||
name = "Corruptor"
|
name = "Corruptor"
|
||||||
description = "A building which only functions to spread corruption, and does it well"
|
description = "A building which only functions to spread corruption, and does it well"
|
||||||
cost = {
|
cost = {
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
[gd_resource type="Resource" script_class="Building" load_steps=5 format=3 uid="uid://c6vv3hyn5sd7o"]
|
[gd_resource type="Resource" script_class="Building" load_steps=3 format=3 uid="uid://c6vv3hyn5sd7o"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/expansion_patterns/expansion_square_pattern.gd" id="1_attvt"]
|
[ext_resource type="Script" path="res://data/buildings/building.gd" id="1_ssd30"]
|
||||||
[ext_resource type="Script" path="res://scripts/building.gd" id="1_ssd30"]
|
|
||||||
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="2_d8jrj"]
|
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="2_d8jrj"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_nqpn0"]
|
|
||||||
script = ExtResource("1_attvt")
|
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_ssd30")
|
script = ExtResource("1_ssd30")
|
||||||
corruption_pattern = SubResource("Resource_nqpn0")
|
|
||||||
atlas_texture_region = Vector2i(17, 7)
|
|
||||||
name = "Hub"
|
name = "Hub"
|
||||||
description = "Main cheap base that corrupts a square"
|
description = "Main cheap base that corrupts a square"
|
||||||
cost = {
|
cost = {
|
||||||
|
|||||||
13
data/interactions/build/advanced/build_advanced.tres
Normal file
13
data/interactions/build/advanced/build_advanced.tres
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[gd_resource type="Resource" script_class="InteractionBuildBasic" load_steps=4 format=3 uid="uid://kqcdiin4k3jr"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_ce8rd"]
|
||||||
|
[ext_resource type="Script" path="res://data/interactions/build/basic/interaction_build_basic.gd" id="2_xgp0x"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fxfd2"]
|
||||||
|
atlas = ExtResource("1_ce8rd")
|
||||||
|
region = Rect2(1088, 576, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_xgp0x")
|
||||||
|
name = "Advanced"
|
||||||
|
image = SubResource("AtlasTexture_fxfd2")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
extends Interaction
|
||||||
|
class_name InteractionBuildAdvanced
|
||||||
|
|
||||||
|
func interact_at(pos: Vector2i, root: Node) -> Array[Interaction]:
|
||||||
|
print("Building at: %s" % pos)
|
||||||
|
return []
|
||||||
13
data/interactions/build/basic/build_basic.tres
Normal file
13
data/interactions/build/basic/build_basic.tres
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[gd_resource type="Resource" script_class="InteractionBuildBasic" load_steps=4 format=3 uid="uid://k4dq7122cnu0"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://data/interactions/build/basic/interaction_build_basic.gd" id="1_8f33m"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_qfmuq"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_w7o8k"]
|
||||||
|
atlas = ExtResource("1_qfmuq")
|
||||||
|
region = Rect2(1024, 576, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_8f33m")
|
||||||
|
name = "Basic"
|
||||||
|
image = SubResource("AtlasTexture_w7o8k")
|
||||||
6
data/interactions/build/basic/interaction_build_basic.gd
Normal file
6
data/interactions/build/basic/interaction_build_basic.gd
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
extends Interaction
|
||||||
|
class_name InteractionBuildBasic
|
||||||
|
|
||||||
|
func interact_at(pos: Vector2i, root: Node) -> Array[Interaction]:
|
||||||
|
print("Building at: %s" % pos)
|
||||||
|
return []
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
extends Interaction
|
extends Interaction
|
||||||
class_name InteractionBuild
|
class_name InteractionBuild
|
||||||
|
|
||||||
|
const BUILD_ADVANCED = preload("res://data/interactions/build/advanced/build_advanced.tres")
|
||||||
|
const BUILD_BASIC = preload("res://data/interactions/build/basic/build_basic.tres")
|
||||||
|
|
||||||
func interact_at(pos: Vector2i, root: Node) -> Array[Interaction]:
|
func interact_at(pos: Vector2i, root: Node) -> Array[Interaction]:
|
||||||
print("Building at: %s" % pos)
|
return [BUILD_BASIC, BUILD_ADVANCED]
|
||||||
return []
|
|
||||||
|
|||||||
@@ -77,12 +77,18 @@ move_down={
|
|||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
select={
|
interact={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
build={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":66,"key_label":0,"unicode":98,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|||||||
89
scene/build_menu.tscn
Normal file
89
scene/build_menu.tscn
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cym5p3olst2nc"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/build_menu.gd" id="1_v2c78"]
|
||||||
|
|
||||||
|
[sub_resource type="Theme" id="Theme_0djom"]
|
||||||
|
|
||||||
|
[node name="BuildMenu" type="CanvasLayer"]
|
||||||
|
script = ExtResource("1_v2c78")
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_constants/margin_left = 128
|
||||||
|
theme_override_constants/margin_top = 128
|
||||||
|
theme_override_constants/margin_right = 128
|
||||||
|
theme_override_constants/margin_bottom = 128
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = SubResource("Theme_0djom")
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/PanelContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer/HBoxContainer/ScrollContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="BuildingGroups" type="ItemList" parent="MarginContainer/PanelContainer/HBoxContainer/ScrollContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
auto_height = true
|
||||||
|
|
||||||
|
[node name="ScrollContainer2" type="ScrollContainer" parent="MarginContainer/PanelContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer/HBoxContainer/ScrollContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="Buildings" type="ItemList" parent="MarginContainer/PanelContainer/HBoxContainer/ScrollContainer2/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
auto_height = true
|
||||||
|
|
||||||
|
[node name="DetailsContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_stretch_ratio = 3.0
|
||||||
|
|
||||||
|
[node name="Title" type="Label" parent="MarginContainer/PanelContainer/HBoxContainer/DetailsContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Select a building"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="HSeparator" type="HSeparator" parent="MarginContainer/PanelContainer/HBoxContainer/DetailsContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Description" type="Label" parent="MarginContainer/PanelContainer/HBoxContainer/DetailsContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
text = " "
|
||||||
|
|
||||||
|
[node name="BuildMaterials" type="GridContainer" parent="MarginContainer/PanelContainer/HBoxContainer/DetailsContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
columns = 2
|
||||||
|
|
||||||
|
[node name="BuildButtonsContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/HBoxContainer/DetailsContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="BuildButton" type="Button" parent="MarginContainer/PanelContainer/HBoxContainer/DetailsContainer/BuildButtonsContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Build
|
||||||
|
"
|
||||||
|
|
||||||
|
[connection signal="item_selected" from="MarginContainer/PanelContainer/HBoxContainer/ScrollContainer/VBoxContainer/BuildingGroups" to="." method="_on_building_groups_item_selected"]
|
||||||
|
[connection signal="item_selected" from="MarginContainer/PanelContainer/HBoxContainer/ScrollContainer2/VBoxContainer/Buildings" to="." method="_on_buildings_item_selected"]
|
||||||
|
[connection signal="pressed" from="MarginContainer/PanelContainer/HBoxContainer/DetailsContainer/BuildButtonsContainer/BuildButton" to="." method="_on_build_button_pressed"]
|
||||||
14
scene/interaction_bar.tscn
Normal file
14
scene/interaction_bar.tscn
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://dfr3hvxqo4fqf"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/interaction_bar.gd" id="1_qwnlc"]
|
||||||
|
|
||||||
|
[node name="InteractionBar" type="ProgressBar"]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_right = -1092.0
|
||||||
|
offset_bottom = -628.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
show_percentage = false
|
||||||
|
script = ExtResource("1_qwnlc")
|
||||||
@@ -82,6 +82,7 @@ size = Vector2(40, 45)
|
|||||||
[node name="Player" type="CharacterBody2D"]
|
[node name="Player" type="CharacterBody2D"]
|
||||||
motion_mode = 1
|
motion_mode = 1
|
||||||
script = ExtResource("1_j0htm")
|
script = ExtResource("1_j0htm")
|
||||||
|
SPEED = null
|
||||||
|
|
||||||
[node name="Sprite" type="AnimatedSprite2D" parent="."]
|
[node name="Sprite" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = SubResource("SpriteFrames_tj1nq")
|
sprite_frames = SubResource("SpriteFrames_tj1nq")
|
||||||
|
|||||||
67
scripts/build_menu.gd
Normal file
67
scripts/build_menu.gd
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
extends CanvasLayer
|
||||||
|
|
||||||
|
signal build(building: Building)
|
||||||
|
|
||||||
|
var groups_visible: Array[BuildingGroup] = []
|
||||||
|
var buildings_visible: Array[Building] = []
|
||||||
|
var selected_building: Building
|
||||||
|
|
||||||
|
const ADVANCED_BUILDING_GROUP = preload("res://data/buildings/advanced/advanced_building_group.tres")
|
||||||
|
const BASIC_BUILDING_GROUP = preload("res://data/buildings/basic/basic_building_group.tres")
|
||||||
|
|
||||||
|
@onready var building_groups: ItemList = $MarginContainer/PanelContainer/HBoxContainer/ScrollContainer/VBoxContainer/BuildingGroups
|
||||||
|
@onready var buildings: ItemList = $MarginContainer/PanelContainer/HBoxContainer/ScrollContainer2/VBoxContainer/Buildings
|
||||||
|
|
||||||
|
@onready var title: Label = $MarginContainer/PanelContainer/HBoxContainer/DetailsContainer/Title
|
||||||
|
@onready var description: Label = $MarginContainer/PanelContainer/HBoxContainer/DetailsContainer/Description
|
||||||
|
@onready var build_materials: GridContainer = $MarginContainer/PanelContainer/HBoxContainer/DetailsContainer/BuildMaterials
|
||||||
|
@onready var build_buttons_container: HBoxContainer = $MarginContainer/PanelContainer/HBoxContainer/DetailsContainer/BuildButtonsContainer
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_add_building_group(BASIC_BUILDING_GROUP)
|
||||||
|
_add_building_group(ADVANCED_BUILDING_GROUP)
|
||||||
|
|
||||||
|
func _add_building_group(group: BuildingGroup) -> void:
|
||||||
|
building_groups.add_item(group.name, group.atlas_texture)
|
||||||
|
groups_visible.append(group)
|
||||||
|
|
||||||
|
func _on_building_groups_item_selected(index: int) -> void:
|
||||||
|
buildings.clear()
|
||||||
|
buildings_visible.clear()
|
||||||
|
for building in groups_visible[index].buildings:
|
||||||
|
buildings_visible.append(building)
|
||||||
|
buildings.add_item(building.name, building.atlas_texture)
|
||||||
|
|
||||||
|
description.hide()
|
||||||
|
build_materials.hide()
|
||||||
|
build_buttons_container.hide()
|
||||||
|
selected_building = null
|
||||||
|
|
||||||
|
|
||||||
|
func _on_buildings_item_selected(index: int) -> void:
|
||||||
|
selected_building = buildings_visible[index]
|
||||||
|
title.text = selected_building.name
|
||||||
|
description.text = selected_building.description
|
||||||
|
|
||||||
|
for child in build_materials.get_children():
|
||||||
|
child.queue_free()
|
||||||
|
for res: GameResource in selected_building.cost.keys():
|
||||||
|
var image = TextureRect.new()
|
||||||
|
var texture = AtlasTexture.new()
|
||||||
|
texture.atlas = preload("res://assets/scifi_tilesheet@2.png")
|
||||||
|
texture.region = Rect2(64 * res.atlas_location, Vector2(64, 64))
|
||||||
|
image.texture = texture
|
||||||
|
build_materials.add_child(image)
|
||||||
|
var label = Label.new()
|
||||||
|
label.text = str(selected_building.cost[res])
|
||||||
|
build_materials.add_child(label)
|
||||||
|
|
||||||
|
description.show()
|
||||||
|
build_materials.show()
|
||||||
|
build_buttons_container.show()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_build_button_pressed() -> void:
|
||||||
|
if selected_building:
|
||||||
|
build.emit(selected_building)
|
||||||
|
queue_free()
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
class_name CellData
|
class_name CellData
|
||||||
extends Resource
|
extends Resource
|
||||||
|
|
||||||
const BUILD = preload("res://data/interactions/build.tres")
|
const BUILD = preload("res://data/interactions/build/build.tres")
|
||||||
const GATHER = preload("res://data/interactions/gather.tres")
|
const GATHER = preload("res://data/interactions/gather/gather.tres")
|
||||||
|
|
||||||
@export var layer_info: Dictionary = {
|
@export var layer_info: Dictionary = {
|
||||||
Constants.TilemapLayers.CORRUPTION: false
|
Constants.TilemapLayers.CORRUPTION: false
|
||||||
@@ -40,6 +40,12 @@ func is_corrupted() -> bool:
|
|||||||
func has_layer(layer: int) -> bool:
|
func has_layer(layer: int) -> bool:
|
||||||
return layer_info.has(layer)
|
return layer_info.has(layer)
|
||||||
|
|
||||||
|
func is_interactable() -> bool:
|
||||||
|
return has_resource() or has_building()
|
||||||
|
|
||||||
|
func is_buildable() -> bool:
|
||||||
|
return not has_resource() or not has_building()
|
||||||
|
|
||||||
func get_interaction_options() -> Array[Interaction]:
|
func get_interaction_options() -> Array[Interaction]:
|
||||||
var interactions: Array[Interaction] = []
|
var interactions: Array[Interaction] = []
|
||||||
if has_resource():
|
if has_resource():
|
||||||
|
|||||||
13
scripts/interaction_bar.gd
Normal file
13
scripts/interaction_bar.gd
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
extends ProgressBar
|
||||||
|
class_name InteractionBar
|
||||||
|
|
||||||
|
signal interaction_finished
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
var tween = get_tree().create_tween()
|
||||||
|
tween.tween_property(self, "value", 100, 3)
|
||||||
|
tween.tween_callback(_cleanup_gather)
|
||||||
|
|
||||||
|
func _cleanup_gather() -> void:
|
||||||
|
interaction_finished.emit()
|
||||||
|
self.queue_free()
|
||||||
@@ -40,6 +40,9 @@ func _process(delta: float) -> void:
|
|||||||
if next_interactions.is_empty():
|
if next_interactions.is_empty():
|
||||||
closed.emit()
|
closed.emit()
|
||||||
queue_free()
|
queue_free()
|
||||||
|
else:
|
||||||
|
interactions = next_interactions
|
||||||
|
_ready()
|
||||||
|
|
||||||
func _get_selection_index(angle: float) -> int:
|
func _get_selection_index(angle: float) -> int:
|
||||||
var adjusted_angle = fposmod(angle + (PI / 2.0), 2.0 * PI)
|
var adjusted_angle = fposmod(angle + (PI / 2.0), 2.0 * PI)
|
||||||
|
|||||||
@@ -6,10 +6,15 @@ class_name Player
|
|||||||
var last_direction = 0
|
var last_direction = 0
|
||||||
var interaction_location: Vector2i
|
var interaction_location: Vector2i
|
||||||
var _interaction_options: InteractionWheel
|
var _interaction_options: InteractionWheel
|
||||||
|
var _interacting := false
|
||||||
|
var _attempting_build: Building
|
||||||
|
var _build_placement: Sprite2D
|
||||||
|
|
||||||
@onready var sprite: AnimatedSprite2D = $Sprite
|
@onready var sprite: AnimatedSprite2D = $Sprite
|
||||||
@onready var interaction_timer: Timer = $InteractionTimer
|
@onready var interaction_timer: Timer = $InteractionTimer
|
||||||
const INTERACTION_WHEEL = preload("res://scene/interaction_wheel.tscn")
|
const INTERACTION_BAR = preload("res://scene/interaction_bar.tscn")
|
||||||
|
const BUILD_MENU = preload("res://scene/build_menu.tscn")
|
||||||
|
const BUILDING_BASE = preload("res://data/buildings/building_base.tscn")
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
var input_direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
var input_direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||||
@@ -28,14 +33,32 @@ func _physics_process(delta: float) -> void:
|
|||||||
else:
|
else:
|
||||||
sprite.stop()
|
sprite.stop()
|
||||||
|
|
||||||
|
if _build_placement:
|
||||||
|
_build_placement.position = Grid.grid_to_world_center(interaction_location)
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("select") and not _interaction_options:
|
if event.is_action_pressed("interact"):
|
||||||
var interactions: Array[Interaction] = Grid.get_location_data(interaction_location).get_interaction_options()
|
if _attempting_build and Grid.get_location_data(interaction_location).is_buildable():
|
||||||
if interactions.size() > 0:
|
var build: BuildingBase = BUILDING_BASE.instantiate()
|
||||||
_interaction_options = INTERACTION_WHEEL.instantiate()
|
build.initialize(_attempting_build, interaction_location)
|
||||||
_interaction_options.initialize(interaction_location, interactions)
|
add_sibling(build)
|
||||||
_interaction_options.closed.connect(_on_interation_options_closed)
|
if not _interacting and Grid.get_location_data(interaction_location).is_interactable():
|
||||||
add_sibling(_interaction_options)
|
var interaction = INTERACTION_BAR.instantiate()
|
||||||
|
interaction.position = Grid.grid_to_world_center(interaction_location) - Vector2(30,10)
|
||||||
|
_interacting = true
|
||||||
|
add_sibling(interaction)
|
||||||
|
if event.is_action_pressed("build"):
|
||||||
|
var build_menu = BUILD_MENU.instantiate()
|
||||||
|
build_menu.build.connect(_on_build_menu_build)
|
||||||
|
add_sibling(build_menu)
|
||||||
|
|
||||||
|
func _on_build_menu_build(building: Building) -> void:
|
||||||
|
print("Building: %s" % building.name)
|
||||||
|
_attempting_build = building
|
||||||
|
_build_placement = Sprite2D.new()
|
||||||
|
_build_placement.texture = _attempting_build.atlas_texture
|
||||||
|
_build_placement.self_modulate = Color(1, 0, 0, 0.4)
|
||||||
|
add_sibling(_build_placement)
|
||||||
|
|
||||||
func _on_interation_options_closed() -> void:
|
func _on_interation_options_closed() -> void:
|
||||||
_interaction_options = null
|
_interaction_options = null
|
||||||
|
|||||||
Reference in New Issue
Block a user