public Save.Vehicle GetSaveVehicle() { Save.Vehicle v = new Save.Vehicle(); v.InstalledParts = new List <string>(DefaultParts.ToArray()); //dont ask why v.Type = name.Substring(0, name.Length - 1); return(v); }
int CalculatePrice(Save.Vehicle vehicle) { Resources.LoadAll <VehicleInfo>("ModSystem/Objects"); var vehicleInfoList = new List <VehicleInfo>(Resources.FindObjectsOfTypeAll <VehicleInfo>()); return((int)(vehicleInfoList.First(x => x.name == vehicle.Type + "I").Price * 0.75f)); }
public static void AddVehicle(Save.Vehicle vehicle) { SaveObject.GarageData.Vehicles.Add(vehicle); if (SaveObject.GarageData.VehicleTypes.FirstOrDefault(x => x.Type == vehicle.Type) == null) { VehicleType type = new VehicleType(); type.Type = vehicle.Type; type.OwnedParts = vehicle.InstalledParts; SaveObject.GarageData.VehicleTypes.Add(type); } SaveData(); }
// Update is called once per frame public void BuyButton() { VehicleInfo vehicle = vehicleInfoList[view.SelectedIndex]; if (SaveSystem.GetCash() >= vehicle.Price) { Save.Vehicle v = vehicle.GetSaveVehicle(); SaveSystem.AddVehicle(v); SaveSystem.AddCash(-vehicle.Price); SaveSystem.AddLog(new Save.LogEntry("Dealer", $"Added car {v.Type}")); SaveSystem.SetSelectedVehicleIndex(SaveSystem.GetVehicles().Count - 1); GarageManager.instance.CloseDealerMenu(); } else { Debug.Log("git gud fagit"); } }