private void bRunSingle_Click(object sender, EventArgs e) { if (!EnsureConditions()) { return; } var tileset = cmbTileSet.SelectedItem as RandomTilesList; var hues = cmbHues.SelectedItem as HuesCollection; RandomItem msg = null; ; if (rNoHue.Checked) { msg = new RandomItem(tileset); } else if (rSelectedHue.Checked) { msg = new RandomItem(tileset, Pandora.Profile.Hues.SelectedIndex); } else { msg = new RandomItem(tileset, hues); } Pandora.BoxConnection.SendToServer(msg); }
private void Awake() { ReadData(); RandomNumberGen.Initialize(); randomItem1 = new RandomItem(item.Length - 1); }
public MeteorsGenerator(PlaySettings ss, RandomItem <int> carSizeDistribution, RandomItem <int> carAmountDistribution, RandomItem <int> metAmountDistribution, int minCount, int maxCount, Transform launcher) { if (carAmountDistribution.Items.Min() < 2 || carAmountDistribution.Items.Max() > ss.Road.LinesCount || metAmountDistribution.Items.Min() < 1 || metAmountDistribution.Items.Max() >= carAmountDistribution.Items.Max()) { throw new ArgumentOutOfRangeException(); } _blockGen = new BlockGenerator(ss, carSizeDistribution, carAmountDistribution); _metAmountDistr = metAmountDistribution; _carCountDistr = carAmountDistribution; _carSizeDistr = carSizeDistribution; _launcher = launcher; _ss = ss; _minCount = minCount; _maxCount = maxCount; _lowerBounds = new float[_ss.Road.LinesCount]; _topBounds = new float[_ss.Road.LinesCount]; _lastOnLine = new CarDescriptor[_ss.Road.LinesCount]; _isActual = new bool[_ss.Road.LinesCount]; _isMeteorTarget = new bool[_ss.Road.LinesCount]; }
/// <summary> /// ساختن اقلام مورد نیاز مشتری به صورت دستی /// </summary> /// <returns></returns> public async Task <List <ItemsEntity> > CreateItemsCustomer() { var itemsList = new List <ItemsEntity>(); var getRandomItems = new RandomItem(); var randomItemNumber = new Random().Next(1, 5); await Task.Run(() => { for (int i = 1; i <= randomItemNumber; i++) { var newItem = getRandomItems.SetItemsCustomer(); // زمانی که یک آیتم تکراری انتخاب شده است آیتم مورد نظر در لیست بروزرسانی می گردد var clearDoubleItems = itemsList.FirstOrDefault(a => a.Stuff == newItem.Stuff); if (clearDoubleItems != null) { clearDoubleItems.Qnt += newItem.Qnt; } else { itemsList.Add(newItem); } } }); return(itemsList); }
void Start() { rnd = new RandomItem(seed); collision = new CollisionDetection(); supportFunctions = new GeneratorSupprtFunctions(rnd, Rooms, wallFragments); StartCoroutine(Reset(secondsToWaitForReset)); }
public SoloMeteorGenerator(PlaySettings ss, float minDelay, float maxDelay, float addVelocity, RandomItem <int> secondBlockCarAmntDistr) { SS = ss; _carAmountDistr = secondBlockCarAmntDistr; _blockGen = new BlockGenerator(SS, new RandomItem <int>(new[] { 1, 2 }), _carAmountDistr); _minDelay = minDelay; _maxDelay = maxDelay; _addVelocity = addVelocity; }
public CopterGenerator(PlaySettings ps, float reloadTime, float missileVel, float missileRotVel, float missileLimit, int minCount, int maxCount, RandomItem <int> carSizeDistr, RandomItem <int> carCountDistr) { _ps = ps; _reloadTime = reloadTime; _missileVel = missileVel; _missileRotVel = missileRotVel; _missileLimit = missileLimit; _minCount = minCount; _maxCount = maxCount; _blockGen = new BlockGenerator(ps, carSizeDistr, carCountDistr); }
void InitRandomItems() { shuffle = new int[randomString.Length]; for (int i = 0; i < randomString.Length; i++) { shuffle[i] = new int(); shuffle[i] = i; RandomItem tempRandom = Instantiate(randomItemPrefab, randomItemParent); int positon = GetPosition(i); tempRandom.UpdateText(randomString[i], positon); randomItems.Add(tempRandom); } }
protected override void ParseElementConditions(System.Xml.Linq.XElement elemtype, ContentConfiguration <T> .Content content) { var elemRandoms = elemtype.Elements("random"); foreach (XElement elemRandom in elemRandoms) { //right now, we don't actuallyu care about any parameters int seed = items.Count; RandomItem item = new RandomItem(); XAttribute elemScale = elemRandom.Attribute("scale"); if (elemScale != null) { float scale = 1; float.TryParse(elemScale.Value, out scale); item.scale_x = scale; item.scale_y = scale; item.scale_z = scale; } XAttribute elemScaleX = elemRandom.Attribute("scale_x"); if (elemScaleX != null) { float scale = 1; float.TryParse(elemScaleX.Value, out scale); item.scale_x = scale; } XAttribute elemScaleY = elemRandom.Attribute("scale_y"); if (elemScaleY != null) { float scale = 1; float.TryParse(elemScaleY.Value, out scale); item.scale_y = scale; } XAttribute elemScaleZ = elemRandom.Attribute("scale_z"); if (elemScaleZ != null) { float scale = 1; float.TryParse(elemScaleZ.Value, out scale); item.scale_z = scale; } XAttribute elemIntensity = elemRandom.Attribute("intensity"); if (elemIntensity != null) { float scale = 1; float.TryParse(elemIntensity.Value, out scale); item.intensity = scale; } item.content = content; item.noise = new OpenSimplexNoise(seed); items.Add(item); } }
/// <summary> /// Sets a random value for the parameters in the script, after which it updates the parameters in the UI. /// Level reset function is called after the parameters are updated. /// </summary> public void RandomizeParameters() { RandomItem random = new RandomItem(); worldGeneratorScript.SetNumberOfExpansionRooms(random.GetSystemRandom(5, 15)); worldGeneratorScript.SetNumberOfRooms(random.GetSystemRandom(5, 15)); int newSeed = random.GetSystemRandom(1, 9999); while (worldGeneratorScript.GetSeed() == newSeed) { newSeed = random.GetSystemRandom(1, 9999); } worldGeneratorScript.SetSeed(newSeed); worldGeneratorScript.ResetLevel(); }
public bool Add(int Ratio, T Value) { this.SetImmutable(); this._ratioCursor += Ratio; RandomItem item = new RandomItem() { Ratio = Ratio, Item = Value, Cursor = this._ratioCursor }; _list.Add(this._ratioCursor, item); return(true); }
/// <summary> /// Spawn the dungeon objects in the level. /// </summary> public void SpawnDungeonObjects() { if (spawnableDungeonObjects.Length == 0) { return; } dungeonObjectsParent = new GameObject("Containers - "); dungeonObjectsParent.transform.parent = GameObject.FindGameObjectWithTag("Dungeon").transform; rnd = new RandomItem(); GatherIntel(); SpawnGroundObjects(); SpawnWallObjects(); SpawnCeilingObjects(); dungeonObjectsParent.name += dungeonObjectsParent.GetComponentsInChildren <DungeonObject>().Length; }
public WallGenerator(PlaySettings ss, RandomItem <int> carSizeDistr, RandomItem <int> carCountDistr, float wallLenMin, float wallLenMax, float gapLenMin, float gapLenMax, float vehVelDelta, int minCount, int maxCount, bool modifable) { _ss = ss; _wallLenMax = wallLenMax; _wallLenMin = wallLenMin; _gapLenMax = gapLenMax; _gapLenMin = gapLenMin; _minCarSpeed = _ss.NormalCarSpeed - vehVelDelta; _maxCarSpeed = _ss.NormalCarSpeed + vehVelDelta; _maxCount = maxCount; _minCount = minCount; _bufferList = new LinkedList <IDescriptorWithID>(); _blockGen = new BlockGenerator(ss, carSizeDistr, carCountDistr, 0x20); _modifable = modifable; }
public async Task <IActionResult> TestAsync() { var config = await _config.GetLatestValueAsync(); var item = new RandomItem { Timestamp = DateTime.UtcNow, Something = "Something!", ConfigValue = config.TestValue, ConfigTimestamp = config.Loaded }; await _cachingService.SetValueAsync(null, "item.123", item, TimeSpan.FromMinutes(15)); var item2 = await _cachingService.GetItemAsync <RandomItem>(null, "item.123"); return(Ok(item2)); }
public MultiGenerator(int minCount, int maxCount, RandomItem <IMiniGenerator> miniGens, float modProbability = 0, int maxModCount = 0, RandomItem <IBlockModifier> blockMods = null) { if (miniGens == null || miniGens.Length == 0) { throw new ArgumentException(); } if (blockMods != null && blockMods.Length == 0) { throw new ArgumentException(); } _minCount = minCount; _maxCount = maxCount; _gensDistr = miniGens; _modsDistr = blockMods; _modProb = modProbability; _maxModCount = maxModCount; DescriptorList = new LinkedList <IDescriptorWithID>(); }
public BlockGenerator(PlaySettings ss, RandomItem <int> carSizeDistribution, RandomItem <int> carAmountDistribution, byte mask = 0) { SS = ss; _carSizeDistr = carSizeDistribution; if (_carSizeDistr.Length > 3 || _carSizeDistr.Items.Max() > 3 || _carSizeDistr.Items.Min() < 1) { throw new ArgumentException("Bad blockLengthDistribution"); } _carAmntDistr = carAmountDistribution; if (carAmountDistribution != null && (carAmountDistribution.Items.Min() < 1 || carAmountDistribution.Items.Max() > SS.Road.LinesCount)) { throw new ArgumentException("Bad carAmountDistribution"); } _topBounds = new float[SS.Road.LinesCount]; _topBoundsFtr = new float[SS.Road.LinesCount]; _mask = mask; }
private static Recipe GenerateRecipe(ItemCptn[] allItems, Recipe recipe) { Recipe newRecipe = ScriptableObject.CreateInstance <Recipe>(); newRecipe.potion = recipe.potion; int i = 0; foreach (Item item in recipe.Items) { if (item as RandomItem != null) { RandomItem randomItem = item as RandomItem; newRecipe.Items[i++] = RandomItem(allItems, randomItem.rarity); } else { newRecipe.Items[i++] = item; } } System.Array.Sort(newRecipe.Items); return(newRecipe); }
void Awake() { _DEBUG_MODE = debugLog; if (_DEBUG_MODE) { FileLogger = new FileLogger(); } if (Rooms.Length == 0) { if (_DEBUG_MODE) { FileLogger.LogError(">!< No rooms to use(array is empty)! >!<"); } Debug.LogError("Please add rooms first."); } if (InitialRoom == null) { if (_DEBUG_MODE) { FileLogger.LogError(">!< No initial room has been set! >!<"); } Debug.LogError("Please specify an initial room first."); } MaxNumberOfRooms = 250; MaxNumberOfExpansionRooms = 250; InitialisingLevel = true; hasExitRoomBeenSuccessfullyAdded = false; MAX_UNSUCCESSFUL_ROOM_REPLACEMENT_ATTEMPTS = Rooms.Length / 3; CURRENT_UNSUCCESSFUL_ROOM_REPLACMENT_ATTEMPTS = 0; if (randomizeSeed || randomizeNumOfRooms || randomizeExpansion) { RandomItem sysRnd = new RandomItem(); if (randomizeSeed) { int newSeed = seed; while (seed == newSeed) { newSeed = sysRnd.GetSystemRandom(1, 9999); } seed = newSeed; } if (randomizeNumOfRooms) { numberOfRooms = sysRnd.GetSystemRandom(1, MaxNumberOfRooms); } if (randomizeExpansion) { expandPathBy = sysRnd.GetSystemRandom(1, MaxNumberOfRooms); // don't exceed the main path rooms } } if (useCanvas && canvasToUse != null) { if (canvasToUse.gameObject.activeSelf) { canvasEvents = canvasToUse.GetComponent <CanvasEvents>(); } else { if (_DEBUG_MODE) { FileLogger.Log("Canvas object is disabled. Turning off the use of the canvas."); } useCanvas = false; } } }
/// <summary> /// Initialize the variables that will be used. /// </summary> /// <param name="rnd">Instance of the RandomItem object to be used.</param> /// <param name="Rooms">The array of room objects to be used.</param> /// <param name="Fragments">The array of fragment objects to be used.</param> public GeneratorSupprtFunctions(RandomItem rnd, Room[] Rooms, Fragment[] Fragments) { this.rnd = rnd; this.Rooms = Rooms; this.wallFragments = Fragments; }