public void SelectMainDriversForSession() { bool flag = Game.instance.sessionManager.sessionType == SessionDetails.SessionType.Qualifying && this.championship.Rules.gridSetup == ChampionshipRules.GridSetup.AverageLap; for (int inCarIndex = 0; inCarIndex < CarManager.carCount; ++inCarIndex) { Driver[] driversForCar = this.GetDriversForCar(inCarIndex); this.mSelectedSessionDrivers[inCarIndex].Clear(); for (int index = 0; index < driversForCar.Length; ++index) { Driver inDriver = driversForCar[index]; if (this.contractManager.IsSittingOutEvent(inDriver)) { this.mSelectedSessionDrivers[inCarIndex].Add(this.GetReserveDriverToReplaceSitOut()); } else if (!flag) { this.mSelectedSessionDrivers[inCarIndex].Add(inDriver); } else if (this.mSelectedSessionDrivers[inCarIndex].Count < 2 && !this.IsWorstDriver(inDriver, driversForCar)) { this.mSelectedSessionDrivers[inCarIndex].Add(inDriver); } } } for (int index1 = 0; index1 < CarManager.carCount; ++index1) { int index2 = 0; if (!this.IsPlayersTeam()) { index2 = RandomUtility.GetRandom(0, this.mSelectedSessionDrivers[index1].Count); } this.mVehicleSessionDrivers[index1] = this.mSelectedSessionDrivers[index1][index2]; } }
public void LoadMechanicBonusesFromDatabase(List <DatabaseEntry> mechanicBonuses) { for (int index = 0; index < mechanicBonuses.Count; ++index) { MechanicBonus mechanicBonus = new MechanicBonus(); mechanicBonus.bonusID = mechanicBonuses[index].GetIntValue("ID"); mechanicBonus.trait = (MechanicBonus.Trait)(mechanicBonus.bonusID - 1); mechanicBonus.traitName = mechanicBonuses[index].GetStringValue("Trait Name"); mechanicBonus.nameLocalisationID = mechanicBonuses[index].GetStringValue("Name ID"); mechanicBonus.flavourText = mechanicBonuses[index].GetStringValue("Flavour Text"); mechanicBonus.textLocalisationID = mechanicBonuses[index].GetStringValue("Text ID"); mechanicBonus.icon = mechanicBonuses[index].GetIntValue("Icon"); mechanicBonus.level = mechanicBonuses[index].GetIntValue("Level"); mechanicBonus.objectType = mechanicBonuses[index].GetStringValue("Object Type"); mechanicBonus.bonus = mechanicBonuses[index].GetStringValue("Bonus"); string stringValue = mechanicBonuses[index].GetStringValue("Session"); if (stringValue != string.Empty && stringValue != "0") { mechanicBonus.usefullForAnySession = false; mechanicBonus.usefullForSpecificSession = (SessionDetails.SessionType)Enum.Parse(typeof(SessionDetails.SessionType), stringValue); } if (mechanicBonus.level == 1) { mechanicBonus.bonusUnlockAt = RandomUtility.GetRandom(20, 60); } else if (mechanicBonus.level == 2) { mechanicBonus.bonusUnlockAt = 100; } this.mechanicBonuses.Add(mechanicBonus.bonusID, mechanicBonus); } }
private void RandomizeTaskStats(ref AIPitCrewTaskStat[] inTaskStats, Mechanic inMechanic) { for (int index = 0; index < inTaskStats.Length; ++index) { inTaskStats[index].taskType = (SessionSetupChangeEntry.Target)index; inTaskStats[index].taskStat = inMechanic.stats.pitStops; inTaskStats[index].taskConfidence = RandomUtility.GetRandom(0.75f, 1f); } }
public static float GetRandomDistribution(float inMinValue, float inMaxValue, int inNumberOfRolls, System.Random inRandom) { //Debug.Assert(inNumberOfRolls > 0, "Jason - Cannot roll 0 times for GetRandomDistribution"); float num = 0.0f; for (int index = 0; index < inNumberOfRolls; ++index) { num = RandomUtility.GetRandom(inMinValue, inMaxValue, inRandom); } return(num / (float)inNumberOfRolls); }
private static string GenerateName() { string str = string.Empty + (object)(char)(65 + RandomUtility.GetRandom(0, 26)); int num = 3; while (num > 0) { --num; str += ((char)(65 + RandomUtility.GetRandom(0, 26))).ToString(); } return(str); }
public static void Shuffle <T>(ref List <T> inList) { int count = inList.Count; for (int index = 0; index < count; ++index) { int random = RandomUtility.GetRandom(0, count); T obj = inList[random]; inList[random] = inList[index]; inList[index] = obj; } }
private CarPart GetDefaultPart(CarPart.PartType inType, Team inTeam) { CarPart partEntity = CarPart.CreatePartEntity(inType, this.championship); partEntity.stats.SetStat(CarPartStats.CarPartStat.MainStat, (float)(GameStatsConstants.specPartValues[this.championship.championshipID] + RandomUtility.GetRandom(0, 10))); partEntity.stats.SetStat(CarPartStats.CarPartStat.Reliability, 0.8f); partEntity.stats.partCondition.SetCondition(0.8f); partEntity.stats.partCondition.redZone = GameStatsConstants.initialRedZone; partEntity.stats.maxReliability = 1f; partEntity.stats.maxPerformance = 0.0f; partEntity.buildDate = Game.instance.time.now; partEntity.stats.level = 0; partEntity.PostStatsSetup(this.championship); return(partEntity); }
public static float GetRandom(float inMin, float inMax) { return(RandomUtility.GetRandom(inMin, inMax, RandomUtility.globalRandomInstance)); }