void CreateBook(int _index, int _id) { BookItem item = BookItem.CeateBook(_index, bookParent, true); item.gameObject.SetActive(true); item.chooseBtn.gameObject.SetActive(false); item.chooseYetBtn.gameObject.SetActive(false); ItemUI bookItem = item.GetComponent <ItemUI>(); bookItem.FillInfo(new EquipmentInfo(_id, EquipmentBelongTo.PREVIEW)); bookItem.SetActionBtn(ItemActionType.None, ItemActionType.None, ItemActionType.SelectAdd); }
void FillAItem(int _copyKey) { if (petSkillByCopyAll.ContainsKey(_copyKey)) { int skillId = petSkillByCopyAll[_copyKey]; if (bookItem == null) { bookItem = BookItem.CeateBook(0, parent, false); bookItem.gameObject.SetActive(true); bookItem.transform.localPosition = new Vector3(200, -50); ItemUI bookItemUI = bookItem.GetComponent <ItemUI>(); bookItemUI.FillInfo(new EquipmentInfo(skillId, EquipmentBelongTo.PREVIEW)); bookItem.transform.parent = parent.transform; bookItem.chooseBtn.gameObject.SetActive(true); bookItem.chooseYetBtn.gameObject.SetActive(false); if (bookItem.chooseBtn != null) { UIEventListener.Get(bookItem.chooseBtn.gameObject).onClick -= OnClickChooseOneToBag; UIEventListener.Get(bookItem.chooseBtn.gameObject).onClick += OnClickChooseOneToBag; UIEventListener.Get(bookItem.chooseBtn.gameObject).parameter = _copyKey; } } else { ItemUI bookItemUi = bookItem.GetComponent <ItemUI>(); bookItemUi.FillInfo(new EquipmentInfo(skillId, EquipmentBelongTo.PREVIEW)); bookItem.transform.parent = parent.transform; bookItem.chooseBtn.gameObject.SetActive(true); bookItem.chooseYetBtn.gameObject.SetActive(false); if (_copyKey == GameCenter.mercenaryMng.choosedSkillId) { bookItem.chooseBtn.gameObject.SetActive(false); bookItem.chooseYetBtn.gameObject.SetActive(true); } if (bookItem.chooseBtn != null) { UIEventListener.Get(bookItem.chooseBtn.gameObject).onClick -= OnClickChooseOneToBag; UIEventListener.Get(bookItem.chooseBtn.gameObject).onClick += OnClickChooseOneToBag; UIEventListener.Get(bookItem.chooseBtn.gameObject).parameter = _copyKey; } } } }
/// <summary> /// 获得的技能书(抄写成功) /// </summary> void ShowBook() { if (eqt == null) { eqt = ConfigMng.Instance.GetEquipmentRef(2200001); } if (diamondLab != null && eqt != null && MainPlayerInfo != null) { diamondLab.text = eqt.diamonPrice + "/" + MainPlayerInfo.TotalDiamondCount.ToString(); } if (copyLab != null) { copyLab.text = "1" + "/" + GameCenter.inventoryMng.GetNumberByType(2200001); } if (copyAllLab != null) { copyAllLab.text = "10" + "/" + GameCenter.inventoryMng.GetNumberByType(2200001); } foreach (BookItem book in bookByCopyAll.Values) { book.gameObject.SetActive(false); } int len = petSkillByCopyAll.Count; if (len > 0) { if (len == 1)//如果只抄写了一本书 { using (var key = petSkillByCopyAll.GetEnumerator()) { while (key.MoveNext()) { FillAItem(key.Current.Key); } } } else//如果批量抄写 { int i = 0; SetItemActive(); using (var key = petSkillByCopyAll.GetEnumerator()) { while (key.MoveNext()) { int listlen = bookByCopyAllList.Count; int skillId = petSkillByCopyAll[key.Current.Key]; if (listlen < 10) { BookItem item = BookItem.CeateBook(i, parent, false); item.gameObject.SetActive(true); ItemUI bookItem = item.GetComponent <ItemUI>(); bookItem.FillInfo(new EquipmentInfo(skillId, EquipmentBelongTo.PREVIEW)); bookByCopyAll[key.Current.Key] = item; bookByCopyAllList.Add(item); item.chooseBtn.gameObject.SetActive(true); item.chooseYetBtn.gameObject.SetActive(false); if (item.chooseEx != null) { item.chooseEx.IsGray = UISpriteEx.ColorGray.normal; } if (GameCenter.mercenaryMng.choosedSkillId != 0 && key.Current.Key != GameCenter.mercenaryMng.choosedSkillId) { if (item.chooseEx != null) { item.chooseEx.IsGray = UISpriteEx.ColorGray.Gray; } } else { if (key.Current.Key == GameCenter.mercenaryMng.choosedSkillId) { item.chooseBtn.gameObject.SetActive(false); item.chooseYetBtn.gameObject.SetActive(true); } } if (item.chooseBtn != null) { UIEventListener.Get(item.chooseBtn.gameObject).onClick -= OnClickChooseToBag; UIEventListener.Get(item.chooseBtn.gameObject).onClick += OnClickChooseToBag; UIEventListener.Get(item.chooseBtn.gameObject).parameter = key.Current.Key; } i++; } else { if (listlen > i) { BookItem item = bookByCopyAllList[i]; item.gameObject.SetActive(true); ItemUI bookItem = item.GetComponent <ItemUI>(); bookItem.FillInfo(new EquipmentInfo(skillId, EquipmentBelongTo.PREVIEW)); bookByCopyAll[key.Current.Key] = item; bookByCopyAllList.Add(item); item.chooseBtn.gameObject.SetActive(true); item.chooseYetBtn.gameObject.SetActive(false); if (item.chooseEx != null) { item.chooseEx.IsGray = UISpriteEx.ColorGray.normal; } if (GameCenter.mercenaryMng.choosedSkillId != 0 && key.Current.Key != GameCenter.mercenaryMng.choosedSkillId) { if (item.chooseEx != null) { item.chooseEx.IsGray = UISpriteEx.ColorGray.Gray; } } else { if (key.Current.Key == GameCenter.mercenaryMng.choosedSkillId) { item.chooseBtn.gameObject.SetActive(false); item.chooseYetBtn.gameObject.SetActive(true); } } if (item.chooseBtn != null) { UIEventListener.Get(item.chooseBtn.gameObject).onClick -= OnClickChooseToBag; UIEventListener.Get(item.chooseBtn.gameObject).onClick += OnClickChooseToBag; UIEventListener.Get(item.chooseBtn.gameObject).parameter = key.Current.Key; } i++; } } } } } } }