private void RefreshItem() { roleRoot.SetActive(false); gameObject.GetComponent <Image>().color = new Color(1, 1, 1, 0); CommonItemIcon icon = GetComponentInChildren <CommonItemIcon>(); if (icon == null) { icon = CommonItemIcon.Create(transform); } icon.SetGameResData(_GameResData); _commonItemIcon = icon; if (roleTypeIconImage != null) { roleTypeIconImage.gameObject.SetActive(false); } SetName(Localization.Get(_commonItemIcon.ItemInfo.itemData.name)); if (_commonHeroIcon != null) { _commonHeroIcon.gameObject.SetActive(false); } if (_commonEquipIcon != null) { _commonEquipIcon.gameObject.SetActive(false); } if (_commonItemIcon != null) { _commonItemIcon.gameObject.SetActive(true); } }
private void RefreshMaterial() { TransformUtil.ClearChildren(materialRoot, true); materialPrefab.gameObject.SetActive(true); BlackMarketInfo info = BlackMarketProxy.instance.selectBlackMarketInfo; List <GameResData> material = null; if (info != null) { material = info.materials; } else { material = new List <GameResData>(); } int count = material.Count; GameResData resData; for (int i = 0; i < 4; i++) { Transform tran = Instantiate <Transform>(materialPrefab); tran.transform.SetParent(materialRoot, false); Text textCount = tran.Find("text_count").GetComponent <Text>(); Transform material_root = tran.Find("materialRoot"); if (i < count) { resData = material[i]; CommonItemIcon icon = CommonItemIcon.Create(material_root); icon.SetGameResData(resData); icon.HideCount(); int ownCount = 0; if (resData.type == BaseResType.Item) { ownCount = ItemProxy.instance.GetItemCountByItemID(resData.id); } else { ownCount = GameProxy.instance.BaseResourceDictionary.GetValue(resData.type); } string countString = string.Format(Localization.Get("common.value/max"), ownCount, resData.count); textCount.text = ownCount >= resData.count ? UIUtil.FormatToGreenText(countString) : UIUtil.FormatToRedText(countString); } else { textCount.text = string.Empty; } } materialPrefab.gameObject.SetActive(false); }
public IEnumerator RefreshCoroutine() { rootPanel.gameObject.SetActive(false); yield return(null); textTitle.text = Localization.Get(_itemInfo.itemData.name); textDes.text = Localization.Get(_itemInfo.itemData.des); DropMessageData data = DropMessageData.GetDropMsgDataByResData((int)BaseResType.Item, _itemInfo.itemData.id); textFrom.text = data == null ? "" : Localization.Get(data.des); CommonItemIcon icon = CommonItemIcon.Create(iconRoot); icon.SetItemInfo(new ItemInfo(0, _itemInfo.itemData.id, 0)); icon.GetComponent <ItemDesButton>().enabled = false; RefreshSpecialUse(); float useDeltaHeight = (string.IsNullOrEmpty(textUse.text) ? 0 : textUse.preferredHeight) - _defaultContentLineHeight; float fromDeltaHeight = (string.IsNullOrEmpty(textFrom.text) ? 0 : textFrom.preferredHeight) - _defaultContentLineHeight; float deltaHeight = useDeltaHeight + fromDeltaHeight; textFrom.transform.localPosition += new Vector3(0, useDeltaHeight); rootPanel.sizeDelta = new Vector2(_originSizeDelta.x, _originSizeDelta.y + deltaHeight); float screenHalfHeight = UIMgr.instance.designResolution.y / 2; Vector3 localPosition = transform.InverseTransformPoint(_worldPos); float x = 0f; float y = localPosition.y + rootPanel.sizeDelta.y / 2; if (localPosition.x > 0) { x = localPosition.x - _sizeDelta.x / 2 - rootPanel.sizeDelta.x / 2 - _defaultBorderX; } else { x = localPosition.x + _sizeDelta.x / 2 + rootPanel.sizeDelta.x / 2 + _defaultBorderX; } if (y < rootPanel.sizeDelta.y - screenHalfHeight) { y = rootPanel.sizeDelta.y - screenHalfHeight; } if (y > screenHalfHeight) { y = screenHalfHeight; } localPosition = new Vector3(x, y); rootPanel.localPosition = localPosition; rootPanel.gameObject.SetActive(true); }