Add info on hover bottom left

This commit is contained in:
Ategon 2024-09-15 01:37:02 -04:00
parent 14046cef33
commit 3047e14916
20 changed files with 261 additions and 7 deletions

View file

@ -4,6 +4,8 @@ extends TileMapLayer
@export var tree_spots: Array[Vector2i]
@export var rock_spots: Array[Vector2i]
@export var th_spots: Array[Vector2i]
@export var level: int
var ruins_spots: Array[Vector2i]
var building_data = {}
var last_tile
@ -60,7 +62,7 @@ func _process(delta: float) -> void:
var building_mode = Persister.get_value("building_mode")
for spot in building_spots:
if not building_data.has(spot) and not tree_spots.has(spot) and not rock_spots.has(spot) and not th_spots.has(spot):
if not building_data.has(spot) and not tree_spots.has(spot) and not rock_spots.has(spot) and not th_spots.has(spot) and not ruins_spots.has(spot):
erase_cell(spot)
if last_tile != tile:
@ -85,6 +87,11 @@ func _process(delta: float) -> void:
last_text.text = "[center]Town Hall"
last_text.position = map_to_local(tile) + Vector2(-25, -10)
add_sibling(last_text)
elif ruins_spots.has(tile):
last_text = NAME_ICON.instantiate()
last_text.text = "[center]Ruins"
last_text.position = map_to_local(tile) + Vector2(-25, -10)
add_sibling(last_text)
elif building_data.has(tile):
last_text = NAME_ICON.instantiate()
last_text.text = "[center]%s" % [Data.data.buildings[building_data[tile].key].name]
@ -96,19 +103,47 @@ func _process(delta: float) -> void:
if not building_mode:
return
if building_spots.has(tile) and not rock_spots.has(tile) and not tree_spots.has(tile) and not th_spots.has(tile):
if building_spots.has(tile) and not rock_spots.has(tile) and not tree_spots.has(tile) and not th_spots.has(tile) and not building_data.has(tile) and not ruins_spots.has(tile):
var build_data = building_to_tile_map[Persister.get_value("building_key")]
set_cell(tile, build_data["source"], Vector2i(build_data["atlas"],rand), 0)
func _ready() -> void:
Triggerer.listen("flood_level", _on_flood_level)
func _on_flood_level(data):
var value = int(data.value)
if value >= level:
for coords in building_data:
var building = building_data[coords]
var build_data = Data.data.buildings[building.key]
var bttm = building_to_tile_map[building.key]
var atlas = bttm.atlas
var source
match build_data.type:
"utility":
source = 11
"housing":
source = 12
"production":
source = 10
ruins_spots.push_back(coords)
set_cell(coords, source, Vector2i(atlas,building.rand), 0)
building_data.clear()
func place_building():
var tile = local_to_map(get_global_mouse_position())
if building_spots.has(tile) and not building_data.has(tile) and not tree_spots.has(tile) and not rock_spots.has(tile) and not th_spots.has(tile):
if building_spots.has(tile) and not building_data.has(tile) and not tree_spots.has(tile) and not rock_spots.has(tile) and not th_spots.has(tile) and not ruins_spots.has(tile):
Persister.persist_data("building_mode", false)
building_data[tile] = {
"key": Persister.get_value("building_key"),
"rand": rand
}
var build_data = Data.data.buildings[Persister.get_value("building_key")]

View file

@ -28,7 +28,7 @@
[sub_resource type="Animation" id="Animation_ycb31"]
resource_name = "start"
length = 3.0
length = 4.0
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@ -125,6 +125,18 @@ tracks/7/keys = {
"update": 0,
"values": [Vector2(41, -28), Vector2(41, -28.4693), Vector2(41, -29.4842), Vector2(41, -30.4547), Vector2(41, -30.7911), Vector2(41, -29.9036), Vector2(41, -27.2025), Vector2(41, -22.0979), Vector2(41, -14), Vector2(41, -5.90214), Vector2(41, -0.797525), Vector2(41, 1.90362), Vector2(41, 2.79109), Vector2(41, 2.45468), Vector2(41, 1.48416), Vector2(41, 0.469339), Vector2(41, 0)]
}
tracks/8/type = "value"
tracks/8/imported = false
tracks/8/enabled = true
tracks/8/path = NodePath("CanvasLayer/BuildingMenu:position")
tracks/8/interp = 1
tracks/8/loop_wrap = true
tracks/8/keys = {
"times": PackedFloat32Array(2.8, 2.83333, 2.86667, 2.9, 2.93333, 2.96667, 3, 3.03333, 3.06667, 3.1, 3.13333, 3.16667, 3.2, 3.23333, 3.26667, 3.3, 3.33333, 3.36667, 3.4),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
"update": 0,
"values": [Vector2(0, 363.755), Vector2(0, 362.197), Vector2(0, 357.522), Vector2(0, 349.732), Vector2(0, 338.825), Vector2(0, 324.802), Vector2(0, 307.662), Vector2(0, 301.314), Vector2(0, 308.538), Vector2(0, 312.646), Vector2(0, 313.637), Vector2(0, 311.513), Vector2(0, 306.272), Vector2(0, 297.914), Vector2(0, 300.348), Vector2(0, 301.056), Vector2(0, 298.648), Vector2(0, 297.992), Vector2(0, 297)]
}
[sub_resource type="Animation" id="Animation_gcod0"]
length = 0.001
@ -212,6 +224,18 @@ tracks/6/keys = {
"update": 0,
"values": [Vector2(41, -28)]
}
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("CanvasLayer/BuildingMenu:position")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, 363.755)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8mn2x"]
_data = {
@ -304,6 +328,7 @@ script = ExtResource("5_3vufn")
building_spots = Array[Vector2i]([Vector2i(33, 5), Vector2i(33, 4), Vector2i(33, 3), Vector2i(34, 4), Vector2i(34, 3), Vector2i(34, 2), Vector2i(34, 1), Vector2i(35, 3), Vector2i(35, 2), Vector2i(36, 3), Vector2i(36, 2), Vector2i(37, 3), Vector2i(38, 4), Vector2i(38, 3), Vector2i(39, 4), Vector2i(39, 3), Vector2i(39, 5), Vector2i(40, 5), Vector2i(40, 4), Vector2i(40, 3), Vector2i(40, 2), Vector2i(40, 1), Vector2i(41, 4), Vector2i(41, 3), Vector2i(41, 2), Vector2i(41, 1), Vector2i(41, 0), Vector2i(42, 4), Vector2i(42, 3), Vector2i(42, 2), Vector2i(42, 1), Vector2i(43, 2), Vector2i(43, 3), Vector2i(44, 3), Vector2i(41, -4), Vector2i(41, -5), Vector2i(42, -3), Vector2i(42, -4), Vector2i(42, -5), Vector2i(43, -5)])
tree_spots = Array[Vector2i]([Vector2i(34, 1), Vector2i(41, 0), Vector2i(41, -4)])
rock_spots = Array[Vector2i]([Vector2i(33, 3), Vector2i(38, 4), Vector2i(42, 4)])
level = 2
[node name="UILevel2" type="TileMapLayer" parent="Node2D/Level2"]
y_sort_enabled = true
@ -331,6 +356,7 @@ script = ExtResource("5_3vufn")
building_spots = Array[Vector2i]([Vector2i(37, 1), Vector2i(37, 0), Vector2i(38, 1), Vector2i(38, 0), Vector2i(36, -3), Vector2i(36, -4), Vector2i(37, -2), Vector2i(37, -3), Vector2i(37, -4), Vector2i(38, -1), Vector2i(38, -2), Vector2i(38, -3), Vector2i(38, -4), Vector2i(38, -5), Vector2i(39, -2), Vector2i(39, -1), Vector2i(39, -3), Vector2i(39, -4), Vector2i(39, -5), Vector2i(39, -6), Vector2i(40, -3), Vector2i(40, -4)])
tree_spots = Array[Vector2i]([Vector2i(37, 0), Vector2i(36, -4), Vector2i(38, -5), Vector2i(39, -5), Vector2i(39, -6)])
rock_spots = Array[Vector2i]([Vector2i(37, 1), Vector2i(39, -1)])
level = 3
[node name="UILevel3" type="TileMapLayer" parent="Node2D/Level3"]
y_sort_enabled = true
@ -357,6 +383,7 @@ tile_set = ExtResource("2_68wnv")
script = ExtResource("5_3vufn")
building_spots = Array[Vector2i]([Vector2i(31, -3), Vector2i(31, -2), Vector2i(31, -1), Vector2i(31, 0), Vector2i(32, -2), Vector2i(32, -3), Vector2i(32, -4), Vector2i(33, -3), Vector2i(33, -4), Vector2i(33, -5), Vector2i(33, -2), Vector2i(33, -1), Vector2i(34, -2), Vector2i(34, -3), Vector2i(34, -1), Vector2i(34, -4), Vector2i(34, -5), Vector2i(35, -6), Vector2i(35, -3), Vector2i(35, -2), Vector2i(35, -1), Vector2i(35, 0), Vector2i(36, -2), Vector2i(36, -6), Vector2i(36, -7), Vector2i(37, -7)])
rock_spots = Array[Vector2i]([Vector2i(31, 0), Vector2i(31, -3), Vector2i(33, -4), Vector2i(35, -2), Vector2i(37, -7)])
level = 4
[node name="UILevel4" type="TileMapLayer" parent="Node2D/Level4"]
y_sort_enabled = true
@ -383,6 +410,7 @@ tile_set = ExtResource("2_68wnv")
script = ExtResource("5_3vufn")
building_spots = Array[Vector2i]([Vector2i(30, -6), Vector2i(30, -5), Vector2i(31, -6), Vector2i(31, -7), Vector2i(32, -7), Vector2i(32, -8), Vector2i(33, -7), Vector2i(33, -8), Vector2i(34, -8)])
rock_spots = Array[Vector2i]([Vector2i(31, -6), Vector2i(32, -8)])
level = 5
[node name="UILevel5" type="TileMapLayer" parent="Node2D/Level5"]
y_sort_enabled = true
@ -406,6 +434,7 @@ tile_set = ExtResource("2_68wnv")
script = ExtResource("5_3vufn")
building_spots = Array[Vector2i]([Vector2i(29, -8), Vector2i(29, -9), Vector2i(30, -9), Vector2i(30, -8)])
th_spots = Array[Vector2i]([Vector2i(29, -8), Vector2i(29, -9), Vector2i(30, -9), Vector2i(30, -8)])
level = 6
[node name="UILevel6" type="TileMapLayer" parent="Node2D/Node2D"]
y_sort_enabled = true
@ -610,6 +639,8 @@ visible = false
pivot_offset = Vector2(114, 128)
[node name="BuildingMenu" parent="CanvasLayer" instance=ExtResource("7_hnxcf")]
offset_top = 3.755
offset_bottom = 66.755
[node name="Night" parent="CanvasLayer" instance=ExtResource("13_8fvl0")]
modulate = Color(1, 1, 1, 0)

View file

@ -27,12 +27,52 @@ texture = ExtResource("2_bubm3")
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_83p42"]
texture = ExtResource("3_7x1fh")
0:0/0 = 0
0:0/0/texture_origin = Vector2i(0, 4)
1:0/0 = 0
1:0/0/texture_origin = Vector2i(0, 4)
1:1/0 = 0
1:1/0/texture_origin = Vector2i(0, 4)
2:1/0 = 0
2:1/0/texture_origin = Vector2i(0, 4)
0:1/0 = 0
0:1/0/texture_origin = Vector2i(0, 4)
2:0/0 = 0
2:0/0/texture_origin = Vector2i(0, 4)
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_mrgl4"]
texture = ExtResource("4_axgg8")
0:0/0 = 0
0:0/0/texture_origin = Vector2i(0, 4)
0:1/0 = 0
0:1/0/texture_origin = Vector2i(0, 4)
1:1/0 = 0
1:1/0/texture_origin = Vector2i(0, 4)
2:1/0 = 0
2:1/0/texture_origin = Vector2i(0, 4)
3:1/0 = 0
3:1/0/texture_origin = Vector2i(0, 4)
3:0/0 = 0
3:0/0/texture_origin = Vector2i(0, 4)
2:0/0 = 0
2:0/0/texture_origin = Vector2i(0, 4)
1:0/0 = 0
1:0/0/texture_origin = Vector2i(0, 4)
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_w6ttr"]
texture = ExtResource("5_16ny2")
0:0/0 = 0
0:0/0/texture_origin = Vector2i(0, 4)
0:1/0 = 0
0:1/0/texture_origin = Vector2i(0, 4)
1:1/0 = 0
1:1/0/texture_origin = Vector2i(0, 4)
2:1/0 = 0
2:1/0/texture_origin = Vector2i(0, 4)
2:0/0 = 0
2:0/0/texture_origin = Vector2i(0, 4)
1:0/0 = 0
1:0/0/texture_origin = Vector2i(0, 4)
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_jhyw0"]
texture = ExtResource("6_q784e")

View file

@ -1,4 +1,5 @@
name: Conduit
short: Boosts Production
type: production
resource: essence
amount: 1

View file

@ -1,4 +1,5 @@
name: Field
short: Produces Wheat
type: utility
cost[]
wood: 2

View file

@ -1,4 +1,5 @@
name: Farmhouse
short: Turns Wheat to Food
type: utility
cost[]
wood: 4

View file

@ -1,5 +1,6 @@
name: House
type: housing
short: Space for 5 People
amount: 5
cost[]
wood: 18

View file

@ -1,6 +1,7 @@
name: Quarter
type: housing
amount: 3
short: Space for 3 People
cost[]
wood: 12
stone: 7

View file

@ -4,5 +4,6 @@ resource: stone
amount: 1
time: 10
max_workers: 6
short: Gathers Stone
cost[]
stone: 2

View file

@ -1,6 +1,7 @@
name: Tent
type: housing
amount: 1
short: Space for 1 Person
cost[]
wood: 6
stone: 4

View file

@ -1,5 +1,6 @@
name: Water Processor
type: utility
short: Cleans Water
cost[]
wood: 6
stone: 10

View file

@ -1,4 +1,5 @@
name: Water Pump
type: utility
short: Produces Water
cost[]
stone: 3

View file

@ -4,5 +4,6 @@ resource: wood
amount: 1
time: 10
max_workers: 6
short: Gathers Wood
cost[]
stone: 3

View file

@ -1,8 +1,21 @@
time_to_flood_change: 25
time_to_flood_change: 10
flood_levels[]
0
2
1
0
1
2
1
1
1
1
1
1
1
1
1
1
1
1

View file

@ -9,7 +9,7 @@ func _process_custom_fx(char_fx: CharFXTransform) -> bool:
var local_time = fmod(time, 1)
if time < 1:
char_fx.offset = Vector2(0, -5 * (sin(local_time * PI)))
char_fx.offset = Vector2(0, -1 * (sin(local_time * PI)))
if time < 3 or time >= 8:
var color_time = local_time
if time >= 1 and time < 3:

View file

@ -9,6 +9,9 @@ var current_flood_state = 0
func _process(delta: float) -> void:
if not Persister.get_value("game_started"):
return
game_time += delta
if last_flood_time + globals.time_to_flood_change < game_time:

View file

@ -1,16 +1,22 @@
[gd_scene load_steps=5 format=3 uid="uid://b7o2i7tgirg64"]
[gd_scene load_steps=8 format=3 uid="uid://b7o2i7tgirg64"]
[ext_resource type="Script" path="res://ui/building_icon.gd" id="1_6qgij"]
[ext_resource type="Theme" uid="uid://d035h7upxrw3h" path="res://theme.tres" id="1_kp3wm"]
[ext_resource type="Texture2D" uid="uid://clqov5mu3bpaw" path="res://parts/buildings/images/foodprocessing.png" id="2_3vnc8"]
[ext_resource type="PackedScene" uid="uid://dykc1mgg5uopw" path="res://components/Cursor/MouseHandler.tscn" id="3_tf3sl"]
[ext_resource type="Script" path="res://small_wave.gd" id="5_e8eo3"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0bdxp"]
[sub_resource type="RichTextEffect" id="RichTextEffect_erhh0"]
script = ExtResource("5_e8eo3")
[node name="BuildingIcon" type="ColorRect"]
custom_minimum_size = Vector2(32, 32)
offset_right = 32.0
offset_bottom = 32.0
pivot_offset = Vector2(16, 16)
theme = ExtResource("1_kp3wm")
script = ExtResource("1_6qgij")
[node name="TextureRect" type="TextureRect" parent="."]
@ -34,6 +40,80 @@ position = Vector2(16, 17)
[node name="CollisionShape2D" type="CollisionShape2D" parent="MouseHandler"]
shape = SubResource("RectangleShape2D_0bdxp")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -42.0
offset_top = -34.0
offset_right = 42.0
offset_bottom = -3.0
grow_horizontal = 2
scale = Vector2(1e-05, 1e-05)
pivot_offset = Vector2(42, 15)
color = Color(0, 0, 0, 0.47451)
[node name="RichTextLabel" type="RichTextLabel" parent="ColorRect"]
modulate = Color(1, 0.85098, 0.776471, 1)
clip_contents = false
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -43.0
offset_top = 1.0
offset_right = 43.0
offset_bottom = 41.0
grow_horizontal = 2
theme_override_constants/outline_size = 3
bbcode_enabled = true
text = "[center]Name"
custom_effects = [SubResource("RichTextEffect_erhh0")]
[node name="RichTextLabel2" type="RichTextLabel" parent="ColorRect"]
clip_contents = false
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -43.0
offset_top = 8.0
offset_right = 43.0
offset_bottom = 48.0
grow_horizontal = 2
theme_override_constants/outline_size = 3
bbcode_enabled = true
text = "[center]This is short text"
[node name="RichTextLabel3" type="RichTextLabel" parent="ColorRect"]
clip_contents = false
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -43.0
offset_top = 15.0
offset_right = 43.0
offset_bottom = 55.0
grow_horizontal = 2
theme_override_constants/outline_size = 3
bbcode_enabled = true
[node name="RichTextLabel4" type="RichTextLabel" parent="ColorRect"]
clip_contents = false
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -43.0
offset_top = 22.0
offset_right = 43.0
offset_bottom = 62.0
grow_horizontal = 2
theme_override_constants/outline_size = 3
bbcode_enabled = true
[connection signal="clicked" from="MouseHandler" to="." method="_on_mouse_handler_clicked"]
[connection signal="hovered" from="MouseHandler" to="." method="_on_mouse_handler_hovered"]
[connection signal="released" from="MouseHandler" to="." method="_on_mouse_handler_released"]

View file

@ -71,6 +71,7 @@ alignment = 1
self_modulate = Color(1, 1, 1, 0.176471)
layout_mode = 2
color = Color(0.314316, 0.314316, 0.314316, 1)
left = true
[node name="Spacer" parent="Buildings/VBoxContainer" instance=ExtResource("3_ji0ar")]
layout_mode = 2

View file

@ -2,11 +2,42 @@ extends ColorRect
var key
var clicked = false
@export var left = false
@onready var texture_rect: TextureRect = $TextureRect
@onready var rich_text_label: RichTextLabel = $ColorRect/RichTextLabel
@onready var rich_text_label_2: RichTextLabel = $ColorRect/RichTextLabel2
@onready var rich_text_label_3: RichTextLabel = $ColorRect/RichTextLabel3
@onready var rich_text_label_4: RichTextLabel = $ColorRect/RichTextLabel4
@onready var color_rect: ColorRect = $ColorRect
var hover_tween
func _ready() -> void:
if left:
color_rect.position += Vector2(20, 0)
func _created():
var data = Data.data.buildings[key]
rich_text_label.text = "[center][smallwave]%s" % [data.name]
rich_text_label_2.text = "[center]%s" % [data.short]
if data.cost.has("wood") and data.cost.has("stone"):
rich_text_label_3.text = "[center]%s stone" % [data.cost.stone]
rich_text_label_3.modulate = Color.html("#425a67")
rich_text_label_4.modulate = Color.html("#884244")
rich_text_label_4.text = "[center]%s wood" % [data.cost.wood]
elif data.cost.has("wood"):
rich_text_label_3.text = "[center]%s wood" % [data.cost.wood]
rich_text_label_4.text = ""
rich_text_label_3.modulate = Color.html("#884244")
else:
rich_text_label_3.text = "[center]%s stone" % [data.cost.stone]
rich_text_label_4.text = ""
rich_text_label_3.modulate = Color.html("#425a67")
func _on_mouse_handler_clicked() -> void:
clicked = true
@ -16,7 +47,9 @@ func _on_mouse_handler_clicked() -> void:
hover_tween = create_tween()
hover_tween.set_ease(Tween.EASE_OUT)
hover_tween.set_trans(Tween.TRANS_BACK)
hover_tween.set_parallel()
hover_tween.tween_property(self, "scale", Vector2.ONE * 0.95, 0.25)
hover_tween.tween_property(color_rect, "scale", Vector2.ONE, 0.25)
func _on_mouse_handler_hovered() -> void:
@ -26,7 +59,10 @@ func _on_mouse_handler_hovered() -> void:
hover_tween = create_tween()
hover_tween.set_ease(Tween.EASE_OUT)
hover_tween.set_trans(Tween.TRANS_BACK)
hover_tween.set_parallel()
hover_tween.tween_property(self, "scale", Vector2.ONE * 1.05, 0.25)
hover_tween.tween_property(color_rect, "scale", Vector2.ONE, 0.25)
func _on_mouse_handler_unhovered() -> void:
@ -43,7 +79,9 @@ func _on_mouse_handler_unhovered() -> void:
hover_tween = create_tween()
hover_tween.set_ease(Tween.EASE_OUT)
hover_tween.set_trans(Tween.TRANS_QUAD)
hover_tween.set_parallel()
hover_tween.tween_property(self, "scale", Vector2.ONE, 0.25)
hover_tween.tween_property(color_rect, "scale", Vector2.ZERO, 0.25)
func _on_mouse_handler_released() -> void:
@ -60,4 +98,6 @@ func _on_mouse_handler_released() -> void:
hover_tween = create_tween()
hover_tween.set_ease(Tween.EASE_OUT)
hover_tween.set_trans(Tween.TRANS_BACK)
hover_tween.set_parallel()
hover_tween.tween_property(self, "scale", Vector2.ONE, 0.25)
hover_tween.tween_property(color_rect, "scale", Vector2.ZERO, 0.25)

View file

@ -44,6 +44,7 @@ func swap_to_tab(index):
icons[i].visible = true
icons[i].key = filtered_buildings[i]
icons[i].texture_rect.texture = Data.data.images[filtered_buildings[i]]
icons[i]._created()
if i > 0:
spacers[i - 1].visible = true