/// <summary> /// 设置item信息 /// </summary> /// <param name="itemObj"></param> /// <param name="id"></param> private async void SetItemInfo(GameObject itemObj, int id) { GameItemDefine itemData = StaticData.configExcel.GetGameItemByID(id); Sprite icon = await ZillionaireToolManager.LoadItemSpriteByIconName(itemData.Icon); Image itemIcon = itemObj.transform.Find("BG/Icon").GetComponent <Image>(); itemIcon.sprite = icon; itemIcon.SetNativeSize(); itemObj.transform.Find("BG/Name").GetComponent <Text>().text = LocalizationDefineHelper.GetStringNameById(itemData.ItemName); }
/// <summary> /// 初始化值 数量+名称+图片+等级 /// </summary> /// <param name="id"></param> /// <param name="num"></param> /// <param name="localScale"></param> public async void InitValue(int id, int num, float localScale = 0.0f, bool isShowLv = false) { Init(); GameItemDefine itemData = StaticData.configExcel.GetGameItemByID(id); _name.text = LocalizationDefineHelper.GetStringNameById(itemData.ItemName); Sprite icon = await ZillionaireToolManager.LoadItemSpriteByIconName(itemData.Icon); _lv.SetActive(isShowLv); if (isShowLv) { _lvNum.text = itemData.Grade.ToString(); } _level1.SetActive(false); _level2.SetActive(false); _level3.SetActive(false); switch (itemData.Rarity) { case TypeRarity.Intermediate: _level2.SetActive(true); _level2Icon.sprite = icon; _level2Icon.SetNativeSize(); break; case TypeRarity.Senior: _level3.SetActive(true); _level3Icon.sprite = icon; _level3Icon.SetNativeSize(); break; default: _level1.SetActive(true); _level1Icon.sprite = icon; _level1Icon.SetNativeSize(); break; } if (num <= 0) { _num.gameObject.SetActive(false); } _num.text = num.ToString(); if (localScale != 0.0f) { gameObject.transform.localScale = new Vector3(localScale, localScale); } }
/// <summary> /// 订单界面显示 /// </summary> /// <param name="itemData"></param> /// <param name="num"></param> public async void InitValue(GameItemDefine itemData, string ownAndDemand) { Init(); _name.gameObject.SetActive(false); _name.gameObject.transform.parent.gameObject.SetActive(false); _num.gameObject.SetActive(false); _lv.SetActive(false); Sprite icon = await ZillionaireToolManager.LoadItemSpriteByIconName(itemData.Icon); _level1.SetActive(false); _level2.SetActive(false); _level3.SetActive(false); switch (itemData.Rarity) { case TypeRarity.Intermediate: _level2.SetActive(true); _level2Icon.sprite = icon; _level2Icon.SetNativeSize(); break; case TypeRarity.Senior: _level3.SetActive(true); _level3Icon.sprite = icon; _level3Icon.SetNativeSize(); break; default: _level1.SetActive(true); _level1Icon.sprite = icon; _level1Icon.SetNativeSize(); break; } _ownAndDemandValue.gameObject.SetActive(true); _ownAndDemandValue.text = ownAndDemand; }
/// <summary> /// 生成显示的种子 /// </summary> private async void SpawnSeedShow() { for (int i = 0; i < _seedMiniList.childCount; i++) { Destroy(_seedMiniList.GetChild(i).gameObject); } GameObject itemObj = null; GameItemDefine itemData = null; for (int i = 0; i < _unlockCrops.Count; i++) { itemData = StaticData.configExcel.GetGameItemByID(_unlockCrops[i].ID); Sprite icon = await ZillionaireToolManager.LoadItemSpriteByIconName(itemData.Icon); string name = LocalizationDefineHelper.GetStringNameById(itemData.ItemName); itemObj = Instantiate(_seedItem, _seedMiniList); itemObj.transform.Find("Icon").GetComponent <Image>().sprite = icon; itemObj.transform.Find("NameBG/Name").GetComponent <Text>().text = name; itemObj.SetActive(true); } }