示例#1
0
        private void Refresh()
        {
            CommonRewardIcon icon = goodsRoot.GetComponentInChildren <CommonRewardIcon>();

            if (icon == null)
            {
                icon = CommonRewardIcon.Create(goodsRoot);
            }
            icon.SetGameResData(_gameResData, true);
            icon.SetDesButtonEnable(false);
            icon.HideCount();
            if (_gameResData.type == BaseResType.Hero)
            {
                goodsNameText.text = Localization.Get(icon.RoleInfo.heroData.name);
            }
            else if (_gameResData.type == BaseResType.Equipment)
            {
                goodsNameText.text = Localization.Get(icon.CommonEquipmentIcon.EquipmentInfo.equipmentData.name);
            }
            else
            {
                goodsNameText.text = Localization.Get(icon.CommonItemIcon.ItemInfo.itemData.name);
            }
            RefreshPath();
        }
示例#2
0
        private void Refresh()
        {
            textTitle.text = _title;
            TransformUtil.ClearChildren(rewardRoot, true);
            GameResData resData;
            int         totalMoney      = 0;
            int         totalAccountExp = 0;

            for (int i = 0, count = _dataList.Count; i < count; i++)
            {
                resData = _dataList[i];
                if (resData.type != BaseResType.Account_Exp && resData.type != BaseResType.Hero_Exp && resData.type != BaseResType.Gold)
                {
                    CommonRewardIcon icon = CommonRewardIcon.Create(rewardRoot);
                    icon.SetGameResData(resData);
                }

                if (resData.type == BaseResType.Gold)
                {
                    totalMoney += resData.count;
                }
                else if (resData.type == BaseResType.Account_Exp)
                {
                    totalAccountExp += resData.count;
                }
            }
            if (rewardRoot.childCount == 0)
            {
                gameObject.GetComponent <LayoutElement>().preferredHeight = gameObject.GetComponent <LayoutElement>().preferredHeight - 100;
            }
            //exp
            textAccountLv.text = _accountLevel.ToString();
//			textAccountName.text = GameProxy.instance.PlayerInfo.name;
            textAccountName.text = GameProxy.instance.AccountName;
            sliderAccountBar.transform.localPosition = textAccountName.transform.localPosition + new Vector3(textAccountName.preferredWidth + 21, 0, 0);
            textAccountAdd.text = string.Format("+{0}%", (int)_addExpPercent);
            AccountExpData expData = AccountExpData.GetAccountExpDataByLv(_accountLevel);

            if (expData == null)
            {
                sliderAccountBar.value = 0;
            }
            else
            {
                sliderAccountBar.value = (_accountExp + 0.0f) / expData.exp;
            }

            //money
            textMoney.text = totalMoney.ToString();
            int vip = VIPProxy.instance.VIPLevel;

            if (vip > 0)
            {
                textMoneyVipTip.text = string.Format("(vip{0} +{1}%)", vip, VIPProxy.instance.VIPData.dungeonExtraGoldAmount);
            }
            else
            {
                textMoneyVipTip.text = string.Empty;
            }
        }
示例#3
0
        private void RefreshVIPDetail()
        {
            VIPData currentVIPData = VIPData.GetVIPData(_currentVIPLevel);

            VIPDetailTitleText.text = Localization.Get(currentVIPData.name);
            if (currentVIPData.IsMinLevelVIPData())
            {
                previousVIPDetailButton.gameObject.SetActive(false);
                nextVIPDetailButton.gameObject.SetActive(true);
            }
            else if (currentVIPData.IsMaxLevelVIPData())
            {
                previousVIPDetailButton.gameObject.SetActive(true);
                nextVIPDetailButton.gameObject.SetActive(false);
            }
            else
            {
                previousVIPDetailButton.gameObject.SetActive(true);
                nextVIPDetailButton.gameObject.SetActive(true);
            }
            LeanTween.value(vipDetailContent.gameObject, OnVIPDetailContentXUpdate, vipDetailContent.anchoredPosition.x, -_currentVIPLevel * vipPrivilegeDetailItemPrefab.GetComponent <LayoutElement>().preferredWidth, 0.25f);

            TransformUtil.ClearChildren(vipBenefitsItemsRoot, true);
            List <GameResData> benefitItemList = currentVIPData.benefitItemList;

            for (int i = 0, benefitItemCount = benefitItemList.Count; i < benefitItemCount; i++)
            {
                CommonRewardIcon rewardIcon = CommonRewardIcon.Create(vipBenefitsItemsRoot);
                rewardIcon.SetGameResData(benefitItemList[i]);
            }
            VIPBenefitsRootGameObject.gameObject.SetActive(benefitItemList.Count > 0);
            drawVIPBenefitsButton.gameObject.SetActive(!VIPProxy.instance.HasReceivedGiftVIPLevelList.Contains(_currentVIPLevel));
        }
示例#4
0
        void Awake()
        {
            titleText.text           = Localization.Get("ui.world_boss_reward.title");
            killRewardTitleText.text = Localization.Get("ui.world_boss_reward.kill_reward_title");

            damageRankRewardIntervalItemPrefab.gameObject.SetActive(false);
            TransformUtil.ClearChildren(damageRankRewardIntervalItemRoot, true);
            List <WorldBossData> damageRankWorldBossDataList = WorldBossData.GetDamageRankWorldBossDataList();
            int damageRankWorldBossDataCount = damageRankWorldBossDataList.Count;

            for (int i = 0; i < damageRankWorldBossDataCount; i++)
            {
                WorldBossDamageRankRewardIntervalItem damageRankRewardIntervalItem = GameObject.Instantiate <WorldBossDamageRankRewardIntervalItem>(damageRankRewardIntervalItemPrefab);
                damageRankRewardIntervalItem.SetInfo(damageRankWorldBossDataList[i]);
                damageRankRewardIntervalItem.gameObject.SetActive(true);
                damageRankRewardIntervalItem.transform.SetParent(damageRankRewardIntervalItemRoot, false);
            }

            TransformUtil.ClearChildren(killWorldBossRewardRoot, true);
            List <GameResData> killWorldBossRewardList = WorldBossData.GetKillWorldBossReward().rewardShowList;
            int killWorldBossRewardCount = killWorldBossRewardList.Count;

            for (int i = 0; i < killWorldBossRewardCount; i++)
            {
                CommonRewardIcon commonRewardIcon = CommonRewardIcon.Create(killWorldBossRewardRoot);
                commonRewardIcon.transform.localScale = new Vector3(86f / 108, 86f / 108, 1);
                commonRewardIcon.SetGameResData(killWorldBossRewardList[i]);
            }
        }
示例#5
0
        public void RefreshUIDropReward()
        {
            List <GameResData> rewards = DungeonDetailProxy.instance.GetDropRewardList();

            GameResData resData;

            TransformUtil.ClearChildren(TranRewardRoot, true);
            int accountExp = 0;
            int heroExp    = 0;

            for (int i = 0, count = rewards.Count; i < count; i++)
            {
                resData = rewards[i];
                BaseResType type = resData.type;
                if (type == BaseResType.Hero || type == BaseResType.Equipment || type == BaseResType.Item)
                {
                    CommonRewardIcon icon = CommonRewardIcon.Create(TranRewardRoot);
                    icon.SetGameResData(resData);
                    icon.SetDesButtonType(ShowDescriptionType.click);
                }
                else if (type == BaseResType.Account_Exp)
                {
                    accountExp += resData.count;
                }
                else if (type == BaseResType.Hero_Exp)
                {
                    heroExp += resData.count;
                }
            }
            text_reward_hero_exp.text    = heroExp.ToString();
            text_reward_account_exp.text = accountExp.ToString();
        }
示例#6
0
        private void DoShowDropItem()
        {
            if (!treasureBox.gameObject.activeSelf)
            {
                return;
            }

            panelDrop.SetActive(true);
            treasureBox.gameObject.SetActive(false);

            TransformUtil.ClearChildren(tranDropRoot, true);
            int count = _dropHeroAndEquipList.Count;


            int   half                = count / 2;
            float scaleShakeTime      = 0.2f;
            float scaleShakeDelayTime = 0.1f;
            float allDelay            = 0.5f;
            float btnDelayShowTime    = count * scaleShakeTime + 0.5f + allDelay;


            //drop
            GameResData heroGRD = null;

            for (int i = 0; i < count; i++)
            {
                DropItem         dropItem = _dropHeroAndEquipList[i];
                CommonRewardIcon rewardIcon;
                rewardIcon = CommonRewardIcon.Create(tranDropRoot);
                GameResData resData = new GameResData((BaseResType)dropItem.itemType, dropItem.itemNo, dropItem.itemNum, dropItem.heroStar);

                rewardIcon.SetGameResData(resData);
                rewardIcon.SetDesButtonType(ShowDescriptionType.click);
                rewardIcon.ShowRewardCount(true);
                Transform  tran = rewardIcon.transform;
                GameObject go   = rewardIcon.gameObject;
                if (count % 2 == 0)
                {
                    tran.localPosition = new Vector3((i - half) * 120 + 60, 0, 0);
                }
                else
                {
                    tran.localPosition = new Vector3((i - half) * 120, 0, 0);
                }
                go.AddComponent <ScaleShake>().init(0, 1, scaleShakeTime, i * scaleShakeDelayTime + allDelay, ScaleShake.ScaleShakeType.ScleShake_After);
                if (resData.type == BaseResType.Hero)
                {
                    heroGRD = resData;
                }
            }

            ShowBtnRoot(btnDelayShowTime, heroGRD);

            //bg light

            Vector3 to = image_light.localScale;

            image_light.localScale = Vector3.zero;
            LeanTween.scale(image_light, to, scaleShakeTime).setDelay(allDelay);
        }
        private void ResetLoot(DungeonData dungeonData)
        {
            TransformUtil.ClearChildren(lootRootTransform, true);
            List <GameResData> lootList = dungeonData.eachLootPresent;
            int lootCount = lootList.Count;

            for (int i = 0; i < lootCount; i++)
            {
                CommonRewardIcon commonRewardIcon = CommonRewardIcon.Create(lootRootTransform);
                commonRewardIcon.SetGameResData(lootList[i]);
                commonRewardIcon.HideCount();
                commonRewardIcon.SetDesButtonType(ShowDescriptionType.click);
            }
        }
        public void RefreshRewardIcons()
        {
            TransformUtil.ClearChildren(rewardRoot, true);
            List <GameResData> rewards = _selectedWorldTreeDungeonInfo.dungeonData.eachLootPresent;
            GameResData        resData = null;
            int exp = 0;

            for (int i = 0, count = rewards.Count; i < count; i++)
            {
                resData = rewards[i];
                CommonRewardIcon icon = CommonRewardIcon.Create(rewardRoot);
                icon.SetGameResData(resData);
                icon.SetDesButtonType(ShowDescriptionType.click);
            }
        }
示例#9
0
        public void SetDataList(List <GameResData> dataList, bool combineList)
        {
            if (dataList == null)
            {
                return;
            }
            if (combineList)
            {
                dataList = UIUtil.CombineGameResList(dataList);
            }

            TransformUtil.ClearChildren(rewardIconRoot, true);
            int count         = dataList.Count;
            int spaceHorizon  = 130;
            int spaceVertical = 120;
            int columnMax     = 4;
            int totalRow      = count / columnMax + (count % columnMax == 0 ? 0 : 1);

            rewardIconPrefab.gameObject.SetActive(true);
            for (int i = 0; i < count; i++)
            {
                Transform   iconTran = Instantiate <Transform>(rewardIconPrefab);
                GameResData resData  = dataList[i];

                iconTran.SetParent(rewardIconRoot, false);
                float x   = 0;
                float y   = 0;
                int   row = i / columnMax;
                int   col = i % columnMax;
                if (totalRow == 1)               //单行时居中
                {
                    x = count % 2 == 0 ?((i - count / 2) * spaceHorizon + spaceHorizon / 2):((i - count / 2) * spaceHorizon);
                }
                else                  //左对齐
                {
                    x = columnMax % 2 == 0 ? ((col - columnMax / 2) * spaceHorizon + spaceHorizon / 2):((col - columnMax / 2) * spaceHorizon);
                    y = totalRow % 2 == 0 ? ((totalRow / 2 - row) * spaceVertical - spaceVertical / 2):((totalRow / 2 - row) * spaceVertical);
                }

                iconTran.localPosition = new Vector3(x, y);
                Text countText = iconTran.Find("text_count").GetComponent <Text>();
                countText.text = string.Format(Localization.Get("common.x_count"), resData.count);
                CommonRewardIcon rewardIcon = CommonRewardIcon.Create(iconTran);
                rewardIcon.SetGameResData(resData);
                rewardIcon.HideCount();
            }
            rewardIconPrefab.gameObject.SetActive(false);
        }
示例#10
0
        private void SetReward()
        {
            TransformUtil.ClearChildren(rewardIconRoot, true);

            rewardIconPrefab.gameObject.SetActive(true);
            for (int i = 0, count = _prizeData.bonusList.Count; i < count; i++)
            {
                GameResData resData = _prizeData.bonusList[i];
                Transform   icon    = Instantiate <Transform>(rewardIconPrefab);
                icon.SetParent(rewardIconRoot, false);
                icon.Find("text_count").GetComponent <Text>().text = string.Format(Localization.Get("common.x_count"), resData.count);
                CommonRewardIcon rewardIcon = CommonRewardIcon.Create(icon);
                rewardIcon.transform.SetAsFirstSibling();
                rewardIcon.SetGameResData(resData);
                rewardIcon.HideCount();
            }
            rewardIconPrefab.gameObject.SetActive(false);
        }
        public void SetInfo(WorldBossData worldBossData)
        {
            if (worldBossData.rankMin <= 3)
            {
                if (worldBossData.rankMin == 1)
                {
                    top3TitleImage.SetSprite(ResMgr.instance.Load <Sprite>("sprite/main_ui/icon_1st"));
                }
                else if (worldBossData.rankMin == 2)
                {
                    top3TitleImage.SetSprite(ResMgr.instance.Load <Sprite>("sprite/main_ui/icon_2st"));
                }
                else if (worldBossData.rankMin == 3)
                {
                    top3TitleImage.SetSprite(ResMgr.instance.Load <Sprite>("sprite/main_ui/icon_3st"));
                }
                top3TitleImage.SetNativeSize();
                top3TitleImage.gameObject.SetActive(true);
                intervalText.gameObject.SetActive(false);
            }
            else
            {
                top3TitleImage.gameObject.SetActive(false);
                intervalText.gameObject.SetActive(true);
                if (worldBossData.rankMax > 0)
                {
                    intervalText.text = string.Format(Localization.Get("ui.world_boss_reward.interval_1"), worldBossData.rankMin, worldBossData.rankMax);
                }
                else
                {
                    intervalText.text = string.Format(Localization.Get("ui.world_boss_reward.interval_2"), worldBossData.rankMin);
                }
            }

            List <GameResData> rewardShowList = worldBossData.rewardShowList;
            int rewardShowItemCount           = rewardShowList.Count;

            for (int i = 0; i < rewardShowItemCount; i++)
            {
                CommonRewardIcon commonRewardIcon = CommonRewardIcon.Create(rewardItemRoot);
                commonRewardIcon.SetGameResData(rewardShowList[i]);
            }
        }
示例#12
0
        private void Refresh()
        {
            if (_rewardIcon == null)
            {
                _rewardIcon = CommonRewardIcon.Create(rewardRoot);
                _rewardIcon.transform.SetAsFirstSibling();
            }
            GameResData data = info.signData.awardItemList[0];

            _rewardIcon.SetGameResData(data);
            _rewardIcon.SetDesButtonType(ShowDescriptionType.click);
            float scale      = 1;
            bool  isGrayMark = false;
            bool  isSignMark = false;

            if (SignInProxy.instance.curSignInId == info.id)           //today
            {
                if (!SignInProxy.instance.isSignInToday)               //未签到
                {
                    scale = 1.1f;
                }
                else
                {
                    isSignMark = true;
                }
            }
            else
            {
                isSignMark = info.isSign;
                isGrayMark = !info.isSign;
            }
            _rewardIcon.transform.localScale = new Vector3(scale, scale, scale);
            signGO.SetActive(isSignMark);
            notSignGO.SetActive(isGrayMark);
            UIUtil.SetGray(_rewardIcon.gameObject, isGrayMark);
            textDay.text = info.id.ToString();
            vipGO.SetActive(info.signData.vip_lv > 0);
            textVip.text         = string.Format(Localization.Get("ui.signInView.Vip"), info.signData.vip_lv);
            textVipMultiple.text = string.Format(Localization.Get("ui.signInView.VipMultiple"), info.signData.vip_multiple);
        }
        public void SetData(BlackMarketInfo info, bool bigHero = false, ShowDescriptionType clickType = ShowDescriptionType.longPress)
        {
            blackMarketInfo = info;

            if (_commonRewardIcon != null)
            {
                GameObject.DestroyObject(_commonRewardIcon.gameObject);
            }
            if (_commonHeroIcon != null)
            {
                GameObject.DestroyObject(_commonHeroIcon.gameObject);
            }
            if (bigHero)
            {
                _commonHeroIcon = CommonHeroIcon.View.CommonHeroIcon.CreateBigIcon(transform);
                _commonHeroIcon.transform.SetAsFirstSibling();
                _commonHeroIcon.SetGameResData(info.itemData);
                RoleDesButton.Get(_commonHeroIcon.gameObject).SetRoleInfo(info.itemData, clickType);
            }
            else
            {
                _commonRewardIcon = CommonRewardIcon.Create(transform);
                _commonRewardIcon.transform.SetAsFirstSibling();
                _commonRewardIcon.SetGameResData(info.itemData);
                if (clickType == ShowDescriptionType.longPress)
                {
                    _commonRewardIcon.onClickHandler = OnClickRewardBtnHandler;
                }
                _commonRewardIcon.SetDesButtonType(clickType);
            }
            remaindCountText.text = info.remaindCountString;
            if (maskGameObject != null)
            {
                maskGameObject.SetActive(GameProxy.instance.AccountLevel < blackMarketInfo.limitLv);
                limitLevelText.text = string.Format(Localization.Get("ui.black_market_view.limit_lv"), blackMarketInfo.limitLv);
            }

            GetComponent <Image>().enabled = false;
        }
示例#14
0
        private void RefreshMaterial()
        {
            HeroInfo heroInfo = HeroAdvanceProxy.instance.advanceHeroInfo;

            for (int i = 0, count = materialCountText.Length; i < count; i++)
            {
                materialCountText[i].gameObject.SetActive(false);
                CommonRewardIcon icon = materialCountText[i].transform.parent.GetComponentInChildren <CommonRewardIcon>();
                if (icon != null)
                {
                    GameObject.DestroyImmediate(icon.gameObject);
                }
            }

            if (heroInfo.IsMaxAdvanceLevel)
            {
                advanceOperationRootGameObject.SetActive(false);
                starReachMaxText.gameObject.SetActive(true);
                return;
            }

            HeroAdvanceData advanceData = HeroAdvanceData.GetHeroAdvanceDataByStar(heroInfo.advanceLevel);

            if (advanceData == null)
            {
                return;
            }
            ItemInfo           itemInfo;
            GameResData        resData;
            GridLayoutGroup    materialRootGridLayout = materialRoot.GetComponent <GridLayoutGroup>();
            List <GameResData> itemDataList           = advanceData.GetItemIdByHeroType(heroInfo.heroData.roleType);
            Transform          parent;

            for (int i = 0, dataListCount = itemDataList.Count; i < dataListCount; i++)
            {
                if (i < materialRoot.childCount)
                {
                    parent = materialRoot.GetChild(i);
                }
                else
                {
                    parent = materialRoot;
                }
                resData  = itemDataList[i];
                itemInfo = ItemProxy.instance.GetItemInfoByItemID(resData.id);

                CommonRewardIcon item     = CommonRewardIcon.Create(parent);
                RectTransform    itemTran = item.transform as RectTransform;
                itemTran.localPosition = Vector3.zero;
                float width = itemTran.sizeDelta.x;
                item.SetGameResData(resData);
                float scale = materialRootGridLayout.cellSize.x / width;
                item.transform.localScale = new Vector3(scale, scale, 1);
                item.HideCount();
                item.onClickHandler = ClickMaterialHandler;
                int    count = itemInfo == null ? 0 : itemInfo.count;
                string text  = string.Format(Localization.Get("common.value/max"), count, resData.count);
                if (count < resData.count)
                {
                    text = UIUtil.FormatToRedText(text);
                }
                else
                {
                    text = UIUtil.FormatToGreenText(text);
                }
                Text countText = parent.Find("text_count").GetComponent <Text>();
                countText.text = text;
                countText.gameObject.SetActive(true);
            }
            string needLvString = string.Format(Localization.Get("ui.hero_advance_view.need_level"), advanceData.lv_limit);

            if (heroInfo.level < advanceData.lv_limit)
            {
                needLevelText.text = UIUtil.FormatToRedText(needLvString);
            }
            else
            {
                needLevelText.text = UIUtil.FormatToColorText(needLvString, "FFAB25");//深黄
            }
            advanceOperationRootGameObject.SetActive(true);
            starReachMaxText.gameObject.SetActive(false);
        }
示例#15
0
        public void Refresh()
        {
            //root.sizeDelta = _defaultRootSize;
            //contentBgRT.sizeDelta = _defaultTitleRootSize;
            MailData data = mailInfo.mailData;

            if (mailInfo.titleParam != null && mailInfo.titleParam.Length != 0)
            {
                titleText.text = string.Format(Localization.Get(data.name), mailInfo.titleParam);
            }
            else
            {
                titleText.text = Localization.Get(data.name);
            }

            if (mailInfo.contentParam != null && mailInfo.contentParam.Length != 0)
            {
                contentText.text = string.Format(Localization.Get(data.des), mailInfo.contentParam);
            }
            else
            {
                contentText.text = Localization.Get(data.des);
            }
            string contentString = contentText.text;

            if (contentString.Length >= 17 && !_isShowDetail)
            {
                contentText.text = contentString.Substring(0, 12) + "...";
            }

            btnRewardText.text = mailInfo.isGetReward ?  Localization.Get("ui.mail_view.alreadyGet") : Localization.Get("ui.mail_view.getmail");
            GameObject btn = btnRewardText.transform.parent.gameObject;

            btn.GetComponent <Button>().interactable = !mailInfo.isGetReward;
            UIUtil.SetGray(btn, mailInfo.isGetReward);

            if (mailIcon != null)
            {
                string picPath = data.pic;
                if (!string.IsNullOrEmpty(mailInfo.picParam))
                {
                    picPath = string.Format(Localization.Get(data.pic), mailInfo.picParam);
                }
                mailIcon.SetSprite(ResMgr.instance.Load <Sprite>(picPath));
                mailIcon.SetNativeSize();
            }
            if (sendTimeText != null)
            {
                System.DateTime time = TimeUtil.FormatTime((int)(mailInfo.createTime / 1000));
                sendTimeText.text = string.Format(Localization.Get("ui.mail_view.time"), time);
            }
            TransformUtil.ClearChildren(reward_root, true);
            GameResData resData;
            int         count = mailInfo.rewardList.Count;

            if (!_isShowDetail)
            {
                count = count > 4 ? 4:count;
            }
            for (int i = 0; i < count; i++)
            {
                resData = mailInfo.rewardList[i];
                CommonRewardIcon icon = CommonRewardIcon.Create(reward_root);
                icon.SetGameResData(resData);
                //if(_isShowDetail)
                //icon.ShowName(true);
            }

            if (count == 0)
            {
                btnRewardGO.SetActive(false);
            }
            else
            {
                btnRewardGO.SetActive(true);
//				if(_isShowDetail)
//				{
//					GridLayoutGroup grid = reward_root.GetComponent<GridLayoutGroup>();
//					if(grid != null)
//					{
//						int row = count/grid.constraintCount + (count%grid.constraintCount == 0? 0:1);
//						float h = row*grid.cellSize.y+(row-1)*grid.spacing.y;
//						float delta = h-_defaultRewardSize.y;
//						Vector2 deltaVec = new Vector2(0,delta);
//						root.sizeDelta += deltaVec;
//						contentBgRT.sizeDelta += deltaVec;
//					}
//
//				}
            }
        }
        public void SetDataList(List <GameResData> dataList)
        {
            if (dataList == null)
            {
                return;
            }
            TransformUtil.ClearChildren(rewardIconRoot, true);
            int count         = dataList.Count;
            int spaceHorizon  = 130;
            int spaceVertical = 120;
            int columnMax     = 4;
            int totalRow      = count / columnMax + (count % columnMax == 0 ? 0 : 1);
            //
            GridLayoutGroup layout = rewardIconRoot.GetComponent <GridLayoutGroup>();

            float         height              = layout.cellSize.y + layout.spacing.y;
            RectTransform rectTran            = rewardIconRoot.transform as RectTransform;
            Vector2       rewardRootSizeDelta = rectTran.sizeDelta;

            rewardRootSizeDelta = rectTran.sizeDelta = new Vector2(rewardRootSizeDelta.x, height * totalRow - layout.spacing.y + 50);

            if (totalRow == 1)
            {
                if (layout != null)
                {
                    layout.enabled = false;
                }
            }
            else
            {
                if (layout != null)
                {
                    layout.enabled = true;
                }
            }
            rewardIconPrefab.SetActive(true);

            float xPadding = rewardRootSizeDelta.x / 2;
            float yPadding = -100;

            for (int i = 0; i < count; i++)
            {
                GameObject clone = Instantiate <GameObject>(rewardIconPrefab);

                CommonRewardIcon icon     = CommonRewardIcon.Create(clone.transform);
                RectTransform    iconTran = icon.transform as RectTransform;
                iconTran.SetAsFirstSibling();
//				iconTran.anchorMax = iconTran.anchorMin = new Vector2(0.5f,0.5f);
                GameResData resData = dataList[i];
                icon.SetGameResData(resData);
                Transform tran = clone.transform;
                tran.SetParent(rewardIconRoot, false);
                float x = 0;
                float y = 0;

                int row = i / columnMax;
                int col = i % columnMax;
                if (totalRow == 1)               //单行时居中
                {
                    x = count % 2 == 0 ?((i - count / 2) * spaceHorizon + spaceHorizon / 2):((i - count / 2) * spaceHorizon);
                }
                else                  //左对齐
                {
                    x = columnMax % 2 == 0 ? ((col - columnMax / 2) * spaceHorizon + spaceHorizon / 2):((col - columnMax / 2) * spaceHorizon);
                    y = totalRow % 2 == 0 ? ((totalRow / 2 - row) * spaceVertical - spaceVertical / 2):((totalRow / 2 - row) * spaceVertical);
                }

                tran.localPosition = new Vector3(x + xPadding, y + yPadding);
                Text countText = tran.Find("text_count").GetComponent <Text>();
                countText.text = string.Format(Localization.Get("common.x_count"), resData.count);

                icon.ShowRewardCount(true);
            }
            rewardIconPrefab.SetActive(false);
        }
示例#17
0
        private void RefreshReward()
        {
            for (int i = 0, tcount = imgRewardIcon.Length; i < tcount; i++)
            {
                Transform commonRoot = imgRewardIcon[i].transform.parent.Find("common_root");
                TransformUtil.ClearChildren(commonRoot, true);
                if (i >= taskInfo.taskData.rewardList.Count)
                {
                    imgRewardIcon[i].gameObject.SetActive(false);
                    textRewardCount[i].gameObject.SetActive(false);
                    continue;
                }

                GameResData data = taskInfo.taskData.rewardList[i];

                imgRewardIcon[i].gameObject.SetActive(true);
                textRewardCount[i].gameObject.SetActive(true);

                string  path       = "";
                bool    isShowBox  = false;
                Vector3 localScale = Vector3.one;
//				switch(data.type)
//				{
//				case BaseResType.Hero:         //伙伴
//				case BaseResType.Equipment:      //装备
//				case BaseResType.Item:          //道具
//				{
//					isShowBox = true;
//					CommonRewardIcon icon = CommonRewardIcon.Create(commonRoot);
//					icon.SetGameResData(data);
//					icon.HideCount();
//				}
//
//					break;
//				default:
//					path = UIUtil.GetBaseResIconPath(data.type);
//					break;
//				}

                isShowBox = true;
                CommonRewardIcon icon = CommonRewardIcon.Create(commonRoot);
                icon.SetGameResData(data);
                icon.HideCount();


                //imgRewardIcon[i].transform.localScale = localScale;
//				imgRewardIcon[i].gameObject.SetActive(!isShowBox);
//				int count = 0;
//				if(isShowBox)
//				{
//					//count = 1;
//				}
//				else
//				{
//					imgRewardIcon[i].SetSprite(ResMgr.instance.Load<Sprite>(path));
//					imgRewardIcon[i].SetNativeSize();
//					//count = data.count;
//				}
                textRewardCount[i].text = string.Format(Localization.Get("common.x_count"), data.count);
            }
        }
示例#18
0
        private void RefreshMaterial()
        {
            TransformUtil.ClearChildren(materialRoot, true);
            materialRootGO.SetActive(false);
            materialTipText.gameObject.SetActive(false);
            if (_currentClickSkillInfo == null)
            {
                return;
            }
            if (_currentClickSkillInfo.IsMaxLevel)
            {
                materialTipText.gameObject.SetActive(true);
                materialTipText.text = Localization.Get("ui.player_cultivate_view.maxLevel");
                return;
            }
            List <GameResData> costList = _currentClickSkillInfo.UpgradeCost;

            for (int i = 0, count = costList.Count; i < count; i++)
            {
                GameResData   res = costList[i];
                GameObject    go  = Instantiate <GameObject>(materialPrefab);
                RectTransform rt  = go.transform as RectTransform;
                go.name = i.ToString();
                go.SetActive(true);
                rt.SetParent(materialRoot, false);

                CommonRewardIcon icon  = CommonRewardIcon.Create(rt);
                float            scale = rt.sizeDelta.x / (icon.transform as RectTransform).sizeDelta.x;
                icon.transform.localScale = new Vector3(scale, scale, scale);
                icon.SetGameResData(res);
                icon.HideCount();

                Text countText = rt.Find("text_count").GetComponent <Text>();
                int  own       = 0;
                if (res.type == BaseResType.Item)
                {
                    own = ItemProxy.instance.GetItemCountByItemID(res.id);
                }
                else
                {
                    own = GameProxy.instance.BaseResourceDictionary.GetValue(res.type);
                }
                string countString = string.Format("{0}/{1}", own, res.count);
                countText.text = res.count > own?UIUtil.FormatToRedText(countString) : UIUtil.FormatToGreenText(countString);
            }
            int    level         = _currentClickSkillInfo.level;
            string expNeedString = string.Format("{0}/{1}", _currentClickSkillInfo.exp, _currentClickSkillInfo.talentData.exp_need);

            activeNeedExpText.text = _currentClickSkillInfo.isMaxExp ? UIUtil.FormatToGreenText(expNeedString) : UIUtil.FormatToRedText(expNeedString);
            if (level == 0)
            {
                activeButtonText.text = Localization.Get("ui.player_cultivate_view.activate");
                activeNeedExpGO.SetActive(true);
            }
            else
            {
                activeButtonText.text = Localization.Get("ui.player_cultivate_view.upgrade");
                activeNeedExpGO.SetActive(false);
            }
            PlayerSkillTalentInfo preInfo = PlayerTalentProxy.instance.GetSkillTalentInfo(_currentClickSkillInfo.talentData.pre_id);

            if (preInfo != null)
            {
                if (preInfo.level == 0)
                {
                    materialRootGO.SetActive(false);
                    materialTipText.gameObject.SetActive(true);
                    materialTipText.text = string.Format(Localization.Get("ui.player_cultivate_view.needActivePre"), Localization.Get(preInfo.name));
                }
                else
                {
                    materialRootGO.SetActive(true);
                    materialTipText.gameObject.SetActive(false);
                }
            }
            else
            {
                materialRootGO.SetActive(true);
                materialTipText.gameObject.SetActive(false);
            }
        }