123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- 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;
- //*********************搭配数据*********************************
- //需要传输的数据:MathingDressDate,DressUpBgID,DressPropIdList,TransformDataList,
- public DressUpData MathingDressDate = DressUpData.CreateDefault();
- public int DressUpBgID = 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<int> _equipSceneData = new List<int>();//当前穿戴的场景数据(从套装获得)
- //***************************************************************
- public int MatchingCompetitionSeason = 1;
- public int MatchingRemainingTimes = 1;
- //本期排行榜数据
- public List<MatchingPlayerData> _currentRankList = new List<MatchingPlayerData>() { new MatchingPlayerData()};
- //往期排行榜数据
- public Dictionary<int, MatchingPlayerData> _beforeRankDic = new Dictionary<int, MatchingPlayerData>();
- //根据时间判断: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 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_id = 0;
- for (int i = 0; i < DressPropNameList.Count; i++)
- {
- bool containsUnderscore = Regex.IsMatch(DressPropNameList[i], "_");
- if(!containsUnderscore)
- {
- indexRoleData = i;
- }
- else
- {
- // 使用正则表达式分割字符串
- string[] parts = Regex.Split(DressPropNameList[i], "_");
- int partID = int.Parse(parts[0]);
- if(flog_id == 3 && int.Parse(parts[1]) == 1)
- {
- continue;
- }
- flog_id = 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()
- {
- 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 OtherMatchingCompetitionDataManager : SingletonBase<OtherMatchingCompetitionDataManager>
- {
- //其他玩家信息用于展示
- //人物位置信息
- public TransformData roleTransFormData = new TransformData();
- public GameObject roleGameobj;
- //*********************搭配数据*********************************
- //需要传输的数据:MathingDressDate,DressUpBgID,DressPropIdList,TransformDataList,
- public DressUpData MathingDressDate = DressUpData.CreateDefault();
- public int DressUpBgID = 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<int> _equipSceneData = new List<int>();//当前穿戴的场景数据
- //***************************************************************
- }
- }
|