private void Btn_Unlock()
    {
        var cost = trayInfo.costToUnlock[this.slotID];

        if (!isUnlockable())
        {
            ConfirmYesNoInterface.Ask("Research Lab", "You need\n<color={0}><size=+20>{2} {1}</size></color>\nto unlock this slot.".Format2(ColorConstants.HTML_GOLD, cost.type, cost.amount), "OK");
            return;
        }

        ConfirmYesNoInterface.Ask("Research Lab", "Would you like\nto unlock this\nResearch Slot?\n<size=+20><color={0}>{2} {1}</color></size>".Format2(ColorConstants.HTML_GOLD, cost.type, cost.amount))
        .Then(answer => {
            if (answer == "NO")
            {
                TimelineTween.ShakeError(this.gameObject);
                return;
            }

            ChangeStatus(ResearchSlotStatus.UNLOCKED, cost.type, cost.amount)
            .Then(slot => {
                FXPulse(imgStatus.transform);
                INTERFACE.UpdateAllSlots();
            });
        });
    }
    public void Btn_Details()
    {
        if (_item.isResearched)
        {
            ConfirmYesNoInterface.Ask("Researched Item", "Cannot bring up details of items in research.", "OK");
            return;
        }

        _details = ItemDetailsInterface.Open(_item);
        _details.btnEnchant.gameObject.SetActive(false);

        //_item.isIdentified = false;
        trace("Value " + _item.Value +
              ", SellValue " + _item.SellValue +
              ", ItemTier " + _item.data.Tier +
              ", ItemLevel " + _item.ItemLevel +
              ", Item Quality " + _item.QualitySeed
              );

        switch (_transactionType)
        {
        case StoreTransactionType.Buy:
            _details.AddButton("Buy\n<color={0}>(-{1} gold)</color>".Format2(ColorConstants.HTML_GOLD, _item.Value), Btn_Buy);
            break;

        case StoreTransactionType.Sell:
            _detailsSell = _details.AddButton(GetSellValueButtonLabel(), Btn_Sell);
            break;
        }
    }
Example #3
0
    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 static ConfirmYesNoInterface AskCustom(string title, string interfaceName, params string[] labels)
    {
        ConfirmYesNoInterface confirm = (ConfirmYesNoInterface)menuMan.Load("Interface_ConfirmYesNo");

        confirm._promise        = new Promise <string>();
        confirm.labelTitle.text = title;
        confirm.labelConfirm.gameObject.SetActive(false);
        confirm.CreateButtonsFromLabels(labels);

        GameObject prefab = Resources.Load <GameObject>("Interfaces/" + interfaceName);
        GameObject custom = Instantiate <GameObject>(prefab);

        custom.transform.SetParent(confirm.CustomArea);
        custom.transform.localScale    = Vector2.one;
        custom.transform.localPosition = Vector2.zero;

        TMP_InputField input = custom.GetComponentInChildren <TMP_InputField>();

        if (input != null)
        {
            input.Select();
            input.ActivateInputField();
        }

        return(confirm);
    }
Example #5
0
    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);
        }
    }
Example #6
0
 public void Btn_RetireHero()
 {
     ConfirmYesNoInterface.Ask("Retire Hero", "Are you sure, this\nhero will no longer\nbe accessible?").Then(answer => {
         if (answer == "YES")
         {
             RetireConfirm();
         }
     });
 }
Example #7
0
    void TryEquip(Item item)
    {
        if (item.heroID > 0)
        {
            traceError("Item {0} is already equipped by Hero #{1}, unequip it first.".Format2(item.DebugID, item.heroID));
            return;
        }

        EquipmentType type = item.data.EquipType;

        if (!Equipped.ContainsKey(type))
        {
            Equip(item);
            return;
        }

        //If we already have an item on this EquipType slot, unequip it first:
        Item itemPrevious = Equipped[type];

        if (itemPrevious.MongoID < 1)
        {
            trace(itemPrevious.stackTrace);
            throw new Exception("Previous equipped item doesn't have a valid MongoID: " + itemPrevious.DebugID);
        }

        var cost = CurrencyManager.ParseToCost(globals.GetGlobalAsString(GlobalProps.UNEQUIP_FEE));

        cost.amount = Mathf.RoundToInt(cost.amount * itemPrevious.ItemLevel);

        string question =
            "What do you wish to do\n" +
            "with your previous item?\n\n" +
            "<color=#fff><size=+8>{0}</size></color>\n\n" +
            "<color=#fff>Unbind:</color> Keep it for <color=#fdfc93>{1} {2}</color>\n" +
            "<color=#fff>Discard:</color> Lose it and replace\nwith new selection.";

        string[] choices = new string[] { "*CANCEL", "DISCARD", "UNBIND" };

        string itemName = SplitIfTooLong(itemPrevious.Name);

        ConfirmYesNoInterface.Ask("Unbinding Fee", question.Format2(itemName, cost.amount, cost.type), choices)
        .Then(answer => {
            switch (answer)
            {
            case "UNBIND": SwapItems(itemPrevious, item, cost); break;

            case "DISCARD": DiscardAndEquip(itemPrevious, item); break;
            }

            ItemDetailsInterface.Instance.Close();
        })
        .Catch(err => {
            trace("Cancelled...");
        });
    }
    private void Btn_BusySelectBooster()
    {
        var   costBase       = trayInfo.costToBoostBase;
        float costMultiplier = trayInfo.costToBoostMultiplier;
        int   minutesLeft    = (int)(dateEnd - DateTime.Now).TotalMinutes;

        var gemsType = costBase.type;
        int gemsCost = costBase.amount + Mathf.CeilToInt(minutesLeft * costMultiplier);
        int gemsLeft = gemsType.GetAmount();

        //int cost
        ConfirmYesNoInterface.Ask(
            "Instant Identify",
            "How would you".JoinNewLines(
                "like to instantly",
                "identify this item?\n",
                "<size=+10><color=#4286f4>{0} {1}</color></size>",
                "<size=-3>({2} remaining)</size>",
                "-or-",
                "<size=+10><color=#f4eb41>1 Identify Scrolls</color></size>",
                "<size=-3>({3} remaining)</size>"
                ).Format2(gemsCost, gemsType, gemsLeft, CurrencyTypes.SCROLLS_IDENTIFY.GetAmount()),
            "USE\n" + gemsType, "USE\nSCROLLS"
            ).Then(answer => {
            if (answer.Contains(gemsType.ToString()))
            {
                AudioManager.Instance.Play(SFX_UI.ShardsChing);
                return(ChangeStatus(ResearchSlotStatus.COMPLETED, gemsType, gemsCost));
            }

            if (!CurrencyTypes.SCROLLS_IDENTIFY.HasEnough(1))
            {
                TimelineTween.ShakeError(this.gameObject);
                traceError("Unsufficient Identify Scrolls.");
                return(null);
            }

            AudioManager.Instance.Play(SFX_UI.PageFlip);

            return(ChangeStatus(ResearchSlotStatus.COMPLETED, CurrencyTypes.SCROLLS_IDENTIFY, 1));
        }).Then(slot => {
            if (slot == null)
            {
                return;
            }
            trace("Slot should now be set to COMPLETED!");
            trace(slot.status);

            Btn_CompletedIdentifying();
        })
        .Catch(err => {
            traceError("Could not mark the slot as COMPLETED: " + GameAPIManager.GetErrorMessage(err));
        });
    }
    ///////////////////////////////////////////////////////////

    public static ConfirmYesNoInterface Ask(string title, string confirmMsg, params string[] labels)
    {
        ConfirmYesNoInterface confirm = (ConfirmYesNoInterface)menuMan.Load("Interface_ConfirmYesNo");

        confirm._promise          = new Promise <string>();
        confirm.labelTitle.text   = title;
        confirm.labelConfirm.text = confirmMsg;
        confirm.CreateButtonsFromLabels(labels);

        return(confirm);
    }
Example #10
0
    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));
        });
    }
    // Use this for initialization
    void Start()
    {
        Instance = this;

        _faderAlpha = fader.color.a;
        fader.color = new Color(0, 0, 0, 0);

        panel.localScale = Vector2.zero;
        Show();

        BtnClose.onClick.AddListener(() => Close());
        BtnBackground.onClick.AddListener(() => Close());
    }
    public override void CloseTransition()
    {
        fader.DOFade(0, _timeHide);
        panel.DOScale(0, _timeHide)
        .SetEase(Ease.InBack)
        .OnComplete(() => {
            menuMan.Remove(this);
            if (_input != null)
            {
                _input.onValueChanged.RemoveAllListeners();
            }
            Instance = null;
        });

        foreach (PromiseButton btnPromise in _buttons)
        {
            btnPromise.btn.onClick.RemoveAllListeners();
        }
    }
Example #13
0
    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); });
        });
    }
Example #14
0
    public void Btn_RenameHero()
    {
        ConfirmYesNoInterface renamePrompt = ConfirmYesNoInterface.AskCustom("Rename Hero", "Interface_ConfirmTextPrompt");

        renamePrompt.SetCharLimit(24);
        var input = renamePrompt.GetInputText();

        input.text = selectedHero.Name;

        renamePrompt
        .Then(answer => {
            if (answer == "YES")
            {
                RenameHero(input.text);
            }
        })
        .Catch(err => {
            traceError("Nope! Not renaming hero: " + err.Message);
        });
    }
Example #15
0
    void Btn_OnLogout()
    {
        if (_isClosing)
        {
            return;
        }

        ConfirmYesNoInterface.Ask("Logout", "Are you sure\nyou want to\nlogout?")
        .Then(answer => {
            if (answer != "YES")
            {
                return;
            }

            btnLogout.interactable = false;

            API.Users.Logout()
            .Then(res => OnLogoutComplete());
        })
        .Catch(err => {
            trace("ERR: " + err.Message);
        });
    }
    private void CheckEmergencyWipeInput()
    {
        if (!isAllowEmergencyWipe || _emergencyConfirm != null || !Input.GetMouseButton(0))
        {
            _emergencyWipeSeconds = 0;
            return;
        }

        _emergencyWipeSeconds += Time.deltaTime;

        if (_emergencyWipeSeconds > 2.0)
        {
            _emergencyConfirm = ConfirmYesNoInterface.Ask("Wipe Data?", "Would you like to\nwipe all PlayerPrefs?");
            _emergencyConfirm.Then(answer => {
                if (answer == "YES")
                {
                    PlayerPrefs.DeleteAll();
                    audioMan.Play(SFX_UI.Explosion);
                }

                this.Wait(1.0f, () => _emergencyConfirm = null);
            });
        }
    }
Example #17
0
    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());
        }
    }