当前位置: 首页>>代码示例>>C#>>正文


C# Randomizer类代码示例

本文整理汇总了C#中Randomizer的典型用法代码示例。如果您正苦于以下问题:C# Randomizer类的具体用法?C# Randomizer怎么用?C# Randomizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Randomizer类属于命名空间,在下文中一共展示了Randomizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Phase2

 private void Phase2()
 {
     lblPhase2.Enabled = true;
     Randomizer rnd = new Randomizer(progressBar);
     lblPhase2.Text += "   |DONE|";
     lblPhase2.Enabled = false;
 }
开发者ID:ruppinserver,项目名称:Dances_Words_Algorithm,代码行数:7,代码来源:Form1.cs

示例2: GetRandomBuildingInfo_Upgrade

        // 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]);
        }
开发者ID:aoighost,项目名称:BuildingThemes,代码行数:28,代码来源:BuildingManagerDetour.cs

示例3: _generateNameHelper

        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);
        }
开发者ID:wufire,项目名称:CitiesSkylinesBuildingNameGenerator,代码行数:27,代码来源:BuildingNameGenerator.cs

示例4: CreatePath

        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);
        }
开发者ID:robbiemu,项目名称:Skylines-Traffic-Manager,代码行数:27,代码来源:CustomPathManager.cs

示例5: GetBufferStatus

 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);
     }
 }
开发者ID:klyte45,项目名称:CS-VehicleLimitExpander,代码行数:30,代码来源:FakePassengerTrainAI.cs

示例6: OnBuildingCreated

 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);
     }
 }
开发者ID:earalov,项目名称:Skylines-UnlimitedOutsideConnections,代码行数:30,代码来源:BuildingManagerHooks.cs

示例7: Initialize

 // 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();
 }
开发者ID:tuvoksg1,项目名称:RulesEngine,代码行数:8,代码来源:TestAuditController.cs

示例8: CreateSegment

        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;
        }
开发者ID:boformer,项目名称:GrowableOverhaul,代码行数:34,代码来源:NetManagerDetour.cs

示例9: StartPathFind

 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;
 }
开发者ID:Katalyst6,项目名称:CSL.TransitAddonMod,代码行数:31,代码来源:CustomHearseAI.cs

示例10: StyleCreator

 public StyleCreator(ConfigFacade config, Randomizer randomizer)
 {
     randomNumber = new Random();
     configFacade = config;
     this.randomizer = randomizer;
     defaults = new Defaults();
 }
开发者ID:amilasurendra,项目名称:pdf-generator,代码行数:7,代码来源:StyleCreator.cs

示例11: CalculateHomeCount

        /// <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;
        }
开发者ID:OMMatte,项目名称:WG_RealisticCitySkylines,代码行数:36,代码来源:AI_Residential.cs

示例12: Sin

        /// <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;
        }
开发者ID:Mpdreamz,项目名称:Bogus,代码行数:63,代码来源:ExtensionsForCanada.cs

示例13: checkIfShouldMoveIn

        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;
        }
开发者ID:BoostHungry,项目名称:SeniorCitizenCenterMod,代码行数:33,代码来源:MoveInProbabilityHelper.cs

示例14: RandomizersWithSameSeedsReturnSameValues

        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()));
        }
开发者ID:Phaiax,项目名称:dotnetautoupdate,代码行数:8,代码来源:RandomizerTests.cs

示例15: Start

 //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;
 }
开发者ID:gianlucadelfino,项目名称:LightsOut,代码行数:9,代码来源:DifficultyButton.cs


注:本文中的Randomizer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。