private void Phase2() { lblPhase2.Enabled = true; Randomizer rnd = new Randomizer(progressBar); lblPhase2.Text += " |DONE|"; lblPhase2.Enabled = false; }
private static string _generateNameHelper(List<NamePart> nameParts, Randomizer randomizer) { List<BuildableNamePart>bnpList = new List<BuildableNamePart>(); int nameLength = 0; for (int i = 0; i < nameParts.Count; i++) { NamePart part = nameParts[i]; bool buildableIsOptional = false; if(part.isOptional) { if (randomizer.Int32(10) > 5) { continue; } buildableIsOptional = true; } string newWord = part.nameList[randomizer.Int32((uint)part.nameList.Count)]; if (! newWord.Trim().Equals("")) { newWord += " "; } BuildableNamePart bnp = new BuildableNamePart(buildableIsOptional, newWord); bnpList.Add(bnp); nameLength += newWord.Length; } return _bestFitName(bnpList, nameLength); }
/// <summary> /// /// </summary> /// <param name="r"></param> /// <param name="width"></param> /// <param name="length"></param> /// <returns></returns> public override int CalculateHomeCount(Randomizer r, int width, int length) { ItemClass item = this.m_info.m_class; int level = (int)(item.m_level >= 0 ? item.m_level : 0); // Force it to 0 if the level was set to None int[] array; // int approxFloorCount = 1; // bool aprint = false; if(item.m_subService == ItemClass.SubService.ResidentialLow) { array = DataStore.residentialLow[level]; } else { array = DataStore.residentialHigh[level]; // approxFloorCount = ((int)this.m_info.m_size.y) / 3; // aprint = true; } int num = array[DataStore.PEOPLE]; int householdCount = Mathf.Max(100, width * length * num + r.Int32(100u)) / 100; /* if (aprint) { Vector3 v = this.m_info.m_size; Debugging.writeDebugToFile("x/y/z: " + v.x + " * " + v.y + " * " + v.z + ", household: " + householdCount); } */ return householdCount; }
public override void GetBufferStatus(ushort vehicleID, ref Vehicle data, out string localeKey, out int current, out int max) { localeKey = "Default"; current = (int)data.m_transferSize; max = this.m_passengerCapacity; if (data.m_leadingVehicle == 0) { VehicleManager instance = Singleton<VehicleManager>.instance; ushort trailingVehicle = data.m_trailingVehicle; int num = 0; while (trailingVehicle != 0) { VehicleInfo info = instance.m_vehicles.m_buffer [(int)trailingVehicle].Info; if (instance.m_vehicles.m_buffer [(int)trailingVehicle].m_leadingVehicle != 0) { int num2; int num3; info.m_vehicleAI.GetBufferStatus (trailingVehicle, ref instance.m_vehicles.m_buffer [(int)trailingVehicle], out localeKey, out num2, out num3); current += num2; max += num3; } trailingVehicle = instance.m_vehicles.m_buffer [(int)trailingVehicle].m_trailingVehicle; if (++num > 65536) { CODebugBase<LogChannel>.Error (LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } } if ((data.m_flags & Vehicle.Flags.DummyTraffic) != Vehicle.Flags.None) { Randomizer randomizer = new Randomizer ((int)vehicleID); current = randomizer.Int32 (max >> 1, max); } }
public static void OnBuildingCreated(ushort buildingID) { #if DEBUG UnityEngine.Debug.Log($"UnlimitedOutsideConnections - OnBuildingCreated. buildingID={buildingID}"); #endif var instance = BuildingManager.instance; var connectionAi = instance.m_buildings.m_buffer[buildingID].Info?.m_buildingAI as OutsideConnectionAI; if (connectionAi == null) { return; } var serviceBuildings = BuildingUtil.FindServiceBuildings(buildingID); foreach (var id in serviceBuildings) { var ai = instance.m_buildings.m_buffer[id].Info.GetAI() as TransportStationAI; if (ai?.m_transportLineInfo == null) { continue; } var gateIndex = 0; if (ai.m_spawnPoints != null && ai.m_spawnPoints.Length != 0) { var randomizer = new Randomizer(id); gateIndex = randomizer.Int32((uint)ai.m_spawnPoints.Length); } instance.m_buildings.m_buffer[buildingID].m_flags |= Building.Flags.IncomingOutgoing; TransportStationAIDetour.CreateConnectionLines(ai, id, ref instance.m_buildings.m_buffer[id], buildingID, ref instance.m_buildings.m_buffer[buildingID], gateIndex); BuildingUtil.ReleaseOwnVehicles(id); } }
public StyleCreator(ConfigFacade config, Randomizer randomizer) { randomNumber = new Random(); configFacade = config; this.randomizer = randomizer; defaults = new Defaults(); }
protected override bool StartPathFind(ushort vehicleID, ref Vehicle vehicleData) { if ((vehicleData.m_flags & Vehicle.Flags.WaitingTarget) != 0) { return true; } if ((vehicleData.m_flags & Vehicle.Flags.GoingBack) != 0) { if (vehicleData.m_sourceBuilding != 0) { BuildingManager instance = Singleton<BuildingManager>.instance; BuildingInfo info = instance.m_buildings.m_buffer[(int)vehicleData.m_sourceBuilding].Info; Randomizer randomizer = new Randomizer((int)vehicleID); Vector3 vector; Vector3 endPos; info.m_buildingAI.CalculateUnspawnPosition(vehicleData.m_sourceBuilding, ref instance.m_buildings.m_buffer[(int)vehicleData.m_sourceBuilding], ref randomizer, this.m_info, out vector, out endPos); return this.StartPathFind(ExtendedVehicleType.Hearse, vehicleID, ref vehicleData, vehicleData.m_targetPos3, endPos, IsHeavyVehicle(), IgnoreBlocked(vehicleID, ref vehicleData)); } } else if (vehicleData.m_targetBuilding != 0) { BuildingManager instance2 = Singleton<BuildingManager>.instance; BuildingInfo info2 = instance2.m_buildings.m_buffer[(int)vehicleData.m_targetBuilding].Info; Randomizer randomizer2 = new Randomizer((int)vehicleID); Vector3 vector2; Vector3 endPos2; info2.m_buildingAI.CalculateUnspawnPosition(vehicleData.m_targetBuilding, ref instance2.m_buildings.m_buffer[(int)vehicleData.m_targetBuilding], ref randomizer2, this.m_info, out vector2, out endPos2); return this.StartPathFind(ExtendedVehicleType.Hearse, vehicleID, ref vehicleData, vehicleData.m_targetPos3, endPos2, IsHeavyVehicle(), IgnoreBlocked(vehicleID, ref vehicleData)); } return false; }
/// <summary> /// Social Insurance Number for Canada /// </summary> public static string Sin(this Person p) { const string Key = nameof(ExtensionsForCanada) + "SIN"; if (p.context.ContainsKey(Key)) { return p.context[Key] as string; } //bit verbose, but works. :) //could be mathematically simplified. //brute forced this one. yeah. // //should pass basic validation, but only some //numbers dont start with 8 etc. /* 1 — Atlantic Provinces: Nova Scotia, New Brunswick, Prince Edward Island, and Newfoundland and Labrador (this may also cover overseas residents). 2–3 — Quebec 4–5 — Ontario (#4 includes overseas forces) 6 — Prairie Provinces (Manitoba, Saskatchewan, and Alberta), Northwest Territories, and Nunavut 7 — Pacific Region (British Columbia and Yukon) 8 — Not used 9 — Temporary resident 0 — Not used (Canada Revenue may assign fictitious SIN numbers beginning with zero to taxpayers who do not have SINs) */ var r = new Randomizer(); //get 8 numbers var numbers = r.Digits(8); // the last number that makes it pass the checksum. var last = 10 - (numbers.Sum() % 10); if (last == 10) last = 0; var digits = numbers.Concat(new[] { last }).ToArray(); var comp = digits .Zip(Mask, (n, c) => { if( c == 2 && n % c == 1 ) { // odd digit, it was multiplied, reverse the process return (10 + (n - 1)) / 2; } if( c == 2 ) { //simply divide an even number by two return n / 2; } //else c == 1, and n was multiplied by 1 return n; }).ToArray(); var sinstr = $"{comp[0]}{comp[1]}{comp[2]} {comp[3]}{comp[4]}{comp[5]} {comp[6]}{comp[7]}{comp[8]}"; p.context[Key] = sinstr; return sinstr; }
// ReSharper disable once UnusedMember.Global public void Initialize() { _auditor = new Auditor(UnitTestHelper.FakeAuditingClient.Object); _authenticationManager = UnitTestHelper.FakeSecurity.Object; _userGroupManager = UnitTestHelper.FakeUserGroupManager.Object; _randomizer = new Randomizer(); }
public new bool CreatePath(out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, PathUnit.Position vehiclePosition, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue, ItemClass.Service vehicleService) { while (!Monitor.TryEnter(this.m_bufferLock, SimulationManager.SYNCHRONIZE_TIMEOUT)) { } uint num; try { if (!this.m_pathUnits.CreateItem(out num, ref randomizer)) { unit = 0u; bool result = false; return result; } this.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u); } finally { Monitor.Exit(this.m_bufferLock); } unit = num; byte simulationFlags = createSimulationFlag(isHeavyVehicle, ignoreBlocked, stablePath, vehicleService); assignPathProperties(unit, buildIndex, startPosA, startPosB, endPosA, endPosB, vehiclePosition, laneTypes, vehicleTypes, maxLength, simulationFlags); return findShortestPath(unit, skipQueue); }
public static bool CreateSegment(NetManager _this, out ushort segmentID, ref Randomizer randomizer, NetInfo info, ushort startNode, ushort endNode, Vector3 startDirection, Vector3 endDirection, uint buildIndex, uint modifiedIndex, bool invert) { var ai = info.m_netAI as RoadAI; if (ai != null && ai.m_enableZoning) { var caller = new System.Diagnostics.StackFrame(1).GetMethod().Name; switch (caller) { case "MoveMiddleNode": // segment that was modified because user added network, apply style of previous segment newBlockColumnCount = MoveMiddleNode_releasedColumnCount >= 0 ? MoveMiddleNode_releasedColumnCount : InputThreadingExtension.userSelectedColumnCount; break; case "SplitSegment": // segment that was split by new node, apply style of previous segment newBlockColumnCount = SplitSegment_releasedColumnCount >= 0 ? SplitSegment_releasedColumnCount : InputThreadingExtension.userSelectedColumnCount; break; default: // unknown caller (e.g. new road placed), set to depth selected by user newBlockColumnCount = InputThreadingExtension.userSelectedColumnCount; SplitSegment_releasedColumnCount = -1; MoveMiddleNode_releasedColumnCount = -1; break; } } // Call original method CreateSegmentRedirector.Revert(); var success = _this.CreateSegment(out segmentID, ref randomizer, info, startNode, endNode, startDirection, endDirection, buildIndex, modifiedIndex, invert); CreateSegmentRedirector.Apply(); return success; }
// Called every frame on building upgrade public static BuildingInfo GetRandomBuildingInfo_Upgrade(Vector3 position, ushort prefabIndex, ref Randomizer r, ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, int width, int length, BuildingInfo.ZoningMode zoningMode, int style) { // This method is very fragile, no logging here! var districtId = Singleton<DistrictManager>.instance.GetDistrict(position); // See if there is a special upgraded building var buildingInfo = BuildingThemesManager.instance.GetUpgradeBuildingInfo(prefabIndex, districtId); if (buildingInfo != null) { return buildingInfo; } var areaIndex = BuildingThemesManager.GetAreaIndex(service, subService, level, width, length, zoningMode); // list of possible prefabs var fastList = Singleton<BuildingThemesManager>.instance.GetAreaBuildings(districtId, areaIndex); if (fastList == null || fastList.m_size == 0) { return (BuildingInfo)null; } // select a random prefab from the list int index = r.Int32((uint)fastList.m_size); return PrefabCollection<BuildingInfo>.GetPrefab((uint)fastList.m_buffer[index]); }
public static bool checkIfShouldMoveIn(uint[] familyWithSeniors, ref Building buildingData, ref Randomizer randomizer, float operationRadius, int quality, ref NumWorkers numWorkers) { float chanceValue = BASE_CHANCE_VALUE; Logger.logInfo(LOG_CHANCES, "---------------------------------"); // Age chanceValue += getAgeChanceValue(familyWithSeniors); // Distance chanceValue += getDistanceChanceValue(familyWithSeniors, ref buildingData, operationRadius); // Family Status chanceValue += getFamilyStatusChanceValue(familyWithSeniors); // Wealth chanceValue += getWealthChanceValue(familyWithSeniors, quality); // Workers chanceValue += getWorkersChanceValue(ref numWorkers); // Check for no chance if (chanceValue <= 0) { Logger.logInfo(LOG_CHANCES, "MoveInProbabilityHelper.checkIfShouldMoveIn -- No Chance: {0}", chanceValue); return false; } // Check against random value uint maxChance = (uint) MAX_CHANCE_VALUE; int randomValue = randomizer.Int32(maxChance); Logger.logInfo(LOG_CHANCES, "MoveInProbabilityHelper.checkIfShouldMoveIn -- Total Chance Value: {0} -- Random Number: {1} -- result: {2}", chanceValue, randomValue, randomValue <= chanceValue); return randomValue <= chanceValue; }
public FeatureCreator(ConfigFacade configuration, IDataProvider dataProvider, Randomizer randomGen) { docTree = new DocumentTree(); randomNumberGen = new Random(); this.configuration = configuration; this.DataProvider = dataProvider; this.randomGen = randomGen; }
//protected: protected void Start() { m_diffLevel = Difficulty.easy; m_randomizer = (GameObject.Find ("GameManager")).GetComponent<Randomizer>(); m_MenuState = (GameObject.Find ("GameManager")).GetComponent<MenuState>(); m_EventManager = EventManager.Instance; m_myCam = (GameObject.Find ("GameManager")).camera; }
public void RandomizersWithSameSeedsReturnSameValues() { Randomizer r1 = new Randomizer(1234); Randomizer r2 = new Randomizer(1234); for (int i = 0; i < 10; i++) Assert.That(r1.NextDouble(), Is.EqualTo(r2.NextDouble())); }
public void RandomizersWithDifferentSeedsReturnDifferentValues() { Randomizer r1 = new Randomizer(1234); Randomizer r2 = new Randomizer(4321); for (int i = 0; i < 10; i++) Assert.That(r1.NextDouble(), Is.Not.EqualTo(r2.NextDouble())); }
public void RandomIntsAreUnique() { Randomizer r = new Randomizer(); int[] values = new int[10]; for (int i = 0; i < 10; i++) values[i] = r.Next(); Assert.That(values, Is.Unique); }
/// <summary> /// Calculated to the similar way the original code would have done it /// </summary> /// <param name="r"></param> /// <param name="width"></param> /// <param name="length"></param> /// <param name="subService"></param> /// <param name="level"></param> /// <returns></returns> public static int CalculateHomeCount(Randomizer r, int width, int length, ItemClass.SubService subService, ItemClass.Level level) { int[][] residentialArray = { new int [] { 20, 25, 30, 35, 40 }, new int [] { 60, 100, 130, 150, 160 } }; int iLevel = (int)(level >= 0 ? level : 0); int density = (subService == ItemClass.SubService.ResidentialLow) ? 0 : 1; int num = residentialArray[density][iLevel]; return Mathf.Max(100, width * length * num + r.Int32(100u)) / 100; }
public void RandomDoublesAreUnique() { Randomizer r = new Randomizer(); double[] values = new double[10]; for (int i = 0; i < 10; i++) values[i] = r.NextDouble(); Assert.That(values, Is.Unique); }
/// <summary> /// /// </summary> /// <param name="r"></param> /// <param name="width"></param> /// <param name="length"></param> /// <param name="level0"></param> /// <param name="level1"></param> /// <param name="level2"></param> /// <param name="level3"></param> public override void CalculateWorkplaceCount(Randomizer r, int width, int length, out int level0, out int level1, out int level2, out int level3) { ItemClass @class = this.m_info.m_class; int num; if (@class.m_level == ItemClass.Level.Level1) { num = DataStore.office[0][DataStore.PEOPLE]; level0 = 0; level1 = 40; level2 = 50; level3 = 10; } else if (@class.m_level == ItemClass.Level.Level2) { num = DataStore.office[1][DataStore.PEOPLE]; level0 = 0; level1 = 20; level2 = 50; level3 = 30; } else { num = DataStore.office[2][DataStore.PEOPLE]; level0 = 0; level1 = 0; level2 = 40; level3 = 60; } if (num != 0) { num = Mathf.Max(200, width * length * num + r.Int32(100u)) / 100; int num2 = level0 + level1 + level2 + level3; if (num2 != 0) { level0 = (num * level0 + r.Int32((uint)num2)) / num2; num -= level0; } num2 = level1 + level2 + level3; if (num2 != 0) { level1 = (num * level1 + r.Int32((uint)num2)) / num2; num -= level1; } num2 = level2 + level3; if (num2 != 0) { level2 = (num * level2 + r.Int32((uint)num2)) / num2; num -= level2; } level3 = num; } }
public ZombieInfo getZombieInfo(uint zombieId) { if (this.m_instance != 0) { return Singleton<ZombieManager>.instance.m_instances.m_buffer[(int)this.m_instance].Info; } ItemClass.Service service = ItemClass.Service.Residential; // @todo figure out a way to set a logical ItemClass for a Zombie. Citizen.Gender gender = Citizen.GetGender(zombieId); Randomizer randomizer = new Randomizer(zombieId); return Singleton<ZombieManager>.instance.GetGroupZombieInfo(ref randomizer, service, gender, Citizen.SubCulture.Generic); }
private static void NextConnection(ref SqlConnection con, Randomizer rand) { if (con != null) { con.Close(); } string connString = _connectionStrings[rand.Next(_connectionStrings.Length)]; con = new SqlConnection(connString); con.Open(); }
public override string GenerateName(ushort buildingID, InstanceID caller) { if (this.m_info.m_prefabDataIndex == -1) { return null; } Randomizer randomizer = new Randomizer ((int)buildingID); string key = PrefabCollection<BuildingInfo>.PrefabName ((uint)this.m_info.m_prefabDataIndex); uint num = Locale.CountUnchecked ("BUILDING_NAME", key); if (num != 0u) { return Locale.Get ("BUILDING_NAME", key, randomizer.Int32 (num)); } return BuildingNameGenerator.GenerateName (this.m_info.m_class.m_service, randomizer); }
internal override void Generate(Randomizer randomizer, ActorResourceTypes resourceType) { switch (resourceType) { case ActorResourceTypes.Mana: ManaCost = 20; Damage = Damage * 1.1f; break; case ActorResourceTypes.Energy: EnergyCost = 20; break; } }
public void DroneCommander_search_works() { // Given var randomizer = new Randomizer(); var map = new Map(5, randomizer); var droneSupervisor = new DroneSupervisor(map, randomizer); // When var winner = droneSupervisor.Search(); // Then winner.Value.Should().Be(droneSupervisor.GoalValue); }
public static string Cpr(this Person p) { const string Key = nameof(ExtensionsForDenmark) + "CPR"; if (p.context.ContainsKey(Key)) { return p.context[Key] as string; } var r = new Randomizer(); var final = $"{p.DateOfBirth:ddMMyy}-{r.Replace("####")}"; p.context[Key] = final; return final; }
public SeniorCitizenManager() { Logger.logInfo(LOG_SENIORS, "SeniorCitizenManager Created"); instance = this; this.randomizer = new Randomizer((uint) 73); this.citizenManager = Singleton<CitizenManager>.instance; this.buildingManager = Singleton<BuildingManager>.instance; // TODO: This array size is excessive but will allow for never worrying about resizing, should consider allowing for resizing instead this.familiesWithSeniors = new uint[CitizenManager.MAX_UNIT_COUNT]; this.seniorCitizensBeingProcessed = new HashSet<uint>(); }
public DocumentCreator(IDataProvider dataProvider, String outputFilePath, String runConfigPath, String docFeaturesPath) { docTree = new DocumentTree(); randomNumberGen = new Random(); defualts = new Defaults(); xmlWriter = new XmlWriter(outputFilePath); runConfig = new RunConfig(runConfigPath, defualts); docFeatures = new DocFeatures(docFeaturesPath); config = new ConfigFacade(runConfig, docFeatures, defualts); randomGen = new Randomizer(config); styleCreator = new StyleCreator(config, randomGen); featureCreator = new FeatureCreator(config, dataProvider, randomGen); }
static void Main(string[] args) { var markov = new Markov("nameResidential", false, 4); //var markov = new ExtendedBuildings.Markov("ExtendedBuildings.markov.descriptionsWorkplaces.txt", false, 6); Randomizer randomizer = new Randomizer(50); for (var i = 0; i < 100; i += 1) { Console.WriteLine(markov.GetText(ref randomizer, 6, 13, true, true)); } //Console.Write(markov.GetText(120, 220, true)); var x = Console.ReadLine(); if (x == "") { } }
public static void MaxHealthContainerPickup() { Randomizer.showHint("$Health Cell$"); Characters.Sein.Mortality.Health.GainMaxHeartContainer(); }
public void BeforeRunningTestSession() { r = new Randomizer(); }
public static Pitch GetKey(GuitarTuning tuning) { var possibleKeys = new[] { tuning.Pitches[0], tuning.Pitches[0] + 2, tuning.Pitches[1] }; // e.g. E, F#, A (0, 2, 5) return(possibleKeys[Randomizer.Next(possibleKeys.Length)].FromMidiPitch()); }
/// <summary> /// Resets the <see cref="Randomizer"/>. /// </summary> public void Dispose() { Randomizer.Reset(); }
// Token: 0x06003798 RID: 14232 public static void CheckPickups(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { Randomizer.LogError("CheckPickups: " + e.Error.ToString()); } if (!e.Cancelled && e.Error == null) { string[] array = e.Result.Split(new char[] { ',' }); int bf = int.Parse(array[0]); foreach (RandomizerSyncManager.SkillInfoLine skillInfoLine in RandomizerSyncManager.SkillInfos) { if (RandomizerSyncManager.getBit(bf, skillInfoLine.bit) && !Characters.Sein.PlayerAbilities.HasAbility(skillInfoLine.skill)) { RandomizerSwitch.GivePickup(new RandomizerAction("SK", skillInfoLine.id), 0, false); } } int bf2 = int.Parse(array[1]); foreach (RandomizerSyncManager.EventInfoLine eventInfoLine in RandomizerSyncManager.EventInfos) { if (RandomizerSyncManager.getBit(bf2, eventInfoLine.bit) && !eventInfoLine.checker()) { RandomizerSwitch.GivePickup(new RandomizerAction("EV", eventInfoLine.id), 0, false); } } int bf4 = int.Parse(array[2]); foreach (RandomizerSyncManager.TeleportInfoLine teleportInfoLine in RandomizerSyncManager.TeleportInfos) { if (RandomizerSyncManager.getBit(bf4, teleportInfoLine.bit) && !RandomizerSyncManager.isTeleporterActivated(teleportInfoLine.id)) { RandomizerSwitch.GivePickup(new RandomizerAction("TP", teleportInfoLine.id), 0, false); } } if (array[3] != "") { string[] upgrades = array[3].Split(';'); foreach (string rawUpgrade in upgrades) { string[] splitpair = rawUpgrade.Split('x'); int id = int.Parse(splitpair[0]); int cnt = int.Parse(splitpair[1]); if (RandomizerBonus.UpgradeCount(id) < cnt) { RandomizerBonus.UpgradeID(id); } else if (RandomizerBonus.UpgradeCount(id) > cnt) { RandomizerBonus.UpgradeID(-id); } } } if (array[4] != "") { string[] hints = array[4].Split(';'); foreach (string rawHint in hints) { string[] splitpair = rawHint.Split(':'); int coords = int.Parse(splitpair[0]); int player = int.Parse(splitpair[1]); RandomizerSyncManager.Hints[coords] = player; } } if (array.Length > 5) { foreach (string text in array[5].Split(new char[] { '|' })) { if (text == "stop") { RandomizerChaosManager.ClearEffects(); } else if (text.StartsWith("msg:")) { Randomizer.printInfo(text.Substring(4), 360); } else if (text.StartsWith("pickup:")) { string[] parts = text.Substring(7).Split(new char[] { '|' }); RandomizerAction action; if (Randomizer.StringKeyPickupTypes.Contains(parts[0])) { action = new RandomizerAction(parts[0], parts[1]); } else { int pickup_id; int.TryParse(parts[1], out pickup_id); action = new RandomizerAction(parts[0], pickup_id); } RandomizerSwitch.GivePickup(action, 0, false); } else if (text == "spawnChaos") { Randomizer.ChaosVerbose = true; RandomizerChaosManager.SpawnEffect(); RandomizerSyncManager.ChaosTimeoutCounter = 3600; } RandomizerSyncManager.webClient.DownloadStringAsync(new Uri(RandomizerSyncManager.RootUrl + "/signalCallback/" + text)); } } return; } if (e.Error.GetType().Name == "WebException" && ((HttpWebResponse)((WebException)e.Error).Response).StatusCode == HttpStatusCode.PreconditionFailed) { if (Randomizer.SyncMode == 1) { Randomizer.printInfo("Co-op server error, try reloading the seed (Alt+L)"); } else { Randomizer.LogError("Co-op server error, try reloading the seed (Alt+L)"); } return; } }
public bool CreatePath(out uint unit, ref Randomizer randomizer, PathCreationArgs args) { uint pathUnitId; try { Monitor.Enter(this.m_bufferLock); int numIters = 0; while (true) // NON-STOCK CODE { ++numIters; if (!this.m_pathUnits.CreateItem(out pathUnitId, ref randomizer)) { unit = 0u; return(false); } this.m_pathUnits.m_buffer[pathUnitId].m_simulationFlags = 1; this.m_pathUnits.m_buffer[pathUnitId].m_referenceCount = 1; this.m_pathUnits.m_buffer[pathUnitId].m_nextPathUnit = 0u; // NON-STOCK CODE START if (queueItems[pathUnitId].queued) { ReleasePath(pathUnitId); if (numIters > 10) { unit = 0u; return(false); } continue; } break; } queueItems[pathUnitId].vehicleType = args.extVehicleType; queueItems[pathUnitId].vehicleId = args.vehicleId; queueItems[pathUnitId].pathType = args.extPathType; queueItems[pathUnitId].spawned = args.spawned; queueItems[pathUnitId].queued = true; // NON-STOCK CODE END this.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u); } finally { Monitor.Exit(this.m_bufferLock); } unit = pathUnitId; if (args.isHeavyVehicle) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 16; } if (args.ignoreBlocked || args.ignoreFlooded) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 32; } if (args.stablePath) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 64; } if (args.randomParking) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 2; } if (args.hasCombustionEngine) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 4; } if (args.ignoreCosts) { this.m_pathUnits.m_buffer[unit].m_simulationFlags |= 8; } this.m_pathUnits.m_buffer[unit].m_pathFindFlags = 0; this.m_pathUnits.m_buffer[unit].m_buildIndex = args.buildIndex; this.m_pathUnits.m_buffer[unit].m_position00 = args.startPosA; this.m_pathUnits.m_buffer[unit].m_position01 = args.endPosA; this.m_pathUnits.m_buffer[unit].m_position02 = args.startPosB; this.m_pathUnits.m_buffer[unit].m_position03 = args.endPosB; this.m_pathUnits.m_buffer[unit].m_position11 = args.vehiclePosition; this.m_pathUnits.m_buffer[unit].m_laneTypes = (byte)args.laneTypes; this.m_pathUnits.m_buffer[unit].m_vehicleTypes = (ushort)args.vehicleTypes; this.m_pathUnits.m_buffer[unit].m_length = args.maxLength; this.m_pathUnits.m_buffer[unit].m_positionCount = 20; int minQueued = 10000000; #if PF2 CustomPathFind2 pathFind = null; #else CustomPathFind pathFind = null; #endif #if QUEUEDSTATS TotalQueuedPathFinds = 0; #endif for (int i = 0; i < _replacementPathFinds.Length; ++i) { #if PF2 CustomPathFind2 pathFindCandidate = _replacementPathFinds[i]; #else CustomPathFind pathFindCandidate = _replacementPathFinds[i]; #endif #if QUEUEDSTATS TotalQueuedPathFinds += (uint)pathFindCandidate.m_queuedPathFindCount; #endif if (pathFindCandidate.IsAvailable && pathFindCandidate.m_queuedPathFindCount < minQueued) { minQueued = pathFindCandidate.m_queuedPathFindCount; pathFind = pathFindCandidate; } } #if PF2 if (pathFind != null && pathFind.CalculatePath(unit, args.skipQueue)) { return(true); } #else if (pathFind != null && pathFind.ExtCalculatePath(unit, args.skipQueue)) { return(true); } #endif // NON-STOCK CODE START try { Monitor.Enter(this.m_bufferLock); queueItems[pathUnitId].queued = false; // NON-STOCK CODE END this.ReleasePath(unit); // NON-STOCK CODE START this.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u); } finally { Monitor.Exit(this.m_bufferLock); } // NON-STOCK CODE END return(false); }
public void UnconfiguredRandomizerThrowsException() { Randomizer.Reset(); Assert.Throws <InvalidOperationException>(() => Randomizer.Instance); }
public void GetRandomInt() { var number = Randomizer <int> .Create(new IntRange(1, 2)); Assert.IsTrue(number == 1 || number == 2); }
public bool BorrowResources(ITurnPlayer player, IGamePlayer rightNeighbor, IGamePlayer leftNeighbor, IList <BorrowResourceData> data, bool allowAutomaticChoice) { if (!data.Any()) { return(true); } //If some of the data doesn't have a direction preference and is not allowed to automatic choose, nothing happens if (!allowAutomaticChoice && data.Any(r => r.ChosenNeighbor != PlayerDirection.ToTheLeft && r.ChosenNeighbor != PlayerDirection.ToTheRight)) { return(false); } //Select a random direction for the non preference entries. foreach (var r in data.Where(r => r.ChosenNeighbor != PlayerDirection.ToTheLeft && r.ChosenNeighbor != PlayerDirection.ToTheRight)) { var availableDirections = new List <PlayerDirection>(); availableDirections.Add(PlayerDirection.ToTheLeft); availableDirections.Add(PlayerDirection.ToTheRight); r.ChosenNeighbor = Randomizer.SelectOne(availableDirections); } var fromRight = data.Where(r => r.ChosenNeighbor == PlayerDirection.ToTheRight).Select(r => r.ResourceType).ToList(); var fromLeft = data.Where(r => r.ChosenNeighbor == PlayerDirection.ToTheLeft).Select(r => r.ResourceType).ToList(); LoggerHelper.DebugFormat("Player {0} will borrow {1} resources from right neighbor and {2} resources from left neighbor.", player.Name, fromRight.Count, fromLeft.Count); var missingFromRight = BorrowResourceFromNeighbor(rightNeighbor, fromRight); var missingFromLeft = BorrowResourceFromNeighbor(leftNeighbor, fromLeft); if (missingFromRight.Any() || missingFromLeft.Any()) { //If not allowed to automatic choose and some resource is missing, it can't be completed. if (!allowAutomaticChoice) { return(false); } LoggerHelper.DebugFormat("Player {0} could not borrow {1} resources from right neighbor and {2} resources from left neighbor.", player.Name, fromRight.Count, fromLeft.Count); //Move missing resources between neighbors and try to borrow again. RemoveResourcesAndAddRange(fromRight, missingFromRight, missingFromLeft); RemoveResourcesAndAddRange(fromLeft, missingFromLeft, missingFromRight); if (BorrowResourceFromNeighbor(rightNeighbor, fromRight).Any() || BorrowResourceFromNeighbor(leftNeighbor, fromLeft).Any()) { return(false); } //Clears former data and create new using the correct neighbors. data.Clear(); foreach (var rt in fromRight) { data.Add(new BorrowResourceData { ChosenNeighbor = PlayerDirection.ToTheRight, ResourceType = rt }); } foreach (var rt in fromLeft) { data.Add(new BorrowResourceData { ChosenNeighbor = PlayerDirection.ToTheLeft, ResourceType = rt }); } } //Checks if got enough coins to pay. foreach (var d in data) { player.CoinsLeft -= player.HasDiscount(d.ChosenNeighbor, Enumerator.GetTradeDiscountType(d.ResourceType)) ? ConstantValues.COIN_VALUE_FOR_SHARE_DISCOUNT : ConstantValues.COIN_VALUE_FOR_SHARE_DEFAULT; if (player.CoinsLeft < 0) { LoggerHelper.DebugFormat("Player {0} cannot afford costs in coins. Will not be able to borrow resources.", player.Name); return(false); } } //If everything went ok player.AddTemporaryResources(data.Select(r => r.ResourceType).ToList()); SaveEventOperations(player, rightNeighbor, leftNeighbor, data); return(true); }
private static void Postfix(BuildingAI __instance, ushort buildingID, ref Building data, ref Randomizer randomizer, CitizenInfo info, ref Vector3 position, ref Vector3 target, ref CitizenInstance.Flags specialFlags) { if (WeatherInfo?.IsBadWeather != true || data.Info == null || data.Info.m_enterDoors == null) { return; } BuildingInfo.Prop[] enterDoors = data.Info.m_enterDoors; bool doorFound = false; for (int i = 0; i < enterDoors.Length; ++i) { PropInfo prop = enterDoors[i].m_finalProp; if (prop == null) { continue; } if (prop.m_doorType == PropInfo.DoorType.Enter || prop.m_doorType == PropInfo.DoorType.Both) { doorFound = true; break; } } if (!doorFound) { return; } __instance.CalculateSpawnPosition(buildingID, ref data, ref randomizer, info, out Vector3 spawnPosition, out Vector3 spawnTarget); position = spawnPosition; target = spawnTarget; specialFlags &= ~(CitizenInstance.Flags.HangAround | CitizenInstance.Flags.SittingDown); }
public Human CreateHuman(Sex sex) { return(new Parent(Randomizer.GetRandomParentAge(), NamesHelper.GenerateName(Sex.Man), Sex.Man, rnd.Next(maxChildsNum))); }
/// <summary> /// Harmony Prefix patch to ResidentialBuildingAI.CalculateHomeCount to implement mod population calculations. /// </summary> /// <param name="__result">Original method result</param> /// <param name="__instance">Original AI instance reference</param> /// <param name="level">Building level</param> /// <param name="r">Randomizer (unused)</param> /// <param name="width">Building lot width (unused)</param> /// <param name="length">Building lot length (unused)</param> /// <returns>Always false (don't execute base game method after this)</returns> public static bool Prefix(ref int __result, ResidentialBuildingAI __instance, ItemClass.Level level, Randomizer r, int width, int length) { // Get population value from cache. __result = PopData.instance.HouseholdCache(__instance.m_info, (int)level); // Always set at least one. if (__result < 1) { Logging.Error("invalid homecount result ", __result.ToString(), " for ", __instance.m_info.name, "; setting to 1"); __result = 1; } // Don't execute base method after this. return(false); }
public void NextRandomNumber_ShouldReturnANumberGreaterThan_Minus_1() { Randomizer randomizer = new Randomizer(new Random()); Assert.Greater(randomizer.NextRandomNumber(9), -1); }
public static void MapStonePickup() { Randomizer.showHint("Map Stone"); Characters.Sein.Inventory.MapStones++; }
public override void SimulationStep() { if (this.m_prefab == null) { this.m_wasPrefab = (PropInfo)null; this.m_propInfo = (PropInfo)null; } else { if (this.m_propInfo == null || this.m_wasPrefab != this.m_prefab) { this.m_wasPrefab = this.m_prefab; Randomizer r = this.m_randomizer; this.m_propInfo = (Singleton <ToolManager> .instance.m_properties.m_mode & ItemClass.Availability.AssetEditor) == ItemClass.Availability.None ? this.m_prefab.GetVariation(ref r) : this.m_prefab; m_randomizer = this.m_randomizer; } ToolBase.RaycastInput input = new ToolBase.RaycastInput(this.m_mouseRay, this.m_mouseRayLength); //begin mod input.m_ignoreBuildingFlags = Building.Flags.None; input.m_ignoreNodeFlags = NetNode.Flags.None; input.m_ignoreSegmentFlags = NetSegment.Flags.None; input.m_buildingService = new RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default); input.m_netService = new RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default); input.m_netService2 = new RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default); //end mod ulong[] collidingSegments; ulong[] collidingBuildings; this.m_toolController.BeginColliding(out collidingSegments, out collidingBuildings); try { ToolBase.RaycastOutput output; if (this.m_mouseRayValid && ToolBase.RayCast(input, out output)) { if (this.m_mode == PropTool.Mode.Brush) { this.m_mousePosition = output.m_hitPos; this.m_placementErrors = !Singleton <PropManager> .instance.CheckLimits() ? ToolBase.ToolErrors.TooManyObjects : ToolBase.ToolErrors.Pending; if (this.m_mouseLeftDown == this.m_mouseRightDown) { return; } this.ApplyBrush(); } else { if (this.m_mode != PropTool.Mode.Single) { return; } //begin mod //end mod Randomizer r = this.m_randomizer; ushort id = Singleton <PropManager> .instance.m_props.NextFreeItem(ref r); ToolBase.ToolErrors toolErrors = PropTool.CheckPlacementErrors(this.m_propInfo, output.m_hitPos, /*output.m_currentEditObject*/ false, id, collidingSegments, collidingBuildings); if ((Singleton <ToolManager> .instance.m_properties.m_mode & ItemClass.Availability.Game) != ItemClass.Availability.None) { int constructionCost = this.m_propInfo.GetConstructionCost(); if (constructionCost != 0 && constructionCost != Singleton <EconomyManager> .instance.PeekResource( EconomyManager.Resource.Construction, constructionCost)) { toolErrors |= ToolBase.ToolErrors.NotEnoughMoney; } } if (!Singleton <PropManager> .instance.CheckLimits()) { toolErrors |= ToolBase.ToolErrors.TooManyObjects; } this.m_mousePosition = output.m_hitPos; this.m_placementErrors = toolErrors; //begin mod //end mod } } else { this.m_placementErrors = ToolBase.ToolErrors.RaycastFailed; } } finally { this.m_toolController.EndColliding(); } } }
public LeadPerson(Randomizer randomizer) { Random = randomizer; }
private void Start() { Randomizer.Instantiate(cube); Debug.Log("working"); }
public static T PickRandom <T>(this List <T> list) => list.Any() ? list[Randomizer.Next(list.Count)] : default(T);
public AFish FindNextVictim() { return(Aquarium.GetFishes() .FirstOrDefault(fish => Randomizer.Success(0.4) && Settings.Piranha.Food.Contains(fish.Type))); }
// Token: 0x0600376D RID: 14189 RVA: 0x000E2764 File Offset: 0x000E0964 public static void UpgradeID(int ID) { bool flag = ID < 0; if (flag) { ID = -ID; } if (RandomizerBonusSkill.BonusSkillNames.ContainsKey(ID)) { RandomizerBonusSkill.FoundBonusSkill(ID); return; } if (ID >= 200 && ID < 260) { int abilityId = (ID - 200) % 30; Ability ability = abilities[abilityId]; if (ID < 230) { ability.Found(); } else { ability.Lost(); } return; } switch (ID) { case 0: if (!flag) { Characters.Sein.Mortality.Health.SetAmount((float)(Characters.Sein.Mortality.Health.MaxHealth + 20)); RandomizerSwitch.PickupMessage("Mega Health"); return; } break; case 1: if (!flag) { Characters.Sein.Energy.SetCurrent(Characters.Sein.Energy.Max + 5f); RandomizerSwitch.PickupMessage("Mega Energy"); return; } break; case 2: Randomizer.returnToStart(); RandomizerSwitch.PickupMessage("Go Home!"); return; case 20: break; case 6: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("Attack Upgrade (" + RandomizerBonus.SpiritFlameLevel().ToString() + ")"); return; } if (RandomizerBonus.SpiritFlameLevel() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("Attack Upgrade (" + RandomizerBonus.SpiritFlameLevel().ToString() + ")"); return; } break; case 8: RandomizerSwitch.PickupMessage("Explosion Power Upgrade"); if (!RandomizerBonus.ExplosionPower()) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); return; } break; case 9: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); } else if (Characters.Sein.Inventory.GetRandomizerItem(ID) > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); } if (Characters.Sein.Inventory.GetRandomizerItem(ID) == 1) { RandomizerSwitch.PickupMessage("Spirit Light Efficiency"); } else { RandomizerSwitch.PickupMessage("Spirit Light Efficiency (" + Characters.Sein.Inventory.GetRandomizerItem(ID).ToString() + ")"); } break; case 10: RandomizerSwitch.PickupMessage("Extra Air Dash"); if (!RandomizerBonus.DoubleAirDash()) { Characters.Sein.Inventory.SetRandomizerItem(ID, 1); return; } break; case 11: RandomizerSwitch.PickupMessage("Charge Dash Efficiency"); if (!RandomizerBonus.ChargeDashEfficiency()) { Characters.Sein.Inventory.SetRandomizerItem(ID, 1); return; } break; case 12: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); if (RandomizerBonus.DoubleJumpUpgrades() == 1) { RandomizerSwitch.PickupMessage("Extra Double Jump"); return; } RandomizerSwitch.PickupMessage("Extra Double Jump (" + RandomizerBonus.DoubleJumpUpgrades().ToString() + ")"); return; } else if (RandomizerBonus.DoubleJumpUpgrades() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); if (RandomizerBonus.DoubleJumpUpgrades() == 1) { RandomizerSwitch.PickupMessage("Extra Double Jump"); return; } RandomizerSwitch.PickupMessage("Extra Double Jump (" + RandomizerBonus.DoubleJumpUpgrades().ToString() + ")"); return; } break; case 13: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("Health Regeneration (" + RandomizerBonus.HealthRegeneration().ToString() + ")"); return; } if (RandomizerBonus.HealthRegeneration() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("Health Regeneration (" + RandomizerBonus.HealthRegeneration().ToString() + ")"); return; } break; case 15: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("Energy Regeneration (" + RandomizerBonus.EnergyRegeneration().ToString() + ")"); return; } if (RandomizerBonus.EnergyRegeneration() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("Energy Regeneration (" + RandomizerBonus.EnergyRegeneration().ToString() + ")"); return; } break; case 17: if (flag) { if (RandomizerBonus.WaterVeinShards() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("*Water Vein Shard (" + RandomizerBonus.WaterVeinShards().ToString() + "/3)*"); } } else if (RandomizerBonus.WaterVeinShards() >= 3) { RandomizerSwitch.PickupMessage("*Water Vein Shard (extra)*"); } else { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("*Water Vein Shard (" + RandomizerBonus.WaterVeinShards().ToString() + "/3)*", 300); } Keys.GinsoTree = (RandomizerBonus.WaterVeinShards() >= 3); if (Keys.GinsoTree) { RandomizerStatsManager.FoundEvent(0); } return; case 19: if (flag) { if (RandomizerBonus.GumonSealShards() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("#Gumon Seal Shard (" + RandomizerBonus.GumonSealShards().ToString() + "/3)#"); } } else if (RandomizerBonus.GumonSealShards() >= 3) { RandomizerSwitch.PickupMessage("#Gumon Seal Shard (extra)#"); } else { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("#Gumon Seal Shard (" + RandomizerBonus.GumonSealShards().ToString() + "/3)#", 300); } Keys.ForlornRuins = (RandomizerBonus.GumonSealShards() >= 3); if (Keys.ForlornRuins) { RandomizerStatsManager.FoundEvent(2); } return; case 21: if (flag) { if (RandomizerBonus.SunstoneShards() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("@Sunstone Shard (" + RandomizerBonus.SunstoneShards().ToString() + "/3)@"); } } else if (RandomizerBonus.SunstoneShards() >= 3) { RandomizerSwitch.PickupMessage("@Sunstone Shard (extra)@"); } else { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("@Sunstone Shard (" + RandomizerBonus.SunstoneShards().ToString() + "/3)@", 300); } Keys.MountHoru = (RandomizerBonus.SunstoneShards() >= 3); if (Keys.MountHoru) { RandomizerStatsManager.FoundEvent(4); } return; case 28: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); } else if (RandomizerBonus.WarmthFrags() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); } if (Randomizer.fragKeyFinish < RandomizerBonus.WarmthFrags()) { RandomizerSwitch.PickupMessage("@Warmth Fragment (extra)@", 300); return; } RandomizerSwitch.PickupMessage(string.Concat(new object[] { "@Warmth Fragment (", RandomizerBonus.WarmthFrags().ToString(), "/", Randomizer.fragKeyFinish, ")@" }), 300); break; case 29: return; case 30: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("Bleeding x" + RandomizerBonus.Bleeding().ToString()); return; } if (RandomizerBonus.Bleeding() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("Bleeding x" + RandomizerBonus.Bleeding().ToString()); return; } break; case 31: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); } else if (RandomizerBonus.Lifesteal() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); } if (Lifesteal() == 1) { RandomizerSwitch.PickupMessage("Health Leech"); } else { RandomizerSwitch.PickupMessage("Health Leech x" + RandomizerBonus.Lifesteal().ToString()); } break; case 32: if (!flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); } else if (RandomizerBonus.Manavamp() > 0) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); } if (Manavamp() == 1) { RandomizerSwitch.PickupMessage("Energy Leech"); } else { RandomizerSwitch.PickupMessage("Energy Leech x" + RandomizerBonus.Manavamp().ToString()); } break; case 33: if (!flag) { int v = Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("Skill Velocity Upgrade x" + v.ToString()); if (Characters.Sein.Inventory.GetRandomizerItem(108) == 0) { RandomizerBonusSkill.FoundBonusSkill(108); } return; } if (RandomizerBonus.Velocity() > 0) { int v = Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("Skill Velocity Upgrade x" + v.ToString()); return; } break; case 34: Characters.Sein.Inventory.SetRandomizerItem(34, 1); RandomizerSwitch.PickupMessage("Return to start disabled!"); break; case 35: Characters.Sein.Inventory.SetRandomizerItem(34, 0); RandomizerSwitch.PickupMessage("Return to start enabled!"); break; case 36: RandomizerSwitch.PickupMessage("Underwater Skill Usage"); Characters.Sein.Inventory.SetRandomizerItem(36, 1); break; case 37: if (!flag) { int v = Characters.Sein.Inventory.IncRandomizerItem(ID, 1); RandomizerSwitch.PickupMessage("Jump Upgrade x" + v.ToString()); if (Characters.Sein.Inventory.GetRandomizerItem(108) == 0) { RandomizerBonusSkill.FoundBonusSkill(108); } return; } if (RandomizerBonus.Jumpgrades() > 0) { int v = Characters.Sein.Inventory.IncRandomizerItem(ID, -1); RandomizerSwitch.PickupMessage("Jump Upgrade x" + v.ToString()); return; } break; case 40: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@Wall Jump Lost!!@", 240); Characters.Sein.PlayerAbilities.WallJump.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 41: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@ChargeFlame Lost!!@", 240); Characters.Sein.PlayerAbilities.ChargeFlame.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 42: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@DoubleJump Lost!!@", 240); Characters.Sein.PlayerAbilities.DoubleJump.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 43: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@Bash Lost!!@", 240); Characters.Sein.PlayerAbilities.Bash.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 44: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@Stomp Lost!!@", 240); Characters.Sein.PlayerAbilities.Stomp.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 45: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@Glide Lost!!@", 240); Characters.Sein.PlayerAbilities.Glide.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 46: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@Climb Lost!!@", 240); Characters.Sein.PlayerAbilities.Climb.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 47: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@Charge Jump Lost!!@", 240); Characters.Sein.PlayerAbilities.ChargeJump.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 48: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@Dash Lost!!@", 240); Characters.Sein.PlayerAbilities.Dash.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 49: if (!Characters.Sein || flag) { return; } RandomizerSwitch.PickupMessage("@Grenade Lost!!@", 240); Characters.Sein.PlayerAbilities.Grenade.HasAbility = false; Characters.Sein.Prefabs.EnsureRightPrefabsAreThereForAbilities(); return; case 81: if (Characters.Sein.Inventory.GetRandomizerItem(ID) > 0) { return; } Characters.Sein.Inventory.IncRandomizerItem(ID, 1); string s_color = ""; string g_color = ""; if (Characters.Sein.PlayerAbilities.HasAbility(AbilityType.Stomp)) { s_color = "$"; } if (Characters.Sein.PlayerAbilities.HasAbility(AbilityType.Grenade)) { g_color = "$"; } RandomizerSwitch.PickupMessage(s_color + "Stomp: " + Randomizer.StompZone + s_color + g_color + " Grenade: " + Randomizer.GrenadeZone + g_color, 480); break; default: if (flag) { Characters.Sein.Inventory.IncRandomizerItem(ID, -1); } else { Characters.Sein.Inventory.IncRandomizerItem(ID, 1); } return; } }
public void SecondConfigureThrowsException() { Assert.Throws <InvalidOperationException>(() => Randomizer.Configure(0)); }
/// <summary> /// Default no argument constructor for NUnitTestCaseBuilder /// </summary> public NUnitTestCaseBuilder() { randomizer = Randomizer.CreateRandomizer(); }
/// <summary> /// Initializes a new instance of the <see cref="RandomizerTest"/> class. /// </summary> public RandomizerTest() { Randomizer.Configure(); }
public override void CalculateUnspawnPosition(ushort buildingID, ref Building data, ref Randomizer randomizer, CitizenInfo info, ushort ignoreInstance, out Vector3 position, out Vector3 target, out Vector2 direction, out CitizenInstance.Flags specialFlags) { if (info.m_citizenAI.IsAnimal() && info.m_class.m_service == ItemClass.Service.Residential && info.m_class.m_subService == ItemClass.SubService.ResidentialLow) { int max1 = data.Width * 30; int max2 = data.Length * 30; position.x = (float)randomizer.Int32(-max1, max1) * 0.1f; position.y = 0.0f; position.z = (float)randomizer.Int32(-max2, max2) * 0.1f; position = data.CalculatePosition(position); target = position; direction = Vector2.zero; specialFlags = CitizenInstance.Flags.HangAround; } else { base.CalculateUnspawnPosition(buildingID, ref data, ref randomizer, info, ignoreInstance, out position, out target, out direction, out specialFlags); } }
public int Roll() { return(Randomizer.GetInstance().GetNext(5) + 1); }
public override void CalculateSpawnPosition(ushort buildingID, ref Building data, ref Randomizer randomizer, CitizenInfo info, out Vector3 position, out Vector3 target) { if (info.m_citizenAI.IsAnimal() && info.m_class.m_service == ItemClass.Service.Residential && info.m_class.m_subService == ItemClass.SubService.ResidentialLow) { int max1 = data.Width * 30; int max2 = data.Length * 30; position.x = (float)randomizer.Int32(-max1, max1) * 0.1f; position.y = 0.0f; position.z = (float)randomizer.Int32(-max2, max2) * 0.1f; position = data.CalculatePosition(position); float f = (float)randomizer.Int32(360U) * ((float)System.Math.PI / 180f); target = position; target.x += Mathf.Cos(f); target.z += Mathf.Sin(f); } else { base.CalculateSpawnPosition(buildingID, ref data, ref randomizer, info, out position, out target); } }
public RandomizerTest() { r = new Randomizer(); }
private int TargetAnimals(ushort buildingID, ref Building data) { Randomizer randomizer = new Randomizer((int)buildingID); return(Mathf.Max(100, data.Width * data.Length * 30 + randomizer.Int32(100U)) / 100); }
public static void KeystonePickup() { Randomizer.showHint("Keystone"); Characters.Sein.Inventory.CollectKeystones(1); }
public static void TeleportPickup(string Value) { TeleporterController.Instance.Activate(Value); Randomizer.showHint("Teleporter activated: " + Value); }