Esempio n. 1
0
    void ShowBagItems()
    {
        HideAllGoItems();
        int index = 0;

        using (var e = tempBagItems.GetEnumerator())
        {
            while (e.MoveNext())
            {
                EquipmentInfo info = e.Current.Value;
                if (info == null)
                {
                    continue;
                }
                GameObject go = null;
                if (!allGoItems.ContainsKey(info.InstanceID))
                {
                    go = Instantiate(exResources.GetResource(ResourceType.GUI, "Backpack/DecomposeItem")) as GameObject;
                    allGoItems[info.InstanceID] = go;
                }
                go = allGoItems[info.InstanceID];
                go.SetActive(true);
                go.transform.parent        = bagItemsPanel.transform;
                go.transform.localPosition = new Vector3(positionInfo.x, positionInfo.y - positionInfo.w * index, -1);
                go.transform.localScale    = Vector3.one;
                DecomposeItemUI bagItemUI = go.GetComponent <DecomposeItemUI>();
                go = null;
                bagItemUI.SetData(info, ChooseBagItem);
                index++;
            }
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 显示背包中的装备
    /// </summary>
    /// <param name="itemDic">装备列表</param>
    /// <param name="needCheckFirst">If set to <c>true</c> 是否需要选中第一个装备</param>
    void ShowBagItems(Dictionary <int, EquipmentInfo> itemDic, bool needCheckFirst = true)
    {
        HideAllGoItems();
        int                  index    = 0;
        DecomposeItemUI      firstOne = null;
        List <EquipmentInfo> itemList = new List <EquipmentInfo>(itemDic.Values);

        itemList.Sort(CompareEquip);
        for (int i = 0, count = itemList.Count; i < count; i++)
        {
            EquipmentInfo info = itemList[i];
            if (info == null)
            {
                continue;
            }
            EquipmentInfo selectOne = GameCenter.equipmentTrainingMng.CurSelectEquipmentInfo;
            if (GameCenter.equipmentTrainingMng.CurSlot != EquipSlot.None && (GameCenter.equipmentTrainingMng.CurSlot != info.Slot || (selectOne != null && (selectOne.NeedProf != info.NeedProf || info.InstanceID == selectOne.InstanceID))))
            {
                continue;
            }
            //选中了副装备就隐藏副装备
            if (GameCenter.equipmentTrainingMng.CurViceEquipmentInfo != null && GameCenter.equipmentTrainingMng.CurViceEquipmentInfo.InstanceID == info.InstanceID)
            {
                continue;
            }
            DecomposeItemUI itemUI = null;
            if (!allGoItems.ContainsKey(index))
            {
                if (equipGo != null)
                {
                    itemUI = equipGo.CreateNew(itemParent.transform);
                }
                allGoItems[index] = itemUI;
            }
            itemUI = allGoItems[index];
            itemUI.gameObject.SetActive(true);
            itemUI.SetData(info, ChooseBagItem, initSubGUIType);
            if (index == 0 && needCheckFirst)
            {
                firstOne = itemUI;
            }
            index++;
        }
        if (firstOne != null && needCheckFirst)
        {
            firstOne.SetChecked();
        }
        if (scrollView != null)
        {
            scrollView.SetDragAmount(0, 0, false);
        }
        if (itemParent != null)
        {
            itemParent.repositionNow = true;
        }
        if (itemDic.Count == 0)
        {
            GameCenter.equipmentTrainingMng.CurSelectEquipmentInfo = null;
        }
    }
Esempio n. 3
0
 /// <summary>
 /// 刷新展示出来的装备的红点(背包中材料变化即刷新)
 /// </summary>
 void RefreshRedTip()
 {
     foreach (var go in allGoItems.Values)
     {
         if (go != null && go.gameObject.activeSelf)
         {
             DecomposeItemUI itemUI = go.GetComponent <DecomposeItemUI>();
             if (itemUI != null)
             {
                 itemUI.ShowRedTip();
             }
         }
     }
 }
Esempio n. 4
0
    /// <summary>
    /// 显示坐骑身上的装备
    /// </summary>
    void ShowEquipItems()
    {
        HideAllGoItems();
        int                  index     = 0;
        DecomposeItemUI      checkOne  = null;
        EquipmentInfo        selectOne = GameCenter.newMountMng.CurSelectEquipmentInfo;
        List <EquipmentInfo> itemList  = new List <EquipmentInfo>(GameCenter.newMountMng.MountEquipDic.Values);

        //Debug.Log("itemList:" + itemList.Count);
        for (int i = 0, count = itemList.Count; i < count; i++)
        {
            EquipmentInfo info = itemList[i];
            if (info == null)
            {
                continue;
            }
            DecomposeItemUI itemUI = null;
            if (!allGoItems.ContainsKey(index))
            {
                if (equipGo != null)
                {
                    itemUI = equipGo.CreateNew(itemParent.transform);
                }
                allGoItems[index] = itemUI;
            }
            itemUI = allGoItems[index];
            itemUI.gameObject.SetActive(true);
            itemUI.SetData(info, ChooseItem, SubGUIType.MOUNTEQUIP);
            if (selectOne != null)
            {
                if (selectOne.InstanceID == info.InstanceID)
                {
                    checkOne = itemUI;
                }
            }
            else
            {
                if (index == 0)
                {
                    checkOne = itemUI;
                }
            }
            index++;
        }
        if (scrollView != null)
        {
            scrollView.SetDragAmount(0, 0, false);
        }
        if (itemParent != null)
        {
            itemParent.repositionNow = true;
        }
        if (checkOne != null)
        {
            checkOne.SetChecked();
        }
        if (itemList.Count == 0)
        {
            GameCenter.newMountMng.CurSelectEquipmentInfo = null;
        }
    }
Esempio n. 5
0
    protected override void HandEvent(bool _bind)
    {
        base.HandEvent(_bind);
        if (_bind)
        {
            if (toggleEquip != null)
            {
                UIEventListener.Get(toggleEquip.gameObject).onClick = OnChangeEquipList;
            }
            if (toggleBag != null)
            {
                UIEventListener.Get(toggleBag.gameObject).onClick = OnChangeEquipList;
            }
            if (quickTog != null)
            {
                EventDelegate.Add(quickTog.onChange, OnChangeQuickTog);
            }
            GameCenter.inventoryMng.OnGetSealEquResult += RefreshLeft;
            if (shenGo != null)
            {
                UIEventListener.Get(shenGo).onClick = delegate {
                    ToolTipMng.ShowEquipmentTooltip(consumeInfo, ItemActionType.None, ItemActionType.None, ItemActionType.None, ItemActionType.None);
                }
            }
            ;
        }
        else
        {
            if (toggleEquip != null)
            {
                UIEventListener.Get(toggleEquip.gameObject).onClick = null;
            }
            if (toggleBag != null)
            {
                UIEventListener.Get(toggleBag.gameObject).onClick = null;
            }
            if (quickTog != null)
            {
                EventDelegate.Remove(quickTog.onChange, OnChangeQuickTog);
            }
            GameCenter.inventoryMng.OnGetSealEquResult -= RefreshLeft;
            if (shenGo != null)
            {
                UIEventListener.Get(shenGo).onClick = null;
            }
        }
    }

    /// <summary>
    /// 是否快捷购买
    /// </summary>
    void OnChangeQuickTog()
    {
        goldGo.SetActive(quickTog.value);
    }

    /// <summary>
    /// 切换身上和背包按钮
    /// </summary>
    void OnChangeEquipList(GameObject go)
    {
        itemsPanel.GetComponent <UIScrollView>().ResetPosition();
        if (toggleEquip.value)
        {
            GetEquipFromEqu();
        }
        else if (toggleBag.value)
        {
            GetEquipFromBag();
        }
        ShowItems();
    }

    /// <summary>
    /// 获得身上的所有装备
    /// </summary>
    void GetEquipFromEqu()
    {
        tempItems.Clear();
        Dictionary <int, EquipmentInfo> backDic = GameCenter.inventoryMng.GetPlayerEquipList();

        using (var e = backDic.GetEnumerator())
        {
            while (e.MoveNext())
            {
                EquipmentInfo info = e.Current.Value;
                if (info.Slot != EquipSlot.None && info.StackCurCount != 0)
                {
                    tempItems[info.InstanceID] = info;
                }
            }
        }
    }

    /// <summary>
    /// 获得背包中的所有装备
    /// </summary>
    void GetEquipFromBag()
    {
        tempItems.Clear();
        Dictionary <int, EquipmentInfo> backDic = GameCenter.inventoryMng.GetBackpackEquipDic();

        using (var e = backDic.GetEnumerator())
        {
            while (e.MoveNext())
            {
                EquipmentInfo info = e.Current.Value;
                if (info.Slot != EquipSlot.None && info.StackCurCount != 0)
                {
                    tempItems[info.InstanceID] = info;
                }
            }
        }
    }

    #region 右侧逻辑
    /// <summary>
    /// 显示右边的装备信息
    /// </summary>
    void ShowItems()
    {
        HideAllGoItems();
        int index = 0;

        using (var e = tempItems.GetEnumerator())
        {
            while (e.MoveNext())
            {
                EquipmentInfo info = e.Current.Value;
                if (info == null)
                {
                    continue;
                }
                GameObject go = null;
                if (!allGoItems.ContainsKey(info.InstanceID))
                {
                    go = Instantiate(exResources.GetResource(ResourceType.GUI, "Backpack/DecomposeItem")) as GameObject;
                    allGoItems[info.InstanceID] = go;
                }
                go = allGoItems[info.InstanceID];
                go.SetActive(true);
                go.transform.parent        = itemsPanel.transform;
                go.transform.localPosition = new Vector3(positionInfo.x, positionInfo.y - positionInfo.w * index, -1);
                go.transform.localScale    = Vector3.one;
                DecomposeItemUI bagItemUI = go.GetComponent <DecomposeItemUI>();
                go = null;
                bagItemUI.SetData(info, ChooseBagItem);
                index++;
            }
        }
    }

    void HideAllGoItems()
    {
        using (var e = allGoItems.GetEnumerator())
        {
            while (e.MoveNext())
            {
                GameObject go = e.Current.Value;
                if (go != null)
                {
                    go.SetActive(false);
                }
            }
        }
    }

    void ChooseBagItem(GameObject go)
    {
        curEquInfo = (EquipmentInfo)UIEventListener.Get(go).parameter;
        RefreshLeft(curEquInfo);
    }

    #endregion

    #region 左侧逻辑

    /// <summary>
    /// 刷新左边的信息
    /// </summary>
    void RefreshLeft(EquipmentInfo _info)
    {
        if (_info != null)
        {
            curEquInfo = _info;
        }
        if (curEquInfo != null)
        {
            curChooseItem.FillInfo(new EquipmentInfo(curEquInfo, EquipmentBelongTo.PREVIEW));
        }
        else
        {
            curChooseItem.FillInfo(null);
        }
        if (curEquInfo != null)
        {
            if (bindLabel[0] != null)
            {
                bindLabel[0].gameObject.SetActive(curEquInfo.IsBind);
            }
            if (bindLabel[1] != null)
            {
                bindLabel[1].gameObject.SetActive(!curEquInfo.IsBind);
            }
            if (bindBtn != null)
            {
                bindBtn.gameObject.SetActive(!curEquInfo.IsBind);
            }
            if (cancelBindBtn != null)
            {
                cancelBindBtn.gameObject.SetActive(curEquInfo.IsBind);
            }
        }
        else
        {
            if (bindLabel[0] != null)
            {
                bindLabel[0].gameObject.SetActive(false);
            }
            if (bindLabel[1] != null)
            {
                bindLabel[1].gameObject.SetActive(false);
            }
        }
        int num = GameCenter.inventoryMng.GetNumberByType(4000013);

        if (consumeLabel != null)
        {
            consumeLabel.text = "1/" + (num >= 1 ? num.ToString() :"[ff0000]" + num);
        }
        if (goldLabel != null)
        {
            goldLabel.text = consumeInfo.DiamondPrice + "/" + GameCenter.mainPlayerMng.MainPlayerInfo.TotalDiamondCount;
        }
    }

    #endregion
}