123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518 |
- using ET;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using UnityEngine;
- using Live2D.Cubism.Rendering;
- using FairyGUI;
- using UI.MatchingCompetition;
- namespace GFGGame
- {
- class MatchingCompetitionDataManager : SingletonBase<MatchingCompetitionDataManager>
- {
- ////搭配赛标记
- //public int type = 2;
- //位置信息数据索引
- public int indexRoleData = 0;
- //人物位置信息
- public TransformData roleTransFormData = new TransformData();
- public GameObject roleGameobj;
- public int roleID = -1;
- //*********************搭配数据*********************************
- //需要传输的数据:MathingDressDate,DressUpBgID,DressPropIdList,TransformDataList,
- public DressUpData MathingDressDate = DressUpData.CreateDefault();
- public int DressUpBgID = 0;
- //*****这两个id放列表的最后面
- //边框id
- public int BorderID = 0;
- //NpcId
- public int NpcID = 0;
- //*************=**************
- //道具数据,一一对应
- //场景名字,自己搭配的数据
- public List<string> DressPropNameList = new List<string>();
- //道具id
- public List<int> DressPropIdList = new List<int>();
- //道具位置信息
- public List<TransformData> TransformDataList = new List<TransformData>();
- public List<GameObject> itemGameObjs = new List<GameObject>();
- //所有信息的列表,用于前后端交互
- public List<CollocationInfo> AllDressIDInfoList = new List<CollocationInfo>();
- //public List<int> _equipSceneData = new List<int>();//当前穿戴的场景数据(从套装获得)
- //***************************************************************
- public int MatchingCompetitionSeason = 1;
- public int MatchingState = 1;
- public long MatchingEndTimes = 0;
- public long WorksID = 0;
- public string TempPictureUrl = "";
- public int MatchingRemainingTimes = 1;
- public MyWorksIdInfo myWorks;
- /// <summary>
- /// 搭配赛相册
- /// </summary>
- /// <typeparam name="PoemPhotoData"></typeparam>
- /// <returns></returns>
- public List<PoemPhotoData> MatchingPhotoInfos = new List<PoemPhotoData>();
- //角色详情界面图片信息
- public NTexture DetailNtexture;
- //本期排行榜数据
- public List<MatchingPhotoWorksData> _currentRankList = new List<MatchingPhotoWorksData>();
- //往期作品集
- public List<MatchingWorksData> _BeforeWorksList = new List<MatchingWorksData>();
- //往期排行榜数据
- public List<MatchingPhotoWorksData> _BeforeRankList = new List<MatchingPhotoWorksData>();
- //根据时间判断:1:集结期 2:评选期 3;结算期
- //public int CheckCompetitionState()
- //{
- // long currentTime = TimeHelper.ServerNow();
- // DateTime dateTime = DateTimeOffset.FromUnixTimeSeconds(currentTime).DateTime;
- // // 获取星期几
- // DayOfWeek dayOfWeek = dateTime.DayOfWeek;
- // int week = (int)dayOfWeek;
- // int hour = dateTime.Hour;
- // if(week == 0)
- // {
- // if(hour >= 21)
- // {
- // return 3;
- // }
- // else
- // {
- // return 2;
- // }
- // }
- // if(week <= 3 && week >= 1)
- // {
- // if(week == 3 && hour >= 5)
- // {
- // return 2;
- // }
- // if(week == 1 && hour < 5)
- // {
- // return 3;
- // }
- // return 1;
- // }
- // else if(week > 3 && week <= 6)
- // {
- // return 2;
- // }
- // return -1;
- //}
- public void ConvertInfoToList()
- {
- //将所有需要存储的信息转换成list
- AllDressIDInfoList.Clear();
- foreach(var item in MathingDressDate.itemList)
- {
- CollocationInfo itemInfo = new CollocationInfo();
- itemInfo.ItemId = item;
- itemInfo.ClientPosition = "";
- AllDressIDInfoList.Add(itemInfo);
- }
- for(int i = 0;i< DressPropIdList.Count;i++)
- {
- CollocationInfo itemInfo = new CollocationInfo();
- itemInfo.ItemId = DressPropIdList[i];
- string transStr = TransformDataList[i].position.x.ToString()+"_" + TransformDataList[i].position.y.ToString() + "_"
- + TransformDataList[i].position.z.ToString()
- + "_" + TransformDataList[i].rotationZ.ToString()
- + "_" + TransformDataList[i].scale.x.ToString() + "_" +
- TransformDataList[i].scale.y.ToString() + "_" + TransformDataList[i].scale.z.ToString();
- itemInfo.ClientPosition = transStr;
- AllDressIDInfoList.Add(itemInfo);
- }
- CollocationInfo itemBgInfo = new CollocationInfo();
- itemBgInfo.ItemId = MatchingCompetitionDataManager.Instance.DressUpBgID;
- itemBgInfo.ClientPosition = "";
- AllDressIDInfoList.Add(itemBgInfo);
- CollocationInfo itemActionInfo = new CollocationInfo();
- itemActionInfo.ItemId = MatchingCompetitionDataManager.Instance.MathingDressDate.actionId;
- itemActionInfo.ClientPosition = "";
- AllDressIDInfoList.Add(itemActionInfo);
- }
- //解析后台获取的信息
- public void AnalysisInfoToList()
- {
- List<int> dressitemIDList = new List<int>();
- List<int> propIDList = new List<int>();
- List<TransformData> transDataList = new List<TransformData>();
- DressUpBgID = 0;
- MathingDressDate.actionId = 0;
- for (int i = 0; i < AllDressIDInfoList.Count; i++)
- {
- if(AllDressIDInfoList[i].ItemId == roleID)
- {
- propIDList.Add(AllDressIDInfoList[i].ItemId);
- transDataList.Add(AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
- }
- else
- {
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(AllDressIDInfoList[i].ItemId);
- if (itemCfg != null && itemCfg.itemType == ConstItemType.DRESS_UP)
- {
- if(itemCfg.subType == 19 || itemCfg.subType == 17 || itemCfg.subType == 21|| itemCfg.subType == 22)
- {
- //记录道具和位置信息
- propIDList.Add(AllDressIDInfoList[i].ItemId);
- transDataList.Add(AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
- }
- else if (itemCfg != null && itemCfg.subType == ConstDressUpItemType.BEI_JING)
- {
- DressUpBgID = itemCfg.id;
- }
- else
- {
- dressitemIDList.Add(AllDressIDInfoList[i].ItemId);
- }
- }
- else if (itemCfg != null && itemCfg.itemType == ConstItemType.PHOTOGRAPH)
- {
- //记录道具和位置信息
- propIDList.Add(AllDressIDInfoList[i].ItemId);
- transDataList.Add(AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
- }
- else if(itemCfg == null)
- {
- SuitCfg actionId = SuitCfgArray.Instance.GetCfg(AllDressIDInfoList[i].ItemId);
- if(actionId !=null)
- {
- MathingDressDate.actionId = AllDressIDInfoList[i].ItemId;
- }
- }
- }
- }
- MathingDressDate.itemList = dressitemIDList;
- DressPropIdList = propIDList;
- TransformDataList = transDataList;
- }
- public TransformData AnalysisStringToTransform(string strTrans)
- {
- TransformData transData = new TransformData();
- string[] parts = Regex.Split(strTrans, "_");
- if(parts.Length > 6)
- {
- transData.position.x = float.Parse(parts[0]);
- transData.position.y = float.Parse(parts[1]);
- transData.position.z = float.Parse(parts[2]);
- transData.rotationZ = float.Parse(parts[3]);
- transData.scale.x = float.Parse(parts[4]);
- transData.scale.y = float.Parse(parts[5]);
- transData.scale.z = float.Parse(parts[6]);
- }
- return transData;
- }
- //存储道具信息
- public void SetTransformData()
- {
- DressPropNameList.Clear();
- TransformDataList.Clear();
- for (int i =0;i<itemGameObjs.Count;i++)
- {
- if(itemGameObjs[i].name == "Role")
- {
- TransformData itemData = new TransformData();
- roleTransFormData.position = itemGameObjs[i].transform.position;
- roleTransFormData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
- roleTransFormData.scale = itemGameObjs[i].transform.localScale;
- TransformDataList.Add(roleTransFormData);
- DressPropNameList.Add(itemGameObjs[i].name);
- }
- else
- {
- TransformData itemData = new TransformData();
- itemData.position = itemGameObjs[i].transform.position;
- itemData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
- itemData.scale = itemGameObjs[i].transform.localScale;
- TransformDataList.Add(itemData);
- DressPropNameList.Add(itemGameObjs[i].name);
- }
- }
- SetNameToIdList();
- }
- //将名字转换成道具id
- public void SetNameToIdList()
- {
- DressPropIdList.Clear();
- int flog_prefix = 0;
- int flog_suffix = 0;
- for (int i = 0; i < DressPropNameList.Count; i++)
- {
- bool containsUnderscore = Regex.IsMatch(DressPropNameList[i], "_");
- if(!containsUnderscore)
- {
- if (DressPropNameList[i] == "Role")
- {
- DressPropIdList.Add(roleID);
- }
- else if (DressPropNameList[i] == "Border")
- {
- if (BorderID != 0)
- {
- DressPropIdList.Add(BorderID);
- }
- }
- else if (DressPropNameList[i] == "Npc")
- {
- if (NpcID != 0)
- {
- DressPropIdList.Add(NpcID);
- }
- }
- }
- else
- {
- // 使用正则表达式分割字符串
- string[] parts = Regex.Split(DressPropNameList[i], "_");
- int partID = int.Parse(parts[0]);
- if(flog_prefix == int.Parse(parts[0]))
- {
- if((flog_suffix == 3 && int.Parse(parts[1]) == 1)|| (flog_suffix == 1 && int.Parse(parts[1]) == 3))
- flog_prefix = 0;
- flog_suffix = 0;
- continue;
- }
- flog_prefix = int.Parse(parts[0]);
- flog_suffix = int.Parse(parts[1]);
- DressPropIdList.Add(partID);
- }
- }
- }
- //将穿戴数据分类
- //public void ClassifyEquipData()
- //{
- // _equipSceneData.Clear();
- // PhotographDataManager.Instance.dressUpObj = new DressUpObj();
- // //for (int i = 0; i < MathingDressDate.itemList.Count; i++)
- // //{
- // // int itemId = MathingDressDate.itemList[i];
- // // if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId, false))
- // // {
- // // if (!_equipSceneData.ContainsKey(itemId))
- // // {
- // // _equipSceneData.Add(itemId, new List<int>());
- // // }
- // // _equipSceneData[itemId].Add(itemId);
- // // }
- // //}
- // for(int i =0;i<DressPropIdList.Count;i++)
- // {
- // int itemId = DressPropIdList[i];
- // if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId, false))
- // {
- // _equipSceneData.Add(itemId);
- // }
- // }
- //}
- public void InsertGameObjectList()
- {
- for(int i=0;i< DressPropIdList.Count;i++)
- {
- if (DressPropIdList[i] == roleID)
- {
- indexRoleData = i;
- }
- }
- if(itemGameObjs.Count ==0)
- {
- itemGameObjs.Add(roleGameobj);
- }
- else
- {
- itemGameObjs.Insert(indexRoleData, roleGameobj);
- }
- }
- public void SetNumToRank(int index,UI_Component4 rankCom)
- {
- int c1 = 0;
- int c2 = 0;
- if(index<=3&& index >=1)
- {
- c2 = index;
- }
- if (index > 3 && index <= 9)
- {
- c1 = 0;
- }
- else if(index >9 && index <= 20)
- {
- c1 = 1;
- }
- else
- {
- c1 = 2;
- }
- rankCom.m_c1.selectedIndex = c1;
- rankCom.m_c2.selectedIndex = c2;
- if(c1 == 0)
- {
- rankCom.m_num3.url = string.Format("ui://MatchingCompetition/{0}",index.ToString());
- }
- else if(c1 == 1)
- {
- int one = index / 10;
- int two = index % 10;
- rankCom.m_num1.url = string.Format("ui://MatchingCompetition/{0}", one.ToString());
- rankCom.m_num2.url = string.Format("ui://MatchingCompetition/{0}", two.ToString());
- }
- else
- {
- rankCom.m_RankText.text = index.ToString();
- }
- }
- public async void AddSceneItem(ItemCfg itemCfg, bool setLayer)
- {
- Vector3 pos = Vector3.zero;
- if (!string.IsNullOrEmpty(itemCfg.resLayer3))
- {
- GameObject parentGameObj3 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 3));
- await PhotographSceneManager.Instance.AddSceneItem(parentGameObj3, itemCfg, 3, setLayer);
- if (setLayer)
- {
- if (parentGameObj3.transform.childCount > 0)
- {
- parentGameObj3.transform.localPosition = -parentGameObj3.transform.GetChild(0).localPosition;
- pos = parentGameObj3.transform.localPosition;
- }
- }
- }
- if (!string.IsNullOrEmpty(itemCfg.resLayer2))
- {
- GameObject parentGameObj2 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 2));
- await PhotographSceneManager.Instance.AddSceneItem(parentGameObj2, itemCfg, 2, setLayer);
- if (setLayer)
- {
- if (parentGameObj2.transform.childCount > 0)
- {
- parentGameObj2.transform.localPosition = pos == Vector3.zero ? -parentGameObj2.transform.GetChild(0).localPosition : pos;
- pos = parentGameObj2.transform.localPosition;
- }
- }
- }
- if (!string.IsNullOrEmpty(itemCfg.resLayer1))
- {
- GameObject parentGameObj1 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 1));
- await PhotographSceneManager.Instance.AddSceneItem(parentGameObj1, itemCfg, 1, setLayer);
- if (setLayer)
- {
- if (parentGameObj1.transform.childCount > 0)
- {
- parentGameObj1.transform.localPosition = pos == Vector3.zero ? -parentGameObj1.transform.GetChild(0).localPosition : pos;
- pos = parentGameObj1.transform.localPosition;
- }
- }
- }
- }
- public void OnClickBtnRule()
- {
- ViewManager.Show<MatchingCompetitionRuleTipsView>();
- }
- }
- class MatchingOneDataManager : SingletonBase<MatchingOneDataManager>
- {
- //其他玩家信息用于展示
- public MatchingPhotoWorksData OneRoleInfo = new MatchingPhotoWorksData();
- //人物位置信息
- public TransformData roleTransFormData = new TransformData();
- public GameObject roleGameobj;
- public int roleID = -1;
- //*********************搭配数据*********************************
- //需要传输的数据:MathingDressDate,DressUpBgID,DressPropIdList,TransformDataList,
- public DressUpData MathingDressDate = DressUpData.CreateDefault();
- public int DressUpBgID = 0;
- //*****这两个id放列表的最后面
- //边框id
- public int BorderID = 0;
- //NpcId
- public int NpcID = 0;
- //道具数据,一一对应
- //道具id
- public List<int> DressPropIdList = new List<int>();
- //道具位置信息
- public List<TransformData> TransformDataList = new List<TransformData>();
- public List<GameObject> itemGameObjs = new List<GameObject>();
- //***************************************************************
- //解析后台获取的信息
- public void AnalysisInfoToList()
- {
- List<int> dressitemIDList = new List<int>();
- List<int> propIDList = new List<int>();
- List<TransformData> transDataList = new List<TransformData>();
- for (int i = 0; i < OneRoleInfo.JudgingInfo.CollocationInfoList.Count; i++)
- {
- if (OneRoleInfo.JudgingInfo.CollocationInfoList[i].ItemId == roleID)
- {
- propIDList.Add(OneRoleInfo.JudgingInfo.CollocationInfoList[i].ItemId);
- }
- else
- {
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(OneRoleInfo.JudgingInfo.CollocationInfoList[i].ItemId);
- if (itemCfg != null && itemCfg.itemType == ConstItemType.DRESS_UP)
- {
- if (itemCfg.subType == 9 || itemCfg.subType == 10 || itemCfg.subType == 11 || itemCfg.subType == 12)
- {
- //记录道具和位置信息
- propIDList.Add(OneRoleInfo.JudgingInfo.CollocationInfoList[i].ItemId);
- transDataList.Add(MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(OneRoleInfo.JudgingInfo.CollocationInfoList[i].ClientPosition));
- }
- else
- {
- dressitemIDList.Add(OneRoleInfo.JudgingInfo.CollocationInfoList[i].ItemId);
- }
- }
- else if (itemCfg != null && itemCfg.itemType == ConstItemType.PHOTOGRAPH)
- {
- //记录道具和位置信息
- propIDList.Add(OneRoleInfo.JudgingInfo.CollocationInfoList[i].ItemId);
- transDataList.Add(MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(OneRoleInfo.JudgingInfo.CollocationInfoList[i].ClientPosition));
- }
- }
- }
- MathingDressDate.itemList = dressitemIDList;
- MathingDressDate.actionId = OneRoleInfo.JudgingInfo.ActionId;
- DressPropIdList = propIDList;
- TransformDataList = transDataList;
- DressUpBgID = OneRoleInfo.JudgingInfo.BagId;
- }
- public void InsertGameObjectList()
- {
- int indexRoleData = 0;
- for (int i = 0; i < DressPropIdList.Count; i++)
- {
- if (DressPropIdList[i] == roleID)
- {
- indexRoleData = i;
- }
- }
- if (itemGameObjs.Count == 0)
- {
- itemGameObjs.Add(roleGameobj);
- }
- else
- {
- itemGameObjs.Insert(indexRoleData, roleGameobj);
- }
- }
- }
- class MatchingTwoDataManager : SingletonBase<MatchingTwoDataManager>
- {
- //其他玩家信息用于展示
- public MatchingPhotoWorksData LeftRoleInfo = new MatchingPhotoWorksData();
- //其他玩家信息用于展示
- public MatchingPhotoWorksData RightRoleInfo = new MatchingPhotoWorksData();
- }
- }
|