/// <summary> /// 点击物品出现选中物品光效 /// </summary> /// <param name="item"></param> public void SelectItemEffect(ItemUIView item) { for (int i = 0; i < itemUIList.Count; i++) { if (item.itemUIid == itemUIList[i].itemUIid) { itemUIList[i].itemselectbg_obj.SetActive(true); } else { itemUIList[i].itemselectbg_obj.SetActive(false); } } }
public void Init(int _num) { for (int idx = 0; idx < _num; idx++) { if (_num > ListAward.Count) { ItemUIView itemUiView = InitItemInfo().GetComponent <ItemUIView>(); itemUiView.Init(); ListAward.Add(itemUiView); } else { return; } } }
/// <summary> /// 点击物品时,对物品弹框赋值 /// </summary> /// <param name="item"></param> public void ClickItem(ItemUIView item) { if (item == null) { return; } ItemUIView itemUI = null; for (int i = 0; i < itemUIList.Count; i++) { if (item.itemUIid == itemUIList[i].itemUIid) { itemUI = itemUIList[i]; } } if (curId == itemUI.itemUIid) { quantity_txt.text = item.num_txt.text; } else { curId = itemUI.itemUIid; itemname_txt.text = JsonMgr.GetSingleton().GetItemConfigByID(itemUI.itemUIid).name; quantity_txt.text = item.num_txt.text; ItemConfig ic = JsonMgr.GetSingleton().GetItemConfigByID(itemUI.itemUIid); itemiconcolor_img.sprite = ResourceMgr.Instance.LoadSprite(ColorMgr.Border[ic.rare - 1]); itemicon_img.sprite = ResourceMgr.Instance.LoadSprite(ic.icon); propertydes_txt.text = JsonMgr.GetSingleton().GetItemConfigByID(itemUI.itemUIid).propertydes; use_txt.text = JsonMgr.GetSingleton().GetItemConfigByID(itemUI.itemUIid).usedes; unitprice_txt.text = JsonMgr.GetSingleton().GetItemConfigByID(itemUI.itemUIid).price.ToString(); } inventorypop_obj.SetActive(true); if (JsonMgr.GetSingleton().GetItemConfigByID(itemUI.itemUIid).type == FuncType.CONSUMABLES) { use_btn.gameObject.SetActive(true); details_btn.gameObject.SetActive(false); } else { use_btn.gameObject.SetActive(false); details_btn.gameObject.SetActive(true); } }
/// <summary> /// 更新物品信息 /// </summary> /// <param name="itemList"></param> public void UpdateItemView(List <Item> itemList) { for (int i = 0; i < itemList.Count; i++) { if (itemList.Count > itemUIList.Count) //创建物品 { GameObject item = InitItemInfo(); ItemUIView itemUIView = item.GetComponent <ItemUIView>(); itemUIView.Init(); itemUIList.Add(itemUIView); } else if (itemUIList.Count > itemList.Count)//隐藏物品 { for (int idx = 0; idx < itemUIList.Count; idx++) { if (i >= itemList.Count) { itemUIList[idx].gameObject.SetActive(false); itemUIList[idx].isRegister = false; } } } } //当UI中存在该物品时 if (itemUIList != null) { for (int i = 0; i < itemList.Count; i++) { for (int j = 0; j < itemUIList.Count; j++) { if (!itemUIList[j].gameObject.activeSelf) { itemUIList[j].gameObject.SetActive(true); itemUIList[j].SetInfo(itemList[i].itemId, itemList[i].itemNum); } } } } Collating(false); }
public void Init(int _id, bool _isUpdate, int _heroid) { if (AwardItem_obj.transform.childCount == 0 || _isUpdate) { if (_isUpdate) { foreach (var item in SignInItem) { Destroy(item.Value.gameObject); SignInItem.Remove(item.Key); } } Dictionary <int, Item> itemData = JsonMgr.GetSingleton().GetSignInItemData(_id); foreach (var item in itemData) { ItemUIView itemView = InitItemInfo().GetComponent <ItemUIView>(); itemView.Init(); itemView.SetInfo(item.Value.itemId, item.Value.itemNum); SignInItem.Add(item.Key, itemView); } } Init(_heroid); }
private void openTreasureTip(Vector2Int[] data, Vector2 pos, int align, Vector2 offset) { int maxTextWidth = 0; int needItem = data.Length - _items.Count; int needText = data.Length - _itemNums.Count; if (needItem > 0) { for (int idx = 0; idx < needItem; ++idx) { GameObject itemGo = GameObject.Instantiate(ItemView.gameObject); itemGo.transform.parent = this.treasuretips_rect; itemGo.transform.localScale = Vector3.one; ItemUIView view = itemGo.GetComponent <ItemUIView>(); view.Init(); _items.Add(view); } } if (needText > 0) { for (int idx = 0; idx < needText; ++idx) { GameObject textGo = GameObject.Instantiate(ItemNumTxt.gameObject); textGo.transform.parent = this.treasuretips_rect; textGo.transform.localScale = Vector3.one; Text tx = textGo.GetComponent <Text>(); _itemNums.Add(tx); } } for (int idx = 0; idx < _items.Count; ++idx) { if (idx < data.Length) { _items[idx].SetInfo(data[idx].x, 0); _items[idx].gameObject.SetActive(true); RectTransform itemRect = _items[idx].GetComponent <RectTransform>(); itemRect.sizeDelta = new Vector2(50, 50); itemRect.anchoredPosition = new Vector2(10, -idx * 61 - 11); } else { _items[idx].gameObject.SetActive(false); } } for (int idx = 0; idx < _itemNums.Count; ++idx) { if (idx < data.Length) { string itemnum = data[idx].y.ToString(); _itemNums[idx].text = itemnum; if (itemnum.Length > maxTextWidth) { maxTextWidth = itemnum.Length; } _itemNums[idx].gameObject.SetActive(true); RectTransform itemRect = _itemNums[idx].GetComponent <RectTransform>(); itemRect.anchoredPosition = new Vector2(70, -idx * 61 - 11); } else { _items[idx].gameObject.SetActive(false); } } Vector2 size = new Vector2(80 + maxTextWidth * 16, 11 * (data.Length + 1) + 50 * data.Length); this.treasuretips_rect.sizeDelta = size; this.treasuretips_rect.anchoredPosition = calAlignment(pos, size, align, offset); this.treasuretips_rect.gameObject.SetActive(true); }
public void Init() { BattleMgr.Instance.isOff = false; int stra = BattleMgr.Instance.GetStar(BattleMgr.Instance.LevelID); LevelData data = JsonMgr.GetSingleton().GetLevel(BattleMgr.Instance.LevelID); Power = data.power; intro_txt.text = data.desc; //简介 power_txt.color = Role.Instance.Power < data.power ? Color.red : Color.white; power_txt.text = data.power.ToString(); //体力消耗 combat_txt.text = data.combat_effect.ToString(); name_txt.text = data.name; // InitItemInfo() EnemyView enemyico = null; for (int idx = 0; idx < data.monster_tip.Length; idx++) { if (idx == EnemyIcoList.Count) { enemyico = InitItemInfo(EnemyIco.gameObject, enemyShow_obj).GetComponent <EnemyView>(); enemyico.Init(); EnemyIcoList.Add(enemyico); } else { enemyico = EnemyIcoList[idx]; } if (idx == data.monster_tip.Length - 1) { enemyico.gameObject.GetComponent <LayoutElement>().preferredHeight = 190; enemyico.gameObject.GetComponent <LayoutElement>().preferredWidth = 190; enemyico.Endow(data.monster_tip[idx], true); } else { enemyico.Endow(data.monster_tip[idx], false); } enemyico.isShow = true; } ItemUIView drop_tip = null; for (int idx = 0; idx < data.drop_tip.Length; idx++) { if (idx == Drop_TipList.Count) { drop_tip = InitItemInfo(Drop_Tip.gameObject, dropOutShow_obj).GetComponent <ItemUIView>(); drop_tip.Init(); Drop_TipList.Add(drop_tip); } else { drop_tip = Drop_TipList[idx]; } drop_tip.isShow = true; drop_tip.SetInfo(data.drop_tip[idx], 0); } switch (stra) //根据本关卡获得星数对关卡显示界面星星赋值 { case 0: star_1_img.color = new Color(star_1_img.color.r, star_1_img.color.g, star_1_img.color.b, 0); star_2_img.color = new Color(star_2_img.color.r, star_2_img.color.g, star_2_img.color.b, 0); star_3_img.color = new Color(star_3_img.color.r, star_3_img.color.g, star_3_img.color.b, 0); break; case 1: star_1_img.color = new Color(star_1_img.color.r, star_1_img.color.g, star_1_img.color.b, 1); star_2_img.color = new Color(star_2_img.color.r, star_2_img.color.g, star_2_img.color.b, 0); star_3_img.color = new Color(star_3_img.color.r, star_3_img.color.g, star_3_img.color.b, 0); break; case 2: star_1_img.color = new Color(star_1_img.color.r, star_1_img.color.g, star_1_img.color.b, 1); star_2_img.color = new Color(star_2_img.color.r, star_2_img.color.g, star_2_img.color.b, 1); star_3_img.color = new Color(star_3_img.color.r, star_3_img.color.g, star_3_img.color.b, 0); break; case 3: star_1_img.color = new Color(star_1_img.color.r, star_1_img.color.g, star_1_img.color.b, 1); star_2_img.color = new Color(star_2_img.color.r, star_2_img.color.g, star_2_img.color.b, 1); star_3_img.color = new Color(star_3_img.color.r, star_3_img.color.g, star_3_img.color.b, 1); break; } if (data.times == 1) // 精英及史诗副本通关次数如果小于1 { time_obj.SetActive(false); // CustomsPass_obj.SetActive(true); } else { for (int idx2 = 0; idx2 < BattleMgr.Instance.Genlevel[BattleMgr.Instance.SectionKey][BattleMgr.Instance.SectionChapter].GenStage.Count; idx2++) { if (BattleMgr.Instance.Genlevel[BattleMgr.Instance.SectionKey][BattleMgr.Instance.SectionChapter].GenStage[idx2].LevelID == BattleMgr.Instance.LevelID) { if (BattleMgr.Instance.Genlevel[BattleMgr.Instance.SectionKey][BattleMgr.Instance.SectionChapter].GenStage[idx2].ResidueTime == 0) //剩余次数 { nowTime_txt.text = "0"; } else { if (BattleMgr.Instance.Genlevel[BattleMgr.Instance.SectionKey][BattleMgr.Instance.SectionChapter].GenStage[idx2].isZeki) { time_obj.SetActive(true); Total_txt.text = "/" + data.times.ToString(); nowTime_txt.text = BattleMgr.Instance.Genlevel[BattleMgr.Instance.SectionKey][BattleMgr.Instance.SectionChapter].GenStage[idx2].ResidueTime.ToString(); } } // CustomsPass_obj.SetActive(true); return; } } } }
/// <summary> /// 点击物品,生成物品弹框 /// </summary> /// <param name="id"></param> public void SpawnItemPop(ItemUIView item) { SelectItemEffect(item); ClickItem(item); }