public void BtnShardItem() { if (selectedItem == null) { return; } //selectedItem.ConvertToCommonShards(); Debug.LogError(" --- Shard Item here"); CurrencyTypes type = selectedItem.GetDisenchantType(); int value = selectedItem.GetDisenchantValue(type); CurrencyManager.Cost shards = type.ToCostObj(value); string shardInfo = shards.amount + " " + shards.type.ToString().Replace('_', ' '); string q = "Are you sure you\nwant to shard this\nitem?"; ConfirmYesNoInterface.Ask("Confirm Shards", q) .Then(answer => { if (answer != "YES") { return; } AudioManager.Instance.Play(SFX_UI.ShardsChing); DataManager.API.Currency.AddCurrency(shards) .Then(res => DataManager.API.Items.Remove(selectedItem)) .Then(res => RemoveFromInventory(selectedItem)); itemDetails.Hide(); }); }
public void BtnAffixChange() { if (selectedItem == null) { return; } CurrencyManager.Cost cost = GetEnchantValue(true); if (HasUnsufficientShards(cost, true)) { ConfirmYesNoInterface.Ask("Confirm Shards", "Are you sure you\nwant to adjust the\n affixes of this item?\n<color=#ff5555>This will alter the\naffixes and can't be\n undone.</color>") .Then(answer => { if (answer != "YES") { return; } AudioManager.Instance.Play(SFX_UI.ShardsChing); StartCoroutine(FadeToWhite()); DataManager.API.Currency.AddCurrency(cost) .Then(res => { selectedItem.RerollAffixes(); OnRerollSuccess(); }) .Catch(err => { Debug.LogError("Could not spend Shards in AffixChange: " + err); }); }); } else { AudioManager.Instance.Play(SFX_UI.Invalid); } }
// The costs for enchanting are determined here, you can change these CurrencyManager.Cost GetEnchantValue(bool forAffix = false) { CurrencyManager.Cost shards = new CurrencyManager.Cost(); switch (selectedItem.Quality) { case ItemQuality.Magic: if (forAffix) { // 7 common, 2 magic shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_COMMON, -7); shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_MAGIC, -2); } else { // 5 common, 1 magic shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_COMMON, -5); shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_MAGIC, -1); } return(shards); case ItemQuality.Rare: if (forAffix) { // 7 common, 3 magic shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_COMMON, -7); shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_MAGIC, -3); } else { // 5 common, 1 rare shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_COMMON, -5); shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_RARE, -1); } return(shards); case ItemQuality.Unique: if (forAffix) { // 13 common, 5 rare shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_COMMON, -13); shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_RARE, -3); } else { // 10 common, 3 rare shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_COMMON, -10); shards.AddOrSet(CurrencyTypes.SHARDS_ITEMS_RARE, -3); } return(shards); case ItemQuality.Common: default: return(shards); } }
public void Btn_Shard() { if (!Close()) { return; //Prevents multiple clicks/taps } // TODO trace("TODO", "Remove the item and add the value * marketfees (like 20% of buy value or something) of it to the currency"); Debug.Log("Shard Gear - [C: " + item.ConvertToCommonShards() + "][M: " + item.ConvertToMagicShards() + "][R: " + item.ConvertToRareShards() + "][U: " + item.ConvertToUniqueShards() + "]"); CurrencyManager.Cost shards = null; switch (item.Quality) { case ItemQuality.Common: shards = CurrencyTypes.SHARDS_ITEMS_COMMON.ToCostObj(item.ConvertToCommonShards()); break; case ItemQuality.Magic: shards = CurrencyTypes.SHARDS_ITEMS_MAGIC.ToCostObj(item.ConvertToMagicShards()); break; case ItemQuality.Rare: shards = CurrencyTypes.SHARDS_ITEMS_RARE.ToCostObj(item.ConvertToRareShards()); break; case ItemQuality.Unique: shards = CurrencyTypes.SHARDS_ITEMS_RARE.ToCostObj(item.ConvertToUniqueShards()); break; } string shardInfo = shards.amount + " " + shards.type.ToString().Replace('_', ' '); string q = "Are you sure you\nwant to shard this\nitem?\n<size=+5><color=#a00>{0}</color></size>".Format2(shardInfo); ConfirmYesNoInterface.Ask("Confirm Shards", q) .Then(answer => { if (answer != "YES") { return; } AudioManager.Instance.Play(SFX_UI.ShardsChing); API.Currency.AddCurrency(shards) .Then(res => API.Items.Remove(item)) .Then(res => RemoveFromInventory(item)); }); }
bool HasUnsufficientShards(CurrencyManager.Cost cost, bool affixCost = false) { if (cost.Count <= 0) { return(false); } foreach (CurrencyTypes type in cost.Keys) { if (cost[type] > type.GetAmount()) { return(false); } } return(true); }
void SwapItems(Item itemPrevious, Item item, CurrencyManager.Cost cost) { API.Items.Unequip(itemPrevious, cost.type, cost.amount) .Then(res => { audioMan.Play(SFX_UI.Coin); trace("Successfully unequipped before swapping with item " + item.DebugID); itemPrevious.heroID = 0; Equipped.Remove(item.data.EquipType); CloseButton.interactable = true; Equip(item); }) .Catch(err => { traceError("Error unequipping previously equipped Item {0}: {1}".Format2(itemPrevious.DebugID, err.Message)); }); }
public void BtnPurchase() { ConfirmYesNoInterface.Ask("Confirm Purchase", "Purchase\n" + currency + "\nfor <color=#ff5555>" + value + " Gems</color>?") .Then(answer => { if (answer != "YES") { return; } AudioManager.Instance.Play(SFX_UI.ShardsChing); CurrencyManager.Cost cost = CurrencyTypes.GEMS.ToCostObj(-value); DataManager.API.Currency.AddCurrency(cost) .Then(res => { DataManager.API.Currency.AddCurrency(type, 1); }) .Catch(err => { Debug.LogError("Could not spend Shards in PowerChange: " + err); }); }); }
void Start() { if (!DataManager.Instance.isLoaded) { return; } Instance = this; _dateLastRefreshed = DateTime.MinValue; string refreshCostStr = GlobalProps.SHOP_REFRESH_KEY_COST.GetString(); REFRESH_COST = CurrencyManager.ParseToCost(refreshCostStr); txtRefreshCost.text = "REFRESH FOR " + REFRESH_COST.amount; UpdateSortedInventoryItems(); Btn_ShowStoreBuyMenu(); }
IEnumerator ResurrectForGems(ActiveExploration activeZone) { bool optionSelected = false; // popup here string q = "Would you like to\ntry again?\n<color=#2fb20e>25 Gems</color>"; ConfirmYesNoInterface.Ask("Resurrect", q) .Then(answer => { if (answer != "YES") { optionSelected = true; BattleResultsInterface battleResultsPanel = (BattleResultsInterface)MenuManager.Instance.Load("Interface_BattleResults"); battleResultsPanel.Initialize(0, 0, 0, activeZone, true); } else { AudioManager.Instance.Play(SFX_UI.ShardsChing); CurrencyManager.Cost cost = CurrencyTypes.GEMS.ToCostObj(dataMan.globalData.GetGlobalAsInt(GlobalProps.BATTLE_RESURRECTION_COST)); DataManager.API.Currency.AddCurrency(cost) .Then(res => { optionSelected = true; UnityEngine.SceneManagement.SceneManager.LoadScene("BossBattle"); }); } }); while (!optionSelected) { yield return(new WaitForEndOfFrame()); } }
void STATE_Currency() { int COIN_AMOUNT = 1000; int SCROLLS_AMOUNT = 10; int SHARDS_AMOUNT = 10; int RELIC_AMOUNT = 10; int ESSENCE_AMOUNT = 10; int BOOST_AMOUNT = 1; if (changedState) { traceCheats("CURRENCY: Add " + COIN_AMOUNT + " of [G]old, G[e]ms, Scrolls-[I]dentify, Scrolls-[S]ummon, Scrolls-[M]onster, [B]oosts, [A]ll" + _EST_TO_EXIT); } IPromise <NodeResponse> promise = null; if (Input.GetKeyDown(KeyCode.G)) { AUDIO.Play(SFX_UI.Coin); promise = API.Currency.AddCurrency(CurrencyTypes.GOLD, COIN_AMOUNT); } if (Input.GetKeyDown(KeyCode.E)) { AUDIO.Play(SFX_UI.ShardsChing); promise = API.Currency.AddCurrency(CurrencyTypes.GEMS, COIN_AMOUNT); } if (Input.GetKeyDown(KeyCode.I)) { AUDIO.Play(SFX_UI.Identify); promise = API.Currency.AddCurrency(CurrencyTypes.SCROLLS_IDENTIFY, SCROLLS_AMOUNT); } if (Input.GetKeyDown(KeyCode.S)) { AUDIO.Play(SFX_UI.WooshIn); var cost = new CurrencyManager.Cost(); cost.AddOrSet(CurrencyTypes.SCROLLS_IDENTIFY, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_COMMON, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_RARE, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_DARK, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_FIRE, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_LIGHT, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_WATER, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_NATURE, SCROLLS_AMOUNT); promise = API.Currency.AddCurrency(cost); } if (Input.GetKeyDown(KeyCode.M)) { AUDIO.Play(SFX_UI.WooshIn); promise = API.Currency.AddCurrency(CurrencyTypes.SCROLLS_SUMMON_MONSTER_DARK, SCROLLS_AMOUNT); } if (Input.GetKeyDown(KeyCode.B)) { AUDIO.Play(SFX_UI.PageFlip); var boostCost = new CurrencyManager.BoostCost(); boostCost.AddOrSet(BoostType.Gold, BOOST_AMOUNT); boostCost.AddOrSet(BoostType.MagicFind, BOOST_AMOUNT); boostCost.AddOrSet(BoostType.Health, BOOST_AMOUNT); boostCost.AddOrSet(BoostType.XP, BOOST_AMOUNT); promise = API.Users.BoostAddCurrency(boostCost); } if (Input.GetKeyDown(KeyCode.A)) { AUDIO.Play(SFX_UI.ShardsChing); var cost = new CurrencyManager.Cost(); cost.AddOrSet(CurrencyTypes.GOLD, COIN_AMOUNT); cost.AddOrSet(CurrencyTypes.GEMS, COIN_AMOUNT); cost.AddOrSet(CurrencyTypes.MAGIC_ORBS, COIN_AMOUNT); cost.AddOrSet(CurrencyTypes.ESSENCE_HIGH, ESSENCE_AMOUNT); cost.AddOrSet(CurrencyTypes.ESSENCE_LOW, ESSENCE_AMOUNT); cost.AddOrSet(CurrencyTypes.ESSENCE_MID, ESSENCE_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_IDENTIFY, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_COMMON, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_RARE, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_DARK, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_FIRE, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_LIGHT, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_WATER, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SCROLLS_SUMMON_MONSTER_NATURE, SCROLLS_AMOUNT); cost.AddOrSet(CurrencyTypes.SHARDS_ITEMS_COMMON, SHARDS_AMOUNT); cost.AddOrSet(CurrencyTypes.SHARDS_ITEMS_MAGIC, SHARDS_AMOUNT); cost.AddOrSet(CurrencyTypes.SHARDS_ITEMS_RARE, SHARDS_AMOUNT); cost.AddOrSet(CurrencyTypes.SHARDS_ITEMS_RARE, SHARDS_AMOUNT); cost.AddOrSet(CurrencyTypes.XP_FRAGMENT, SHARDS_AMOUNT); cost.AddOrSet(CurrencyTypes.XP_FRAGMENT, SHARDS_AMOUNT); cost.AddOrSet(CurrencyTypes.XP_FRAGMENT_PLUS, SHARDS_AMOUNT); cost.AddOrSet(CurrencyTypes.XP_FRAGMENT_PLUS, SHARDS_AMOUNT); cost.AddOrSet(CurrencyTypes.RELICS_BOW, RELIC_AMOUNT); cost.AddOrSet(CurrencyTypes.RELICS_SHIELD, RELIC_AMOUNT); cost.AddOrSet(CurrencyTypes.RELICS_STAFF, RELIC_AMOUNT); cost.AddOrSet(CurrencyTypes.RELICS_SWORD, RELIC_AMOUNT); var boostCost = new CurrencyManager.BoostCost(); boostCost.AddOrSet(BoostType.Gold, BOOST_AMOUNT); boostCost.AddOrSet(BoostType.MagicFind, BOOST_AMOUNT); boostCost.AddOrSet(BoostType.Health, BOOST_AMOUNT); boostCost.AddOrSet(BoostType.XP, BOOST_AMOUNT); promise = API.Users.BoostAddCurrency(boostCost) .Then(res => { traceCheats("Boost Currency set: " + res.pretty); return(API.Currency.AddCurrency(cost)); }); } if (promise != null) { promise.Then(res => { traceCheats("Currency set: " + res.pretty); }); } }
void SelectItem(Item item) { selectedItem = item; inventory.Btn_Hide(); itemDetails.LoadItem(item); if (!item.isIdentified) { BtnPower.interactable = false; BtnAffix.interactable = false; SetEnchantButtonTextColors(new Color(0.5f, 0.5f, 0.5f, 1f)); } else { // Set the enchanting prices based on the rarity of the items // globals? BtnPower.interactable = true; BtnAffix.interactable = true; SetEnchantButtonTextColors(Color.white); int commonCount = CurrencyTypes.SHARDS_ITEMS_COMMON.GetAmount(); int magicCount = CurrencyTypes.SHARDS_ITEMS_MAGIC.GetAmount(); int rareCount = CurrencyTypes.SHARDS_ITEMS_RARE.GetAmount(); CurrencyManager.Cost powerCost = GetEnchantValue(); CurrencyManager.Cost affixCost = GetEnchantValue(true); if (powerCost.Count > 0) { int index = 0; foreach (CurrencyTypes type in powerCost.Keys) { PowerLabels[index].gameObject.SetActive(true); PowerLabels[index].Init(type.GetAmount() + "/" + -powerCost[type], GetShardSprite(type)); if (type.GetAmount() < powerCost[type]) { PowerLabels[index].SetColor(Color.red); } index++; } index = 0; foreach (CurrencyTypes type in affixCost.Keys) { AffixLabels[index].Init(type.GetAmount() + "/" + -affixCost[type], GetShardSprite(type)); if (type.GetAmount() < affixCost[type]) { AffixLabels[index].SetColor(Color.red); } index++; } for (index = powerCost.Count; index < PowerLabels.Count; index++) { PowerLabels[index].gameObject.SetActive(false); } for (index = affixCost.Count; index < AffixLabels.Count; index++) { AffixLabels[index].gameObject.SetActive(false); } } else { BtnPower.interactable = false; BtnAffix.interactable = false; SetEnchantButtonTextColors(new Color(0.5f, 0.5f, 0.5f, 1f)); foreach (EnchantingCostIcon icon in PowerLabels) { icon.ShowNoCost(); } foreach (EnchantingCostIcon icon in AffixLabels) { icon.ShowNoCost(); } } } }
void AwakenHero() { Debug.Log("Awaken Hero"); Random.InitState(GameManager.Instance.GetSeed()); // Get the target hero Identity string newHeroIdentity = ""; List <HeroData> heroList = DataManager.Instance.heroDataList.FindAll(h => ((h.AwokenReference != null) ? h.AwokenReference.Identity == hero.data.Identity : false)); if (heroList.Count < 1) { Debug.LogError("[Error] No heroes to awaken to"); return; } print("Awaken Options: " + heroList.Count); newHeroIdentity = heroList[Random.Range(0, heroList.Count)].Identity; // Get the cost of the awaken CurrencyManager.Cost cost = new CurrencyManager.Cost(); switch (hero.data.Class) { case HeroClass.Assassin: cost.AddOrSet(CurrencyTypes.RELICS_BOW, 1); break; case HeroClass.Tank: cost.AddOrSet(CurrencyTypes.RELICS_SHIELD, 1); break; case HeroClass.Mage: cost.AddOrSet(CurrencyTypes.RELICS_STAFF, 1); break; default: case HeroClass.Bruiser: cost.AddOrSet(CurrencyTypes.RELICS_SWORD, 1); // Already set to sword break; } cost.AddOrSet(CurrencyTypes.ESSENCE_HIGH, 15); // Swap the identity to preserve the hero seeds and levels GameAPIManager.Instance.Heroes.SwapIdentity(hero, newHeroIdentity, cost) .Then((res) => { //hero = DataManager.Instance.allHeroesList. print("updated to " + hero.data.Identity); // Destroy the old hero ui piece Destroy(heroRef); // Update the current UI with the new hero UIModel heroRef = Instantiate(hero.LoadUIAnimationReference(), ModelContainer); RectTransform heroRT = heroRef.GetComponent <RectTransform>(); heroRT.anchorMin = new Vector2(0.5f, 0f); heroRT.anchorMax = new Vector2(0.5f, 0f); heroRT.pivot = new Vector2(0.5f, 0f); heroRT.anchoredPosition = new Vector2(0f, 50f); heroRT.localScale *= 2.5f; // Update the hero details interface with the new hero heroInterface.Initialize(hero, heroInterface.campHeroInterface); // Populate Hero List heroInterface.campHeroInterface.PopulateHeroList(); }); }
IEnumerator UpgradeSequence() { // Switch buttons to just an OK AcceptButton.gameObject.SetActive(false); CancelButton.gameObject.SetActive(false); ContinueButton.gameObject.SetActive(true); // full sequence for an Awaken // Flash flashImg.DOColor(new Color(1f, 1f, 1f, 1f), 0.75f).SetEase(Ease.InCubic); StarContainer.DOScale(0f, 0.5f); AwakenContainer.DOScale(0f, 0.5f); yield return(new WaitForSeconds(0.75f)); // Do the upgrade here // replace this with the actual quality increase after testing is complete int quality = (int)hero.Quality + 1; // Need to charge the user for the upgrade and feed it through the API Around here //if () if (quality <= (int)HeroQuality.Legendary) { // Consume currency here CurrencyManager.Cost cost = new CurrencyManager.Cost(); switch (hero.data.Class) { case HeroClass.Assassin: cost.AddOrSet(CurrencyTypes.RELICS_BOW, -1); break; case HeroClass.Tank: cost.AddOrSet(CurrencyTypes.RELICS_SHIELD, -1); break; case HeroClass.Mage: cost.AddOrSet(CurrencyTypes.RELICS_STAFF, -1); break; default: case HeroClass.Bruiser: cost.AddOrSet(CurrencyTypes.RELICS_SWORD, -1); // Already set to sword break; } switch (hero.Quality) { case HeroQuality.Common: cost.AddOrSet(CurrencyTypes.ESSENCE_LOW, -25); break; case HeroQuality.Rare: cost.AddOrSet(CurrencyTypes.ESSENCE_MID, -15); break; case HeroQuality.Legendary: cost.AddOrSet(CurrencyTypes.ESSENCE_HIGH, -15); break; } GameAPIManager.Instance.Currency.AddCurrency(cost); hero.IncreaseQuality(); StartCoroutine(ResultStarTransitionIn(quality, 0.3f)); } else { AwakenHero(); AwakenText.text = "Awoken"; AwakenContainer.DOScale(1f, 0.5f); } // Wait for loaded Assets if needed yield return(new WaitForSeconds(0.25f)); // Ease out flash flashImg.DOColor(new Color(0.5f, 0.5f, 0.5f, 0f), 0.5f).SetEase(Ease.OutCubic); // Show star gain if it was a non-awaken upgrade if (hero.Quality < HeroQuality.Legendary) { StarContainer.gameObject.SetActive(false); ResultStarContainer.gameObject.SetActive(true); } }