Example #1
0
    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);
    }
Example #2
0
 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;
             }
         }
     }
 }
Example #3
0
    /// <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++;
                            }
                        }
                    }
                }
            }
        }
    }
Example #4
0
    /// <summary>
    /// 显示背包中的高级、顶级技能书
    /// </summary>
    void ShowBookInBag()
    {
        int lenth = choosedPetSkill.Count;

        if (lenth <= 0)
        {
            if (noNeedBook != null)
            {
                noNeedBook.gameObject.SetActive(true);
            }
        }
        else
        {
            noNeedBook.gameObject.SetActive(false);
        }
        if (parent != null)
        {
            UIGrid grid = parent.GetComponent <UIGrid>();
            grid.maxPerLine = lenth / 2 + lenth % 2;
        }
        foreach (BookItem book in bookInBag.Values)
        {
            book.gameObject.SetActive(false);
        }
        ItemUI choodeitem = composeBookBtn.GetComponent <ItemUI>();

        for (int i = 0; i < lenth; i++)
        {
            int id = choosedPetSkill[i];
            if (choodeitem != null && choodeitem.EQInfo != null)
            {
                EquipmentRef info = ConfigMng.Instance.GetEquipmentRef(id);
                if (info.psetSkillLevel < needLev)
                {
                    continue;
                }
            }
            if (!bookInBag.ContainsKey(id))//创建
            {
                BookItem item = BookItem.CeateNew(i, parent, true);
                item.gameObject.SetActive(true);
                item.chooseBtn.gameObject.SetActive(true);
                item.chooseYetBtn.gameObject.SetActive(false);
                item.curType = ChooseType.GETMAT;
                ItemUI bookItem = item.GetComponent <ItemUI>();
                bookItem.FillInfo(new EquipmentInfo(id, GameCenter.inventoryMng.GetNumberByType(id), EquipmentBelongTo.PREVIEW));
                int num = 0;
                for (int j = 0; j < choosedBookInMat.Count; j++)
                {
                    if (id == choosedBookInMat[j])
                    {
                        ++num;
                    }
                }
                bookItem.FillInfo(new EquipmentInfo(id, GameCenter.inventoryMng.GetNumberByType(id) - num, EquipmentBelongTo.PREVIEW));
                if (item.chooseBtn != null)
                {
                    UIEventListener.Get(item.chooseBtn.gameObject).onClick  -= OnClickChooseToMat;
                    UIEventListener.Get(item.chooseBtn.gameObject).onClick  += OnClickChooseToMat;
                    UIEventListener.Get(item.chooseBtn.gameObject).parameter = id;
                }
                bookInBag[id] = item;
            }
            else//刷新
            {
                BookItem book = bookInBag[id] as BookItem;
                book.gameObject.SetActive(true);
                book.transform.localPosition = new Vector3((i % 2) * 120, -(i / 2) * 168);
                book.chooseBtn.gameObject.SetActive(true);
                book.chooseYetBtn.gameObject.SetActive(false);
                ItemUI bookItem = book.GetComponent <ItemUI>();
                bookItem.FillInfo(new EquipmentInfo(id, GameCenter.inventoryMng.GetNumberByType(id), EquipmentBelongTo.PREVIEW));
                int num = 0;
                for (int j = 0; j < choosedBookInMat.Count; j++)
                {
                    if (id == choosedBookInMat[j])
                    {
                        ++num;
                    }
                }
                bookItem.FillInfo(new EquipmentInfo(id, (GameCenter.inventoryMng.GetNumberByType(id) - num), EquipmentBelongTo.PREVIEW));
            }
        }
    }
Example #5
0
    /// <summary>
    /// 在下方显示背包中的技能书
    /// </summary>
    void ShowBookItem()
    {
        GameCenter.mercenaryMng.GetBookFromBag();
        int count = allPetSkillBook.Count;

        for (int i = 0, max = bookItemList.Count; i < max; i++)
        {
            bookItemList[i].gameObject.SetActive(false);
        }

        if (parent != null)
        {
            UIGrid grid = parent.GetComponent <UIGrid>();
            if (grid != null)
            {
                grid.maxPerLine = count > 6 ? count : 6;
                ItemUI   bookItem = null;
                BookItem item     = null;
                for (int i = 0, max = grid.maxPerLine; i < max; i++)
                {
                    if (bookItemList.Count <= i)
                    {
                        item = BookItem.CeateNew(i, parent, false);
                        item.gameObject.SetActive(true);
                        item.chooseBtn.gameObject.SetActive(false);
                        item.chooseYetBtn.gameObject.SetActive(false);
                        bookItem             = item.GetComponent <ItemUI>();
                        bookItem.ShowTooltip = false;//关闭热感
                        if (GameCenter.mercenaryMng.curPetId == MercenaryMng.noPet || GameCenter.mercenaryMng.mercenaryInfoList.Count <= 0)
                        {
                            bookItem.ShowTooltip = true;
                        }
                        bookItem.itemName.gameObject.SetActive(false);//隐藏名字
                        if (count > i)
                        {
                            if (allPetSkillBook.ContainsKey(skillBookKey[i]))
                            {
                                int id = skillBookKey[i];
                                item.gameObject.SetActive(true);
                                item.chooseBtn.gameObject.SetActive(false);
                                item.chooseYetBtn.gameObject.SetActive(false);
                                bookItem = item.GetComponent <ItemUI>();
                                bookItem.FillInfo(new EquipmentInfo(id, allPetSkillBook[id], EquipmentBelongTo.PREVIEW));
                                item.petSkillRefDate = ConfigMng.Instance.GetPetSkillRefByBook(id);
                                UIButton button = item.GetComponent <UIButton>();
                                if (button != null && item.petSkillRefDate != null)
                                {
                                    UIEventListener.Get(button.gameObject).onClick  -= OnClickStudySkill;
                                    UIEventListener.Get(button.gameObject).onClick  += OnClickStudySkill;
                                    UIEventListener.Get(button.gameObject).parameter = item.petSkillRefDate.id;//技能id
                                }
                            }
                        }
                        bookItemList.Add(item);
                    }
                    else
                    {
                        bookItemList[i].gameObject.SetActive(true);
                        bookItemList[i].chooseBtn.gameObject.SetActive(false);
                        bookItemList[i].chooseYetBtn.gameObject.SetActive(false);
                        bookItem             = bookItemList[i].GetComponent <ItemUI>();
                        bookItem.ShowTooltip = false;//关闭热感
                        if (GameCenter.mercenaryMng.curPetId == MercenaryMng.noPet || GameCenter.mercenaryMng.mercenaryInfoList.Count <= 0)
                        {
                            bookItem.ShowTooltip = true;
                        }
                        bookItem.itemName.gameObject.SetActive(false);//隐藏名字
                        if (count > i)
                        {
                            int id = skillBookKey[i];
                            bookItemList[i].gameObject.SetActive(true);
                            bookItemList[i].chooseBtn.gameObject.SetActive(false);
                            bookItemList[i].chooseYetBtn.gameObject.SetActive(false);
                            bookItem = bookItemList[i].GetComponent <ItemUI>();
                            bookItem.FillInfo(new EquipmentInfo(id, allPetSkillBook[id], EquipmentBelongTo.PREVIEW));
                            bookItemList[i].petSkillRefDate = ConfigMng.Instance.GetPetSkillRefByBook(id);
                            UIButton button = bookItemList[i].GetComponent <UIButton>();
                            if (button != null && bookItemList[i].petSkillRefDate != null)
                            {
                                UIEventListener.Get(button.gameObject).onClick  -= OnClickStudySkill;
                                UIEventListener.Get(button.gameObject).onClick  += OnClickStudySkill;
                                UIEventListener.Get(button.gameObject).parameter = bookItemList[i].petSkillRefDate.id;//技能id
                            }
                        }
                        else
                        {
                            bookItem.FillInfo(null);
                        }
                    }
                }
            }
        }
    }