Compare commits
4 Commits
2024/0204-
...
d74bfda9a3
| Author | SHA1 | Date | |
|---|---|---|---|
| d74bfda9a3 | |||
| 856b6a0400 | |||
| 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 []
|
||||||
@@ -18,6 +18,7 @@ config/icon="res://icon.svg"
|
|||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
Grid="*res://scripts/autoloads/grid.gd"
|
Grid="*res://scripts/autoloads/grid.gd"
|
||||||
|
ResourceManager="*res://scripts/autoloads/resource_manager.gd"
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
@@ -29,6 +30,38 @@ theme/custom="res://data/world_theme.tres"
|
|||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
ui_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
|
||||||
|
, 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":65,"key_label":0,"unicode":97,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
|
||||||
|
, 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":68,"key_label":0,"unicode":100,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
||||||
|
, 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":87,"key_label":0,"unicode":119,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||||
|
, 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":83,"key_label":0,"unicode":115,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
view_right={
|
view_right={
|
||||||
"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":4194321,"key_label":0,"unicode":0,"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":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
@@ -77,12 +110,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]
|
||||||
|
|
||||||
|
|||||||
90
scene/build_menu.tscn
Normal file
90
scene/build_menu.tscn
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
[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
|
||||||
|
allow_search = false
|
||||||
|
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"]
|
||||||
9
scene/interaction_bar.tscn
Normal file
9
scene/interaction_bar.tscn
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[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"]
|
||||||
|
offset_right = 60.0
|
||||||
|
offset_bottom = 20.0
|
||||||
|
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,95 @@
|
|||||||
[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")
|
||||||
|
|
||||||
[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="."]
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
[gd_scene load_steps=12 format=3 uid="uid://m0us5xqa3gnk"]
|
[gd_scene load_steps=11 format=3 uid="uid://m0us5xqa3gnk"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/world.gd" id="1_yf6q1"]
|
[ext_resource type="Script" path="res://scripts/world.gd" id="1_yf6q1"]
|
||||||
[ext_resource type="Resource" uid="uid://dr00rd4f42jqe" path="res://data/game_resources/gem/gem_resource.tres" id="2_rn4a2"]
|
[ext_resource type="Resource" uid="uid://dr00rd4f42jqe" path="res://data/game_resources/gem/gem_resource.tres" id="2_rn4a2"]
|
||||||
[ext_resource type="TileSet" uid="uid://d1sh6dy2w10b0" path="res://data/scifi_tileset.tres" id="2_sa7dm"]
|
[ext_resource type="TileSet" uid="uid://d1sh6dy2w10b0" path="res://data/scifi_tileset.tres" id="2_sa7dm"]
|
||||||
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="3_pq6ic"]
|
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="3_pq6ic"]
|
||||||
[ext_resource type="Script" path="res://scripts/building_manager.gd" id="4_61js3"]
|
[ext_resource type="Script" path="res://scripts/building_manager.gd" id="4_61js3"]
|
||||||
[ext_resource type="Script" path="res://scripts/resource_manager.gd" id="5_k5643"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="5_qhth7"]
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="5_qhth7"]
|
||||||
[ext_resource type="Script" path="res://scripts/gui.gd" id="6_yuatk"]
|
[ext_resource type="Script" path="res://scripts/gui.gd" id="6_yuatk"]
|
||||||
|
|
||||||
@@ -41,13 +40,6 @@ layer_4/tile_data = PackedInt32Array()
|
|||||||
[node name="BuildingManager" type="Node2D" parent="."]
|
[node name="BuildingManager" type="Node2D" parent="."]
|
||||||
script = ExtResource("4_61js3")
|
script = ExtResource("4_61js3")
|
||||||
|
|
||||||
[node name="ResourceManager" type="Node2D" parent="."]
|
|
||||||
script = ExtResource("5_k5643")
|
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="ResourceManager"]
|
|
||||||
wait_time = 5.0
|
|
||||||
autostart = true
|
|
||||||
|
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="GUI" type="Control" parent="CanvasLayer"]
|
[node name="GUI" type="Control" parent="CanvasLayer"]
|
||||||
@@ -146,6 +138,3 @@ other info here too"
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_stretch_ratio = 2.0
|
size_flags_stretch_ratio = 2.0
|
||||||
|
|
||||||
[connection signal="changed_resource" from="ResourceManager" to="CanvasLayer/GUI" method="_on_resource_manager_changed_resource"]
|
|
||||||
[connection signal="timeout" from="ResourceManager/Timer" to="ResourceManager" method="_on_timer_timeout"]
|
|
||||||
|
|||||||
@@ -37,3 +37,6 @@ func get_location_data(pos: Vector2i) -> CellData:
|
|||||||
func change_location_resource(pos: Vector2i, data: GameResource) -> void:
|
func change_location_resource(pos: Vector2i, data: GameResource) -> void:
|
||||||
world_data[pos].change_resource(data)
|
world_data[pos].change_resource(data)
|
||||||
world_grid.set_cell(Constants.TilemapLayers.ENVIRONMENT, pos, 0, data.atlas_location)
|
world_grid.set_cell(Constants.TilemapLayers.ENVIRONMENT, pos, 0, data.atlas_location)
|
||||||
|
|
||||||
|
func change_location_building(pos: Vector2i, data: BuildingBase) -> void:
|
||||||
|
world_data[pos].change_building(data)
|
||||||
|
|||||||
46
scripts/autoloads/resource_manager.gd
Normal file
46
scripts/autoloads/resource_manager.gd
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
extends Node
|
||||||
|
signal changed_resource
|
||||||
|
|
||||||
|
@export var resources := {}
|
||||||
|
|
||||||
|
func _on_gained_resource(res: GameResource) -> void:
|
||||||
|
print("Gained Resource: %s" % res)
|
||||||
|
var changed_resources := {
|
||||||
|
res: res.pickup_value
|
||||||
|
}
|
||||||
|
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
||||||
|
|
||||||
|
func pickup(resource: GameResource) -> void:
|
||||||
|
if not resources.has(resource):
|
||||||
|
resources[resource] = 0
|
||||||
|
resources[resource] += resource.pickup_value
|
||||||
|
var changed_resources := {
|
||||||
|
resource: resource.pickup_value
|
||||||
|
}
|
||||||
|
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
||||||
|
|
||||||
|
func has_amount(res: GameResource, amount: int) -> bool:
|
||||||
|
return resources[res] >= amount if resources.has(res) else false
|
||||||
|
|
||||||
|
func has_resources(cost: Dictionary) -> bool:
|
||||||
|
return cost.keys().reduce(func(accum, res): return accum and has_amount(res, cost[res]), true)
|
||||||
|
|
||||||
|
func use_resources(cost: Dictionary) -> void:
|
||||||
|
var changed_resources := {
|
||||||
|
}
|
||||||
|
for res in cost.keys():
|
||||||
|
resources[res] -= cost[res]
|
||||||
|
changed_resources[res] = -cost[res]
|
||||||
|
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
||||||
|
|
||||||
|
#func _on_timer_timeout() -> void:
|
||||||
|
#var corrupted_resources := Grid.get_corrupted_resources()
|
||||||
|
#if corrupted_resources.size() > 0:
|
||||||
|
#var changed_resources := {}
|
||||||
|
#for corrupted_resource: CellData in corrupted_resources:
|
||||||
|
#var res: GameResource = corrupted_resource.get_resource()
|
||||||
|
#if not resources.has(res):
|
||||||
|
#resources[res] = 0
|
||||||
|
#resources[res] += res.pickup_value
|
||||||
|
#changed_resources[res] = resources[res]
|
||||||
|
#changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
||||||
70
scripts/build_menu.gd
Normal file
70
scripts/build_menu.gd
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
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)
|
||||||
|
#building_groups.set_focus()
|
||||||
|
|
||||||
|
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])
|
||||||
|
if not ResourceManager.has_amount(res, selected_building.cost[res]):
|
||||||
|
label.add_theme_color_override("font_color", Color.RED)
|
||||||
|
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()
|
||||||
@@ -4,11 +4,11 @@ extends Node2D
|
|||||||
var base = preload("res://scene/base.tscn")
|
var base = preload("res://scene/base.tscn")
|
||||||
var building = preload("res://data/buildings/hub.tres")
|
var building = preload("res://data/buildings/hub.tres")
|
||||||
|
|
||||||
func _unhandled_input(event):
|
#func _unhandled_input(event):
|
||||||
if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
|
#if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
var build: Base = base.instantiate()
|
#var build: Base = base.instantiate()
|
||||||
build.position = get_global_mouse_position()
|
#build.position = get_global_mouse_position()
|
||||||
build.world = world
|
#build.world = world
|
||||||
build.building_data = building.duplicate(true)
|
#build.building_data = building.duplicate(true)
|
||||||
add_child(build)
|
#add_child(build)
|
||||||
#world_grid.set_cell(2, world_grid.local_to_map(get_global_mouse_position()), 0, Vector2i(16,2))
|
#world_grid.set_cell(2, world_grid.local_to_map(get_global_mouse_position()), 0, Vector2i(16,2))
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -25,6 +25,9 @@ func change_layer(layer: int, data: Variant) -> bool:
|
|||||||
func change_resource(data: GameResource) -> void:
|
func change_resource(data: GameResource) -> void:
|
||||||
layer_info[Constants.TilemapLayers.ENVIRONMENT] = data
|
layer_info[Constants.TilemapLayers.ENVIRONMENT] = data
|
||||||
|
|
||||||
|
func change_building(data: BuildingBase) -> void:
|
||||||
|
layer_info[Constants.TilemapLayers.BUILDINGS] = data
|
||||||
|
|
||||||
func get_resource() -> GameResource:
|
func get_resource() -> GameResource:
|
||||||
return layer_info[Constants.TilemapLayers.ENVIRONMENT] as GameResource
|
return layer_info[Constants.TilemapLayers.ENVIRONMENT] as GameResource
|
||||||
|
|
||||||
@@ -40,19 +43,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() and 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 +56,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())
|
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ const SCIFI_TILESHEET = preload("res://assets/scifi_tilesheet@2.png")
|
|||||||
|
|
||||||
var _resource_displays := {}
|
var _resource_displays := {}
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
ResourceManager.changed_resource.connect(_on_resource_manager_changed_resource)
|
||||||
|
|
||||||
func _on_resource_manager_changed_resource(changed: ResourceChangedSignal) -> void:
|
func _on_resource_manager_changed_resource(changed: ResourceChangedSignal) -> void:
|
||||||
for resource: GameResource in changed.changed_resources.keys():
|
for resource: GameResource in changed.changed_resources.keys():
|
||||||
if not _resource_displays.has(resource):
|
if not _resource_displays.has(resource):
|
||||||
@@ -17,11 +20,11 @@ func _on_resource_manager_changed_resource(changed: ResourceChangedSignal) -> vo
|
|||||||
img.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
|
img.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL
|
||||||
resource_container.add_child(img)
|
resource_container.add_child(img)
|
||||||
|
|
||||||
var label = Label.new()
|
var label := Label.new()
|
||||||
label.text = str(changed.changed_resources[resource])
|
label.text = str(changed.changed_resources[resource])
|
||||||
resource_container.add_child(label)
|
resource_container.add_child(label)
|
||||||
|
|
||||||
var data = ResourceData.new()
|
var data := ResourceData.new()
|
||||||
data.image = img
|
data.image = img
|
||||||
data.label = label
|
data.label = label
|
||||||
data.value = changed.changed_resources[resource]
|
data.value = changed.changed_resources[resource]
|
||||||
|
|||||||
19
scripts/interaction_bar.gd
Normal file
19
scripts/interaction_bar.gd
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
extends ProgressBar
|
||||||
|
class_name InteractionBar
|
||||||
|
|
||||||
|
signal interaction_finished
|
||||||
|
|
||||||
|
var grid_position: Vector2i
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
position = Grid.grid_to_world_center(grid_position) - Vector2(30,10)
|
||||||
|
|
||||||
|
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()
|
||||||
|
var res: GameResource = Grid.get_location_data(grid_position).get_resource()
|
||||||
|
ResourceManager.pickup(res)
|
||||||
|
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,59 @@ 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)
|
||||||
|
_build_placement.self_modulate = Color(0, 1, 0, 0.5) if Grid.get_location_data(interaction_location).is_buildable() else Color(1, 0, 0, 0.4)
|
||||||
|
|
||||||
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:
|
_build()
|
||||||
_interaction_options = INTERACTION_WHEEL.instantiate()
|
elif not _interacting and Grid.get_location_data(interaction_location).is_interactable():
|
||||||
_interaction_options.initialize(interaction_location, interactions)
|
var interaction = INTERACTION_BAR.instantiate()
|
||||||
add_sibling(_interaction_options)
|
interaction.interaction_finished.connect(_on_interaction_finished)
|
||||||
|
interaction.grid_position = interaction_location
|
||||||
|
_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_interaction_finished() -> void:
|
||||||
print("interaction finished: %s" % results)
|
_interacting = false
|
||||||
|
|
||||||
|
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 _build() -> void:
|
||||||
|
ResourceManager.use_resources(_attempting_build.cost)
|
||||||
|
var build: BuildingBase = BUILDING_BASE.instantiate()
|
||||||
|
build.initialize(_attempting_build, interaction_location)
|
||||||
|
add_sibling(build)
|
||||||
|
Grid.change_location_building(interaction_location, build)
|
||||||
|
|
||||||
|
if not ResourceManager.has_resources(_attempting_build.cost):
|
||||||
|
_attempting_build = null
|
||||||
|
_build_placement.queue_free()
|
||||||
|
_build_placement = null
|
||||||
|
|
||||||
|
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:
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
extends Node2D
|
|
||||||
|
|
||||||
signal changed_resource
|
|
||||||
|
|
||||||
@onready var world: World = $".."
|
|
||||||
|
|
||||||
@export var resources := {}
|
|
||||||
|
|
||||||
func _on_gained_resource(res: GameResource) -> void:
|
|
||||||
print("Gained Resource: %s" % res)
|
|
||||||
var changed_resources := {
|
|
||||||
res: res.pickup_value
|
|
||||||
}
|
|
||||||
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
|
||||||
|
|
||||||
#func _on_timer_timeout() -> void:
|
|
||||||
#var corrupted_resources := Grid.get_corrupted_resources()
|
|
||||||
#if corrupted_resources.size() > 0:
|
|
||||||
#var changed_resources := {}
|
|
||||||
#for corrupted_resource: CellData in corrupted_resources:
|
|
||||||
#var res: GameResource = corrupted_resource.get_resource()
|
|
||||||
#if not resources.has(res):
|
|
||||||
#resources[res] = 0
|
|
||||||
#resources[res] += res.pickup_value
|
|
||||||
#changed_resources[res] = resources[res]
|
|
||||||
#changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
|
||||||
@@ -14,7 +14,6 @@ var noise_regions := [-999,0,999]
|
|||||||
var atlas_regions := [Vector2i(0,1),Vector2i(0,0)]
|
var atlas_regions := [Vector2i(0,1),Vector2i(0,0)]
|
||||||
|
|
||||||
@onready var world_grid: TileMap = $world_grid
|
@onready var world_grid: TileMap = $world_grid
|
||||||
@onready var resource_manager: Node2D = $ResourceManager
|
|
||||||
|
|
||||||
func get_noise_value(x: int, y: int):
|
func get_noise_value(x: int, y: int):
|
||||||
return terrain_noise.get_noise_2d(x,y) * 500
|
return terrain_noise.get_noise_2d(x,y) * 500
|
||||||
@@ -62,7 +61,7 @@ func corrupt_location(loc: Vector2i):
|
|||||||
|
|
||||||
func add_resources_to_map() -> void:
|
func add_resources_to_map() -> void:
|
||||||
for res: GameResource in game_resources:
|
for res: GameResource in game_resources:
|
||||||
res.gained_resource.connect(resource_manager._on_gained_resource)
|
#res.gained_resource.connect(ResourceManager._on_gained_resource)
|
||||||
var spawns = res.get_spawn_locations()
|
var spawns = res.get_spawn_locations()
|
||||||
for spawn in spawns:
|
for spawn in spawns:
|
||||||
Grid.change_location_resource(spawn, res)
|
Grid.change_location_resource(spawn, res)
|
||||||
|
|||||||
Reference in New Issue
Block a user