| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     public class MailInfo
 
-     {
 
-         public long mailId;//邮件id
 
-         public string title;//邮件标题
 
-         public long timeSec;//邮件时间戳,单位毫秒
 
-         public string content = "";//邮件内容
 
-         public List<ItemData> rewards;
 
-         public int state;//邮件状态 0未读, 1已读未领取,2已读已领取
 
-         public bool hasItem;//是否有奖励
 
-     }
 
-     public class MailDataManager : SingletonBase<MailDataManager>
 
-     {
 
-         public int PageCount = 30;//每次请求数量
 
-         public int CurPage = 0;//每次请求数量
 
-         private int _totolCount = 0;
 
-         public int TotolCount//邮件总数
 
-         {
 
-             get { return _totolCount; }
 
-             set
 
-             {
 
-                 _totolCount = value;
 
-             }
 
-         }
 
-         private int _unreadCount = 0;
 
-         public int UnreadCount////未读邮件数量
 
-         {
 
-             get { return _unreadCount; }
 
-             set
 
-             {
 
-                 if (_unreadCount != value)
 
-                 {
 
-                     _unreadCount = value;
 
-                     EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
 
-                 }
 
-             }
 
-         }
 
-         private int _startIndex = 0;
 
-         public int StartIndex//起始索引,从0开始
 
-         {
 
-             get { return _startIndex; }
 
-             set { _startIndex = value; }
 
-         }
 
-         public Dictionary<long, MailInfo> _mailInfoDic = new Dictionary<long, MailInfo>();
 
-         public Dictionary<long, MailInfo> MailInfoDic
 
-         {
 
-             get
 
-             {
 
-                 return _mailInfoDic;
 
-             }
 
-         }
 
-         private Dictionary<int, List<long>> _mailIdsDic = new Dictionary<int, List<long>>();
 
-         public List<MailInfo> mailInfos = new List<MailInfo>();
 
-         public void RefreshMailInfoDic(bool sort)
 
-         {
 
-             if (sort)
 
-             {
 
-                 _mailInfoDic.Clear();
 
-                 _mailIdsDic.Clear();
 
-             }
 
-         }
 
-         public void UpdateMainInfoDic(long mailId, MailInfo mailInfo)
 
-         {
 
-             if (!_mailInfoDic.ContainsKey(mailId))
 
-             {
 
-                 _mailInfoDic.Add(mailId, mailInfo);
 
-             }
 
-             else
 
-             {
 
-                 _mailInfoDic[mailId] = mailInfo;
 
-             }
 
-         }
 
-         public void UpdateMailIdList(int page, long mailId)
 
-         {
 
-             if (!_mailIdsDic.ContainsKey(page))
 
-             {
 
-                 _mailIdsDic.Add(page, new List<long>());
 
-             }
 
-             _mailIdsDic[page].Add(mailId);
 
-         }
 
-         public void UpdateMailContent(long mailId, int state, string content = "", List<ItemData> rewards = null)
 
-         {
 
-             _mailInfoDic[mailId].state = state;
 
-             if (content != "") _mailInfoDic[mailId].content = content;
 
-             if (rewards != null) _mailInfoDic[mailId].rewards = rewards;
 
-             UnreadCount = UnreadCount - 1;
 
-         }
 
-         public long GetMailIdByIndex(int index)
 
-         {
 
-             int page = index / PageCount;
 
-             int pageIndex = index % PageCount;
 
-             if (_mailIdsDic.ContainsKey(page) && _mailIdsDic[page].Count > pageIndex)
 
-             {
 
-                 return _mailIdsDic[page][pageIndex];
 
-             }
 
-             return -1;
 
-         }
 
-         public List<long> GetMailIdByPage(int page)
 
-         {
 
-             if (_mailIdsDic.ContainsKey(page))
 
-             {
 
-                 return _mailIdsDic[page];
 
-             }
 
-             return null;
 
-         }
 
-         /// <summary>
 
-         /// 根据邮件Id获取邮件信息
 
-         /// </summary>
 
-         /// <param name="mailId"></param>
 
-         /// <returns></returns>
 
-         public MailInfo GetMailInfoById(long mailId)
 
-         {
 
-             if (_mailInfoDic.ContainsKey(mailId))
 
-             {
 
-                 return _mailInfoDic[mailId];
 
-             }
 
-             return null;
 
-         }
 
-         //0未读,1无奖已读,2有奖未领,3有奖已领
 
-         public int GetMailState(MailInfo data)
 
-         {
 
-             if (data.hasItem == false)
 
-             {
 
-                 if ((ConstMailStatus)data.state == ConstMailStatus.Unread) return 0;
 
-                 if ((ConstMailStatus)data.state == ConstMailStatus.ReadedButNotGet) return 1;
 
-                 if ((ConstMailStatus)data.state == ConstMailStatus.ReadedAndGot) return 1;
 
-             }
 
-             else
 
-             {
 
-                 if ((ConstMailStatus)data.state == ConstMailStatus.Unread) return 2;
 
-                 if ((ConstMailStatus)data.state == ConstMailStatus.ReadedButNotGet) return 2;
 
-                 if ((ConstMailStatus)data.state == ConstMailStatus.ReadedAndGot) return 3;
 
-             }
 
-             return 0;
 
-         }
 
-     }
 
- }
 
 
  |