public override void Die() { for (int i = 0; i < DropTable.Length; i++) { if (UnityEngine.Random.value < DropTable[i].DropChancePercent / 100.0f) { var drop = Instantiate(DropTable[i].DropPrefab, Pivot.transform.position, Quaternion.identity); drop.GetComponent <Rigidbody>().velocity = UnityEngine.Random.insideUnitSphere * 5.0f; DropChance.ResetMultiplier(); } } var particle = GetComponentInChildren <ParticleSystem>(); if (particle) { particle.transform.SetParent(null, true); particle.transform.position = Pivot.transform.position; particle.transform.rotation = Pivot.transform.rotation; particle.transform.localScale = Pivot.transform.lossyScale; particle.Emit(100); GameObject.Destroy(particle.gameObject, 2.0f); } Destroy(gameObject, 0.1f); }
public static int GetRandomElementDictionary(DropChance typeEnum) { float[] array; var isExists = DictionaryArrayPercent.TryGetValue(typeEnum, out array); if (isExists == false) { throw new UnityException("It is unknown GameStage in class RandomExtensions"); } return(RandomElementArray(array)); }
private void DropLoot() { for (int i = 0; i < DropTable.Length; i++) { if (UnityEngine.Random.value < DropTable[i].DropChancePercent / 100.0f) { var drop = Instantiate(DropTable[i].DropPrefab, transform.position, Quaternion.identity); drop.GetComponent <Rigidbody>().velocity = UnityEngine.Random.insideUnitSphere * 5.0f; DropChance.ResetMultiplier(); } } }
//---------------- раздача карт по типу private IEnumerator SpawnCardsByType(CardType type, DropChance typeDropChance, DropChance rarityDropChance, int count) { SelectCardInDeck(_poolGameCard); yield return(new WaitForSeconds(0.3f)); SubTypeCard[] arrayType; var arrayRarity = new[] { CardRarity.Common, CardRarity.Rare, CardRarity.Legendary }; switch (type) { case CardType.Equipment: arrayType = new[] { SubTypeCard.Decoration }; break; case CardType.Spell: arrayType = new[] { SubTypeCard.AttackingSpell, SubTypeCard.ImprovingSpell, SubTypeCard.CurseSpell }; break; case CardType.Consumables: arrayType = new[] { SubTypeCard.Consumables }; break; default: throw new UnityException("It is unknown CardType in SpawnCardsByType"); } var typeCard = arrayType[RandomExtensions.GetRandomElementDictionary(typeDropChance)]; var rarity = arrayRarity[RandomExtensions.GetRandomElementDictionary(rarityDropChance)]; var number = 1; foreach (var card in _poolGameCard) { if (number > count) { break; } if (card.activeSelf) { continue; } var cardDisplay = card.GetComponent <ActionsWithCards>(); var randomCard = _objectStorage.GetRandomCardByType(typeCard, rarity); cardDisplay.СhangeCardType(randomCard); cardDisplay.SetIdCard(number); cardDisplay.CardGame.DisplayCardInGame(card); cardDisplay.SetDependecies(_publisher, _animaManager); card.SetActive(true); _animaManager.SetStateAnimation(card, "dist_num", number); yield return(new WaitForSeconds(0.2f)); ++number; } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Boundary")) { return; } if (other.tag == "Enemy") { return; } if (other.tag == "PickUp") { return; } Destroy(other.gameObject); Destroy(gameObject); if (explosion != null) { Instantiate(explosion, transform.position, transform.rotation); } if (other.tag == "Player") { Instantiate(playerExplosion, other.transform.position, other.transform.rotation); gameController.GameOver(); } if (CompareTag("Bolt") == false || CompareTag("Player") == true) //&& other.CompareTag ("Bolt") == false) { { Debug.Log("Rolling Drop for this Collision"); foreach (GameObject drop in dropList) { DropChance chance = drop.GetComponent <DropChance> (); if (chance != null) { if (Random.value <= chance.chanceValue) { Instantiate(drop, transform.position, transform.rotation); break; } } } } if (other.tag == "Bolt") { gameController.AddScore(scoreValue); } }
protected override void CompileLayout(SuperGumpLayout layout) { layout.Add( "background", () => { AddBackground(0, 40, 694, 360, 2600); AddImage(242, 17, 1419); AddImage(319, -1, 1417); AddImage(328, 8, 9012); AddBackground(50, 85, 591, 264, 9270); AddBackground(63, 96, 566, 240, 9200); AddLabel(53, 64, 0, @"Level Editor"); AddLabel(57, 360, 0, @"Accept?"); AddButton(118, 360, 2074, 2076, OnAccept); }); layout.Add( "MaxKills", () => { AddBackground(71, 124, 121, 28, 9350); AddLabel(71, 105, 0, @"Max Kills for Level"); AddTextEntryLimited(72, 128, 116, 20, TextHue, MaxKills.ToString(CultureInfo.InvariantCulture), 4, (b, t) => { int sMobs; if (Int32.TryParse(t, out sMobs)) { MaxKills = Math.Max(0, sMobs); } }); }); layout.Add( "TimeLimit", () => { AddBackground(71, 169, 121, 28, 9350); AddLabel(71, 150, 0, @"Time Limit for Level"); AddTextEntryLimited(72, 173, 116, 20, TextHue, TimeLimit.TotalHours.ToString(), 4, (b, t) => { double sTime; if (double.TryParse(t, out sTime)) { TimeLimit = TimeSpan.FromHours(sTime); } }); }); layout.Add( "ConcurrentInvaders", () => { AddLabel(71, 195, 0, @"Concurrent Invaders"); AddBackground(71, 214, 121, 28, 9350); AddTextEntryLimited(72, 218, 116, 20, TextHue, ConcurrentInvaders.ToString(CultureInfo.InvariantCulture), 4, (b, t) => { int sMobs; if (Int32.TryParse(t, out sMobs)) { ConcurrentInvaders = Math.Max(1, sMobs); } }); }); layout.Add( "InvaderTitles", () => { AddBackground(71, 259, 143, 28, 9350); AddLabel(71, 240, 0, @"Invader Titles"); AddTextEntryLimited(72, 263, 139, 20, TextHue, InvaderTitles, 20, (b, t) => InvaderTitles = t); }); layout.Add( "Platinum", () => { AddBackground(71, 304, 121, 28, 9350); AddLabel(71, 285, 0, @"Platinum"); AddTextEntryLimited(72, 308, 116, 20, TextHue, Plat.ToString(), 4, (b, t) => { int sPlat; if (Int32.TryParse(t, out sPlat)) { Plat = Math.Max(0, sPlat); } }); }); layout.Add( "Creatures", () => { AddLabel(256, 105, 0, @"Creatures"); AddLabel(256, 315, 0, @"Add Creature?"); AddButton(356, 315, 2074, 2076, b => Send(new CreatureTypesGump(User, Level, Hide()))); if (PageCount - 1 > Page) { AddButton(387, 300, 2224, 2224, NextPage); } if (Page > 0) { AddButton(358, 300, 2223, 2223, PreviousPage); } }); layout.Add( "regularMobItems", () => { AddLabel(427, 105, 0, @"Items"); AddLabel(427, 315, 0, @"Add Item?"); AddButton(495, 315, 2074, 2076, b => Send(new ItemTypesGump(User, Level, Hide()))); }); layout.Add( "DropChance", () => { AddBackground(546, 124, 65, 28, 9350); AddLabel(546, 105, 0, @"Drop Chance"); AddTextEntryLimited(547, 128, 60, 20, TextHue, DropChance.ToString(CultureInfo.InvariantCulture), 4, (b, t) => { double chance; if (Double.TryParse(t, out chance)) { DropChance = Math.Max(0, chance); } }); }); Dictionary <int, Type> range = GetListRange(); if (range.Count > 0) { CompileEntryLayout(layout, range); } }