| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 | using System;using System.Collections;using ET;using GFGGame;using FairyGUI;using UnityEngine;using UnityEngine.Networking;using System.Collections.Generic;using System.Linq;namespace ET{    public class M2C_NoticeMatchingStateHandler : AMHandler<S2C_PushJudgingRoundInfo>    {        protected override async ETTask Run(Session session, S2C_PushJudgingRoundInfo message)        {            MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason = message.JudgingRoundOpenId;            MatchingCompetitionDataManager.Instance.MatchingEndTimes = message.PhaseEndTime;            MatchingCompetitionDataManager.Instance.MatchingState = message.PhaseType;            //await MatchingCompetitionSproxy.ReqMatchingCompetitionInfo();            await ETTask.CompletedTask;        }    }}namespace GFGGame{    public class MatchingCompetitionSproxy    {        //获取搭配评选赛信息        public static async ETTask<bool> ReqMatchingCompetitionInfo()        {            S2C_GetJudgingRoundInfo response = (S2C_GetJudgingRoundInfo)await MessageHelper.SendToServer(new C2S_GetJudgingRoundInfo { });            if (!(response is { Error: ErrorCode.ERR_Success })) return false;            MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason = response.JudgingRoundOpenId;            MatchingCompetitionDataManager.Instance.MatchingState = response.PhaseType;            MatchingCompetitionDataManager.Instance.MatchingEndTimes = response.PhaseEndTime;            MatchingCompetitionDataManager.Instance.MatchingRemainingTimes = response.Num;            if(response.MyWorks != null)            {                MatchingCompetitionDataManager.Instance.myWorks = response.MyWorks;                MatchingCompetitionDataManager.Instance.WorksID = response.MyWorks.WorksId;                MatchingCompetitionDataManager.Instance.AllDressIDInfoList = response.MyWorks.CollocationInfoList;            }            else            {                MatchingCompetitionDataManager.Instance.myWorks.Score = 0;                MatchingCompetitionDataManager.Instance.AllDressIDInfoList = new List<CollocationInfo>();            }            if(response.MyWorks != null && response.MyWorks.PictureTempUrl != "")            {                Timers.inst.StartCoroutine(MatchingPhotoHelper.DownloadMyself(response.MyWorks.PictureTempUrl));            }            MatchingCompetitionDataManager.Instance.AnalysisInfoToList();            return true;        }        //获取搭配作品信息        //public static async ETTask<bool> ReqMatchingCompetitionDressData()        //{        //    var response = (S2C_RequestUpLoadJudgingRoundWorks)await MessageHelper.SendToServer(new C2S_RequestUpLoadJudgingRoundWorks {});        //    if (!(response is { Error: ErrorCode.ERR_Success })) return false;        //    return true;        //}                //获取一个热门推荐的玩家        public static async ETTask<bool> ReqGetOnePlayers()        {            var response = (S2C_GetOnePlayers)await MessageHelper.SendToServer(new C2S_GetOnePlayers { });            if (!(response is { Error: ErrorCode.ERR_Success })) return false;            MatchingOneDataManager.Instance.OneRoleInfo.JudgingInfo = response.JudgingRoundRole;            if (response.JudgingRoundRole == null)            {                return false;            }            Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingOneDataManager.Instance.OneRoleInfo));            MatchingOneDataManager.Instance.AnalysisInfoToList();            return true;        }        //上传作品信息        public static async ETTask<object[]> UpLoadMatchingCompetitionDressData()        {            MatchingCompetitionDataManager.Instance.ConvertInfoToList();            var response = (S2C_RequestUpLoadJudgingRoundWorks)await MessageHelper.SendToServer(new C2S_RequestUpLoadJudgingRoundWorks            {                PictureType = 1,                BagId = MatchingCompetitionDataManager.Instance.DressUpBgID,                ActionId = MatchingCompetitionDataManager.Instance.MathingDressDate.actionId,                CollocationInfoList = MatchingCompetitionDataManager.Instance.AllDressIDInfoList            });            if (!(response is { Error: ErrorCode.ERR_Success })) return null;            MatchingCompetitionDataManager.Instance.WorksID = response.WorksId;            MatchingCompetitionDataManager.Instance.TempPictureUrl = response.TempPictureUrl;            return new object[] { response.TempPictureUrl, response.WorksId };        }        //通知服务端上传成功        public static async ETTask<bool> UploadSuccess()        {            var response = (S2C_NoticeJudgingRoundWorksUploaded)await MessageHelper.SendToServer(new C2S_NoticeJudgingRoundWorksUploaded            {                WorksId = MatchingCompetitionDataManager.Instance.WorksID            }) ;            if (!(response is { Error: ErrorCode.ERR_Success })) return false;                        return true;        }        //获取两个评选推荐的玩家        public static async ETTask<bool> ReqGetTwoPlayers()        {            var response = (S2C_GetTwoPlayers)await MessageHelper.SendToServer(new C2S_GetTwoPlayers { });            if (!(response is { Error: ErrorCode.ERR_Success })) return false;            if(response.JudgingRoundRoleInfoList == null || response.JudgingRoundRoleInfoList.Count < 2)            {                return false;            }            MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[0];            if(response.JudgingRoundRoleInfoList[0] != null)            {                Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingLeftDataManager.Instance.LeftRoleInfo));            }            MatchingLeftDataManager.Instance.AnalysisInfoToList();            MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[1];            if (response.JudgingRoundRoleInfoList[1] != null)            {                Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingRightDataManager.Instance.RightRoleInfo));            }            MatchingRightDataManager.Instance.AnalysisInfoToList();            return true;        }        //选择搭配作品        public static async ETTask<bool> ReqCheckMatchingCompetitionWork(long workID,long anotherWorkId )        {            var response = (S2C_SelFavoriteWorks)await MessageHelper.SendToServer(new C2S_SelFavoriteWorks            {                WorksId = workID,                AnotherWorksId = anotherWorkId            }) ;            if (!(response is { Error: ErrorCode.ERR_Success })) return false;            if (response.JudgingRoundRoleInfoList == null || response.JudgingRoundRoleInfoList.Count < 2)            {                return false;            }            MatchingCompetitionDataManager.Instance.MatchingRemainingTimes = response.Num;            MatchingCompetitionDataManager.Instance.SpecialBonusList = response.SpecialBonusList;            if (MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo.WorksId == workID)            {                MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[0];                MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[1];            }            else            {                MatchingLeftDataManager.Instance.LeftRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[1];                MatchingRightDataManager.Instance.RightRoleInfo.JudgingInfo = response.JudgingRoundRoleInfoList[0];            }            BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));            return true;        }        //获取当前排行榜        public static async ETTask<bool> ReqCurrentRank(bool isPushEvent = false)        {            MatchingCompetitionDataManager.Instance.IsWork = true;            var response =                (S2C_GetCurJudgingRoundRankList)await MessageHelper.SendToServer(new C2S_GetCurJudgingRoundRankList                    { });            if (!(response is { Error: ErrorCode.ERR_Success })) return false;            //需要从缓存里清理的数据            List<long> delRoleIds = new List<long>();            foreach (var item in MatchingCompetitionDataManager.Instance._currentRankList)            {                if (response.JudgingRoundRoleInfoList.All(a => a.RoleId != item.RoleId))                {                    delRoleIds.Add(item.RoleId);                }            }            //执行清理            if (delRoleIds.Count != 0)            {                foreach (var roleId in delRoleIds)                {                    var itemToRemove =                        MatchingCompetitionDataManager.Instance._currentRankList.FirstOrDefault(item =>                            item.RoleId == roleId);                    if (itemToRemove != null)                    {                        MatchingCompetitionDataManager.Instance._currentRankList.Remove(itemToRemove);                    }                }            }                        foreach (var judgingRoundRoleInfo in response.JudgingRoundRoleInfoList)            {                CurRanMatchingPhotoWorksData matchingPhotoWorksData =                    MatchingCompetitionDataManager.Instance._currentRankList.FirstOrDefault(a =>                        a.RoleId == judgingRoundRoleInfo.RoleId);                if (matchingPhotoWorksData == null)                {                    matchingPhotoWorksData = new CurRanMatchingPhotoWorksData                    {                        RoleId = judgingRoundRoleInfo.RoleId,                        JudgingInfo = judgingRoundRoleInfo                    };                    MatchingCompetitionDataManager.Instance._currentRankList.Add(matchingPhotoWorksData);                }                else                {                    int index = MatchingCompetitionDataManager.Instance._currentRankList                        .IndexOf(matchingPhotoWorksData);                    if (matchingPhotoWorksData.JudgingInfo != null)                    {                        string newTempFileName = StringUtil.GetUrlFileName(matchingPhotoWorksData.JudgingInfo.PictureTempUrl);                        string oldTempFileName = StringUtil.GetUrlFileName(judgingRoundRoleInfo.PictureTempUrl);                        matchingPhotoWorksData.IsUp = newTempFileName != oldTempFileName;                    }                    matchingPhotoWorksData.JudgingInfo = judgingRoundRoleInfo;                    matchingPhotoWorksData.RoleId = judgingRoundRoleInfo.RoleId;                    if (matchingPhotoWorksData.IsUp)                    {                        matchingPhotoWorksData.Ntexture = null;                    }                                        MatchingCompetitionDataManager.Instance._currentRankList[index] = matchingPhotoWorksData;                }            }            //排序            MatchingCompetitionDataManager.Instance._currentRankList.Sort((a, b) =>            {                // 假设列表项具有一个名为 'score' 的属性,你想要按照分数进行排序                if (a.JudgingInfo.Score > b.JudgingInfo.Score)                {                    return -1; // a在b之前                }                else if (a.JudgingInfo.Score < b.JudgingInfo.Score)                {                    return 1; // b在a之前                }                else                {                    return 0; // a和b相同                }            });                        var enumerator = MatchingPhotoHelper.DownloadExt(MatchingCompetitionDataManager.Instance._currentRankList);            Timers.inst.StartCoroutine(enumerator);                        //推送事件            if (isPushEvent)            {                EventAgent.DispatchEvent(ConstMessage.REQ_CURRENT_RANK);            }            return true;        }                public static void UseCoroutine()        {            if (!MatchingCompetitionDataManager.Instance.IsWork)            {                if (MatchingCompetitionDataManager.Instance._coroutineQueue.Count == 0)                {                    return;                }                                int vl = MatchingCompetitionDataManager.Instance._coroutineQueue.Dequeue();                if (vl == 1)                {                    //缓存里面存在数据,那也要再次请求服务器进行更新数据,只是用协程的形式,接着处理完数据后抛出事件                    ReqCurrentRank(true).Coroutine();                }            }        }                //获取往期作品集        public static async ETTask<bool> ReqBeforeWorks()        {            var response = (S2C_GetPreviousWorksCollection)await MessageHelper.SendToServer(new C2S_GetPreviousWorksCollection { });            if (!(response is { Error: ErrorCode.ERR_Success })) return false;                   foreach (var data in MatchingCompetitionDataManager.Instance._BeforeWorksList)            {                data.Bytes = null;                data.WorksInfo = null;                data.Ntexture?.Dispose();            }                        MatchingCompetitionDataManager.Instance._BeforeWorksList.Clear();            foreach (var item in response.WorksCollectionList)            {                MatchingWorksData data = new MatchingWorksData();                data.WorksInfo = item;                MatchingCompetitionDataManager.Instance._BeforeWorksList.Add(data);            }            Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingCompetitionDataManager.Instance._BeforeWorksList));            return true;        }        //获取往期作品排行榜        public static async ETTask<bool> ReqBeforeRank(int id)        {             var response = (S2C_GetOldJudgingRoundRankList)await MessageHelper.SendToServer(new C2S_GetOldJudgingRoundRankList { JudgingRoundOpenId = id});            if (!(response is { Error: ErrorCode.ERR_Success })) return false;                        foreach (var data in MatchingCompetitionDataManager.Instance._BeforeRankList)            {                data.Bytes = null;                data.JudgingInfo = null;                data.Ntexture?.Dispose();            }                        MatchingCompetitionDataManager.Instance._BeforeRankList.Clear();            foreach (var item in response.JudgingRoundRoleInfoList)            {                MatchingPhotoWorksData data = new MatchingPhotoWorksData();                data.RoleId = item.RoleId;                data.JudgingInfo = item;                MatchingCompetitionDataManager.Instance._BeforeRankList.Add(data);            }            Timers.inst.StartCoroutine(MatchingPhotoHelper.Download(MatchingCompetitionDataManager.Instance._BeforeRankList));            return true;        }        //搭配赛相册系协议        public static async ETTask<bool> ReqMatchingPhotoData()        {            var response = (S2C_GetJudgingRoundWorksList)await MessageHelper.SendToServer(new C2S_GetJudgingRoundWorksList { });            if (!(response is { Error: ErrorCode.ERR_Success })) return false;                        foreach (var data in MatchingCompetitionDataManager.Instance.MatchingPhotoInfos)            {                data.Bytes = null;                data.Ntexture?.Dispose();            }                        MatchingCompetitionDataManager.Instance.MatchingPhotoInfos.Clear();            foreach (var item in response.JudgingRoundRoleInfoList)            {                PoemPhotoData photoData = new PoemPhotoData();                photoData.PictureId = item.WorksId;                photoData.CreationTime = item.CreationTime;                photoData.ToppingStatus = item.ToppingStatus;                photoData.PictureTempUrl = item.PictureTempUrl;                MatchingCompetitionDataManager.Instance.MatchingPhotoInfos.Add(photoData);            }            Timers.inst.StartCoroutine(PictureStorageHelper.Download(MatchingCompetitionDataManager.Instance.MatchingPhotoInfos));            return true;        }        //修改图片锁定状态        public static async ETTask<bool> ReqChangeLockingState(long pictureId, bool state, int sourceType)        {            S2C_UpJudgingRoundWorksLockingStatus response = null;            response = (S2C_UpJudgingRoundWorksLockingStatus)await MessageHelper.SendToServer(new C2S_UpJudgingRoundWorksLockingStatus() { WorksId = pictureId, Status = state });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    PoemPhotoDataManager.Instance.ChangeLockingState(response.WorksId, response.Status, sourceType);                    EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);                    return true;                }            }            return false;        }        //修改图片置顶状态        public static async ETTask<bool> ReqChangeToppingState(long pictureId, bool state, int sourceType)        {            S2C_UpJudgingRoundWorksToppingStatus response = null;            response = (S2C_UpJudgingRoundWorksToppingStatus)await MessageHelper.SendToServer(new C2S_UpJudgingRoundWorksToppingStatus() { WorksId = pictureId, Status = state });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    PoemPhotoDataManager.Instance.ChangeToppingState(response.WorksId, response.Status, sourceType);                    EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);                    return true;                }            }            return false;        }        //批量删除玩家相册        public static async ETTask<bool> ReqRemovedPhoto(List<long> pictureIds, int sourceType)        {            S2C_RemovedJudgingRoundWorks response = null;            response = (S2C_RemovedJudgingRoundWorks)await MessageHelper.SendToServer(new C2S_RemovedJudgingRoundWorks() { WorksIds = pictureIds });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    PoemPhotoDataManager.Instance.Remove(response.WorksIds, sourceType);                    EventAgent.DispatchEvent(ConstMessage.POEM_PHOTO_INFOS_CHANGE);                    return true;                }            }            return false;        }    }}
 |