public void AddVehiclePanel(VehicleBehaviour behaviour) { var panel = Instantiate(vehiclePanelPrefab, vehicleListPanel.transform); if (behaviour.Vehicle is Car) { panel.ShowCarUI(); } else if (behaviour.Vehicle is Motorcycle) { panel.ShowMotoUI(); } else if (behaviour.Vehicle is Truck) { panel.ShowTruckUI(); } vehiclePanels.Add(panel); panel.VehicleBehaviour = behaviour; panel.OnDelete.AddListener(x => { GameManager.DeleteVehicle(x); DeleteVehiclePanel(x); }); }
public void DeleteVehicle(VehicleBehaviour behaviour) { vehicleBehaviours.Remove(behaviour); Destroy(behaviour.gameObject); UpdateVehiclePositions(); }
public void AddVehicleBehaviour(VehicleBehaviour behaviour) { vehicleBehaviours.Add(behaviour); behaviour.Place = vehicleBehaviours.Count; UpdateVehiclePositions(); }