Small Godot Wild Jam game
0
fork

Configure Feed

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

Units now travel to locations, treat the sick and modify the score values

+55 -14
+11 -9
Scenes/dialogue/dialogue_container.gd
··· 43 43 fact_listlabel.text = dialogues_array[random_dialogue_index][1] 44 44 correct_choice = dialogues_array[random_dialogue_index][2] 45 45 46 - func choice_check(choice): 46 + func choice_check(choice) -> bool: 47 47 if choice == correct_choice: 48 - Global.people_cured += 1 49 - Global.people_sick -= 3 48 + #Global.people_cured += 1 49 + #Global.people_sick -= 3 50 50 SignalBus.play_cured.emit() 51 51 else: 52 - Global.people_sick += 2 52 + #Global.people_sick += 2 53 53 SignalBus.play_sick.emit() 54 54 55 - queue_free() 55 + return (choice == correct_choice) 56 56 57 57 func _on_doc_button_pressed() -> void: 58 - SignalBus.spawn_unit_request.emit(Global.UnitType.DOCTOR, Global.get_target_location()) 59 - choice_check(Global.UnitType.DOCTOR) 58 + var was_correct := choice_check(Global.UnitType.DOCTOR) 59 + SignalBus.spawn_unit_request.emit(Global.UnitType.DOCTOR, Global.get_target_location(), was_correct) 60 + queue_free() 60 61 61 62 62 63 func _on_priest_button_pressed() -> void: 63 - SignalBus.spawn_unit_request.emit(Global.UnitType.PRIEST, Global.get_target_location()) 64 - choice_check(Global.UnitType.PRIEST) 64 + var was_correct := choice_check(Global.UnitType.PRIEST) 65 + SignalBus.spawn_unit_request.emit(Global.UnitType.PRIEST, Global.get_target_location(), was_correct) 66 + queue_free()
+26 -1
Scenes/unit/unit.gd
··· 5 5 # Copy pasted from the unit in the testing scene 6 6 # 7 7 @export var move_speed: float = 200.0 8 - 8 + @export var treatment_time: float = 5 9 9 @export var unit_type: Global.UnitType 10 + 11 + var was_correct: bool 10 12 11 13 var path: PackedVector2Array = [] 12 14 var reverse_path = [] 13 15 14 16 var reached_target: bool = false 17 + var treated_patient: bool = false 15 18 16 19 func _process(delta: float) -> void: 20 + # if not reached target then follow path, do nothing while patient isn't treated and then follow path in reverse 17 21 if !reached_target: 18 22 follow_path(delta) 23 + else: 24 + if treated_patient: 25 + follow_reverse_path(delta) 26 + 19 27 20 28 func follow_path(delta: float) -> void: 21 29 if path.size() > 0: ··· 28 36 position = next_pos 29 37 else: 30 38 reached_target = true 39 + get_tree().create_timer(treatment_time).timeout.connect(treat_patient) 40 + 41 + func treat_patient() -> void: 42 + Global.handle_choice_result(was_correct) 43 + treated_patient = true 44 + 45 + func follow_reverse_path(delta: float) -> void: 46 + if reverse_path.size() > 0: 47 + var current_pos: Vector2 = global_position 48 + var next_path_position: Vector2 = reverse_path.get(0) 49 + 50 + var next_pos = current_pos + (current_pos.direction_to(next_path_position) * move_speed * delta) 51 + if next_path_position.distance_to(next_pos) < 10: 52 + reverse_path.remove_at(0) 53 + position = next_pos 54 + else: 55 + queue_free()
+3 -2
Scenes/unit/unit_parent.tscn
··· 5 5 [ext_resource type="Texture2D" uid="uid://blimkuqy7it1d" path="res://Assets/sprites/priest_image.png" id="3_xi5tf"] 6 6 7 7 [node name="UnitParent" type="Node2D"] 8 + y_sort_enabled = true 8 9 script = ExtResource("1_idbsb") 9 10 10 11 [node name="DoctorSprite" type="Sprite2D" parent="."] 11 12 visible = false 12 - scale = Vector2(0.1, 0.1) 13 + scale = Vector2(0.08, 0.08) 13 14 texture = ExtResource("2_1eirg") 14 15 15 16 [node name="PreistSprite" type="Sprite2D" parent="."] 16 17 visible = false 17 - scale = Vector2(0.05, 0.05) 18 + scale = Vector2(0.04, 0.04) 18 19 texture = ExtResource("3_xi5tf")
+9
Scripts/global.gd
··· 31 31 var target_location: Vector2 32 32 #endregion 33 33 34 + func handle_choice_result(result: bool) -> void: 35 + if result: 36 + people_cured += 1 37 + people_sick -= 3 38 + #SignalBus.play_cured.emit() 39 + else: 40 + people_sick += 2 41 + #SignalBus.play_sick.emit() 42 + 34 43 func _init() -> void: 35 44 Console.register_custom_command("debug", _toggle_debug_mode) 36 45 Console.register_custom_command("spawn_doctor", _spawn_unit)
+1 -1
Scripts/signal_bus.gd
··· 1 1 extends Node 2 2 3 3 signal debug_mode_changed 4 - signal spawn_unit_request(type: Global.UnitType, target_location: Vector2) 4 + signal spawn_unit_request(type: Global.UnitType, target_location: Vector2, was_correct: bool) 5 5 6 6 signal event_pin_clicked(name: String, target_pos: Vector2) 7 7
+5 -1
Scripts/unit_manager.gd
··· 13 13 setup_astar() 14 14 SignalBus.spawn_unit_request.connect(_spawn_unit) 15 15 16 - func _spawn_unit(type: Global.UnitType, target_location: Vector2) -> void: 16 + func _spawn_unit(type: Global.UnitType, target_location: Vector2, was_correct: bool) -> void: 17 17 18 18 # Units will always spawn at the church 19 19 var spawn_point: NavPoint = church_nav_point ··· 34 34 # Create copy of path in reverse to traveling back to church 35 35 unit.reverse_path = calculate_path(target_location) 36 36 unit.reverse_path.reverse() 37 + 38 + # Store value of question for modifying points later 39 + # Moving state around like this isn't really good but it's fine for now 40 + unit.was_correct = was_correct 37 41 38 42 add_child(unit) 39 43