Compare commits
2 Commits
2024/0204-
...
ca8cfee1e8
| Author | SHA1 | Date | |
|---|---|---|---|
| ca8cfee1e8 | |||
| abde90e75f |
Binary file not shown.
|
Before Width: | Height: | Size: 106 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 = {
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
[gd_resource type="Resource" script_class="Interaction" load_steps=4 format=3 uid="uid://bo3e2jefukgdy"]
|
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_bglkk"]
|
|
||||||
[ext_resource type="Script" path="res://scripts/interaction.gd" id="2_h5okx"]
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3e2ed"]
|
|
||||||
atlas = ExtResource("1_bglkk")
|
|
||||||
region = Rect2(960, 512, 64, 64)
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
script = ExtResource("2_h5okx")
|
|
||||||
name = "Build"
|
|
||||||
image = SubResource("AtlasTexture_3e2ed")
|
|
||||||
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 []
|
||||||
13
data/interactions/build/build.tres
Normal file
13
data/interactions/build/build.tres
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[gd_resource type="Resource" script_class="InteractionBuild" load_steps=4 format=3 uid="uid://bo3e2jefukgdy"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_bglkk"]
|
||||||
|
[ext_resource type="Script" path="res://data/interactions/build/interaction_build.gd" id="2_0g8r2"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_f6dt5"]
|
||||||
|
atlas = ExtResource("1_bglkk")
|
||||||
|
region = Rect2(960, 512, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_0g8r2")
|
||||||
|
name = "Build"
|
||||||
|
image = SubResource("AtlasTexture_f6dt5")
|
||||||
8
data/interactions/build/interaction_build.gd
Normal file
8
data/interactions/build/interaction_build.gd
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
extends Interaction
|
||||||
|
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]:
|
||||||
|
return [BUILD_BASIC, BUILD_ADVANCED]
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
[gd_resource type="Resource" script_class="Interaction" load_steps=4 format=3 uid="uid://r4evto2nkehg"]
|
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_cquks"]
|
|
||||||
[ext_resource type="Script" path="res://scripts/interaction.gd" id="1_m76d8"]
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f8jvb"]
|
|
||||||
atlas = ExtResource("1_cquks")
|
|
||||||
region = Rect2(1024, 512, 64, 64)
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
script = ExtResource("1_m76d8")
|
|
||||||
name = "Gather"
|
|
||||||
image = SubResource("AtlasTexture_f8jvb")
|
|
||||||
13
data/interactions/gather/gather.tres
Normal file
13
data/interactions/gather/gather.tres
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[gd_resource type="Resource" script_class="InteractionGather" load_steps=4 format=3 uid="uid://r4evto2nkehg"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_cquks"]
|
||||||
|
[ext_resource type="Script" path="res://data/interactions/gather/interaction_gather.gd" id="2_4amum"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_jjmaq"]
|
||||||
|
atlas = ExtResource("1_cquks")
|
||||||
|
region = Rect2(1024, 512, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_4amum")
|
||||||
|
name = "Gather"
|
||||||
|
image = SubResource("AtlasTexture_jjmaq")
|
||||||
24
data/interactions/gather/interaction_gather.gd
Normal file
24
data/interactions/gather/interaction_gather.gd
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
extends Interaction
|
||||||
|
class_name InteractionGather
|
||||||
|
|
||||||
|
var interaction_display
|
||||||
|
var _pos
|
||||||
|
|
||||||
|
func interact_at(pos: Vector2i, root: Node) -> Array[Interaction]:
|
||||||
|
_pos = pos
|
||||||
|
print("Gathering at: %s" % pos)
|
||||||
|
|
||||||
|
interaction_display = ProgressBar.new()
|
||||||
|
interaction_display.position = Grid.grid_to_world_center(_pos) - Vector2(30, 10)
|
||||||
|
interaction_display.size = Vector2(60, 20)
|
||||||
|
interaction_display.show_percentage = false
|
||||||
|
var tween = root.create_tween()
|
||||||
|
tween.tween_property(interaction_display, "value", 100, 3)
|
||||||
|
tween.tween_callback(_cleanup_gather)
|
||||||
|
root.add_child(interaction_display)
|
||||||
|
return []
|
||||||
|
|
||||||
|
func _cleanup_gather() -> void:
|
||||||
|
interaction_display.queue_free()
|
||||||
|
var res: GameResource = Grid.get_location_data(_pos).get_resource()
|
||||||
|
res.gained_resource.emit(res)
|
||||||
@@ -3,3 +3,6 @@ class_name Interaction
|
|||||||
|
|
||||||
@export var name: String
|
@export var name: String
|
||||||
@export var image: AtlasTexture
|
@export var image: AtlasTexture
|
||||||
|
|
||||||
|
func interact_at(pos: Vector2i, root: Node) -> Array[Interaction]:
|
||||||
|
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")
|
||||||
@@ -24,17 +24,23 @@ texture = SubResource("AtlasTexture_7xl34")
|
|||||||
[node name="Interactions" type="Node2D" parent="."]
|
[node name="Interactions" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="SpriteNorth" type="Sprite2D" parent="Interactions"]
|
[node name="SpriteNorth" type="Sprite2D" parent="Interactions"]
|
||||||
|
visible = false
|
||||||
position = Vector2(0, -96)
|
position = Vector2(0, -96)
|
||||||
texture = SubResource("AtlasTexture_gdnoe")
|
texture = SubResource("AtlasTexture_gdnoe")
|
||||||
|
|
||||||
|
[node name="SpriteNorthEast" type="Sprite2D" parent="Interactions"]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(68, -68)
|
||||||
|
texture = SubResource("AtlasTexture_gdnoe")
|
||||||
|
|
||||||
[node name="SpriteEast" type="Sprite2D" parent="Interactions"]
|
[node name="SpriteEast" type="Sprite2D" parent="Interactions"]
|
||||||
visible = false
|
visible = false
|
||||||
position = Vector2(96, 0)
|
position = Vector2(96, 0)
|
||||||
texture = SubResource("AtlasTexture_gdnoe")
|
texture = SubResource("AtlasTexture_gdnoe")
|
||||||
|
|
||||||
[node name="SpriteWest" type="Sprite2D" parent="Interactions"]
|
[node name="SpriteSouthEast" type="Sprite2D" parent="Interactions"]
|
||||||
visible = false
|
visible = false
|
||||||
position = Vector2(-96, 0)
|
position = Vector2(68, 68)
|
||||||
texture = SubResource("AtlasTexture_gdnoe")
|
texture = SubResource("AtlasTexture_gdnoe")
|
||||||
|
|
||||||
[node name="SpriteSouth" type="Sprite2D" parent="Interactions"]
|
[node name="SpriteSouth" type="Sprite2D" parent="Interactions"]
|
||||||
@@ -42,8 +48,49 @@ visible = false
|
|||||||
position = Vector2(0, 96)
|
position = Vector2(0, 96)
|
||||||
texture = SubResource("AtlasTexture_gdnoe")
|
texture = SubResource("AtlasTexture_gdnoe")
|
||||||
|
|
||||||
[node name="Cursor" type="Sprite2D" parent="."]
|
[node name="SpriteSouthWest" type="Sprite2D" parent="Interactions"]
|
||||||
visible = false
|
visible = false
|
||||||
|
position = Vector2(-68, 68)
|
||||||
|
texture = SubResource("AtlasTexture_gdnoe")
|
||||||
|
|
||||||
|
[node name="SpriteWest" type="Sprite2D" parent="Interactions"]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(-96, 0)
|
||||||
|
texture = SubResource("AtlasTexture_gdnoe")
|
||||||
|
|
||||||
|
[node name="SpriteNorthWest" type="Sprite2D" parent="Interactions"]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(-68, -68)
|
||||||
|
texture = SubResource("AtlasTexture_gdnoe")
|
||||||
|
|
||||||
|
[node name="Cursor" type="Sprite2D" parent="."]
|
||||||
texture = SubResource("AtlasTexture_ci5w3")
|
texture = SubResource("AtlasTexture_ci5w3")
|
||||||
centered = false
|
centered = false
|
||||||
offset = Vector2(0, -32)
|
offset = Vector2(0, -32)
|
||||||
|
|
||||||
|
[node name="InformationPanel" type="Panel" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -20.0
|
||||||
|
offset_top = -20.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 20.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="InteractionLabel" type="Label" parent="InformationPanel"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 5
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
offset_left = -20.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 24.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
theme_override_font_sizes/font_size = 8
|
||||||
|
text = "Build"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|||||||
@@ -1,51 +1,96 @@
|
|||||||
[gd_scene load_steps=7 format=3 uid="uid://dkvcye4mhvshd"]
|
[gd_scene load_steps=12 format=3 uid="uid://dkvcye4mhvshd"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/player.gd" id="1_j0htm"]
|
[ext_resource type="Script" path="res://scripts/player.gd" id="1_j0htm"]
|
||||||
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_vqdy1"]
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_vqdy1"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8yvc7"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_rbmjr"]
|
||||||
atlas = ExtResource("1_vqdy1")
|
atlas = ExtResource("1_vqdy1")
|
||||||
region = Rect2(640, 192, 64, 64)
|
region = Rect2(832, 640, 64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_xx5oc"]
|
||||||
|
atlas = ExtResource("1_vqdy1")
|
||||||
|
region = Rect2(832, 640, 64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2ckq3"]
|
||||||
|
atlas = ExtResource("1_vqdy1")
|
||||||
|
region = Rect2(896, 704, 64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_vet2c"]
|
||||||
|
atlas = ExtResource("1_vqdy1")
|
||||||
|
region = Rect2(960, 704, 64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fqxfq"]
|
||||||
|
atlas = ExtResource("1_vqdy1")
|
||||||
|
region = Rect2(832, 640, 64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_03ery"]
|
||||||
|
atlas = ExtResource("1_vqdy1")
|
||||||
|
region = Rect2(896, 640, 64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ix8o6"]
|
||||||
|
atlas = ExtResource("1_vqdy1")
|
||||||
|
region = Rect2(960, 640, 64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_tj1nq"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_rbmjr")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_xx5oc")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_2ckq3")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_xx5oc")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_vet2c")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"interact",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_fqxfq")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_03ery")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_fqxfq")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_ix8o6")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"walk",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jav3v"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jav3v"]
|
||||||
size = Vector2(40, 45)
|
size = Vector2(40, 45)
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_47lv4"]
|
|
||||||
resource_name = "walk"
|
|
||||||
length = 1.2
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath("Sprite2D:position")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8, 1, 1.2),
|
|
||||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
|
|
||||||
"update": 0,
|
|
||||||
"values": [Vector2(0, 0), Vector2(0, -1), Vector2(0, -2), Vector2(0, -1), Vector2(0, 0), Vector2(0, 1), Vector2(0, 0)]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ditnu"]
|
|
||||||
_data = {
|
|
||||||
"walk": SubResource("Animation_47lv4")
|
|
||||||
}
|
|
||||||
|
|
||||||
[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="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite" type="AnimatedSprite2D" parent="."]
|
||||||
texture = SubResource("AtlasTexture_8yvc7")
|
sprite_frames = SubResource("SpriteFrames_tj1nq")
|
||||||
|
frame_progress = 0.850199
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource("RectangleShape2D_jav3v")
|
shape = SubResource("RectangleShape2D_jav3v")
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
|
||||||
libraries = {
|
|
||||||
"": SubResource("AnimationLibrary_ditnu")
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
|
||||||
[node name="InteractionTimer" type="Timer" parent="."]
|
[node name="InteractionTimer" type="Timer" parent="."]
|
||||||
|
|||||||
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,19 +40,11 @@ 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 interact(timer: Timer) -> void:
|
func is_interactable() -> bool:
|
||||||
var is_interactable := has_resource() or not has_building()
|
return has_resource() or has_building()
|
||||||
if is_interactable and not interaction_display:
|
|
||||||
timer.timeout.connect(_on_interaction_finished.bind(timer))
|
|
||||||
timer.start(3)
|
|
||||||
|
|
||||||
interaction_display = ProgressBar.new()
|
func is_buildable() -> bool:
|
||||||
interaction_display.position = Grid.grid_to_world_center(_pos) - Vector2(30, 10)
|
return not has_resource() or not has_building()
|
||||||
interaction_display.size = Vector2(60, 20)
|
|
||||||
interaction_display.show_percentage = false
|
|
||||||
var tween = timer.get_tree().create_tween()
|
|
||||||
tween.tween_property(interaction_display, "value", 100, 3)
|
|
||||||
timer.get_parent().add_sibling(interaction_display)
|
|
||||||
|
|
||||||
func get_interaction_options() -> Array[Interaction]:
|
func get_interaction_options() -> Array[Interaction]:
|
||||||
var interactions: Array[Interaction] = []
|
var interactions: Array[Interaction] = []
|
||||||
@@ -61,9 +53,3 @@ func get_interaction_options() -> Array[Interaction]:
|
|||||||
if not has_building():
|
if not has_building():
|
||||||
interactions.append(BUILD)
|
interactions.append(BUILD)
|
||||||
return interactions
|
return interactions
|
||||||
|
|
||||||
func _on_interaction_finished(timer: Timer) -> void:
|
|
||||||
timer.timeout.disconnect(_on_interaction_finished)
|
|
||||||
if has_resource():
|
|
||||||
interaction_display.queue_free()
|
|
||||||
get_resource().gained_resource.emit(get_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()
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
class_name InteractionWheel
|
class_name InteractionWheel
|
||||||
|
|
||||||
|
signal closed
|
||||||
|
|
||||||
var interactions: Array[Interaction]
|
var interactions: Array[Interaction]
|
||||||
|
var grid_position: Vector2i
|
||||||
|
|
||||||
@onready var interaction_icons: Array[Node] = $Interactions.get_children()
|
@onready var interaction_icons: Array[Node] = $Interactions.get_children()
|
||||||
@onready var cursor: Sprite2D = $Cursor
|
@onready var cursor: Sprite2D = $Cursor
|
||||||
|
@onready var information_panel: Panel = $InformationPanel
|
||||||
|
@onready var interaction_label: Label = $InformationPanel/InteractionLabel
|
||||||
|
|
||||||
func initialize(interaction_location: Vector2i, interactions: Array[Interaction]) -> void:
|
func initialize(interaction_location: Vector2i, interactions: Array[Interaction]) -> void:
|
||||||
|
grid_position = interaction_location
|
||||||
position = Grid.grid_to_world_center(interaction_location)
|
position = Grid.grid_to_world_center(interaction_location)
|
||||||
self.interactions = interactions
|
self.interactions = interactions
|
||||||
|
|
||||||
@@ -20,5 +26,24 @@ func _process(delta: float) -> void:
|
|||||||
if selection_direction:
|
if selection_direction:
|
||||||
cursor.rotation = selection_direction.angle()
|
cursor.rotation = selection_direction.angle()
|
||||||
cursor.show()
|
cursor.show()
|
||||||
if Input.is_action_just_pressed("select"):
|
var selection = _get_selection_index(cursor.rotation)
|
||||||
pass
|
if selection < interactions.size():
|
||||||
|
information_panel.show()
|
||||||
|
interaction_label.text = interactions[selection].name
|
||||||
|
else:
|
||||||
|
information_panel.hide()
|
||||||
|
if Input.is_action_just_pressed("select") and cursor.visible:
|
||||||
|
var selection = _get_selection_index(cursor.rotation)
|
||||||
|
print("Selection: %s Rotation: %s" % [selection, cursor.rotation])
|
||||||
|
if selection < interactions.size():
|
||||||
|
var next_interactions = interactions[selection].interact_at(grid_position, get_tree().root)
|
||||||
|
if next_interactions.is_empty():
|
||||||
|
closed.emit()
|
||||||
|
queue_free()
|
||||||
|
else:
|
||||||
|
interactions = next_interactions
|
||||||
|
_ready()
|
||||||
|
|
||||||
|
func _get_selection_index(angle: float) -> int:
|
||||||
|
var adjusted_angle = fposmod(angle + (PI / 2.0), 2.0 * PI)
|
||||||
|
return floor(((int(floor(adjusted_angle / (PI / 8.0))) + 1) % 16) / 2.0)
|
||||||
|
|||||||
@@ -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 animation_player: AnimationPlayer = $AnimationPlayer
|
@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")
|
||||||
@@ -19,26 +24,44 @@ func _physics_process(delta: float) -> void:
|
|||||||
if input_direction:
|
if input_direction:
|
||||||
if _interaction_options:
|
if _interaction_options:
|
||||||
_interaction_options.queue_free()
|
_interaction_options.queue_free()
|
||||||
_interaction_options = null
|
_on_interation_options_closed()
|
||||||
animation_player.current_animation = "walk"
|
sprite.play("walk")
|
||||||
animation_player.play()
|
last_direction = input_direction.angle() + PI / 2
|
||||||
last_direction = input_direction.angle() + 3 * PI / 2
|
|
||||||
rotation = last_direction
|
rotation = last_direction
|
||||||
interaction_location = Grid.world_to_grid(position) + Vector2i(input_direction.round())
|
interaction_location = Grid.world_to_grid(position) + Vector2i(input_direction.round())
|
||||||
Grid.set_selected_tile(interaction_location)
|
Grid.set_selected_tile(interaction_location)
|
||||||
else:
|
else:
|
||||||
animation_player.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)
|
||||||
add_sibling(_interaction_options)
|
if not _interacting and Grid.get_location_data(interaction_location).is_interactable():
|
||||||
|
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 _finished_interaction(results: Dictionary) -> void:
|
func _on_build_menu_build(building: Building) -> void:
|
||||||
print("interaction finished: %s" % results)
|
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:
|
||||||
|
_interaction_options = null
|
||||||
|
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
|
|||||||
Reference in New Issue
Block a user