public MailListItem GetItemByMailId(int mailId) { MailListItem item = _mailItemsList.Find(delegate(MailListItem test) { return(test.MailVo.MailId == mailId); }); return(item); }
void AddMails(MailVo[] mails) { foreach (MailVo mailVo in mails) { MailListItem item = MakeMailItem(mailVo); item.OnClicKHandler = OnClickMailItem; } SortMails(); }
public void RemoveMail(int mailId) { MailListItem item = GetItemByMailId(mailId); _mailItemsList.Remove(item); item.transform.parent = null; Destroy(item.gameObject); RefreshUnReadMailsCount(); SortMails(); }
void UpdateMailItems() { if (null == m_curItemResObj) { return; } // 记录上次正在操作的邮件,重新加载时直接选中 string lastKey = null; if (null != m_curSelectItem) { lastKey = m_curSelectItem.gameObject.name; } m_curSelectItem = null; Utils.CleanGrid(MailListGrid); for (int i = 0; i < m_sortMailList.Count; i++) { System.UInt64 curKey = m_sortMailList[i]; if (!MailData.UserMailMap.ContainsKey(curKey)) { continue; } MailListItem curItem = MailListItem.CreateItem(MailListGrid, m_curItemResObj, curKey.ToString(), this, MailData.UserMailMap[curKey]); if (null == curItem) { continue; } if (null == m_curSelectItem && curKey.ToString() == lastKey) { ShowMailItem(curItem); } } MailListGrid.GetComponent <UIGrid>().Reposition(); //MailListGrid.GetComponent<UITopGrid>().Recenter(m_bFirstUpdate); m_bFirstUpdate = false; if (null == m_curSelectItem && MailListGrid.transform.childCount > 0) { ShowMailItem(MailListGrid.transform.GetChild(0).GetComponent <MailListItem>()); } CurMailGroup.SetActive(null != m_curSelectItem); if (RelationLogic.Instance() != null) { RelationLogic.Instance().ShowNewEmailBigRed(); } // 邮件上限提示 // LabelRecvTips.text = StrDictionary.GetClientDictionaryString("#{1252}", MailData.UserMailMap.Count); }
MailListItem MakeMailItem(MailVo mailVo) { GameObject go = GameObject.Instantiate(templateMailItem.gameObject) as GameObject; go.transform.parent = mailListScrollPanelGrid.transform; go.transform.localScale = Vector3.one; go.transform.localPosition = templateMailItem.transform.localPosition; go.SetActive(true); MailListItem mailItem = go.GetComponent <MailListItem>(); mailItem.MailVo = mailVo; _mailItemsList.Add(mailItem); return(mailItem); }
private GameObject CreateListItem() { GameObject gameObject = (GameObject)Object.Instantiate <GameObject>((M0)this.ItemTemplate); MailListItem component1 = (MailListItem)gameObject.GetComponent <MailListItem>(); if (Object.op_Inequality((Object)component1.listItemEvents, (Object)null)) { component1.listItemEvents.OnSelect = new ListItemEvents.ListItemEvent(this.OnSelect); ListItemEvents component2 = (ListItemEvents)component1.Button.GetComponent <ListItemEvents>(); if (Object.op_Inequality((Object)component2, (Object)null)) { component2.OnSelect = new ListItemEvents.ListItemEvent(this.OnSelect); } } return(gameObject); }
public static MailListItem CreateItem(GameObject grid, GameObject resObj, string name, MailRecvWindow parent, MailData.UserMail data) { if (null == data) { LogModule.ErrorLog("receive mail data null:" + name); return(null); } GameObject curItem = Utils.BindObjToParent(resObj, grid, name); if (null != curItem) { MailListItem curItemComponent = curItem.GetComponent <MailListItem>(); if (null != curItemComponent) { curItemComponent.SetData(parent, data); } return(curItemComponent); } return(null); }
MailData.UserMail GetMailByItem(MailListItem curItem) { if (null == curItem) { return(null); } System.UInt64 curMailID = 0; if (!System.UInt64.TryParse(curItem.gameObject.name, out curMailID)) { LogModule.ErrorLog("can not parse cur mail id:" + curMailID.ToString() + " name : " + curItem.gameObject.name); CurMailGroup.SetActive(false); return(null); } if (!MailData.UserMailMap.ContainsKey(curMailID)) { LogModule.ErrorLog("can not find cur mail id:" + curMailID.ToString()); CurMailGroup.SetActive(false); return(null); } return(MailData.UserMailMap[curMailID]); }
private void UpdateItems() { if (Object.op_Equality((Object)this.ItemTemplate, (Object)null) || this.mMailListItems == null) { return; } List <MailData> currentMails = MonoSingleton <GameManager> .Instance.Player.CurrentMails; if (this.mMailListItems.Count < currentMails.Count) { Transform transform = ((Component)this).get_transform(); int num = currentMails.Count - this.mMailListItems.Count; for (int index = 0; index < num; ++index) { GameObject listItem = this.CreateListItem(); listItem.get_transform().SetParent(transform, false); this.mMailListItems.Add(listItem); } } for (int index1 = 0; index1 < this.mMailListItems.Count; ++index1) { GameObject mMailListItem = this.mMailListItems[index1]; if (index1 >= currentMails.Count) { mMailListItem.SetActive(false); } else { mMailListItem.SetActive(true); MailData data1 = currentMails[index1]; DataSource.Bind <MailData>(mMailListItem, data1); DataSource.Bind <MailData>(((MailListItem)mMailListItem.GetComponent <MailListItem>()).Button, data1); int num = 0; for (int index2 = 0; index2 < data1.gifts.Length; ++index2) { GiftData gift = data1.gifts[index2]; if (gift.CheckGiftTypeIncluded(GiftTypes.Item)) { ++num; } if (gift.CheckGiftTypeIncluded(GiftTypes.Unit)) { ++num; } if (gift.CheckGiftTypeIncluded(GiftTypes.Coin)) { ++num; } if (gift.CheckGiftTypeIncluded(GiftTypes.Gold)) { ++num; } if (gift.CheckGiftTypeIncluded(GiftTypes.ArenaCoin)) { ++num; } if (gift.CheckGiftTypeIncluded(GiftTypes.MultiCoin)) { ++num; } if (gift.CheckGiftTypeIncluded(GiftTypes.KakeraCoin)) { ++num; } if (gift.CheckGiftTypeIncluded(GiftTypes.Award)) { ++num; } if (num > 1) { break; } } if (num >= 2) { MailIcon component = (MailIcon)mMailListItem.GetComponent <MailIcon>(); if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.SetIconTemplate; component.CurrentIcon.SetActive(true); } } else { MailIcon component = (MailIcon)mMailListItem.GetComponent <MailIcon>(); for (int index2 = 0; index2 < data1.gifts.Length; ++index2) { GiftData gift = data1.gifts[index2]; if (!gift.NotSet) { if (gift.CheckGiftTypeIncluded(GiftTypes.Item | GiftTypes.Unit | GiftTypes.SelectUnitItem | GiftTypes.SelectItem | GiftTypes.SelectArtifactItem)) { ItemData data2 = new ItemData(); data2.Setup(0L, gift.iname, gift.num); DataSource.Bind <ItemData>(mMailListItem, data2); if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.ItemIconTemplate; component.CurrentIcon.SetActive(true); break; } break; } if (gift.CheckGiftTypeIncluded(GiftTypes.Artifact)) { ArtifactData artifactData = this.CreateArtifactData(gift.iname); if (artifactData != null) { DataSource.Bind <ArtifactData>(mMailListItem, artifactData); } if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.ArtifactIconTemplate; component.CurrentIcon.SetActive(true); break; } break; } if (gift.CheckGiftTypeIncluded(GiftTypes.Award)) { AwardParam awardParam = MonoSingleton <GameManager> .Instance.GetAwardParam(gift.iname); ItemData data2 = new ItemData(); data2.Setup(0L, awardParam.ToItemParam(), gift.num); DataSource.Bind <ItemData>(mMailListItem, data2); if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.ItemIconTemplate; component.CurrentIcon.SetActive(true); break; } break; } if (gift.CheckGiftTypeIncluded(GiftTypes.Coin)) { if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.CoinIconTemplate; component.CurrentIcon.SetActive(true); break; } break; } if (gift.CheckGiftTypeIncluded(GiftTypes.Gold)) { if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.GoldIconTemplate; component.CurrentIcon.SetActive(true); break; } break; } if (gift.CheckGiftTypeIncluded(GiftTypes.ArenaCoin)) { if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.ArenaCoinIconTemplate; component.CurrentIcon.SetActive(true); } } else { if (gift.CheckGiftTypeIncluded(GiftTypes.MultiCoin)) { if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.MultiCoinIconTemplate; component.CurrentIcon.SetActive(true); break; } break; } if (gift.CheckGiftTypeIncluded(GiftTypes.KakeraCoin)) { if (Object.op_Inequality((Object)component, (Object)null)) { if (Object.op_Inequality((Object)component.CurrentIcon, (Object)null)) { component.CurrentIcon.SetActive(false); } component.CurrentIcon = component.KakeraCoinIconTemplate; component.CurrentIcon.SetActive(true); break; } break; } } } } } MailListItem component1 = (MailListItem)mMailListItem.GetComponent <MailListItem>(); if (Object.op_Inequality((Object)component1, (Object)null)) { component1.Set(data1.IsPeriod, data1.IsReadMail(), data1.post_at, data1.read); } } } GameParameter.UpdateAll(((Component)this).get_gameObject()); }
public void ShowMailItem(MailListItem curItem) { if (null == curItem) { return; } if (m_curSelectItem == curItem) { return; } if (null != m_curSelectItem) { m_curSelectItem.EnableHighlight(false); } m_curSelectItem = curItem; m_curSelectItem.gameObject.SetActive(true); m_curSelectItem.EnableHighlight(true); MailData.UserMail curMail = GetMailByItem(curItem); if (null == curMail) { return; } m_playerName.text = curMail.SenderName; bool bHaveItem = false; LabelCurMailText.text = StrDictionary.GetClientString_WithNameSex(curMail.text);//curMail.text; if (curMail.itemID >= 0) { CurRewardItem.SetData(curMail.itemID, curMail.itemCount); CurRewardItem.gameObject.SetActive(true); bHaveItem = true; } else { CurRewardItem.gameObject.SetActive(false); } if (curMail.moneyCount > 0) { MoneyCountLabel.SetActive(true); MoneyIcon.SetActive(true); m_MoneyBack.gameObject.SetActive(true); MoneyCountLabel.GetComponent <UILabel>().text = curMail.moneyCount.ToString(); if (curMail.moneyType == 0) { MoneyIcon.GetComponent <UISprite>().spriteName = "jinbi"; } else if (curMail.moneyType == 2) { MoneyIcon.GetComponent <UISprite>().spriteName = "bdyuanbao"; } else { MoneyIcon.GetComponent <UISprite>().spriteName = "gonghuijifen"; } bHaveItem = true; } else { MoneyCountLabel.SetActive(false); MoneyIcon.SetActive(false); m_MoneyBack.gameObject.SetActive(false); } if (bHaveItem) { m_awardText.text = "领奖"; } else { m_awardText.text = "删除"; } BtnGetItem.SetActive(true); BtnReplay.SetActive(curMail.senderType != GC_MAIL_UPDATE.MailSender.MAILSENDER_SYS); BtnBtnReport.SetActive(curMail.senderType != GC_MAIL_UPDATE.MailSender.MAILSENDER_SYS); if (!curMail.bReaded) { CG_MAIL_OPERATION packetDelMail = (CG_MAIL_OPERATION)PacketDistributed.CreatePacket(MessageID.PACKET_CG_MAIL_OPERATION); packetDelMail.SetOperationType((int)CG_MAIL_OPERATION.MailOperation.OPERATION_SETREAD); packetDelMail.SetMailGuid(curMail.key); packetDelMail.SendPacket(); } }