예제 #1
0
        /// <summary>
        /// 读取列表完成
        /// </summary>
        private void OnLoadMailEnd(List <MailInfo> list)
        {
            //可能读取db时,玩家下线了
            if (m_char_idx == 0)
            {
                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))
                {
                    list.RemoveAt(i);
                }
            }

            //保存到集合
            list.ForEach(info => m_all_mails.Add(info.mail_idx, info));

            PlayerCache player = PlayerCacheManager.Instance.GetMember(m_char_idx);

            if (player == null)
            {//可能读取db时,玩家下线了
                MailCacheManager.Instance.HanldeLogoutClient(m_char_idx);
                return;
            }

            //转发给ss,每次发10封
            while (list.Count > 0)
            {
                db2ss.MailList msg = PacketPools.Get(db2ss.msg.MAIL_LIST) as db2ss.MailList;
                msg.char_idx = m_char_idx;
                for (int i = list.Count - 1, j = 0; i >= 0 && j < 10; --i, ++j)
                {
                    msg.mail_list.Add(list[i]);
                    list.RemoveAt(i);
                }
                ForServerNetManager.Instance.Send(player.ss_uid, msg);
            }
        }
예제 #2
0
        /// <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);
            }
        }