Exemplo n.º 1
0
    //伙伴根据战力排序,返回最上面的PartnerId
    public int PartnerReposition(int playedPartnerId)
    {
        m_PartnerItemList.Sort(Comp);
        for (int i = 0; i < m_PartnerItemList.Count; ++i)
        {
            if (m_PartnerItemList[i] != null)
            {
                m_PartnerItemList[i].gameObject.name = (c_PartnerNumMax - i).ToString();
            }
        }
        UIPartnerItem partnerItem = GetPartnerItemById(playedPartnerId);

        if (null != partnerItem)
        {
            partnerItem.name = "0";
        }
        if (goItemContainer != null)
        {
            UIGrid grid = goItemContainer.GetComponent <UIGrid>();
            if (grid != null)
            {
                grid.Reposition();
            }
        }
        if (playedPartnerId != -1)
        {
            return(playedPartnerId);
        }
        if (m_PartnerItemList.Count > 0)
        {
            return(m_PartnerItemList[m_PartnerItemList.Count - 1].PartnerId);
        }
        return(-1);
    }
Exemplo n.º 2
0
    //
    public void UpdatePartnerInfo(PartnerInfo info)
    {
        if (info == null)
        {
            return;
        }
        UIPartnerItem partner_item = GetPartnerItemById(info.Id);

        if (partner_item != null)
        {
            partner_item.UpdatePartnerInfo(info);
        }
        RoleInfo role_info = LobbyClient.Instance.CurrentRole;

        if (role_info != null)
        {
            PartnerStateInfo state_info = role_info.PartnerStateInfo;
            if (state_info == null)
            {
                return;
            }
            int active_id = state_info.GetActivePartnerId();
            PartnerReposition(active_id);
        }
    }
Exemplo n.º 3
0
 //
 private UIPartnerItem TryGetPartnerItem(int index)
 {
     if (index < m_PartnerItemList.Count && m_PartnerItemList[index] != null)
     {
         return(m_PartnerItemList[index]);
     }
     if (index < m_PartnerItemList.Count && m_PartnerItemList[index] == null)
     {
         m_PartnerItemList.Remove(m_PartnerItemList[index]);
     }
     if (goItemContainer != null && goPartnerItem != null)
     {
         UnityEngine.GameObject goChild = NGUITools.AddChild(goItemContainer, goPartnerItem);
         if (goChild != null)
         {
             UIPartnerItem partner_item = goChild.GetComponent <UIPartnerItem>();
             if (partner_item != null)
             {
                 m_PartnerItemList.Add(partner_item);
                 return(partner_item);
             }
         }
     }
     return(null);
 }
Exemplo n.º 4
0
    //设置PartnerItem的选中状态
    public void SetPartnerSelected(int partnerId, bool visible)
    {
        UIPartnerItem item = GetPartnerItemById(partnerId);

        if (item != null)
        {
            item.SetSelectedFlagVisible(visible);
        }
    }
Exemplo n.º 5
0
    //添加已经获得的伙伴
    private bool AddExitPartnerItem(PartnerInfo partner_info, int active_id, int partnerIndex)
    {
        if (partner_info == null)
        {
            return(false);
        }
        UIPartnerItem partner_item = TryGetPartnerItem(partnerIndex);

        if (partner_item != null)
        {
            partner_item.InitPartnerItem(partner_info, active_id);
            if (canUpgradeDic != null)
            {
                bool value = false;
                canUpgradeDic.TryGetValue(partner_info.Id, out value);
                partner_item.SetTipActive(value);
            }
            return(true);
        }
        return(false);
    }
Exemplo n.º 6
0
    //添加暂未获得伙伴
    private bool AddNotHavenPartnerItem(PartnerConfig cfg, int partnerIndex)
    {
        if (cfg == null)
        {
            return(false);
        }
        int ownItemNum = GetItemNum(cfg.PartnerFragId);

        //当前拥有碎片数小于等于0的不加载
        if (ownItemNum <= 0)
        {
            return(false);
        }
        UIPartnerItem partner_item = TryGetPartnerItem(partnerIndex);

        if (null != partner_item)
        {
            partner_item.InitNotHavenPartner(cfg);
            return(true);
        }
        return(false);
    }
Exemplo n.º 7
0
 //
 public int Comp(UIPartnerItem item1, UIPartnerItem item2)
 {
     if (item1 == null && item2 == null)
     {
         return(0);
     }
     if (item1 == null)
     {
         return(-1);
     }
     if (item2 == null)
     {
         return(1);
     }
     if (item1.GetPartnerFighting() >= item2.GetPartnerFighting())
     {
         return(1);
     }
     else
     {
         return(-1);
     }
 }