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(); }
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 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); }
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); }
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); } }
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); } }
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); }