Bees return nectar, UI stuff

This commit is contained in:
Dan Baker 2024-05-04 15:13:59 +01:00
parent 76e7ec7ec7
commit 5865778c77
12 changed files with 175 additions and 17 deletions

28
ui/UiComponent.tscn Normal file
View file

@ -0,0 +1,28 @@
[gd_scene load_steps=2 format=3 uid="uid://b7eeptlk47ymd"]
[ext_resource type="Script" path="res://ui/scripts/ui_component.gd" id="1_6lnte"]
[node name="UiComponent" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_6lnte")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="NectarBar" type="ProgressBar" parent="MarginContainer"]
unique_name_in_owner = true
layout_mode = 2

View file

@ -0,0 +1,23 @@
extends Control
class_name UIComponent
var update_interval : float = 1
var last_update : float = 0
@onready var nectar_bar = get_node("%NectarBar")
func _ready():
Log.pr("UIComponent ready")
update_ui()
func _process(delta):
last_update += delta
if last_update > update_interval:
last_update = 0
update_ui()
func update_ui():
Log.pr("UIComponent update_ui")
nectar_bar.value = GameState.gathered_nectar