コード例 #1
0
    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();
            });
        });
    }
コード例 #2
0
    public void Btn_Buy()
    {
        if (_item == null || !CurrencyTypes.GOLD.HasEnough(_item.Value))
        {
            BtnBuy.transform.DOKill();
            AudioManager.Instance.Play(SFX_UI.Invalid);
            TimelineTween.ShakeError(BtnBuy);
            return;
        }

        // Do buy logic here
        print("buying [" + _index + "] " + _item.Name);

        if (CheatManager.ALWAYS_CREATE_AS_UNIDENTIFIED)
        {
            trace("CHEATS: ALWAYS_CREATE_AS_UNIDENTIFIED is enabled, so all purchased items will be unidentified.");
            AudioManager.Instance.Play(SFX_UI.ShardsChing);
            _item.isIdentified = false;
        }

        GameAPIManager.API.Shop.BuyItem(_item, _index, _seed, CurrencyTypes.GOLD, _item.Value, OnItemBought)
        .Then(res => {
            if (_details != null)
            {
                _details.Close();
            }
        })
        .Catch(error => traceError(error));
    }
コード例 #3
0
    public void Btn_BoostsAddSlot()
    {
        if (BoostCanvasGroup.alpha != 1)
        {
            return;
        }

        var cost = CurrencyManager.ParseToCost(GlobalProps.BOOST_SLOT_COST.GetString());

        if (cost.type.GetAmount() < cost.amount)
        {
            TimelineTween.ShakeError(btnBoostAddSlot.gameObject);
            return;
        }

        BoostCanvasGroup.alpha = 0.5f;

        API.Users.BoostAddSlot(cost)
        .Then(res => {
            trace("Boost slot added successfully.");
            RefreshBoostSlots();
            BoostCanvasGroup.alpha = 1;
        })
        .Catch(err => {
            BoostCanvasGroup.alpha = 1;
            TimelineTween.ShakeError(btnBoostAddSlot.gameObject);
            traceError("Could not add new boost slot: " + GameAPIManager.GetErrorMessage(err));
        });
    }
コード例 #4
0
    public void Btn_BuyFeatured()
    {
        // Buy the item and set the timestamp of bought
        if (_featuredItem == null)
        {
            print("Can't buy featured Item it is null");
            return;
        }

        int gold = CurrencyTypes.GOLD.GetAmount();

        if (gold < _featuredItem.Value)
        {
            TimelineTween.ShakeError(btnBuyFeaturedItem.gameObject);
            return;
        }

        GameAPIManager.API.Shop.BuyFeaturedItem(_featuredItem, CurrencyTypes.GOLD, _featuredItem.Value)
        .Then(featuredResponse => {
            PlayerManager.Instance.isLastFeaturedItemPurchased = true;

            print("Successfully bought " + _featuredItem.Name);
        })
        .Catch(error => Debug.LogError(error));
    }
コード例 #5
0
    public static TimelineTween Create(params NextAction[] tweens)
    {
        var timeline = new TimelineTween();

        timeline.Add(tweens);
        timeline.Play();
        return(timeline);
    }
コード例 #6
0
 void Equip(Item item)
 {
     API.Items.EquipToHero(item, hero)
     .Then(res => OnEquipComplete(item))
     .Catch(err => {
         TimelineTween.ShakeError(this.gameObject);
         traceError("Could not equip the item to hero: " + item.DebugID + " : " + hero.DebugID + "\n" + err.Message);
     });
 }
コード例 #7
0
    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));
        });
    }
コード例 #8
0
 IPromise <ResearchSlotInterface> ChangeStatus(ResearchSlotStatus status, CurrencyTypes currency = CurrencyTypes.NONE, int amount = 0, Item item = null)
 {
     isChangingStatus = true;
     return(RESEARCH_API.ChangeStatus(this, status, currency, amount, item)
            .Then(slot => {
         isChangingStatus = false;
     })
            .Catch(err => {
         isChangingStatus = false;
         hasErrors = true;
         AudioManager.Instance.Play(SFX_UI.Invalid);
         TimelineTween.ShakeError(this.gameObject);
     }));
 }
コード例 #9
0
    private void OpenItemDetails(UserProfileItemContainer itemContainer)
    {
        if (itemContainer.imgQuestion.gameObject.activeSelf)
        {
            itemContainer.imgQuestion.transform.DOKill();
            TimelineTween.ShakeError(itemContainer.imgQuestion.gameObject);
            return;
        }

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

        _details.AddButton("Close", () => _details.Close());
    }
コード例 #10
0
    public void Btn_OnRefresh()
    {
        if (_isBusy)
        {
            return;
        }

        int gems = REFRESH_COST.type.GetAmount();

        if (gems < REFRESH_COST.amount)
        {
            //traceError("Unsufficient Funds to refresh!");
            TimelineTween.ShakeError(btnRefresh.gameObject);
            return;
        }
        LoadBuyItemList(true);
    }
コード例 #11
0
    IEnumerator __SellBatchOfItems(Button btn, List <Item> items, CurrencyTypes type, int cost)
    {
        if (items.Count == 0)
        {
            AudioManager.Instance.Play(SFX_UI.Invalid);
            TimelineTween.ShakeError(btn.gameObject);
            yield break;
        }

        btnSellAllCommon.interactable   = false;
        btnSellAllUncommon.interactable = false;

        AnimateItems(false);

        yield return(new WaitForSeconds(0.5f));

        _isBusy = false;

        GameAPIManager.API.Shop.SellItems(items, type, cost)
        .Then(res => {
            DataManager.Instance.allItemsList.RemoveAll(i => items.Contains(i));

            UpdateSortedInventoryItems();
            Btn_ShowStoreSellMenu();
            _isBusy = false;
        })
        .Catch(err => {
            traceError("Could not sell back of items: " + err.Message);
            _isBusy = false;
        });

        while (!_isBusy)
        {
            yield return(new WaitForEndOfFrame());
        }

        AnimateItems(true);

        btnSellAllCommon.interactable   = true;
        btnSellAllUncommon.interactable = true;

        AudioManager.Instance.Play(SFX_UI.Coin);
    }
コード例 #12
0
    void Btn_OnClick()
    {
        btnButton.transform.DOKill();
        FXPulse(btnButton.transform, 1);

        switch (_status)
        {
        case ResearchSlotStatus.UNLOCKED: Btn_UnlockedSelectItem(); break;

        case ResearchSlotStatus.BUSY: Btn_BusySelectBooster(); break;

        case ResearchSlotStatus.LOCKED: Btn_Unlock(); break;

        case ResearchSlotStatus.COMPLETED: Btn_CompletedIdentifying(); break;

        default:
            traceError("Unhandled button click status: " + _status);
            TimelineTween.ShakeError(btnButton.gameObject);
            return;
        }
    }
コード例 #13
0
    void Btn_OnIdentify()
    {
        if (_item == null)
        {
            traceError("Must have one (1) item selected to begin identifying it!");
            TimelineTween.ShakeError(btnIdentify.gameObject);
            return;
        }

        if (!Close())
        {
            return;
        }

        if (OnSelectedItem != null)
        {
            OnSelectedItem(_item);
        }

        DoClosingTransition(panel, modalShadow);
    }
コード例 #14
0
    public void BtnAction_Summon(SummonButtonContainer summonChoice)
    {
        if (!GameManager.Instance.isSummonComplete)
        {
            return;
        }

        _currentChoice = summonChoice;
        _summonButtons.ForEach(choice => choice.btn.interactable = false);

        try {
            GameManager.Instance.SummonHeroAction(summonChoice.summonType, OnSummonComplete);
        } catch (Exception err) {
            TimelineTween.ShakeError(_currentChoice.gameObject);
            AudioManager.Instance.Play(SFX_UI.Invalid);
            traceError("Error summoning hero: " + err.Message);
            traceError(err);

            OnSummonComplete(null);
            GameManager.Instance.isSummonComplete = true;
        }
    }
コード例 #15
0
    public void Btn_ExpandStore()
    {
        if (CurrencyTypes.GEMS.GetAmount() >= cost)
        {
            GameAPIManager.Instance.Shop.SetExpansionSlots(PlayerManager.Instance.ShopExpansion + 1, CurrencyTypes.GEMS, cost)
            .Then(res => {
                Tracer.trace("PlayerManager.Instance.ShopExpansion: " + PlayerManager.Instance.ShopExpansion);
                cost         = 30 + (PlayerManager.Instance.ShopExpansion * 5);
                costTxt.text = cost.ToString();

                AudioManager.Instance.Play <SFX_UI>(SFX_UI.Coin);

                UpdateExpandText();
                shopInterface.RefreshStoreList();
            });
        }
        else
        {
            AudioManager.Instance.Play <SFX_UI>(SFX_UI.Invalid);
            TimelineTween.ShakeError(gameObject);
            Debug.Log("Pop our 'Get more currency by watching a video' interface here because the player does not have enough.");
        }
    }
コード例 #16
0
    void ActivateBoost(HeaderBoostDisplay boostChoice)
    {
        if (BoostCanvasGroup.alpha != 1)
        {
            return;
        }

        var slots      = PlayerManager.Instance.BoostsSlotsActive;
        var slotUnused = slots.Find(slot => slot.data == null);

        //Do an early currency check (client-side), it also checks server-side for HACKERZ! :D
        var boostCurrency = boostChoice.boostData.ToCurrencyType();
        int boostAmount   = boostCurrency.GetAmount();

        if (slotUnused == null || boostAmount <= 0)
        {
            TimelineTween.ShakeError(boostChoice.gameObject);
            return;
        }

        trace("Activating boost!");
        trace(boostChoice.boostData);

        BoostCanvasGroup.alpha = 0.5f;

        API.Users.BoostActivate(slotUnused.slotID, boostChoice.boostData)
        .Then(res => {
            boostChoice.UpdateNumLeft();
            BoostCanvasGroup.alpha = 1;
            RefreshBoostSlots();
        })
        .Catch(err => {
            traceError("Could not activate boost: " + GameAPIManager.GetErrorMessage(err));
            TimelineTween.ShakeError(boostChoice.gameObject);
            BoostCanvasGroup.alpha = 1;
        });
    }
コード例 #17
0
    public void Btn_Explore()
    {
        Debug.Log("Explore Act " + act.ActNumber + " Zone " + _currentZone);
        ZoneData data = DataManager.Instance.GetZonesByActAndZoneID(act.ActNumber, _currentZone + 1, btnDifficulty.selected.AsEnum <ZoneDifficulty>());

        if (selectedPartyMembers.Count < 1)
        {
            TimelineTween.ShakeError(btnExplore.gameObject);
            traceError("No party selected.");
            return;
        }
        else if (data == null)
        {
            TimelineTween.ShakeError(btnExplore.gameObject);
            traceError("No Zone Data or Zone Data is Null.");
            return;
        }

        PlayerManager.Instance.StartExplore(data, selectedPartyMembers)
        .Then(res => {
            buttonLabel.text        = "Active";
            btnExplore.interactable = false;
        })
        .Catch(err => {
            traceError(GameAPIManager.GetErrorMessage(err));
            TimelineTween.ShakeError(btnExplore.gameObject);
        });

        HideParty();
        if (BackButton != null)
        {
            BackButton.interactable = true;
        }

        exploreInterface.HideZoneDetails();
    }
コード例 #18
0
    public void Initialize(LootCrate crate, System.Action callback = null, System.Action callbackOnComplete = null, bool fromStory = false)
    {
        this.crate = crate;
        List <Item> items = crate.GenerateItems();

        this.callbackOnComplete = callbackOnComplete;
        noMenuManagerRef        = fromStory;

        Debug.Log("Adding " + items.Count + " items.");

        /*
         * foreach(Item i in items) {
         *  Debug.Log(" --- --- [Item] " + i.Name);
         * }*/

        // NOTE-TO-SELF: DO call this API method! (Instead of one-by-one, batch-calls adds all generated items)
        API.Items.AddMany(items)
        .Catch(err => traceError("Something went wrong while adding newly generated items to server-side: " + err.Message));
        //.Then(res => trace("Added " + items.Count + " items server-side..."))

        DataManager.Instance.allItemsList.AddRange(items);

        if (!fromStory)
        {
            RemoveCrateFromPlayerData(callback);
        }

        // Crate Sequence
        TimelineTween.Create(
            (next) => {
            AudioManager.Instance.Play(SFX_UI.Earthquake);

            //btnGoBack.transform.DOScale(Vector2.zero, 0.5f * speedScale);
            btnGoBack.GetComponent <RectTransform>().DOAnchorPosY(0f, 0.5f * speedScale);

            crateBtn.transform.SetParent(this.transform);

            // Background Shadow here
            backgroundShadow.DOColor(new Color(0f, 0f, 0f, 0.7f), timeScrollerSlides * speedScale);

            crateBtn.transform.TweenMoveByY(50, timeScrollerSlides * speedScale)
            .SetEase(Ease.InOutSine)
            .OnComplete(() => next());
        },

            (next) => {
            // If on crate screen reset the crate list positions

            crateBtn.transform
            .DOShakePosition(timeCrateShake * speedScale, 10, 30, 90, false, false)
            .OnComplete(() => next());
        },

            (next) => {
            AudioManager.Instance.Stop(SFX_UI.Earthquake);
            AudioManager.Instance.Play(SFX_UI.Explosion);

            GameObject itemPrefab = GetPrefab("SubItems/LootCrateItem");

            var canvasSize = GetScreenSize();
            float itemSize = canvasSize.x / 3f;

            for (int i = 0; i < items.Count; i++)
            {
                Item itemData             = items[i];
                GameObject itemGO         = GameObject.Instantiate(itemPrefab);
                LootCrateItem item        = itemGO.GetComponent <LootCrateItem>();
                Button itemBtn            = itemGO.GetComponent <Button>();
                TextMeshProUGUI itemLabel = itemGO.GetComponentInChildren <TextMeshProUGUI>();
                RectTransform itemTrans   = (RectTransform)itemGO.transform;

                itemTrans.SetParent(this.transform);
                itemTrans.localPosition = Vector2.zero;
                itemTrans.SetWidthAndHeight(itemSize);

                item.itemData = itemData;
                item.UpdateIdentifiedIcon();

                _crateItems.Add(item);

                itemBtn.onClick.AddListener(() => BtnOnItemClick(item, fromStory));
            }

            LayoutUpdate();

            TimelineTween.Scatter(0.08f, _crateItems, (item, id) => {
                return(TimelineTween.Pulsate(item.transform, 1.3f, timeItemsExplode * speedScale));
            });

            Color c = crateBtn.GetComponent <Image>().color;
            c.a     = 0;
            crateBtn.GetComponent <Image>().DOColor(c, 0.3f).OnComplete(() => {
                Destroy(crateBtn.gameObject);
            });

            /*CanvasGroup cg = crateBtn.GetComponent<CanvasGroup>();
             * cg.DOFade(0, 0.3f)
             *  .OnComplete(() => {
             *      Destroy(crateBtn.gameObject);
             *  });*/

            crateBtn.transform
            .DOScale(2.0f, timeCrateExplode * speedScale)
            .SetEase(Ease.OutQuint);

            this.Wait(timeItemsExplode * 2.0f * speedScale, next);
        },

            (next) => {
            TimelineTween.Scatter(0.1f, _crateItems, (item, id) => {
                return(item.filler.DOFade(0, 1 * speedScale));
            });

            this.Wait(timeItemsFormCircle * 1.0f * speedScale, next);
        }
            );
    }