MatchingCompetitionDataManager.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. 
  2. using ET;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Text.RegularExpressions;
  7. using UnityEngine;
  8. using Live2D.Cubism.Rendering;
  9. using FairyGUI;
  10. using UI.MatchingCompetition;
  11. using System.IO;
  12. namespace GFGGame
  13. {
  14. class MatchingCompetitionDataManager : SingletonBase<MatchingCompetitionDataManager>
  15. {
  16. ////搭配赛标记
  17. //public int type = 2;
  18. //位置信息数据索引
  19. public int indexRoleData = 0;
  20. //人物位置信息
  21. public TransformData roleTransFormData = new TransformData();
  22. public GameObject roleGameobj;
  23. public string roleID = "Role";
  24. //*********************搭配数据*********************************
  25. //需要传输的数据:MathingDressDate,DressUpBgID,DressPropIdList,TransformDataList,
  26. public DressUpData MathingDressDate = DressUpData.CreateDefault();
  27. public int DressUpBgID = 0;
  28. //*****这两个id放列表的最后面
  29. //边框id
  30. public int BorderID = 0;
  31. //NpcId
  32. public int NpcID = 0;
  33. //*************=**************
  34. //道具数据,一一对应
  35. //场景名字,自己搭配的数据
  36. public List<string> DressPropNameList = new List<string>();
  37. //道具id
  38. //public List<int> DressPropIdList = new List<int>();
  39. //道具索引
  40. public int DressPropIndex = 0;
  41. //道具索引字典
  42. public Dictionary<string, TransformData> DressPropTransInfoDic = new Dictionary<string, TransformData>();
  43. //道具位置信息
  44. public List<TransformData> TransformDataList = new List<TransformData>();
  45. public List<GameObject> itemGameObjs = new List<GameObject>();
  46. //所有信息的列表,用于前后端交互
  47. public List<CollocationInfo> AllDressIDInfoList = new List<CollocationInfo>();
  48. //public List<int> _equipSceneData = new List<int>();//当前穿戴的场景数据(从套装获得)
  49. //***************************************************************
  50. public int MatchingCompetitionSeason = 1;
  51. public int MatchingState = 1;
  52. public long MatchingEndTimes = 0;
  53. public long WorksID = 0;
  54. public string TempPictureUrl = "";
  55. public int MatchingRemainingTimes = 1;
  56. public MyWorksIdInfo myWorks = new MyWorksIdInfo();
  57. public List<ItemInfoProto> SpecialBonusList = new List<ItemInfoProto>();
  58. /// <summary>
  59. /// 搭配赛相册
  60. /// </summary>
  61. /// <typeparam name="PoemPhotoData"></typeparam>
  62. /// <returns></returns>
  63. public List<PoemPhotoData> MatchingPhotoInfos = new List<PoemPhotoData>();
  64. //角色详情界面图片信息
  65. public NTexture DetailNtexture;
  66. //自己的搭配图片
  67. public NTexture MyNtextture;
  68. public byte[] MyBytes;
  69. //本期排行榜数据
  70. public List<CurRanMatchingPhotoWorksData> _currentRankList = new List<CurRanMatchingPhotoWorksData>();
  71. //本期排行榜数据--协程锁变量
  72. public bool IsWork = false;
  73. //本期排行榜数据--协程消息队列
  74. public Queue<int> _coroutineQueue = new Queue<int>();
  75. //往期作品集
  76. public List<MatchingWorksData> _BeforeWorksList = new List<MatchingWorksData>();
  77. //往期排行榜数据
  78. public List<MatchingPhotoWorksData> _BeforeRankList = new List<MatchingPhotoWorksData>();
  79. //根据时间判断:1:集结期 2:评选期 3;结算期
  80. //public int CheckCompetitionState()
  81. //{
  82. // long currentTime = TimeHelper.ServerNow();
  83. // DateTime dateTime = DateTimeOffset.FromUnixTimeSeconds(currentTime).DateTime;
  84. // // 获取星期几
  85. // DayOfWeek dayOfWeek = dateTime.DayOfWeek;
  86. // int week = (int)dayOfWeek;
  87. // int hour = dateTime.Hour;
  88. // if(week == 0)
  89. // {
  90. // if(hour >= 21)
  91. // {
  92. // return 3;
  93. // }
  94. // else
  95. // {
  96. // return 2;
  97. // }
  98. // }
  99. // if(week <= 3 && week >= 1)
  100. // {
  101. // if(week == 3 && hour >= 5)
  102. // {
  103. // return 2;
  104. // }
  105. // if(week == 1 && hour < 5)
  106. // {
  107. // return 3;
  108. // }
  109. // return 1;
  110. // }
  111. // else if(week > 3 && week <= 6)
  112. // {
  113. // return 2;
  114. // }
  115. // return -1;
  116. //}
  117. public void ConvertInfoToList()
  118. {
  119. //将所有需要存储的信息转换成list
  120. AllDressIDInfoList.Clear();
  121. foreach(var item in MathingDressDate.itemList)
  122. {
  123. CollocationInfo itemInfo = new CollocationInfo();
  124. itemInfo.ItemId = item.ToString();
  125. itemInfo.ClientPosition = "";
  126. AllDressIDInfoList.Add(itemInfo);
  127. }
  128. foreach (var item in DressPropTransInfoDic)
  129. {
  130. CollocationInfo itemInfo = new CollocationInfo();
  131. itemInfo.ItemId = item.Key;
  132. string transStr = item.Value.position.x.ToString() + "_" + item.Value.position.y.ToString() + "_"
  133. + item.Value.position.z.ToString()
  134. + "_" + item.Value.rotationZ.ToString()
  135. + "_" + item.Value.scale.x.ToString() + "_" +
  136. item.Value.scale.y.ToString() + "_" + item.Value.scale.z.ToString();
  137. itemInfo.ClientPosition = transStr;
  138. AllDressIDInfoList.Add(itemInfo);
  139. }
  140. //for(int i = 0;i< DressPropIdList.Count;i++)
  141. //{
  142. // CollocationInfo itemInfo = new CollocationInfo();
  143. // itemInfo.ItemId = DressPropIdList[i];
  144. // string transStr = TransformDataList[i].position.x.ToString()+"_" + TransformDataList[i].position.y.ToString() + "_"
  145. // + TransformDataList[i].position.z.ToString()
  146. // + "_" + TransformDataList[i].rotationZ.ToString()
  147. // + "_" + TransformDataList[i].scale.x.ToString() + "_" +
  148. // TransformDataList[i].scale.y.ToString() + "_" + TransformDataList[i].scale.z.ToString();
  149. // itemInfo.ClientPosition = transStr;
  150. // AllDressIDInfoList.Add(itemInfo);
  151. //}
  152. CollocationInfo itemBgInfo = new CollocationInfo();
  153. itemBgInfo.ItemId = MatchingCompetitionDataManager.Instance.DressUpBgID.ToString();
  154. itemBgInfo.ClientPosition = "";
  155. AllDressIDInfoList.Add(itemBgInfo);
  156. CollocationInfo itemActionInfo = new CollocationInfo();
  157. itemActionInfo.ItemId = MatchingCompetitionDataManager.Instance.MathingDressDate.actionId.ToString();
  158. itemActionInfo.ClientPosition = "";
  159. AllDressIDInfoList.Add(itemActionInfo);
  160. }
  161. //解析后台获取的信息
  162. public void AnalysisInfoToList()
  163. {
  164. List<int> dressitemIDList = new List<int>();
  165. List<int> propIDList = new List<int>();
  166. List<TransformData> transDataList = new List<TransformData>();
  167. DressUpBgID = 180001;
  168. MathingDressDate.bgId = 180001;
  169. MathingDressDate.actionId = 0;
  170. DressPropTransInfoDic.Clear();
  171. for (int i = 0; i < AllDressIDInfoList.Count; i++)
  172. {
  173. if(AllDressIDInfoList[i].ItemId == roleID)
  174. {
  175. //propIDList.Add(AllDressIDInfoList[i].ItemId);
  176. //transDataList.Add(AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  177. if (!DressPropTransInfoDic.ContainsKey(AllDressIDInfoList[i].ItemId))
  178. {
  179. DressPropTransInfoDic.Add(AllDressIDInfoList[i].ItemId.ToString(), AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  180. }
  181. }
  182. else
  183. {
  184. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(GetIDByString(AllDressIDInfoList[i].ItemId));
  185. if (itemCfg != null && itemCfg.itemType == ConstItemType.DRESS_UP)
  186. {
  187. if(itemCfg.subType == 19 || itemCfg.subType == 17 || itemCfg.subType == 21|| itemCfg.subType == 22)
  188. {
  189. //记录道具和位置信息
  190. //propIDList.Add(GetIDByString(AllDressIDInfoList[i].ItemId));
  191. //transDataList.Add(AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  192. if(GetIDListByString(AllDressIDInfoList[i].ItemId).Count > 1)
  193. {
  194. if (!DressPropTransInfoDic.ContainsKey(AllDressIDInfoList[i].ItemId))
  195. {
  196. DressPropTransInfoDic.Add(AllDressIDInfoList[i].ItemId.ToString(), AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  197. }
  198. }
  199. }
  200. else if (itemCfg != null && itemCfg.subType == ConstDressUpItemType.BEI_JING)
  201. {
  202. DressUpBgID = itemCfg.id;
  203. MathingDressDate.bgId = itemCfg.id;
  204. }
  205. else
  206. {
  207. dressitemIDList.Add(GetIDByString(AllDressIDInfoList[i].ItemId));
  208. }
  209. }
  210. else if (itemCfg != null && itemCfg.itemType == ConstItemType.PHOTOGRAPH)
  211. {
  212. //记录道具和位置信息
  213. //propIDList.Add(GetIDByString(AllDressIDInfoList[i].ItemId));
  214. //transDataList.Add(AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  215. if (!DressPropTransInfoDic.ContainsKey(AllDressIDInfoList[i].ItemId))
  216. {
  217. DressPropTransInfoDic.Add(AllDressIDInfoList[i].ItemId.ToString(), AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  218. }
  219. }
  220. else if(itemCfg == null)
  221. {
  222. SuitCfg actionId = SuitCfgArray.Instance.GetCfg(GetIDByString(AllDressIDInfoList[i].ItemId));
  223. if(actionId !=null)
  224. {
  225. MathingDressDate.actionId = GetIDByString(AllDressIDInfoList[i].ItemId);
  226. }
  227. }
  228. }
  229. }
  230. MathingDressDate.itemList = dressitemIDList;
  231. //DressPropIdList = propIDList;
  232. //TransformDataList = transDataList;
  233. }
  234. public TransformData AnalysisStringToTransform(string strTrans)
  235. {
  236. TransformData transData = new TransformData();
  237. string[] parts = Regex.Split(strTrans, "_");
  238. if(parts.Length > 6)
  239. {
  240. transData.position.x = float.Parse(parts[0]);
  241. transData.position.y = float.Parse(parts[1]);
  242. transData.position.z = float.Parse(parts[2]);
  243. transData.rotationZ = float.Parse(parts[3]);
  244. transData.scale.x = float.Parse(parts[4]);
  245. transData.scale.y = float.Parse(parts[5]);
  246. transData.scale.z = float.Parse(parts[6]);
  247. }
  248. return transData;
  249. }
  250. //存储道具信息
  251. public void SetTransformData()
  252. {
  253. DressPropNameList.Clear();
  254. TransformDataList.Clear();
  255. DressPropTransInfoDic.Clear();
  256. for (int i =0;i<itemGameObjs.Count;i++)
  257. {
  258. TransformData itemData = new TransformData();
  259. if (itemGameObjs[i].name == "Role")
  260. {
  261. roleTransFormData.position = itemGameObjs[i].transform.position;
  262. roleTransFormData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
  263. roleTransFormData.scale = itemGameObjs[i].transform.localScale;
  264. TransformDataList.Add(roleTransFormData);
  265. DressPropNameList.Add(itemGameObjs[i].name);
  266. if (!DressPropTransInfoDic.ContainsKey(itemGameObjs[i].name))
  267. {
  268. DressPropTransInfoDic.Add(itemGameObjs[i].name, roleTransFormData);
  269. }
  270. }
  271. else if (itemGameObjs[i].name == "Border")
  272. {
  273. itemData.position = itemGameObjs[i].transform.position;
  274. itemData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
  275. itemData.scale = itemGameObjs[i].transform.localScale;
  276. TransformDataList.Add(roleTransFormData);
  277. DressPropNameList.Add(itemGameObjs[i].name);
  278. if (!DressPropTransInfoDic.ContainsKey(itemGameObjs[i].name))
  279. {
  280. DressPropTransInfoDic.Add(BorderID.ToString(), itemData);
  281. }
  282. }
  283. else if (itemGameObjs[i].name == "Npc")
  284. {
  285. itemData.position = itemGameObjs[i].transform.position;
  286. itemData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
  287. itemData.scale = itemGameObjs[i].transform.localScale;
  288. TransformDataList.Add(roleTransFormData);
  289. DressPropNameList.Add(itemGameObjs[i].name);
  290. if (!DressPropTransInfoDic.ContainsKey(itemGameObjs[i].name))
  291. {
  292. DressPropTransInfoDic.Add(NpcID.ToString(), itemData);
  293. }
  294. }
  295. else
  296. {
  297. itemData.position = itemGameObjs[i].transform.position;
  298. itemData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
  299. itemData.scale = itemGameObjs[i].transform.localScale;
  300. TransformDataList.Add(itemData);
  301. DressPropNameList.Add(itemGameObjs[i].name);
  302. if(!DressPropTransInfoDic.ContainsKey(itemGameObjs[i].name))
  303. {
  304. DressPropTransInfoDic.Add(itemGameObjs[i].name, itemData);
  305. }
  306. }
  307. }
  308. //SetNameToIdList();
  309. }
  310. public int GetIDByString(string name)
  311. {
  312. int id = 0;
  313. //使用正则表达式分割字符串
  314. string[] parts = Regex.Split(name, "_");
  315. if (parts.Length > 0)
  316. {
  317. string vl = parts[0];
  318. bool isNumeric = int.TryParse(vl, out _);
  319. if (vl == "Role")
  320. {
  321. return -1;
  322. }
  323. else if (vl == "Border")
  324. {
  325. return -2;
  326. }
  327. else if (vl == "Npc")
  328. {
  329. return -3;
  330. }
  331. else if(!isNumeric)
  332. {
  333. return -4;
  334. }
  335. id = int.Parse(parts[0]);
  336. }
  337. return id;
  338. }
  339. public List<int> GetIDListByString(string name)
  340. {
  341. List<int> idList = new List<int>();
  342. string[] parts = Regex.Split(name, "_");
  343. foreach(string id in parts)
  344. {
  345. idList.Add(int.Parse(id));
  346. }
  347. return idList;
  348. }
  349. //将名字转换成道具id
  350. //public void SetNameToIdList()
  351. //{
  352. // //DressPropIdList.Clear();
  353. // int flog_prefix = 0;
  354. // int flog_suffix = 0;
  355. // for (int i = 0; i < DressPropNameList.Count; i++)
  356. // {
  357. // bool containsUnderscore = Regex.IsMatch(DressPropNameList[i], "_");
  358. // if(!containsUnderscore)
  359. // {
  360. // if (DressPropNameList[i] == "Role")
  361. // {
  362. // DressPropIdList.Add(roleID);
  363. // }
  364. // else if (DressPropNameList[i] == "Border")
  365. // {
  366. // if (BorderID != 0)
  367. // {
  368. // DressPropIdList.Add(BorderID);
  369. // }
  370. // }
  371. // else if (DressPropNameList[i] == "Npc")
  372. // {
  373. // if (NpcID != 0)
  374. // {
  375. // DressPropIdList.Add(NpcID);
  376. // }
  377. // }
  378. // }
  379. // else
  380. // {
  381. // // 使用正则表达式分割字符串
  382. // string[] parts = Regex.Split(DressPropNameList[i], "_");
  383. // int partID = int.Parse(parts[0]);
  384. // if(flog_prefix == int.Parse(parts[0]))
  385. // {
  386. // if((flog_suffix == 3 && int.Parse(parts[1]) == 1)|| (flog_suffix == 1 && int.Parse(parts[1]) == 3))
  387. // {
  388. // flog_prefix = 0;
  389. // flog_suffix = 0;
  390. // continue;
  391. // }
  392. // if ((flog_suffix == 2 && int.Parse(parts[1]) == 1) || (flog_suffix == 1 && int.Parse(parts[1]) == 2))
  393. // {
  394. // flog_prefix = 0;
  395. // flog_suffix = 0;
  396. // continue;
  397. // }
  398. // }
  399. // flog_prefix = int.Parse(parts[0]);
  400. // flog_suffix = int.Parse(parts[1]);
  401. // DressPropIdList.Add(partID);
  402. // }
  403. // }
  404. //}
  405. //将穿戴数据分类
  406. //public void ClassifyEquipData()
  407. //{
  408. // _equipSceneData.Clear();
  409. // PhotographDataManager.Instance.dressUpObj = new DressUpObj();
  410. // //for (int i = 0; i < MathingDressDate.itemList.Count; i++)
  411. // //{
  412. // // int itemId = MathingDressDate.itemList[i];
  413. // // if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId, false))
  414. // // {
  415. // // if (!_equipSceneData.ContainsKey(itemId))
  416. // // {
  417. // // _equipSceneData.Add(itemId, new List<int>());
  418. // // }
  419. // // _equipSceneData[itemId].Add(itemId);
  420. // // }
  421. // //}
  422. // for(int i =0;i<DressPropIdList.Count;i++)
  423. // {
  424. // int itemId = DressPropIdList[i];
  425. // if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId, false))
  426. // {
  427. // _equipSceneData.Add(itemId);
  428. // }
  429. // }
  430. //}
  431. public void InsertGameObjectList()
  432. {
  433. int i = 0;
  434. foreach(var item in DressPropTransInfoDic)
  435. {
  436. i++;
  437. if (item.Key == roleID)
  438. {
  439. indexRoleData = i;
  440. break;
  441. }
  442. indexRoleData = i;
  443. }
  444. if(itemGameObjs.Count ==0)
  445. {
  446. itemGameObjs.Add(roleGameobj);
  447. }
  448. else
  449. {
  450. if (indexRoleData > itemGameObjs.Count)
  451. {
  452. itemGameObjs.Add(roleGameobj);
  453. }
  454. else
  455. {
  456. itemGameObjs.Insert(indexRoleData, roleGameobj);
  457. }
  458. }
  459. }
  460. public void SetNumToRank(int index,UI_Component4 rankCom)
  461. {
  462. int c1 = 0;
  463. int c2 = 0;
  464. if(index<=3&& index >=1)
  465. {
  466. c2 = index;
  467. }
  468. if (index > 3 && index <= 9)
  469. {
  470. c1 = 0;
  471. }
  472. else if(index >9 && index <= 50)
  473. {
  474. c1 = 1;
  475. }
  476. else
  477. {
  478. c1 = 2;
  479. }
  480. rankCom.m_c1.selectedIndex = c1;
  481. rankCom.m_c2.selectedIndex = c2;
  482. if(c1 == 0)
  483. {
  484. rankCom.m_num3.url = string.Format("ui://MatchingCompetition/{0}",index.ToString());
  485. }
  486. else if(c1 == 1)
  487. {
  488. int one = index / 10;
  489. int two = index % 10;
  490. rankCom.m_num1.url = string.Format("ui://MatchingCompetition/{0}", one.ToString());
  491. rankCom.m_num2.url = string.Format("ui://MatchingCompetition/{0}", two.ToString());
  492. }
  493. else
  494. {
  495. if (index == 0)
  496. {
  497. rankCom.m_RankText.text = "--";
  498. }
  499. else
  500. {
  501. for (int i = 11; i < JudgingRoundRewardCfgArray.Instance.dataArray.Length-1; i++)
  502. {
  503. JudgingRoundRewardCfg judgingCfg = JudgingRoundRewardCfgArray.Instance.GetCfg(i);
  504. JudgingRoundRewardCfg judgingNextCfg = JudgingRoundRewardCfgArray.Instance.GetCfg(i+1);
  505. if (index >= judgingCfg.rank && index < judgingNextCfg.rank)
  506. {
  507. rankCom.m_RankText.text = judgingNextCfg.desc;
  508. }
  509. else
  510. {
  511. rankCom.m_RankText.text = index.ToString();
  512. }
  513. }
  514. }
  515. }
  516. }
  517. public async void AddSceneItem(ItemCfg itemCfg, bool setLayer,int isLeft = 0)
  518. {
  519. Vector3 pos = Vector3.zero;
  520. if (!string.IsNullOrEmpty(itemCfg.resLayer3))
  521. {
  522. DressPropIndex++;
  523. GameObject parentGameObj3 = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, 3,DressPropIndex));
  524. await PhotographSceneManager.Instance.AddSceneItem(parentGameObj3, itemCfg, 3, setLayer,false,isLeft);
  525. if (setLayer)
  526. {
  527. if (parentGameObj3.transform.childCount > 0)
  528. {
  529. parentGameObj3.transform.localPosition = -parentGameObj3.transform.GetChild(0).localPosition;
  530. pos = parentGameObj3.transform.localPosition;
  531. }
  532. }
  533. }
  534. if (!string.IsNullOrEmpty(itemCfg.resLayer2))
  535. {
  536. DressPropIndex++;
  537. GameObject parentGameObj2 = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, 2,DressPropIndex));
  538. await PhotographSceneManager.Instance.AddSceneItem(parentGameObj2, itemCfg, 2, setLayer,false, isLeft);
  539. if (setLayer)
  540. {
  541. if (parentGameObj2.transform.childCount > 0)
  542. {
  543. parentGameObj2.transform.localPosition = pos == Vector3.zero ? -parentGameObj2.transform.GetChild(0).localPosition : pos;
  544. pos = parentGameObj2.transform.localPosition;
  545. }
  546. }
  547. }
  548. if (!string.IsNullOrEmpty(itemCfg.resLayer1))
  549. {
  550. DressPropIndex++;
  551. GameObject parentGameObj1 = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, 1, DressPropIndex));
  552. await PhotographSceneManager.Instance.AddSceneItem(parentGameObj1, itemCfg, 1, setLayer, false, isLeft);
  553. if (setLayer)
  554. {
  555. if (parentGameObj1.transform.childCount > 0)
  556. {
  557. parentGameObj1.transform.localPosition = pos == Vector3.zero ? -parentGameObj1.transform.GetChild(0).localPosition : pos;
  558. pos = parentGameObj1.transform.localPosition;
  559. }
  560. }
  561. }
  562. }
  563. public async void AddSceneItemOne(ItemCfg itemCfg, int layer,int index, int isLeft = 0, bool setLayer = true)
  564. {
  565. Vector3 pos = Vector3.zero;
  566. if(DressPropIndex <= index)
  567. {
  568. DressPropIndex = index + 1;
  569. }
  570. GameObject parentGameObj3 = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.id, layer, index));
  571. await PhotographSceneManager.Instance.AddSceneItem(parentGameObj3, itemCfg, layer, setLayer, false, isLeft);
  572. if (setLayer)
  573. {
  574. if (parentGameObj3.transform.childCount > 0)
  575. {
  576. parentGameObj3.transform.localPosition = -parentGameObj3.transform.GetChild(0).localPosition;
  577. pos = parentGameObj3.transform.localPosition;
  578. }
  579. }
  580. }
  581. public void OnClickBtnRule()
  582. {
  583. ViewManager.Show<MatchingCompetitionRuleTipsView>();
  584. }
  585. }
  586. class MatchingOneDataManager : SingletonBase<MatchingOneDataManager>
  587. {
  588. //其他玩家信息用于展示
  589. public MatchingPhotoWorksData OneRoleInfo = new MatchingPhotoWorksData();
  590. //人物位置信息
  591. public TransformData roleTransFormData = new TransformData();
  592. public GameObject roleGameobj;
  593. public string roleID = "Role";
  594. //*********************搭配数据*********************************
  595. //需要传输的数据:MathingDressDate,DressUpBgID,DressPropIdList,TransformDataList,
  596. public DressUpData MathingDressDate = DressUpData.CreateDefault();
  597. public int DressUpBgID = 0;
  598. //*****这两个id放列表的最后面
  599. //边框id
  600. public int BorderID = 0;
  601. //NpcId
  602. public int NpcID = 0;
  603. //道具数据,一一对应
  604. //道具id
  605. //public List<int> DressPropIdList = new List<int>();
  606. //道具位置信息
  607. public List<TransformData> TransformDataList = new List<TransformData>();
  608. //道具索引
  609. public int DressPropIndex = 0;
  610. //道具索引字典
  611. public Dictionary<string, TransformData> DressPropTransInfoDic = new Dictionary<string, TransformData>();
  612. public List<GameObject> itemGameObjs = new List<GameObject>();
  613. //***************************************************************
  614. //解析后台获取的信息
  615. public void AnalysisInfoToList()
  616. {
  617. List<int> dressitemIDList = new List<int>();
  618. List<int> propIDList = new List<int>();
  619. List<TransformData> transDataList = new List<TransformData>();
  620. DressPropTransInfoDic.Clear();
  621. for (int i = 0; i < OneRoleInfo.JudgingInfo.CollocationInfoList.Count; i++)
  622. {
  623. CollocationInfo colloctItemInfo = OneRoleInfo.JudgingInfo.CollocationInfoList[i];
  624. if (colloctItemInfo.ItemId == roleID)
  625. {
  626. //propIDList.Add(colloctItemInfo.ItemId);
  627. //transDataList.Add(MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  628. if(!DressPropTransInfoDic.ContainsKey(colloctItemInfo.ItemId))
  629. {
  630. DressPropTransInfoDic.Add(colloctItemInfo.ItemId, MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  631. }
  632. }
  633. else
  634. {
  635. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(MatchingCompetitionDataManager.Instance.GetIDByString( colloctItemInfo.ItemId));
  636. if (itemCfg != null && itemCfg.itemType == ConstItemType.DRESS_UP)
  637. {
  638. if (itemCfg.subType == 19 || itemCfg.subType == 17 || itemCfg.subType == 21 || itemCfg.subType == 22)
  639. {
  640. //记录道具和位置信息
  641. //propIDList.Add(colloctItemInfo.ItemId);
  642. //transDataList.Add(MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  643. if (!DressPropTransInfoDic.ContainsKey(colloctItemInfo.ItemId))
  644. {
  645. DressPropTransInfoDic.Add(colloctItemInfo.ItemId, MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  646. }
  647. }
  648. else if (itemCfg != null && itemCfg.subType == ConstDressUpItemType.BEI_JING)
  649. {
  650. DressUpBgID = itemCfg.id;
  651. }
  652. else
  653. {
  654. dressitemIDList.Add(MatchingCompetitionDataManager.Instance.GetIDByString(colloctItemInfo.ItemId));
  655. }
  656. }
  657. else if (itemCfg != null && itemCfg.itemType == ConstItemType.PHOTOGRAPH)
  658. {
  659. //记录道具和位置信息
  660. //propIDList.Add(colloctItemInfo.ItemId);
  661. //transDataList.Add(MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  662. if (!DressPropTransInfoDic.ContainsKey(colloctItemInfo.ItemId))
  663. {
  664. DressPropTransInfoDic.Add(colloctItemInfo.ItemId, MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  665. }
  666. }
  667. }
  668. }
  669. MathingDressDate.itemList = dressitemIDList;
  670. MathingDressDate.actionId = OneRoleInfo.JudgingInfo.ActionId;
  671. //DressPropIdList = propIDList;
  672. //TransformDataList = transDataList;
  673. DressUpBgID = OneRoleInfo.JudgingInfo.BagId;
  674. }
  675. public void InsertGameObjectList()
  676. {
  677. int indexRoleData = 0;
  678. int i = 0;
  679. foreach (var item in DressPropTransInfoDic)
  680. {
  681. i++;
  682. if (item.Key == roleID)
  683. {
  684. indexRoleData = i;
  685. }
  686. }
  687. if (itemGameObjs.Count == 0)
  688. {
  689. itemGameObjs.Add(roleGameobj);
  690. }
  691. else
  692. {
  693. if (indexRoleData > itemGameObjs.Count)
  694. {
  695. itemGameObjs.Add(roleGameobj);
  696. }
  697. else
  698. {
  699. itemGameObjs.Insert(indexRoleData, roleGameobj);
  700. }
  701. }
  702. }
  703. }
  704. }