public static void ColorizeSlashText(CurrencyTypes currencyType, int requiredAmount, TextMeshProUGUI txtField, Button btn = null) { int amount = currencyType.GetAmount(); bool hasSufficient = amount >= requiredAmount; txtField.text = amount + "/" + requiredAmount; txtField.color = hasSufficient ? Color.white : Color.red; if (btn) { btn.interactable = hasSufficient; } }
public void UpdateCounter() { int amount = currency.GetAmount(); counter.text = amount.ToString(); if (amount <= 0) { bg.color = icon.color = new Color(0.5f, 0.5f, 0.5f, 1); } else { bg.color = icon.color = Color.white; } }
public void NotifyCurrency(CurrencyTypes currency, int before = -1) { if (signals == null) { return; } if (before < 0) { before = _currencies[currency]; } if (signals.OnChangedCurrency != null) { signals.OnChangedCurrency(currency.GetAmount(), before, currency); } }
public void SummonHeroAction(SummonType type, Action <Hero> callback = null) { CurrencyTypes scrollType = CurrencyManager.ConvertSummonTypeToCurrency(type); int scrollsTotal = scrollType.GetAmount(); if (scrollsTotal < 1) { throw new Exception("Unsufficient scrolls to summon the specified type: " + type + " => " + scrollType + ", scrolls: " + scrollsTotal); } int Seed = GetSeed(); isSummonComplete = false; List <HeroData> possibleSummons = new List <HeroData>(); HeroType summonType = HeroType.Monster; ElementalTypes ElementalType = ElementalTypes.None; float chance = Random.Range(0f, 1f); // Determine the type of hero to summon switch (type) { case SummonType.Common: if (chance <= GlobalProps.SUMMON_COMMON_HERO.GetFloat()) { summonType = HeroType.Hero; } else if (chance <= (GlobalProps.SUMMON_COMMON_HERO.GetFloat() + GlobalProps.SUMMON_COMMON_SOLDIER.GetFloat())) { summonType = HeroType.Soldier; } else { summonType = HeroType.Monster; } break; case SummonType.Rare: if (chance <= GlobalProps.SUMMON_RARE_HERO.GetFloat()) { summonType = HeroType.Hero; } else if (chance <= (GlobalProps.SUMMON_RARE_HERO.GetFloat() + GlobalProps.SUMMON_RARE_MONSTER.GetFloat())) { summonType = HeroType.Monster; } else { summonType = HeroType.Soldier; } break; case SummonType.MonsterFire: ElementalType = ElementalTypes.Fire; break; case SummonType.MonsterWater: ElementalType = ElementalTypes.Water; break; case SummonType.MonsterNature: ElementalType = ElementalTypes.Nature; break; case SummonType.MonsterDark: ElementalType = ElementalTypes.Dark; break; case SummonType.MonsterLight: ElementalType = ElementalTypes.Light; break; } possibleSummons = dataMan.heroDataList.FindAll(h => h.Type == summonType && h.AwokenReference == null); // Get the hero data list based on the types if (ElementalType != ElementalTypes.None) { // Summon w/ element (filter again from the above filtered list) possibleSummons = possibleSummons.FindAll(h => h.ElementalType == ElementalType); } Dictionary <HeroData, float> HeroChance = new Dictionary <HeroData, float>(); foreach (HeroData hd in possibleSummons) { HeroChance.Add(hd, hd.Rarity); } // Get the hero from the list int summonIndex = Random.Range(0, possibleSummons.Count); trace(summonIndex); //eroChance.GetRandom(); HeroData heroData = MathHelper.WeightedRandom(HeroChance).Key; //possibleSummons[summonIndex]; //heroData = dataMan.heroDataList.GetByIdentity("hero_rareassassin"); // for testing awakening Hero tempHero = new Hero(heroData, Seed); trace("-- Summoning a hero: " + tempHero.Name + " [" + tempHero.Quality + "] (possibilities: " + possibleSummons.Count + ")\n" + (scrollsTotal - 1)); SummonInterface summonUI = (SummonInterface)MenuManager.Instance.Push("Interface_SummonHero"); //First, do the currency transaction: API.Currency.AddCurrency(scrollType, -1) //Then, do the actual adding of the new hero: .Then(res => API.Heroes.Add(tempHero)) .Then(res => { Hero SelectedHero = dataMan.ProcessHeroData(res["newest"].AsArray[0]); summonUI.Initialize(SelectedHero); if (callback != null) { callback(SelectedHero); } if (signals.OnHeroCreated != null) { signals.OnHeroCreated(SelectedHero); } }); }