/// <summary> /// 通知有新邮件 /// </summary> private void OnMailCount(PacketBase packet) { ss2c.MailCount msg = packet as ss2c.MailCount; if (msg.total_mail_count > 0) { ServerMsgSend.SendMailList(); } }
/// <summary> /// 投递邮件到信箱 /// </summary> private void OnLoadMailEnd(List <MailInfo> list) { if (list.Count == 0) { return; } //可能读取db时,玩家下线了 Player player = UnitManager.Instance.GetUnitByIdx(m_char_idx) as Player; if (player == null) { list.ForEach(info => CommonObjectPools.Despawn(info)); return; } //过滤掉已经领取过附件的全局邮件 for (int i = list.Count - 1; i >= 0; --i) { MailInfo mail_info = list[i]; if (mail_info.receiver_idx == 0 && m_had_recv_mails.Contains(mail_info.mail_idx)) { CommonObjectPools.Despawn(mail_info); list.RemoveAt(i); } } //添加到邮件集合 list.ForEach(info => { if (!m_all_mails.ContainsKey(info.mail_idx)) { m_all_mails.Add(info.mail_idx, info); } }); //加入到新邮件列表 list.ForEach(info => m_new_mails.Add(info.mail_idx)); //过滤掉系统内部邮件 List <long> del_list = new List <long>(); for (int i = list.Count - 1; i >= 0; i--) { MailInfo mail_info = list[i]; if (mail_info.mail_type == eMailType.SYSTEM_INTERNAL) { if (mail_info.bin_mail_content.content_type == eMailContentType.MOD) {//修改玩家属性 MailModContent content = mail_info.bin_mail_content.bin_mod_content; foreach (var obj in content.mods) { player.player_attr.SetAttrib(obj.type, obj.value_i, obj.value_str); } list.RemoveAt(i); del_list.Add(mail_info.mail_idx); } } } if (del_list.Count > 0) { this.HandleDeleteMail(del_list); } //通知客户端有新邮件到达 if (list.Count > 0) { //获取未读邮件数量 int unread_count = 0; list.ForEach(info => { if (!Utils.HasFlag(info.flags, (uint)eMailFlags.READED)) { unread_count++; } }); ss2c.MailCount msg = PacketPools.Get(ss2c.msg.MAIL_COUNT) as ss2c.MailCount; msg.total_mail_count = (ushort)list.Count; msg.unread_mail_count = (ushort)unread_count; ServerNetManager.Instance.SendProxy(player.client_uid, msg); } }