| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 | using System.Collections.Generic;using System.Linq;using ET;namespace GFGGame{    public class FriendDataManager : SingletonBase<FriendDataManager>    {        public void Clear()        {            ClearAddFriend();            ClearRecommendDatas();            ClearSearchDatas();            ClearApplyDatas();        }        public int Count//今日已领体力数        {            get            {                return GameGlobal.myNumericComponent.GetAsInt(NumericType.TakeFriendGiftCount);            }        }        //可领取体力的上限值        public int maxGetPowerCount        {            get            {                var t = GameGlobal.myNumericComponent.GetAsInt(ET.NumericType.MonthCardFriendPowerAdd);                return GlobalCfgArray.globalCfg.maxGetPowerCount + t * GlobalCfgArray.globalCfg.onceGivePowerCount;            }        }        private Dictionary<long, FriendInfoData> _friendDic = new Dictionary<long, FriendInfoData>();//好友列表        private List<FriendInfoData> _list = new List<FriendInfoData>();        public List<FriendInfoData> FriendDatas        {            get            {                return _list;            }        }        public void ClearAddFriend()        {            _list.Clear();            _friendDic.Clear();        }        public void AddFriend(FriendInfoData roleInfo)        {            if (_friendDic.ContainsKey(roleInfo.roleInfo.roleId)) return;            _friendDic.Add(roleInfo.roleInfo.roleId, roleInfo);            UpdateFriendList(true);        }        public void RemoveFriend(long roleId)        {            if (_friendDic.ContainsKey(roleId))            {                _friendDic.Remove(roleId);                UpdateFriendList(true);            }        }        public FriendInfoData GetFriendDataById(long roleId)        {            if (_friendDic.ContainsKey(roleId))            {                return _friendDic[roleId];            }            return null;        }        public void ChangeFriendInfo(OtherRoleInfoData roleInfo)        {            if (_friendDic.ContainsKey(roleInfo.roleId))            {                _friendDic[roleInfo.roleId].roleInfo = roleInfo;            }        }        public void ChangeGiveGiftStates(long roleId, int state)        {            if (_friendDic.ContainsKey(roleId))            {                _friendDic[roleId].giveGiftState = state;            }        }        public void ChangeTakeGiftStates(long roleId, int state)        {            if (_friendDic.ContainsKey(roleId))            {                _friendDic[roleId].takeGiftState = state;            }        }        public void ChangeGiveTakeGiftStates(long roleId, int state, int takeState)        {            if (_friendDic.ContainsKey(roleId))            {                _friendDic[roleId].giveGiftState = state;                _friendDic[roleId].takeGiftState = takeState;            }        }        public void UpdateFriendList(bool sort)        {            _list = _friendDic.Values.ToList<FriendInfoData>();            if (!sort) return;            _list.Sort((FriendInfoData a, FriendInfoData b) =>            {                long count = b.roleInfo.offlineTimeSec - a.roleInfo.offlineTimeSec;                if (count > 0)                {                    return -1;                }                else                {                    return 1;                }            });        }        private List<OtherRoleInfoData> _recommendDatas = new List<OtherRoleInfoData>();//推荐列表        public List<OtherRoleInfoData> RecommendDatas        {            get            {                return _recommendDatas;            }        }        public void AddRecommendData(OtherRoleInfoData recommendData)        {            _recommendDatas.Add(recommendData);        }        public void ClearRecommendDatas()        {            _recommendDatas.Clear();        }        private List<OtherRoleInfoData> _searchDatas = new List<OtherRoleInfoData>();//搜索列表        public List<OtherRoleInfoData> SearchDatas        {            get            {                return _searchDatas;            }        }        public void AddSearchData(OtherRoleInfoData searchData)        {            _searchDatas.Add(searchData);        }        public void ClearSearchDatas()        {            _searchDatas.Clear();        }        private List<FriendInfoData> _applyDatas = new List<FriendInfoData>();//申请添加好友列表        public List<FriendInfoData> ApplyDatas        {            get            {                return _applyDatas;            }        }        public void AddApplyData(FriendInfoData applyData)        {            _applyDatas.Add(applyData);        }        public void RemoveApplyData(long roleId)        {            for (int i = _applyDatas.Count - 1; i >= 0; i--)            {                if (roleId == _applyDatas[i].roleInfo.roleId)                {                    _applyDatas.RemoveAt(i);                }            }        }        public void ClearApplyDatas()        {            _applyDatas.Clear();        }        public int GetGiftState(long roleId)        {            FriendInfoData friendInfo = _friendDic[roleId];            if (friendInfo.takeGiftState == ConstBonusStatus.CAN_GET)            {                return 0;            }            if (friendInfo.giveGiftState == (int)ConstGiveGiftStatus.CanGave)            {                return 1;            }            if (friendInfo.giveGiftState == (int)ConstGiveGiftStatus.Gave && friendInfo.takeGiftState != ConstBonusStatus.GOT)            {                return 2;            }            return 3;        }    }}
 |