コード例 #1
0
    /// <summary>
    /// 更新已解锁护符栏
    /// </summary>
    private void CreateBadgeGrid()
    {
        List <ItemInfo> badgeInfo = new List <ItemInfo>(new ItemInfo[40]);

        foreach (ItemInfo temp in BadgeMgr.Instance.badgeUnlocked.Values)
        {
            badgeInfo[(temp.id - 21)] = temp;
        }

        for (int i = 0; i < badgeGridList.Count; ++i)
        {
            Destroy(badgeGridList[i].gameObject);
            badgeGridList[i].transform.SetParent(null);
        }
        badgeGridList.Clear();
        for (int i = 0; i < badgeInfo.Count; ++i)
        {
            ItemCell cell = ResMgr.Instance.Load <GameObject>("ItemCell").GetComponent <ItemCell>();
            cell.transform.SetParent(badgeGrid.transform);
            cell.InitInfo(badgeInfo[i]);
            if (BadgeMgr.Instance.GetEquipedState(badgeInfo[i]))
            {
                cell.ItemOn();
            }
            else
            {
                cell.ItemOff();
            }
            badgeGridList.Add(cell);
        }
    }
コード例 #2
0
    /// <summary>
    /// 页签切换的函数
    /// </summary>
    /// <param name="type"></param>
    public void ChangeType(E_Bag_Type type)
    {
        //默认值是道具列表信息
        List <ItemInfo> tempInfo = GameDataMgr.GetInstance().playerInfo.items;

        switch (type)
        {
        case E_Bag_Type.Equip:
            tempInfo = GameDataMgr.GetInstance().playerInfo.equips;
            break;

        case E_Bag_Type.Gem:
            tempInfo = GameDataMgr.GetInstance().playerInfo.gems;
            break;
        }
        //更新前先删除之前的格子
        for (int i = 0; i < list.Count; i++)
        {
            Destroy(list[i].gameObject);
        }
        list.Clear();
        temp_items.Clear();

        int      totalNum  = 0;
        ItemInfo item_info = new ItemInfo();

        for (int i = 0; i < tempInfo.Count; i++)
        {
            if (temp_items.ContainsKey(tempInfo[i].id))
            {
                totalNum += tempInfo[i].num;
                temp_items[tempInfo[i].id] = new ItemInfo()
                {
                    id = tempInfo[i].id, num = totalNum
                };
            }
            else
            {
                totalNum = tempInfo[i].num;
                temp_items.Add(tempInfo[i].id, new ItemInfo()
                {
                    id = tempInfo[i].id, num = totalNum
                });
            }
        }
        //更新现在的数据
        //动态创建 ItemCell 预设体 并且将它存放到list里面
        foreach (var item in temp_items)
        {
            ItemCell cell = ResMgr.GetInstance().Load <GameObject>("UI/ItemCell").GetComponent <ItemCell>();
            cell.transform.parent     = content;
            cell.transform.localScale = Vector3.one;
            cell.InitInfo(temp_items[item.Key]);
            list.Add(cell);
        }
    }
コード例 #3
0
    public void UpdateRolePanel()
    {
        List <ItemInfo> nowEquips = GameDataMgr.GetInstance().playerInfo.nowEquips;
        Item            itemInfo;

        itemHead.InitInfo(null);
        itemNeck.InitInfo(null);
        itemWeapon.InitInfo(null);
        itemCloth.InitInfo(null);
        itemTrousers.InitInfo(null);
        itemShoes.InitInfo(null);
        for (int i = 0; i < nowEquips.Count; i++)
        {
            Debug.Log("查看一下" + nowEquips[i].id);
            itemInfo = GameDataMgr.GetInstance().GetItemInfo(nowEquips[i].id);
            switch (itemInfo.equipType)
            {
            case (int)E_Item_Type.Head:
                itemHead.InitInfo(nowEquips[i]);
                break;

            case (int)E_Item_Type.Neck:
                itemNeck.InitInfo(nowEquips[i]);
                break;

            case (int)E_Item_Type.Weapon:
                itemWeapon.InitInfo(nowEquips[i]);
                break;

            case (int)E_Item_Type.Cloth:
                itemCloth.InitInfo(nowEquips[i]);
                break;

            case (int)E_Item_Type.Trousers:
                itemTrousers.InitInfo(nowEquips[i]);
                break;

            case (int)E_Item_Type.Shoes:
                itemShoes.InitInfo(nowEquips[i]);
                break;
            }
        }
    }
コード例 #4
0
    /// <summary>
    /// 更新已装备护符栏
    /// </summary>
    private void CreateEquipedGrid()
    {
        for (int i = 0; i < badgeEquipList.Count; ++i)
        {
            GameObject.Destroy(badgeEquipList[i].gameObject);
            badgeEquipList[i].gameObject.transform.SetParent(null);
        }
        badgeEquipList.Clear();

        foreach (ItemInfo info in BadgeMgr.Instance.badgeEquiped.Values)
        {
            ItemCell cell = ResMgr.Instance.Load <GameObject>("ItemCell").GetComponent <ItemCell>();
            cell.transform.SetParent(badgeEquiped.transform);
            cell.InitInfo(info);
            badgeEquipList.Add(cell);
        }
    }