Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Select VehiclePaint
Browse files Browse the repository at this point in the history
  • Loading branch information
CodedOre committed Aug 4, 2021
1 parent c5e2851 commit bb53bc3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions game/VehicleSelect.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ __meta__ = {
}

[connection signal="pressed" from="HUD/ReturnButton" to="." method="return_to_main"]
[connection signal="item_selected" from="HUD/SideContainer/ColorOption" to="." method="set_paint"]
[connection signal="pressed" from="HUD/SideContainer/DriveButton" to="." method="confirm_vehicle"]
[connection signal="pressed" from="HUD/Selector/BackButton" to="." method="move_selection" binds= [ -1 ]]
[connection signal="pressed" from="HUD/Selector/NextButton" to="." method="move_selection" binds= [ 1 ]]
3 changes: 2 additions & 1 deletion scripts/game/Driving.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ signal return_to_main()
# -- Functions --

# - Sets up the driven vehicle -
func setup_driving(vehicle_path: String) -> void:
func setup_driving(vehicle_path: String, paint: int) -> void:
if vehicle_path == null or vehicle_path == "":
push_error("Driving: Can't initialize without an path to a vehicle!")
# Load the selected vehicle
var vehicle_scene : PackedScene = load(vehicle_path)
driven_vehicle = vehicle_scene.instance()
add_child(driven_vehicle)
# Setup nodes
driven_vehicle.VehiclePaint = paint
driven_vehicle.global_transform = spawnpoint.global_transform
gimbalcam.set_vehicle(driven_vehicle)
outermirror.set_displayed_vehicle(driven_vehicle)
Expand Down
3 changes: 2 additions & 1 deletion scripts/game/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ func select_a_vehicle() -> void:
func drive_selected_vehicle() -> void:
# Get selected vehicle
var selected_vehicle : String = state_vehicle_select.chosen_vehicle()
var paint : int = state_vehicle_select.chosen_paint()
# Change states
set_active_state(GameState.DRIVE)
# Setup new scene
state_driving.setup_driving(selected_vehicle)
state_driving.setup_driving(selected_vehicle, paint)

# - State change to TitleScreen -
func return_to_main() -> void:
Expand Down
8 changes: 7 additions & 1 deletion scripts/game/VehicleSelect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ func _transforms_close(a : Transform, b : Transform, threshold : float) -> bool:
and (a.origin - b.origin).length() < threshold
)

# - Returns selected vehicle file -
# - Returns selected settings -
func chosen_vehicle() -> String:
return vehicle_pool[selected_vehicle].filename
func chosen_paint() -> int:
return color_option.selected

# - Sets the paint of the vehicle -
func set_paint(index : int):
vehicle_pool[selected_vehicle].VehiclePaint = index

0 comments on commit bb53bc3

Please sign in to comment.