Add population count

This commit is contained in:
Ategon 2024-09-14 23:43:31 -04:00
parent 01e58dc8f6
commit 0c5120b07d
6 changed files with 106 additions and 2 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=30 format=4 uid="uid://5ske2hm55rce"] [gd_scene load_steps=32 format=4 uid="uid://5ske2hm55rce"]
[ext_resource type="PackedScene" uid="uid://n2lpy72tkyc8" path="res://storm/StormManager.tscn" id="1_gcxt1"] [ext_resource type="PackedScene" uid="uid://n2lpy72tkyc8" path="res://storm/StormManager.tscn" id="1_gcxt1"]
[ext_resource type="Script" path="res://main.gd" id="1_pg2kh"] [ext_resource type="Script" path="res://main.gd" id="1_pg2kh"]
@ -22,11 +22,13 @@
[ext_resource type="Script" path="res://small_wave.gd" id="14_d8e1g"] [ext_resource type="Script" path="res://small_wave.gd" id="14_d8e1g"]
[ext_resource type="Texture2D" uid="uid://dwm8p1koiqee8" path="res://wood.png" id="14_dmibc"] [ext_resource type="Texture2D" uid="uid://dwm8p1koiqee8" path="res://wood.png" id="14_dmibc"]
[ext_resource type="AudioStream" uid="uid://dk2thkxy31doi" path="res://heavy version.wav" id="14_frsfx"] [ext_resource type="AudioStream" uid="uid://dk2thkxy31doi" path="res://heavy version.wav" id="14_frsfx"]
[ext_resource type="Texture2D" uid="uid://c3fl0plvw3dj0" path="res://population.png" id="15_5qoov"]
[ext_resource type="Texture2D" uid="uid://ckbq5ipvom580" path="res://stone.png" id="15_scpqp"] [ext_resource type="Texture2D" uid="uid://ckbq5ipvom580" path="res://stone.png" id="15_scpqp"]
[ext_resource type="Script" path="res://population_count.gd" id="16_knn3d"]
[sub_resource type="Animation" id="Animation_ycb31"] [sub_resource type="Animation" id="Animation_ycb31"]
resource_name = "start" resource_name = "start"
length = 2.0 length = 3.0
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/imported = false tracks/0/imported = false
tracks/0/enabled = true tracks/0/enabled = true
@ -111,6 +113,18 @@ tracks/6/keys = {
"update": 0, "update": 0,
"values": [Vector2(0, -28), Vector2(0, -28.5265), Vector2(0, -29.629), Vector2(0, -30.5916), Vector2(0, -30.6985), Vector2(0, -29.2339), Vector2(0, -25.4821), Vector2(0, -18.7272), Vector2(0, -9.27276), Vector2(0, -2.51792), Vector2(0, 1.23389), Vector2(0, 2.69845), Vector2(0, 2.59156), Vector2(0, 1.629), Vector2(0, 0.526546), Vector2(0, 0)] "values": [Vector2(0, -28), Vector2(0, -28.5265), Vector2(0, -29.629), Vector2(0, -30.5916), Vector2(0, -30.6985), Vector2(0, -29.2339), Vector2(0, -25.4821), Vector2(0, -18.7272), Vector2(0, -9.27276), Vector2(0, -2.51792), Vector2(0, 1.23389), Vector2(0, 2.69845), Vector2(0, 2.59156), Vector2(0, 1.629), Vector2(0, 0.526546), Vector2(0, 0)]
} }
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("CanvasLayer/UI/Background/Control3:position")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(1.86667, 1.9, 1.93333, 1.96667, 2, 2.03333, 2.06667, 2.1, 2.13333, 2.16667, 2.2, 2.23333, 2.26667, 2.3, 2.33333, 2.36667, 2.4),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
"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)]
}
[sub_resource type="Animation" id="Animation_gcod0"] [sub_resource type="Animation" id="Animation_gcod0"]
length = 0.001 length = 0.001
@ -186,6 +200,18 @@ tracks/5/keys = {
"update": 0, "update": 0,
"values": [Vector2(0, -28)] "values": [Vector2(0, -28)]
} }
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("CanvasLayer/UI/Background/Control3:position")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(41, -28)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8mn2x"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_8mn2x"]
_data = { _data = {
@ -466,6 +492,35 @@ vertical_alignment = 1
script = ExtResource("13_fqswr") script = ExtResource("13_fqswr")
key = "wood" key = "wood"
[node name="Control3" type="Control" parent="CanvasLayer/UI/Background"]
anchors_preset = 0
offset_left = 41.0
offset_top = -28.0
offset_right = 81.0
offset_bottom = 12.0
[node name="WoodIcon" type="TextureRect" parent="CanvasLayer/UI/Background/Control3"]
layout_mode = 0
offset_left = 44.0
offset_top = 1.0
offset_right = 60.0
offset_bottom = 17.0
texture = ExtResource("15_5qoov")
expand_mode = 2
[node name="WoodCountLabel" type="Label" parent="CanvasLayer/UI/Background/Control3"]
layout_mode = 2
offset_left = 65.0
offset_right = 124.0
offset_bottom = 24.0
theme_override_colors/font_color = Color(0.301864, 0.365251, 0.444553, 1)
theme_override_constants/outline_size = 3
theme_override_font_sizes/font_size = 8
text = "0/0
"
vertical_alignment = 1
script = ExtResource("16_knn3d")
[node name="Control2" type="Control" parent="CanvasLayer/UI/Background"] [node name="Control2" type="Control" parent="CanvasLayer/UI/Background"]
anchors_preset = 0 anchors_preset = 0
offset_top = -28.0 offset_top = -28.0

BIN
population.aseprite Normal file

Binary file not shown.

BIN
population.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

34
population.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c3fl0plvw3dj0"
path="res://.godot/imported/population.png-c3fd4e79e911096b42818bf7d2293792.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://population.png"
dest_files=["res://.godot/imported/population.png-c3fd4e79e911096b42818bf7d2293792.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

13
population_count.gd Normal file
View file

@ -0,0 +1,13 @@
extends Label
var key = "population"
var key2 = "max_population"
func _ready() -> void:
Triggerer.listen(key, _on_value_change)
Triggerer.listen(key2, _on_value_change)
func _on_value_change(data):
text = "%s/%s" % [str(Persister.get_value("population")), str(Persister.get_value("max_population"))]

2
ui.gd
View file

@ -5,6 +5,8 @@ extends CanvasLayer
func _ready() -> void: func _ready() -> void:
Persister.persist_data("wood", 5) Persister.persist_data("wood", 5)
Persister.persist_data("stone", 5) Persister.persist_data("stone", 5)
Persister.persist_data("population", 3)
Persister.persist_data("max_population", 3)
func _process(delta: float) -> void: func _process(delta: float) -> void:
if Input.is_action_just_pressed("lclick") and not Persister.get_value("game_started"): if Input.is_action_just_pressed("lclick") and not Persister.get_value("game_started"):