//
 private UIPartnerSlot TryGetPartnerItem(int index)
 {
     if (index < m_AllPartners.Count && m_AllPartners[index] != null)
     {
         return(m_AllPartners[index]);
     }
     if (index < m_AllPartners.Count && m_AllPartners[index] == null)
     {
         m_AllPartners.Remove(m_AllPartners[index]);
     }
     if (goPartnerSlotContainer != null && goPartnerSlot != null)
     {
         UnityEngine.GameObject goChild = NGUITools.AddChild(goPartnerSlotContainer, goPartnerSlot);
         if (goChild != null)
         {
             UIPartnerSlot partner_item = goChild.GetComponent <UIPartnerSlot>();
             if (partner_item != null)
             {
                 m_AllPartners.Add(partner_item);
                 return(partner_item);
             }
         }
     }
     return(null);
 }
示例#2
0
 void Start()
 {
     try
     {
         if (hasStart == false)
         {
             if (gridEquipParent != null)
             {
                 int childNum = gridEquipParent.transform.childCount;
                 for (int i = 0; i < childNum; i++)
                 {
                     UnityEngine.GameObject go = gridEquipParent.transform.GetChild(i).gameObject;
                     int index = -1;
                     System.Int32.TryParse(go.name, out index);
                     if (index >= 0 && index < childNum)
                     {
                         equiparry[index].equipSlot = go;
                     }
                     UIEventListener.Get(go).onClick = SlotButtonClick;
                 }
             }
             if (gridPartnersParent != null)
             {
                 int oldDataNum = gridPartnersParent.transform.childCount;
                 for (int i = 0; i < oldDataNum; i++)
                 {
                     DestroyImmediate(gridPartnersParent.transform.GetChild(i).gameObject);
                 }
                 for (int i = 0; i < c_PartnerNum; i++)
                 {
                     if (partnerSlot != null)
                     {
                         UnityEngine.GameObject item = NGUITools.AddChild(gridPartnersParent.gameObject, partnerSlot);
                         UIPartnerSlot          slot = item.GetComponent <UIPartnerSlot>();
                         if (slot != null)
                         {
                             partnerSlotList.Add(slot);
                         }
                     }
                 }
                 gridPartnersParent.repositionNow = true;
             }
         }
         hasStart = true;
     }
     catch (System.Exception ex)
     {
         ArkCrossEngine.LogicSystem.LogErrorFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
 //伙伴出战
 public bool PartnerPlayed(int partnerId)
 {
     for (int index = 0; index < partnersInPvp.Length; ++index)
     {
         UIPartnerSlot slot = partnersInPvp[index];
         if (slot != null && slot.GetPartnerId() == -1 && slot.IsUnlock())
         {
             slot.InitPartnerInfo(partnerId);
             if (lblTotleFighting != null)
             {
                 lblTotleFighting.text = CalculateTotleFighting().ToString();
             }
             return(true);
         }
     }
     return(false);
 }
    //刷新自己拥有的伙伴
    public void RefreshAllPartners()
    {
        RoleInfo role_info = LobbyClient.Instance.CurrentRole;

        if (role_info != null && role_info.PartnerStateInfo != null)
        {
            List <PartnerInfo> allPartners = role_info.PartnerStateInfo.GetAllPartners();
            if (allPartners == null)
            {
                return;
            }
            for (int index = 0; index < allPartners.Count; ++index)
            {
                UIPartnerSlot partner_slot = TryGetPartnerItem(index);
                if (partner_slot != null)
                {
                    partner_slot.InitPartnerInfo(allPartners[index]);
                }
                bool actived = IsInPlayedParnters(allPartners[index].Id);
                partner_slot.SetStoragePartnerPlayed(actived);
            }
            bool setActive = false;
            if (!NGUITools.GetActive(goAllPartners))
            {
                //如果goAllPartners不可见,Reposition()将不起作用,需要将其设为可见
                NGUITools.SetActive(goAllPartners, true);
                setActive = true;
            }
            if (goPartnerSlotContainer != null)
            {
                UITable table = goPartnerSlotContainer.GetComponent <UITable>();
                if (table != null)
                {
                    table.Reposition();
                }
            }
            if (setActive)
            {
                //如果设置为可见,这里需要还原回去
                NGUITools.SetActive(goAllPartners, false);
            }
        }
    }
 //取消出战
 public void CancelPartnerPlayed(int partnerId, UIParternSlotType slotType)
 {
     if (slotType == UIParternSlotType.SettingSlot)
     {
         UIPartnerSlot slot = GetPartnerSlotFromSetting(partnerId);
         if (slot != null)
         {
             slot.CancelSettingPartnerPlayed();
         }
     }
     else
     {
         UIPartnerSlot slot = GetPartnerSlotFromStorage(partnerId);
         if (slot != null)
         {
             slot.SetStoragePartnerPlayed(false);
         }
     }
     if (lblTotleFighting != null)
     {
         lblTotleFighting.text = CalculateTotleFighting().ToString();
     }
 }