private void SpawnBomb() { List <GameObject> fullSlots = new List <GameObject>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (GameManager.StateManager.StateName == States.PlayStateBomb && GameManager.GameManagerInstance.MatrixArray[i, j].transform.childCount > 0) { if (GameManager.GameManagerInstance.MatrixArray[i, j].transform.GetChild(0).tag == "Bomb") { //decrease bomb timer GameManager.GameManagerInstance.MatrixArray[i, j].transform.GetChild(0).GetComponent <Durability>().DecreaseBombDurability(); } } if (GameManager.GameManagerInstance.MatrixArray[i, j].transform.childCount > 0) { fullSlots.Add(GameManager.GameManagerInstance.MatrixArray[i, j]); } } } int rand = RandomWithProbability.GetRandomValue(new RandomWithProbability.RandomSelection(0, 0, 0.8f), new RandomWithProbability.RandomSelection(1, 1, 0.2f)); if (rand == 1) { switch (GameManager.StateManager.StateName) { case States.PlayStateBomb: // get childs container class(holds valuable info for itself) int rand2 = UnityEngine.Random.Range(0, fullSlots.Count - 1); Transform parent = fullSlots[rand2].transform; Destroy(parent.GetChild(0).gameObject); Debug.Log("Bomb"); //lets set our children's parent to their collided slot GameObject clone = (GameObject)Instantiate(GameManager.GameManagerInstance.Bomb, parent.transform); clone.GetComponent <Durability>().durability = UnityEngine.Random.Range(10, 17); clone.GetComponent <Durability>().Start(); clone.transform.SetParent(parent); //we set our children's scale to fit the slot's scale clone.transform.localScale = parent.transform.localScale; clone.transform.GetChild(0).localScale = new Vector3(3, 3, 3); return; } } }
public IpAddressGenerator(RandomWithProbability random, ElementWithProbability <int> uniqueIpCount) { _random = random; _counter = 0; uniqueIpList = new List <IpAddress>(uniqueIpCount.Value); while (uniqueIpCount.Value != uniqueIpList.Count) { oneIp = GenerateOnlyIpAddress(); if (uniqueIpList.Contains(oneIp)) { continue; } uniqueIpList.Add(oneIp); _counter++; } _counter = 0; }
public UserIdGenerator(RandomWithProbability random) { _random = random; _reservedId = Enumerable.Range(count, count + countIncrement).ToList(); }
public RequestLineGenerator(RandomWithProbability random, RequestLineParameters parameters) { _random = random; _parameters = parameters; }
public void SpawnItems() { GetComponent <Animator>().SetTrigger("Spawn"); for (int i = 0; i < 3; i++) { #region InstantiateAndSetColor //get the color randomly Color temp = GameManager.ColorManager.TurnRandomColorFromTheme(); GameObject Clone; //instantiate switch (GameManager.StateManager.StateName) { case States.PlayState: Clone = (GameObject)Instantiate(GameManager.GameManagerInstance.ClassicModeItems[Random.Range(0, GameManager.GameManagerInstance.ClassicModeItems.Length)], SpawnSlotList[i].transform); foreach (Image image in Clone.GetComponentsInChildren <Image>().ToList()) { //set the color of children if (image.color.a != 0) //this is for touch area { image.GetComponent <Canvas>().sortingOrder = 5; if (image.gameObject.tag != "Rock") { image.color = temp; } //change sprite theme here switch (theme) { case BlockTheme.Classic: image.sprite = BlockSpriteThemes[0]; break; case BlockTheme.New: image.sprite = BlockSpriteThemes[1]; break; default: break; } } } break; case States.PlayStateRockSolid: int rand = RandomWithProbability.GetRandomValue(new RandomWithProbability.RandomSelection(0, GameManager.GameManagerInstance.ClassicModeItems.Length - 1, 0.9f), new RandomWithProbability.RandomSelection(GameManager.GameManagerInstance.ClassicModeItems.Length, GameManager.GameManagerInstance.RockSolidModeItems.Length - 1, 0.1f)); Clone = (GameObject)Instantiate(GameManager.GameManagerInstance.RockSolidModeItems[rand], SpawnSlotList[i].transform); int rndm = UnityEngine.Random.Range(1, 4); foreach (Image image in Clone.GetComponentsInChildren <Image>().ToList()) { //set the color of children if (image.color.a != 0) { image.GetComponent <Canvas>().sortingOrder = 5; if (image.gameObject.tag != "Rock") { image.color = temp; //change sprite theme here switch (theme) { case BlockTheme.Classic: image.sprite = BlockSpriteThemes[0]; break; case BlockTheme.New: image.sprite = BlockSpriteThemes[1]; break; default: break; } } else if (Clone.CompareTag("Rock")) { GameObject block = image.gameObject; block.GetComponent <Durability>().durability = rndm; //change sprite theme here int drb = block.GetComponent <Durability>().durability; switch (drb) { case 1: image.sprite = RockSprites[0]; break; case 2: image.sprite = RockSprites[1]; break; case 3: image.sprite = RockSprites[2]; break; case 4: image.sprite = RockSprites[3]; break; default: break; } } } } break; case States.PlayStateBomb: Clone = (GameObject)Instantiate(GameManager.GameManagerInstance.ClassicModeItems[Random.Range(0, GameManager.GameManagerInstance.ClassicModeItems.Length)], SpawnSlotList[i].transform); foreach (Image image in Clone.GetComponentsInChildren <Image>().ToList()) { //set the color of children if (image.color.a != 0) { if (image.gameObject.tag != "Rock") { image.color = temp; //change sprite theme here switch (theme) { case BlockTheme.Classic: image.sprite = BlockSpriteThemes[0]; break; case BlockTheme.New: image.sprite = BlockSpriteThemes[1]; break; default: break; } } //change sprite theme here switch (theme) { case BlockTheme.Classic: image.sprite = BlockSpriteThemes[0]; break; case BlockTheme.New: image.sprite = BlockSpriteThemes[1]; break; default: break; } image.GetComponent <Canvas>().sortingOrder = 5; } } break; default: throw new System.Exception("Spawn Error"); } #endregion } }
public DateGenerator(RandomWithProbability random) { _random = random; _initialDate = new DateTime(random.Next(2011, 2013), DateTime.Now.Month - random.Next(0, DateTime.Now.Month), DateTime.Now.Day - random.Next(0, DateTime.Now.Day)); }
public FileSizeGenerator(RandomWithProbability random) { _random = random; }
public CodeDefinitionGenerator(RandomWithProbability random, IReadOnlyList <ElementWithProbability <int> > codes) { _random = random; _codes = codes; }