Small Godot Wild Jam game
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add progress bar for treatment time

+45 -4
+15 -3
Scenes/unit/unit.gd
··· 16 16 var reached_target: bool = false 17 17 var treated_patient: bool = false 18 18 19 + @onready var progress_bar: ProgressBar = $ProgressBar 20 + @onready var timer: Timer = $Timer 21 + 22 + func _ready() -> void: 23 + timer.timeout.connect(_treat_patient) 24 + 19 25 func _process(delta: float) -> void: 20 26 # if not reached target then follow path, do nothing while patient isn't treated and then follow path in reverse 21 27 if !reached_target: 22 28 follow_path(delta) 23 29 else: 24 - if treated_patient: 30 + if !treated_patient: 31 + progress_bar.value = timer.time_left 32 + else: 25 33 follow_reverse_path(delta) 26 34 27 35 ··· 36 44 position = next_pos 37 45 else: 38 46 reached_target = true 39 - get_tree().create_timer(treatment_time).timeout.connect(treat_patient) 47 + progress_bar.max_value = treatment_time 48 + progress_bar.value = treatment_time 49 + timer.start(treatment_time) 50 + progress_bar.visible = true 40 51 41 - func treat_patient() -> void: 52 + func _treat_patient() -> void: 42 53 Global.handle_choice_result(was_correct) 43 54 treated_patient = true 55 + progress_bar.visible = false 44 56 45 57 func follow_reverse_path(delta: float) -> void: 46 58 if reverse_path.size() > 0:
+30 -1
Scenes/unit/unit_parent.tscn
··· 1 - [gd_scene load_steps=4 format=3 uid="uid://b56hnxnj7ylg8"] 1 + [gd_scene load_steps=5 format=3 uid="uid://b56hnxnj7ylg8"] 2 2 3 3 [ext_resource type="Script" uid="uid://clvx1a0nby8cp" path="res://Scenes/unit/unit.gd" id="1_idbsb"] 4 4 [ext_resource type="Texture2D" uid="uid://da653ustssjlf" path="res://Assets/sprites/doctor_image.png" id="2_1eirg"] 5 5 [ext_resource type="Texture2D" uid="uid://blimkuqy7it1d" path="res://Assets/sprites/priest_image.png" id="3_xi5tf"] 6 6 7 + [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_c5gfg"] 8 + bg_color = Color(0.234569, 0.589674, 0.270734, 1) 9 + corner_radius_top_right = 5 10 + corner_radius_bottom_right = 5 11 + 7 12 [node name="UnitParent" type="Node2D"] 8 13 y_sort_enabled = true 9 14 script = ExtResource("1_idbsb") 10 15 16 + [node name="ProgressBar" type="ProgressBar" parent="."] 17 + visible = false 18 + custom_minimum_size = Vector2(140, 0) 19 + anchors_preset = 8 20 + anchor_left = 0.5 21 + anchor_top = 0.5 22 + anchor_right = 0.5 23 + anchor_bottom = 0.5 24 + offset_left = -70.0 25 + offset_top = -166.0 26 + offset_right = 69.54 27 + offset_bottom = -134.0 28 + grow_horizontal = 2 29 + grow_vertical = 2 30 + scale = Vector2(1, 0.759998) 31 + theme_override_styles/fill = SubResource("StyleBoxFlat_c5gfg") 32 + step = 0.0 33 + value = 50.0 34 + fill_mode = 1 35 + show_percentage = false 36 + 11 37 [node name="DoctorSprite" type="Sprite2D" parent="."] 12 38 visible = false 13 39 scale = Vector2(0.08, 0.08) ··· 17 43 visible = false 18 44 scale = Vector2(0.04, 0.04) 19 45 texture = ExtResource("3_xi5tf") 46 + 47 + [node name="Timer" type="Timer" parent="."] 48 + one_shot = true