MatchingCompetitionDataManager.cs 31 KB

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