MatchingCompetitionDataManager.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  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. using System.IO;
  11. using cfg.GfgCfg;
  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(),
  180. AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  181. }
  182. }
  183. else
  184. {
  185. ItemCfg itemCfg =
  186. CommonDataManager.Tables.TblItemCfg.GetOrDefault(GetIDByString(AllDressIDInfoList[i].ItemId));
  187. if (itemCfg != null && itemCfg.ItemType == ConstItemType.DRESS_UP)
  188. {
  189. if (itemCfg.SubType == 19 || itemCfg.SubType == 17 || itemCfg.SubType == 21 ||
  190. itemCfg.SubType == 22)
  191. {
  192. //记录道具和位置信息
  193. //propIDList.Add(GetIDByString(AllDressIDInfoList[i].ItemId));
  194. //transDataList.Add(AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  195. if (GetIDListByString(AllDressIDInfoList[i].ItemId).Count > 1)
  196. {
  197. if (!DressPropTransInfoDic.ContainsKey(AllDressIDInfoList[i].ItemId))
  198. {
  199. DressPropTransInfoDic.Add(AllDressIDInfoList[i].ItemId.ToString(),
  200. AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  201. }
  202. }
  203. }
  204. else if (itemCfg != null && itemCfg.SubType == ConstDressUpItemType.BEI_JING)
  205. {
  206. DressUpBgID = itemCfg.Id;
  207. MathingDressDate.bgId = itemCfg.Id;
  208. }
  209. else
  210. {
  211. dressitemIDList.Add(GetIDByString(AllDressIDInfoList[i].ItemId));
  212. }
  213. }
  214. else if (itemCfg != null && itemCfg.ItemType == ConstItemType.PHOTOGRAPH)
  215. {
  216. //记录道具和位置信息
  217. //propIDList.Add(GetIDByString(AllDressIDInfoList[i].ItemId));
  218. //transDataList.Add(AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  219. if (!DressPropTransInfoDic.ContainsKey(AllDressIDInfoList[i].ItemId))
  220. {
  221. DressPropTransInfoDic.Add(AllDressIDInfoList[i].ItemId.ToString(),
  222. AnalysisStringToTransform(AllDressIDInfoList[i].ClientPosition));
  223. }
  224. }
  225. else if (itemCfg == null)
  226. {
  227. SuitCfg actionId =
  228. CommonDataManager.Tables.TblSuitCfg.GetOrDefault(
  229. GetIDByString(AllDressIDInfoList[i].ItemId));
  230. if (actionId != null)
  231. {
  232. MathingDressDate.actionId = GetIDByString(AllDressIDInfoList[i].ItemId);
  233. }
  234. }
  235. }
  236. }
  237. MathingDressDate.itemList = dressitemIDList;
  238. //DressPropIdList = propIDList;
  239. //TransformDataList = transDataList;
  240. }
  241. public TransformData AnalysisStringToTransform(string strTrans)
  242. {
  243. TransformData transData = new TransformData();
  244. string[] parts = Regex.Split(strTrans, "_");
  245. if (parts.Length > 6)
  246. {
  247. transData.position.x = float.Parse(parts[0]);
  248. transData.position.y = float.Parse(parts[1]);
  249. transData.position.z = float.Parse(parts[2]);
  250. transData.rotationZ = float.Parse(parts[3]);
  251. transData.scale.x = float.Parse(parts[4]);
  252. transData.scale.y = float.Parse(parts[5]);
  253. transData.scale.z = float.Parse(parts[6]);
  254. }
  255. return transData;
  256. }
  257. //存储道具信息
  258. public void SetTransformData()
  259. {
  260. DressPropNameList.Clear();
  261. TransformDataList.Clear();
  262. DressPropTransInfoDic.Clear();
  263. for (int i = 0; i < itemGameObjs.Count; i++)
  264. {
  265. TransformData itemData = new TransformData();
  266. if (itemGameObjs[i].name == "Role")
  267. {
  268. roleTransFormData.position = itemGameObjs[i].transform.position;
  269. roleTransFormData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
  270. roleTransFormData.scale = itemGameObjs[i].transform.localScale;
  271. TransformDataList.Add(roleTransFormData);
  272. DressPropNameList.Add(itemGameObjs[i].name);
  273. if (!DressPropTransInfoDic.ContainsKey(itemGameObjs[i].name))
  274. {
  275. DressPropTransInfoDic.Add(itemGameObjs[i].name, roleTransFormData);
  276. }
  277. }
  278. else if (itemGameObjs[i].name == "Border")
  279. {
  280. itemData.position = itemGameObjs[i].transform.position;
  281. itemData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
  282. itemData.scale = itemGameObjs[i].transform.localScale;
  283. TransformDataList.Add(roleTransFormData);
  284. DressPropNameList.Add(itemGameObjs[i].name);
  285. if (!DressPropTransInfoDic.ContainsKey(itemGameObjs[i].name))
  286. {
  287. DressPropTransInfoDic.Add(BorderID.ToString(), itemData);
  288. }
  289. }
  290. else if (itemGameObjs[i].name == "Npc")
  291. {
  292. itemData.position = itemGameObjs[i].transform.position;
  293. itemData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
  294. itemData.scale = itemGameObjs[i].transform.localScale;
  295. TransformDataList.Add(roleTransFormData);
  296. DressPropNameList.Add(itemGameObjs[i].name);
  297. if (!DressPropTransInfoDic.ContainsKey(itemGameObjs[i].name))
  298. {
  299. DressPropTransInfoDic.Add(NpcID.ToString(), itemData);
  300. }
  301. }
  302. else
  303. {
  304. itemData.position = itemGameObjs[i].transform.position;
  305. itemData.rotationZ = itemGameObjs[i].transform.eulerAngles.z;
  306. itemData.scale = itemGameObjs[i].transform.localScale;
  307. TransformDataList.Add(itemData);
  308. DressPropNameList.Add(itemGameObjs[i].name);
  309. if (!DressPropTransInfoDic.ContainsKey(itemGameObjs[i].name))
  310. {
  311. DressPropTransInfoDic.Add(itemGameObjs[i].name, itemData);
  312. }
  313. }
  314. }
  315. //SetNameToIdList();
  316. }
  317. public int GetIDByString(string name)
  318. {
  319. int id = 0;
  320. //使用正则表达式分割字符串
  321. string[] parts = Regex.Split(name, "_");
  322. if (parts.Length > 0)
  323. {
  324. string vl = parts[0];
  325. bool isNumeric = int.TryParse(vl, out _);
  326. if (vl == "Role")
  327. {
  328. return -1;
  329. }
  330. else if (vl == "Border")
  331. {
  332. return -2;
  333. }
  334. else if (vl == "Npc")
  335. {
  336. return -3;
  337. }
  338. else if (!isNumeric)
  339. {
  340. return -4;
  341. }
  342. id = int.Parse(parts[0]);
  343. }
  344. return id;
  345. }
  346. public List<int> GetIDListByString(string name)
  347. {
  348. List<int> idList = new List<int>();
  349. string[] parts = Regex.Split(name, "_");
  350. foreach (string id in parts)
  351. {
  352. idList.Add(int.Parse(id));
  353. }
  354. return idList;
  355. }
  356. //将名字转换成道具id
  357. //public void SetNameToIdList()
  358. //{
  359. // //DressPropIdList.Clear();
  360. // int flog_prefix = 0;
  361. // int flog_suffix = 0;
  362. // for (int i = 0; i < DressPropNameList.Count; i++)
  363. // {
  364. // bool containsUnderscore = Regex.IsMatch(DressPropNameList[i], "_");
  365. // if(!containsUnderscore)
  366. // {
  367. // if (DressPropNameList[i] == "Role")
  368. // {
  369. // DressPropIdList.Add(roleID);
  370. // }
  371. // else if (DressPropNameList[i] == "Border")
  372. // {
  373. // if (BorderID != 0)
  374. // {
  375. // DressPropIdList.Add(BorderID);
  376. // }
  377. // }
  378. // else if (DressPropNameList[i] == "Npc")
  379. // {
  380. // if (NpcID != 0)
  381. // {
  382. // DressPropIdList.Add(NpcID);
  383. // }
  384. // }
  385. // }
  386. // else
  387. // {
  388. // // 使用正则表达式分割字符串
  389. // string[] parts = Regex.Split(DressPropNameList[i], "_");
  390. // int partID = int.Parse(parts[0]);
  391. // if(flog_prefix == int.Parse(parts[0]))
  392. // {
  393. // if((flog_suffix == 3 && int.Parse(parts[1]) == 1)|| (flog_suffix == 1 && int.Parse(parts[1]) == 3))
  394. // {
  395. // flog_prefix = 0;
  396. // flog_suffix = 0;
  397. // continue;
  398. // }
  399. // if ((flog_suffix == 2 && int.Parse(parts[1]) == 1) || (flog_suffix == 1 && int.Parse(parts[1]) == 2))
  400. // {
  401. // flog_prefix = 0;
  402. // flog_suffix = 0;
  403. // continue;
  404. // }
  405. // }
  406. // flog_prefix = int.Parse(parts[0]);
  407. // flog_suffix = int.Parse(parts[1]);
  408. // DressPropIdList.Add(partID);
  409. // }
  410. // }
  411. //}
  412. //将穿戴数据分类
  413. //public void ClassifyEquipData()
  414. //{
  415. // _equipSceneData.Clear();
  416. // PhotographDataManager.Instance.dressUpObj = new DressUpObj();
  417. // //for (int i = 0; i < MathingDressDate.itemList.Count; i++)
  418. // //{
  419. // // int itemId = MathingDressDate.itemList[i];
  420. // // if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId, false))
  421. // // {
  422. // // if (!_equipSceneData.ContainsKey(itemId))
  423. // // {
  424. // // _equipSceneData.Add(itemId, new List<int>());
  425. // // }
  426. // // _equipSceneData[itemId].Add(itemId);
  427. // // }
  428. // //}
  429. // for(int i =0;i<DressPropIdList.Count;i++)
  430. // {
  431. // int itemId = DressPropIdList[i];
  432. // if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId, false))
  433. // {
  434. // _equipSceneData.Add(itemId);
  435. // }
  436. // }
  437. //}
  438. public void InsertGameObjectList()
  439. {
  440. int i = 0;
  441. foreach (var item in DressPropTransInfoDic)
  442. {
  443. i++;
  444. if (item.Key == roleID)
  445. {
  446. indexRoleData = i;
  447. break;
  448. }
  449. indexRoleData = i;
  450. }
  451. if (itemGameObjs.Count == 0)
  452. {
  453. itemGameObjs.Add(roleGameobj);
  454. }
  455. else
  456. {
  457. if (indexRoleData > itemGameObjs.Count)
  458. {
  459. itemGameObjs.Add(roleGameobj);
  460. }
  461. else
  462. {
  463. itemGameObjs.Insert(indexRoleData, roleGameobj);
  464. }
  465. }
  466. }
  467. public void SetNumToRank(int index, UI_Component4 rankCom)
  468. {
  469. int c1 = 0;
  470. int c2 = 0;
  471. if (index <= 3 && index >= 1)
  472. {
  473. c2 = index;
  474. }
  475. if (index > 3 && index <= 9)
  476. {
  477. c1 = 0;
  478. }
  479. else if (index > 9 && index <= 50)
  480. {
  481. c1 = 1;
  482. }
  483. else
  484. {
  485. c1 = 2;
  486. }
  487. rankCom.m_c1.selectedIndex = c1;
  488. rankCom.m_c2.selectedIndex = c2;
  489. if (c1 == 0)
  490. {
  491. rankCom.m_num3.url = string.Format("ui://MatchingCompetition/{0}", index.ToString());
  492. }
  493. else if (c1 == 1)
  494. {
  495. int one = index / 10;
  496. int two = index % 10;
  497. rankCom.m_num1.url = string.Format("ui://MatchingCompetition/{0}", one.ToString());
  498. rankCom.m_num2.url = string.Format("ui://MatchingCompetition/{0}", two.ToString());
  499. }
  500. else
  501. {
  502. if (index == 0)
  503. {
  504. rankCom.m_RankText.text = "--";
  505. }
  506. else
  507. {
  508. for (int i = 11; i < CommonDataManager.Tables.TblJudgingRoundRewardCfg.DataList.Count - 1; i++)
  509. {
  510. JudgingRoundRewardCfg judgingCfg =
  511. CommonDataManager.Tables.TblJudgingRoundRewardCfg.GetOrDefault(i);
  512. JudgingRoundRewardCfg judgingNextCfg =
  513. CommonDataManager.Tables.TblJudgingRoundRewardCfg.GetOrDefault(i + 1);
  514. if (index >= judgingCfg.Rank && index < judgingNextCfg.Rank)
  515. {
  516. rankCom.m_RankText.text = judgingNextCfg.Desc;
  517. }
  518. else
  519. {
  520. rankCom.m_RankText.text = index.ToString();
  521. }
  522. }
  523. }
  524. }
  525. }
  526. public async void AddSceneItem(ItemCfg itemCfg, bool setLayer, int isLeft = 0)
  527. {
  528. Vector3 pos = Vector3.zero;
  529. if (!string.IsNullOrEmpty(itemCfg.ResLayer3))
  530. {
  531. DressPropIndex++;
  532. GameObject parentGameObj3 = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.Id, 3, DressPropIndex));
  533. await PhotographSceneManager.Instance.AddSceneItem(parentGameObj3, itemCfg, 3, setLayer, false, isLeft);
  534. if (setLayer)
  535. {
  536. if (parentGameObj3.transform.childCount > 0)
  537. {
  538. parentGameObj3.transform.localPosition = -parentGameObj3.transform.GetChild(0).localPosition;
  539. pos = parentGameObj3.transform.localPosition;
  540. }
  541. }
  542. }
  543. if (!string.IsNullOrEmpty(itemCfg.ResLayer2))
  544. {
  545. DressPropIndex++;
  546. GameObject parentGameObj2 = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.Id, 2, DressPropIndex));
  547. await PhotographSceneManager.Instance.AddSceneItem(parentGameObj2, itemCfg, 2, setLayer, false, isLeft);
  548. if (setLayer)
  549. {
  550. if (parentGameObj2.transform.childCount > 0)
  551. {
  552. parentGameObj2.transform.localPosition = pos == Vector3.zero
  553. ? -parentGameObj2.transform.GetChild(0).localPosition
  554. : pos;
  555. pos = parentGameObj2.transform.localPosition;
  556. }
  557. }
  558. }
  559. if (!string.IsNullOrEmpty(itemCfg.ResLayer1))
  560. {
  561. DressPropIndex++;
  562. GameObject parentGameObj1 = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.Id, 1, DressPropIndex));
  563. await PhotographSceneManager.Instance.AddSceneItem(parentGameObj1, itemCfg, 1, setLayer, false, isLeft);
  564. if (setLayer)
  565. {
  566. if (parentGameObj1.transform.childCount > 0)
  567. {
  568. parentGameObj1.transform.localPosition = pos == Vector3.zero
  569. ? -parentGameObj1.transform.GetChild(0).localPosition
  570. : pos;
  571. pos = parentGameObj1.transform.localPosition;
  572. }
  573. }
  574. }
  575. }
  576. public async void AddSceneItemOne(ItemCfg itemCfg, int layer, int index, int isLeft = 0, bool setLayer = true)
  577. {
  578. Vector3 pos = Vector3.zero;
  579. if (DressPropIndex <= index)
  580. {
  581. DressPropIndex = index + 1;
  582. }
  583. GameObject parentGameObj3 = new GameObject(string.Format("{0}_{1}_{2}", itemCfg.Id, layer, index));
  584. await PhotographSceneManager.Instance.AddSceneItem(parentGameObj3, itemCfg, layer, setLayer, false, isLeft);
  585. if (setLayer)
  586. {
  587. if (parentGameObj3.transform.childCount > 0)
  588. {
  589. parentGameObj3.transform.localPosition = -parentGameObj3.transform.GetChild(0).localPosition;
  590. pos = parentGameObj3.transform.localPosition;
  591. }
  592. }
  593. }
  594. public void OnClickBtnRule()
  595. {
  596. ViewManager.Show<MatchingCompetitionRuleTipsView>();
  597. }
  598. }
  599. class MatchingOneDataManager : SingletonBase<MatchingOneDataManager>
  600. {
  601. //其他玩家信息用于展示
  602. public MatchingPhotoWorksData OneRoleInfo = new MatchingPhotoWorksData();
  603. //人物位置信息
  604. public TransformData roleTransFormData = new TransformData();
  605. public GameObject roleGameobj;
  606. public string roleID = "Role";
  607. //*********************搭配数据*********************************
  608. //需要传输的数据:MathingDressDate,DressUpBgID,DressPropIdList,TransformDataList,
  609. public DressUpData MathingDressDate = DressUpData.CreateDefault();
  610. public int DressUpBgID = 0;
  611. //*****这两个id放列表的最后面
  612. //边框id
  613. public int BorderID = 0;
  614. //NpcId
  615. public int NpcID = 0;
  616. //道具数据,一一对应
  617. //道具id
  618. //public List<int> DressPropIdList = new List<int>();
  619. //道具位置信息
  620. public List<TransformData> TransformDataList = new List<TransformData>();
  621. //道具索引
  622. public int DressPropIndex = 0;
  623. //道具索引字典
  624. public Dictionary<string, TransformData> DressPropTransInfoDic = new Dictionary<string, TransformData>();
  625. public List<GameObject> itemGameObjs = new List<GameObject>();
  626. //***************************************************************
  627. //解析后台获取的信息
  628. public void AnalysisInfoToList()
  629. {
  630. List<int> dressitemIDList = new List<int>();
  631. List<int> propIDList = new List<int>();
  632. List<TransformData> transDataList = new List<TransformData>();
  633. DressPropTransInfoDic.Clear();
  634. for (int i = 0; i < OneRoleInfo.JudgingInfo.CollocationInfoList.Count; i++)
  635. {
  636. CollocationInfo colloctItemInfo = OneRoleInfo.JudgingInfo.CollocationInfoList[i];
  637. if (colloctItemInfo.ItemId == roleID)
  638. {
  639. //propIDList.Add(colloctItemInfo.ItemId);
  640. //transDataList.Add(MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  641. if (!DressPropTransInfoDic.ContainsKey(colloctItemInfo.ItemId))
  642. {
  643. DressPropTransInfoDic.Add(colloctItemInfo.ItemId,
  644. MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo
  645. .ClientPosition));
  646. }
  647. }
  648. else
  649. {
  650. ItemCfg itemCfg =
  651. CommonDataManager.Tables.TblItemCfg.GetOrDefault(
  652. MatchingCompetitionDataManager.Instance.GetIDByString(colloctItemInfo.ItemId));
  653. if (itemCfg != null && itemCfg.ItemType == ConstItemType.DRESS_UP)
  654. {
  655. if (itemCfg.SubType == 19 || itemCfg.SubType == 17 || itemCfg.SubType == 21 ||
  656. itemCfg.SubType == 22)
  657. {
  658. //记录道具和位置信息
  659. //propIDList.Add(colloctItemInfo.ItemId);
  660. //transDataList.Add(MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  661. if (!DressPropTransInfoDic.ContainsKey(colloctItemInfo.ItemId))
  662. {
  663. DressPropTransInfoDic.Add(colloctItemInfo.ItemId,
  664. MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo
  665. .ClientPosition));
  666. }
  667. }
  668. else if (itemCfg != null && itemCfg.SubType == ConstDressUpItemType.BEI_JING)
  669. {
  670. DressUpBgID = itemCfg.Id;
  671. }
  672. else
  673. {
  674. dressitemIDList.Add(
  675. MatchingCompetitionDataManager.Instance.GetIDByString(colloctItemInfo.ItemId));
  676. }
  677. }
  678. else if (itemCfg != null && itemCfg.ItemType == ConstItemType.PHOTOGRAPH)
  679. {
  680. //记录道具和位置信息
  681. //propIDList.Add(colloctItemInfo.ItemId);
  682. //transDataList.Add(MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo.ClientPosition));
  683. if (!DressPropTransInfoDic.ContainsKey(colloctItemInfo.ItemId))
  684. {
  685. DressPropTransInfoDic.Add(colloctItemInfo.ItemId,
  686. MatchingCompetitionDataManager.Instance.AnalysisStringToTransform(colloctItemInfo
  687. .ClientPosition));
  688. }
  689. }
  690. }
  691. }
  692. MathingDressDate.itemList = dressitemIDList;
  693. MathingDressDate.actionId = OneRoleInfo.JudgingInfo.ActionId;
  694. //DressPropIdList = propIDList;
  695. //TransformDataList = transDataList;
  696. DressUpBgID = OneRoleInfo.JudgingInfo.BagId;
  697. }
  698. public void InsertGameObjectList()
  699. {
  700. int indexRoleData = 0;
  701. int i = 0;
  702. foreach (var item in DressPropTransInfoDic)
  703. {
  704. i++;
  705. if (item.Key == roleID)
  706. {
  707. indexRoleData = i;
  708. }
  709. }
  710. if (itemGameObjs.Count == 0)
  711. {
  712. itemGameObjs.Add(roleGameobj);
  713. }
  714. else
  715. {
  716. if (indexRoleData > itemGameObjs.Count)
  717. {
  718. itemGameObjs.Add(roleGameobj);
  719. }
  720. else
  721. {
  722. itemGameObjs.Insert(indexRoleData, roleGameobj);
  723. }
  724. }
  725. }
  726. }
  727. }