Ejemplo n.º 1
0
    private IEnumerator loadPopup()
    {
        AssetRequest <GameObject> assetRequestRewarUI = Content.LoadAsync(halfItemContentKey);

        yield return(assetRequestRewarUI);

        LootTableRewardDefinition       lootDefinition = minigameService.GetLootRewardDefinition(prizeName);
        List <MascotXPRewardDefinition> xp             = (!(lootDefinition.Reward != null)) ? new List <MascotXPRewardDefinition>() : lootDefinition.Reward.GetDefinitions <MascotXPRewardDefinition>();
        DItemRewardPopup rewardPopupData = new DItemRewardPopup();

        rewardPopupData.HeaderText            = "You fished up an item!";
        rewardPopupData.ItemName              = Service.Get <Localizer>().GetTokenTranslation(lootDefinition.DisplayName);
        rewardPopupData.CoinReward            = CoinRewardableDefinition.Coins(lootDefinition.Reward);
        rewardPopupData.XpReward              = ((xp.Count > 0) ? xp[0].XP : 0);
        rewardPopupData.MascotDefinition      = ((xp.Count > 0) ? xp[0].Mascot : null);
        rewardPopupData.MascotAbbreviatedName = ((xp.Count > 0) ? xp[0].Mascot.AbbreviatedName : "");
        rewardPopupData.RewardCategory        = RewardCategory.genericSprite;
        rewardPopupData.RewardData            = new DReward();
        rewardPopupData.RewardData.UnlockID   = lootDefinition.RewardImage;
        rewardPopupData.IsQuestItem           = isQuestPrize;
        rewardPopupData.RewardIcon            = lootDefinition.RewardImage;
        GameObject popup = UnityEngine.Object.Instantiate(assetRequestRewarUI.Asset);

        itemRewardPopup = popup.GetComponent <ItemRewardPopupHalf>();
        if (itemRewardPopup != null)
        {
            itemRewardPopup.SetData(rewardPopupData);
            itemRewardPopup.DoneClose += onPopupClosed;
        }
        Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowPopup(popup));
    }
Ejemplo n.º 2
0
        private void onPrefabLoaded(string path, GameObject prefab)
        {
            DItemRewardPopup dItemRewardPopup = new DItemRewardPopup();

            dItemRewardPopup.HeaderText       = Service.Get <Localizer>().GetTokenTranslation(i18nHeaderText);
            dItemRewardPopup.ItemName         = Service.Get <Localizer>().GetTokenTranslation(i18nItemName);
            dItemRewardPopup.RewardCategory   = RewardCategory;
            dItemRewardPopup.CoinReward       = CoinReward.Value;
            dItemRewardPopup.XpReward         = XpReward.Value;
            dItemRewardPopup.MascotDefinition = MascotDefinition;
            DReward dReward = new DReward();

            if (RewardCategory == RewardCategory.equipmentInstances)
            {
                dReward.EquipmentRequest.definitionId = Convert.ToInt32(RewardID);
            }
            dReward.UnlockID            = RewardID;
            dItemRewardPopup.RewardData = dReward;
            popup           = UnityEngine.Object.Instantiate(prefab);
            itemRewardPopup = popup.GetComponent <ItemRewardPopup>();
            if (itemRewardPopup != null)
            {
                itemRewardPopup.SetData(dItemRewardPopup);
                itemRewardPopup.OpenDelay  = OpenDelay;
                itemRewardPopup.DoneClose += onPopupClosed;
            }
            Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowPopup(popup, destroyPopupOnBackPressed: false, scaleToFit: true, "Accessibility.Popup.Title.ItemReward"));
        }
        private void onPrefabLoaded(string path, GameObject prefab)
        {
            MinigameService                 minigameService      = Service.Get <MinigameService>();
            LootTableRewardDefinition       lootRewardDefinition = minigameService.GetLootRewardDefinition(PrizeName.Value);
            List <MascotXPRewardDefinition> list             = ((!(lootRewardDefinition.Reward != null)) ? new List <MascotXPRewardDefinition>() : lootRewardDefinition.Reward.GetDefinitions <MascotXPRewardDefinition>());
            DItemRewardPopup                dItemRewardPopup = new DItemRewardPopup();

            dItemRewardPopup.HeaderText            = "You fished up an item!";
            dItemRewardPopup.ItemName              = Service.Get <Localizer>().GetTokenTranslation(lootRewardDefinition.DisplayName);
            dItemRewardPopup.CoinReward            = CoinRewardableDefinition.Coins(lootRewardDefinition.Reward);
            dItemRewardPopup.XpReward              = ((list.Count > 0) ? list[0].XP : 0);
            dItemRewardPopup.MascotDefinition      = ((list.Count > 0) ? list[0].Mascot : null);
            dItemRewardPopup.MascotAbbreviatedName = ((list.Count > 0) ? list[0].Mascot.AbbreviatedName : "");
            dItemRewardPopup.RewardCategory        = RewardCategory.genericSprite;
            dItemRewardPopup.RewardData            = new DReward();
            dItemRewardPopup.RewardData.UnlockID   = lootRewardDefinition.RewardImage;
            popup           = Object.Instantiate(prefab);
            itemRewardPopup = popup.GetComponent <ItemRewardPopup>();
            if (itemRewardPopup != null)
            {
                itemRewardPopup.SetData(dItemRewardPopup);
                itemRewardPopup.DoneClose += onPopupClosed;
            }
            Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowPopup(popup, destroyPopupOnBackPressed: false, scaleToFit: true, "Accessibility.Popup.Title.FishingReward"));
        }
Ejemplo n.º 4
0
 public void SetData(DItemRewardPopup itemRewardPopupData)
 {
     popupData = itemRewardPopupData;
     updateBackground();
     ItemNameText.text = itemRewardPopupData.ItemName;
     rewardCategory    = itemRewardPopupData.RewardCategory;
     rewardData        = itemRewardPopupData.RewardData;
     CoroutineRunner.Start(loadItem(rewardCategory, rewardData), this, "RewardPopupScreenItems.loadItem");
 }
Ejemplo n.º 5
0
 public void SetData(DItemRewardPopup itemRewardPopupData)
 {
     localizer         = Service.Get <Localizer>();
     popupData         = itemRewardPopupData;
     ItemNameText.text = itemRewardPopupData.ItemName;
     ClaimText.text    = localizer.GetTokenTranslation("Rewards.PopupLite.ClaimItem");
     if (itemRewardPopupData.IsQuestItem)
     {
         ItemIcon.gameObject.SetActive(value: true);
         Content.LoadAsync(onSpriteLoaded, itemRewardPopupData.RewardIcon);
         CoinOnlyContainer.SetActive(value: false);
     }
     else if (itemRewardPopupData.CoinReward == 0 && itemRewardPopupData.XpReward != 0)
     {
         ItemIcon.gameObject.SetActive(value: false);
         XPOnlyContainer.SetActive(value: true);
         CoroutineRunner.Start(loadXPPrefab(itemRewardPopupData), this, "loadXPPrefab");
     }
     else if (itemRewardPopupData.CoinReward != 0 && itemRewardPopupData.XpReward != 0)
     {
         ItemIcon.gameObject.SetActive(value: false);
         CoinAndXPContainer.SetActive(value: true);
         CoinAndXP_CoinAmountText.text = itemRewardPopupData.CoinReward.ToString();
         if (Service.Get <ProgressionService>().IsMascotMaxLevel(itemRewardPopupData.MascotDefinition.name))
         {
             CoinAndXP_XPText.text = localizer.GetTokenTranslation("MyProgress.MaxLevelText");
         }
         else
         {
             CoinAndXP_XPText.text = itemRewardPopupData.XpReward.ToString();
         }
         for (int i = 0; i < CoinAndXP_XPSpriteSelector.Sprites.Length; i++)
         {
             string value = $"_{itemRewardPopupData.MascotAbbreviatedName}";
             if (CoinAndXP_XPSpriteSelector.Sprites[i].name.Contains(value))
             {
                 CoinAndXP_XPSpriteSelector.SelectSprite(i);
                 break;
             }
         }
     }
     else if (itemRewardPopupData.CoinReward != 0 && itemRewardPopupData.XpReward == 0)
     {
         ItemIcon.gameObject.SetActive(value: false);
         CoinOnlyContainer.SetActive(value: true);
         CoinOnlyAmountText.text = itemRewardPopupData.CoinReward.ToString();
     }
 }
Ejemplo n.º 6
0
        private IEnumerator loadXPPrefab(DItemRewardPopup itemRewardPopupData)
        {
            AssetRequest <GameObject> request = Content.LoadAsync(XP_PREFAB_CONTENT_KEY, itemRewardPopupData.MascotAbbreviatedName);

            yield return(request);

            GameObject xpObject = Object.Instantiate(request.Asset, XPOnlyContainer.transform, worldPositionStays: false);
            Text       xpText   = xpObject.GetComponentInChildren <Text>();

            if (xpText != null)
            {
                if (Service.Get <ProgressionService>().IsMascotMaxLevel(itemRewardPopupData.MascotDefinition.name))
                {
                    xpText.text = localizer.GetTokenTranslation("MyProgress.MaxLevelText");
                }
                xpText.text = itemRewardPopupData.XpReward.ToString();
            }
        }