MergeGameView.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.MiniGame;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class MergeGameView : BaseWindow
  10. {
  11. private UI_MergeGameUI _ui;
  12. private ValueBarController _valueBarController;
  13. private List<List<GComponent>> itemList = new List<List<GComponent>>();
  14. private GComponent guideDouBaoBtn;
  15. private GComponent guideAfuBtn;
  16. private bool canBtn = true;
  17. private List<List<int>> idList = new List<List<int>>();
  18. private int itemNum;
  19. private int maxLv;
  20. private System.Random rand;
  21. private int _gameID;
  22. private int _res;
  23. //当前拖拽的index;
  24. private int indexID;
  25. //开始拖拽的坐标
  26. private float startX;
  27. private float startY;
  28. private int indexX;
  29. private int indexY;
  30. private float waitBtnTime = 0.5f;
  31. //当前任务id;后台获取数据
  32. private int taskId;
  33. //当前点击id信息
  34. private int materialID;
  35. private int propID = 3000020;
  36. public override void Dispose()
  37. {
  38. if (_valueBarController != null)
  39. {
  40. _valueBarController.Dispose();
  41. _valueBarController = null;
  42. }
  43. if (_ui != null)
  44. {
  45. _ui.Dispose();
  46. _ui = null;
  47. }
  48. base.Dispose();
  49. }
  50. protected override void OnInit()
  51. {
  52. base.OnInit();
  53. packageName = UI_MergeGameUI.PACKAGE_NAME;
  54. _ui = UI_MergeGameUI.Create();
  55. this.viewCom = _ui.target;
  56. isfullScreen = true;
  57. isReturnView = true;
  58. _valueBarController = new ValueBarController(_ui.m_valueBar);
  59. _ui.m_backBtn.onClick.Add(Hide);
  60. _ui.m_rewardGet.onClick.Add(SubmitTask);
  61. _ui.m_MergeTipBtn.onClick.Add(ShowMergeRouteTips);
  62. _ui.m_shopBtn.onClick.Add(ShowShopBtn);
  63. _ui.m_sellBtn.target.onClick.Add(OnClickSellBtn);
  64. _ui.target.onClick.Add(OnClickHideTips);
  65. _ui.m_btnProp.target.onClick.Add(OnItemTips);
  66. _ui.m_rewardIcon.onClick.Add(OnClickIconItem);
  67. }
  68. protected override void OnShown()
  69. {
  70. base.OnShown();
  71. _valueBarController.OnShown();
  72. //进入这个界面的时候向后台获取任务id和历史id列表
  73. idList = MiniGameDateManager.Instance.GetIdListToLL();
  74. canBtn = true;
  75. waitBtnTime = 0.5f;
  76. UpdateView();
  77. UpdateList();
  78. UpdateTask();
  79. UpdateItemData();
  80. _ui.m_guildDouBaoBtn.target.touchable = false;
  81. //Timers.inst.AddUpdate(CheckGuide);
  82. }
  83. protected override void OnHide()
  84. {
  85. for (int i = 0; i < itemNum; i++)
  86. {
  87. for (int j = 0; j < itemNum; j++)
  88. {
  89. itemList[i][j].GetChild("icon").icon = "";
  90. itemList[i][j].Dispose();
  91. itemList[i][j] = null;
  92. }
  93. }
  94. idList.Clear();
  95. itemList.Clear();
  96. _ui.m_rangeDown.RemoveChildren();
  97. Timers.inst.Remove(UpdateBtnTimer);
  98. _valueBarController.OnHide();
  99. base.OnHide();
  100. }
  101. protected override void AddEventListener()
  102. {
  103. base.AddEventListener();
  104. }
  105. protected override void RemoveEventListener()
  106. {
  107. base.RemoveEventListener();
  108. }
  109. private void UpdateBtnTimer(object param)
  110. {
  111. canBtn = true;
  112. Timers.inst.Remove(UpdateBtnTimer);
  113. }
  114. private void UpdateView()
  115. {
  116. itemNum = 5;
  117. taskId = MiniGameDateManager.Instance.taskID;
  118. MergeGame mergeCfg = MergeGameArray.Instance.GetCfg(taskId);
  119. propID = mergeCfg.comsumeBuyArr[0][0];
  120. int sellId = mergeCfg.bonusWinArr[0][0];
  121. _valueBarController.UpdateList(new List<int>() { propID, sellId });
  122. _res = MergeGameArray.Instance.GetCfg(taskId).resType;
  123. maxLv = 5;
  124. materialID = 0;
  125. rand = new System.Random();
  126. _ui.m_rewardGet.visible = false;
  127. _ui.m_sellBtn.target.GetChild("sellGetNum").text = "";
  128. _ui.m_sellBtn.target.GetChild("sellReward").icon = "";
  129. //_ui.m_newMaterial.target.visible = false;
  130. _ui.m_name.text = "";
  131. _ui.m_desc.text = "";
  132. _ui.m_bg.url = ResPathUtil.GetBgImgPath("jbnf_xyxbj");
  133. ItemCfg itemcfg = ItemCfgArray.Instance.GetCfg(propID);
  134. _ui.m_doubaoicon.url = ResPathUtil.GetIconPath(itemcfg.res,"png");
  135. _ui.m_afuicon.url = ResPathUtil.GetIconPath(itemcfg.res, "png");
  136. }
  137. private void UpdateList()
  138. {
  139. for (int i = 0; i < itemNum; i++)
  140. {
  141. itemList.Add(new List<GComponent>());
  142. //idList.Add(new List<int>());
  143. for (int j = 0; j < itemNum; j++)
  144. {
  145. //idList[i].Add(j);
  146. itemList[i].Add(UIPackage.CreateObject(UI_MergeGameUI.PACKAGE_NAME, "MergeGameItemUI").asCom);
  147. _ui.m_rangeDown.AddChild(itemList[i][j]);
  148. //对两个按钮单独处理
  149. if (i == itemNum - 1)
  150. {
  151. itemList[i][j].data = -1;
  152. //idList[i][j] = -1;
  153. itemList[i][j].SetPosition((_ui.m_rangeDown.width / 10.0f) * (1 + (j * 2.0f)), (_ui.m_rangeDown.height / 10) * (1 + (i * 2.0f)), 0);
  154. if (j == 0)
  155. {
  156. guideAfuBtn = itemList[i][j];
  157. itemList[i][j].GetChild("icon").icon = "ui://MiniGame/doubao_txkicon";
  158. itemList[i][j].onClick.Add(OnClickDouBaoBtn);
  159. continue;
  160. }
  161. if ( j == itemNum - 1)
  162. {
  163. guideAfuBtn = itemList[i][j];
  164. itemList[i][j].GetChild("icon").icon = "ui://MiniGame/afu_txkicon";
  165. itemList[i][j].onClick.Add(OnClickAFuBtn);
  166. continue;
  167. }
  168. }
  169. //表示id;这里后续要改,默认有两个基础材料
  170. //idList[i][j] = 0;
  171. //if (i == 1 && j == 2)
  172. //{
  173. // idList[i][j] = 1;
  174. //}
  175. //if(i== 2 && j== 2)
  176. //{
  177. // idList[i][j] = 1;
  178. //}
  179. //
  180. itemList[i][j].data = idList[i][j];
  181. itemList[i][j].draggable = true;
  182. itemList[i][j].onDragStart.Add(onDragStart);
  183. itemList[i][j].onDragEnd.Add(onDragEnd);
  184. itemList[i][j].onClick.Add(OnClickItem);
  185. itemList[i][j].dragBounds = new Rect(_ui.m_rangeTop.x + 90, _ui.m_rangeTop.y + 90, _ui.m_rangeTop.width, _ui.m_rangeTop.height);
  186. itemList[i][j].SetPosition( (_ui.m_rangeDown.width / 10.0f) * (1+ (j * 2.0f)), (_ui.m_rangeDown.height / 10) * (1+(i * 2.0f)) , 0);
  187. if (idList[i][j] == 0)
  188. {
  189. itemList[i][j].GetChild("icon").icon = "";
  190. itemList[i][j].draggable = false;
  191. }
  192. else
  193. {
  194. itemList[i][j].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, idList[i][j]).resName, "MergeGame");
  195. }
  196. }
  197. }
  198. }
  199. private void onDragStart(EventContext context)
  200. {
  201. GObject item = context.sender as GObject;
  202. int itemInfo = (int)(context.sender as GObject).data;
  203. indexY = Math.Min(itemNum - 1, (int)(item.x / (_ui.m_rangeDown.width / 5)));
  204. indexX = Math.Min(itemNum - 1, (int)(item.y / (_ui.m_rangeDown.height / 5)));
  205. startX = item.x;
  206. startY = item.y;
  207. indexID = itemInfo;
  208. _ui.m_rangeDown.RemoveChild(item);
  209. _ui.m_rangeTop.AddChild(item);
  210. }
  211. private async void onDragEnd(EventContext context)
  212. {
  213. GObject item = context.sender as GObject;
  214. List<int> afterIDList = MiniGameDateManager.Instance.GetListByll(idList);
  215. int endIndexY = Math.Min(itemNum - 1 , (int)(item.x / (_ui.m_rangeDown.width/5)));
  216. int endIndexX = Math.Min(itemNum - 1 ,(int)(item.y / (_ui.m_rangeDown.height/5)));
  217. int itemEndInfo = (int)itemList[endIndexX][endIndexY].data;
  218. //合成规则:相同合成,但是材料只有五级,5和5不能合成6, 6属于另一类材料的一级
  219. if (itemEndInfo == indexID && (indexX != endIndexX || indexY != endIndexY) && (itemEndInfo % maxLv != 0))
  220. {
  221. indexID = 0;
  222. idList[indexX][indexY] = 0;
  223. itemList[indexX][indexY].data = 0;
  224. itemList[indexX][indexY].GetChild("icon").icon = "";
  225. idList[endIndexX][endIndexY] = itemEndInfo + 1;
  226. itemList[endIndexX][endIndexY].data = itemEndInfo + 1;
  227. itemList[endIndexX][endIndexY].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, itemEndInfo + 1).resName, "MergeGame");
  228. ShowNewMaterialView(endIndexX, endIndexY);
  229. //UI_MergeGameItemUI itemUI = UI_MergeGameItemUI.Proxy(itemList[endIndexX][endIndexY]);
  230. //itemUI.m_t0.Play();
  231. //UI_MergeGameItemUI.ProxyEnd();
  232. if(InspectionTasks())
  233. {
  234. _ui.m_rewardGet.visible = true;
  235. }
  236. else
  237. {
  238. _ui.m_rewardGet.visible = false;
  239. }
  240. _ui.m_name.text = "";
  241. _ui.m_desc.text = "";
  242. _ui.m_sellBtn.target.GetChild("sellReward").icon = "";
  243. _ui.m_sellBtn.target.GetChild("sellGetNum").text = "";
  244. materialID = 0;
  245. bool result = await MiniGameProxy.ReqMergeGame(itemEndInfo, itemEndInfo, afterIDList, MiniGameDateManager.Instance.GetListByll(idList));
  246. if(result)
  247. {
  248. idList = MiniGameDateManager.Instance.GetIdListToLL();
  249. }
  250. }
  251. if (itemEndInfo != indexID && itemEndInfo == 0)
  252. {
  253. idList[indexX][indexY] = 0;
  254. itemList[indexX][indexY].data = 0;
  255. itemList[indexX][indexY].GetChild("icon").icon = "";
  256. idList[endIndexX][endIndexY] = indexID;
  257. itemList[endIndexX][endIndexY].data = indexID;
  258. itemList[endIndexX][endIndexY].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, indexID).resName, "MergeGame");
  259. _ui.m_name.text = "";
  260. _ui.m_desc.text = "";
  261. _ui.m_sellBtn.target.GetChild("sellReward").icon = "";
  262. _ui.m_sellBtn.target.GetChild("sellGetNum").text = "";
  263. materialID = 0;
  264. bool result = await MiniGameProxy.ReqMergeGame(indexID, itemEndInfo, afterIDList, MiniGameDateManager.Instance.GetListByll(idList));
  265. if(result)
  266. {
  267. idList = MiniGameDateManager.Instance.GetIdListToLL();
  268. }
  269. itemEndInfo = indexID;
  270. indexID = 0;
  271. }
  272. item.x = startX;
  273. item.y = startY;
  274. if(indexID == 0)
  275. {
  276. item.draggable = false;
  277. }
  278. if(itemEndInfo > 0 )
  279. {
  280. itemList[endIndexX][endIndexY].draggable = true;
  281. }
  282. startX = 0;
  283. startY = 0;
  284. indexX = 0;
  285. indexY = 0;
  286. indexID = 0;
  287. _ui.m_rangeTop.RemoveChild(item);
  288. _ui.m_rangeDown.AddChild(item);
  289. }
  290. private void OnClickItem(EventContext context)
  291. {
  292. GObject item = context.sender as GObject;
  293. int id = (int)item.data;
  294. if(id <= 0)
  295. {
  296. return;
  297. }
  298. indexY = Math.Min(itemNum - 1, (int)(item.x / (_ui.m_rangeDown.width / 5)));
  299. indexX = Math.Min(itemNum - 1, (int)(item.y / (_ui.m_rangeDown.height / 5)));
  300. materialID = id;
  301. MergeCfg mergeCfg = MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(MiniGameDateManager.Instance.MergeGameMatType,id);
  302. _ui.m_name.text = mergeCfg.name;
  303. _ui.m_desc.text = mergeCfg.desc;
  304. ItemCfg itemReward = ItemCfgArray.Instance.GetCfg(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, id).bonusSellArr[0][0]);
  305. _ui.m_sellBtn.target.GetChild("sellReward").icon = ResPathUtil.GetIconPath(itemReward.res,"png");
  306. _ui.m_sellBtn.target.GetChild("sellGetNum").text = MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, id).bonusSellArr[0][1].ToString();
  307. }
  308. private void OnClickIconItem(EventContext context)
  309. {
  310. int id = MergeGameArray.Instance.GetCfg(taskId).bonusWinArr[0][0];
  311. GoodsItemTipsController.ShowItemTips(id);
  312. }
  313. private async void OnClickSellBtn()
  314. {
  315. if(materialID == 0)
  316. {
  317. return;
  318. }
  319. int index = indexX * itemNum + indexY;
  320. if(index >= 20)
  321. {
  322. index = index - 1;
  323. }
  324. bool result = await MiniGameProxy.ReqMergeGameSellBtn(materialID, index);
  325. if(result)
  326. {
  327. //移除
  328. _ui.m_name.text = "";
  329. _ui.m_desc.text = "";
  330. _ui.m_sellBtn.target.GetChild("sellReward").icon = "";
  331. _ui.m_sellBtn.target.GetChild("sellGetNum").text = "";
  332. materialID = 0;
  333. idList[indexX][indexY] = 0;
  334. itemList[indexX][indexY].data = 0;
  335. UI_MergeGameItemUI itemUI = UI_MergeGameItemUI.Proxy(itemList[indexX][indexY]);
  336. itemUI.m_t2.Play();
  337. itemUI.m_t3.Play();
  338. UI_MergeGameItemUI.ProxyEnd();
  339. indexX = 0;
  340. indexY = 0;
  341. //获得奖励
  342. idList = MiniGameDateManager.Instance.GetIdListToLL();
  343. UpdateTask();
  344. }
  345. }
  346. private async void OnClickAFuBtn()
  347. {
  348. if (!canBtn)
  349. {
  350. return;
  351. }
  352. canBtn = false;
  353. Timers.inst.Add(waitBtnTime, 1,UpdateBtnTimer);
  354. bool gameOver = false;
  355. for (int i = 0; i < itemNum; i++)
  356. {
  357. for (int j = 0; j < itemNum; j++)
  358. {
  359. if (idList[i][j] == 0)
  360. {
  361. gameOver = true;
  362. break;
  363. }
  364. }
  365. }
  366. if (!gameOver)
  367. {
  368. PromptController.Instance.ShowFloatTextPrompt("没有存放空间!");
  369. return;
  370. }
  371. bool result = await MiniGameProxy.ReqMergeGameBtn(2,taskId);
  372. if(result)
  373. {
  374. int x = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[1] / itemNum;
  375. int y = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[1] % itemNum;
  376. int num = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[0];
  377. //if (idList[x][y] == 0)
  378. if (x == 4)
  379. {
  380. if(y == 0)
  381. {
  382. y = 1;
  383. }
  384. else if(y == 1)
  385. {
  386. y = 2;
  387. }
  388. else if(y == 2)
  389. {
  390. y = 3;
  391. }
  392. }
  393. else if (x == 4 && y == 4)
  394. {
  395. y = 3;
  396. }
  397. idList[x][y] = num;
  398. itemList[x][y].data = num;
  399. itemList[x][y].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, num).resName, "MergeGame");
  400. itemList[x][y].draggable = true;
  401. UI_MergeGameItemUI itemUI = UI_MergeGameItemUI.Proxy(itemList[x][y]);
  402. itemUI.m_t1.Play();
  403. UI_MergeGameItemUI.ProxyEnd();
  404. idList = MiniGameDateManager.Instance.GetIdListToLL();
  405. }
  406. else
  407. {
  408. }
  409. }
  410. private async void OnClickDouBaoBtn()
  411. {
  412. if(!canBtn)
  413. {
  414. return;
  415. }
  416. canBtn = false;
  417. Timers.inst.Add(waitBtnTime, 1, UpdateBtnTimer);
  418. bool gameOver = false;
  419. for (int i = 0; i < itemNum; i++)
  420. {
  421. for (int j = 0; j < itemNum; j++)
  422. {
  423. if (idList[i][j] == 0)
  424. {
  425. gameOver = true;
  426. break;
  427. }
  428. }
  429. }
  430. if (!gameOver)
  431. {
  432. PromptController.Instance.ShowFloatTextPrompt("没有存放空间!");
  433. return;
  434. }
  435. bool result = await MiniGameProxy.ReqMergeGameBtn(1,taskId);
  436. if (result)
  437. {
  438. int x = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[1] / itemNum;
  439. int y = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[1] % itemNum;
  440. int num = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[0];
  441. //if (idList[x][y] == 0)
  442. if(x == 4)
  443. {
  444. if (y == 0)
  445. {
  446. y = 1;
  447. }
  448. else if (y == 1)
  449. {
  450. y = 2;
  451. }
  452. else if (y == 2)
  453. {
  454. y = 3;
  455. }
  456. }
  457. else if(x== 4 && y== 4)
  458. {
  459. y = 3;
  460. }
  461. idList[x][y] = num;
  462. itemList[x][y].data = num;
  463. itemList[x][y].draggable = true;
  464. itemList[x][y].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, num).resName, "MergeGame");
  465. UI_MergeGameItemUI itemUI = UI_MergeGameItemUI.Proxy(itemList[x][y]);
  466. itemUI.m_t1.Play();
  467. UI_MergeGameItemUI.ProxyEnd();
  468. idList = MiniGameDateManager.Instance.GetIdListToLL();
  469. }
  470. else
  471. {
  472. }
  473. }
  474. private void UpdateTask()
  475. {
  476. if(MiniGameDateManager.Instance.CurLevelStatus == true)
  477. {
  478. _ui.m_taskShow.visible = false;
  479. _ui.m_taskEnd.visible = true;
  480. }
  481. else
  482. {
  483. _ui.m_taskShow.visible = true;
  484. _ui.m_taskEnd.visible = false;
  485. }
  486. _ui.m_rewardNum.text = String.Format("+{0}", MergeGameArray.Instance.GetCfg(taskId).bonusWinArr[0][1]);
  487. ItemCfg itemReward = ItemCfgArray.Instance.GetCfg(MergeGameArray.Instance.GetCfg(taskId).bonusWinArr[0][0]);
  488. _ui.m_rewardIcon.url = ResPathUtil.GetIconPath(itemReward.res,"png");
  489. for (int k = 0; k < MergeGameArray.Instance.GetCfg(taskId).targetIdArr.Length; k++)
  490. {
  491. int targetID = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][0];
  492. int targetNum = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][1];
  493. switch (k)
  494. {
  495. case 0:
  496. _ui.m_rewardOne.target.visible = true;
  497. _ui.m_rewardTwo.target.visible = false;
  498. _ui.m_rewardOne.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, targetID).resName, "MergeGame");
  499. _ui.m_rewardOne.m_Count.text = targetNum.ToString();
  500. break;
  501. case 1:
  502. _ui.m_rewardTwo.target.visible = true;
  503. _ui.m_rewardTwo.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, targetID).resName, "MergeGame");
  504. _ui.m_rewardTwo.m_Count.text = targetNum.ToString();
  505. break;
  506. default:
  507. break;
  508. }
  509. }
  510. if (InspectionTasks())
  511. {
  512. _ui.m_rewardGet.visible = true;
  513. }
  514. else
  515. {
  516. _ui.m_rewardGet.visible = false;
  517. }
  518. _ui.m_sellBtn.target.GetChild("sellGetNum").text = "";
  519. _ui.m_sellBtn.target.GetChild("sellReward").icon = "";
  520. _ui.m_name.text = "";
  521. _ui.m_desc.text = "";
  522. materialID = 0;
  523. }
  524. private void UpdateShowList()
  525. {
  526. for (int i = 0; i < itemNum; i++)
  527. {
  528. for (int j = 0; j < itemNum; j++)
  529. {
  530. itemList[i][j].data = idList[i][j];
  531. if (idList[i][j] == 0)
  532. {
  533. itemList[i][j].GetChild("icon").icon = "";
  534. }
  535. else if (idList[i][j] > 0)
  536. {
  537. itemList[i][j].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, idList[i][j]).resName, "MergeGame");
  538. }
  539. }
  540. }
  541. }
  542. //提交任务
  543. private async void SubmitTask()
  544. {
  545. if (!InspectionTasks())
  546. {
  547. PromptController.Instance.ShowFloatTextPrompt("提交材料不足!");
  548. return;
  549. }
  550. bool result = await MiniGameProxy.ReqMergeGameLevelPass(taskId);
  551. if(result)
  552. {
  553. //for (int k = 0; k < MergeGameArray.Instance.GetCfg(taskId).targetIdArr.Length; k++)
  554. //{
  555. // int targetID = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][0];
  556. // int targetNum = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][1];
  557. // for (int i = 0; i < itemNum; i++)
  558. // {
  559. // for (int j = 0; j < itemNum; j++)
  560. // {
  561. // if (idList[i][j] == targetID)
  562. // {
  563. // idList[i][j] = 0;
  564. // itemList[i][j].data = 0;
  565. // //UI_MergeGameItemUI itemUI = UI_MergeGameItemUI.Proxy(itemList[i][j]);
  566. // //itemUI.m_t2.Play();
  567. // //itemUI.m_t3.Play();
  568. // //UI_MergeGameItemUI.ProxyEnd();
  569. // targetNum--;
  570. // if (targetNum == 0)
  571. // {
  572. // break;
  573. // }
  574. // }
  575. // }
  576. // if (targetNum == 0)
  577. // {
  578. // break;
  579. // }
  580. // }
  581. //}
  582. //向后台发送任务ID,获得奖励
  583. taskId = MiniGameDateManager.Instance.taskID;
  584. idList = MiniGameDateManager.Instance.GetIdListToLL();
  585. UpdateTask();
  586. UpdateShowList();
  587. }
  588. else
  589. {
  590. }
  591. }
  592. //检查是否达到提交要求
  593. private bool InspectionTasks()
  594. {
  595. bool isTarged = true;
  596. for (int k = 0; k < MergeGameArray.Instance.GetCfg(taskId).targetIdArr.Length; k++)
  597. {
  598. int targetID = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][0];
  599. int targetNum = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][1];
  600. int currentNum = 0;
  601. for (int i = 0; i < itemNum; i++)
  602. {
  603. for (int j = 0; j < itemNum; j++)
  604. {
  605. if (idList[i][j] == targetID)
  606. {
  607. currentNum++;
  608. if (currentNum == targetNum)
  609. {
  610. break;
  611. }
  612. }
  613. }
  614. if (currentNum == targetNum)
  615. {
  616. break;
  617. }
  618. }
  619. if (currentNum == targetNum && isTarged)
  620. {
  621. isTarged = true;
  622. }
  623. else
  624. {
  625. isTarged = false;
  626. }
  627. }
  628. return isTarged;
  629. }
  630. private void ShowNewMaterialView(int i ,int j)
  631. {
  632. //判断是否是新材料。再显示
  633. if(MiniGameDateManager.Instance.NewItemIdDic.ContainsKey(idList[i][j]))
  634. {
  635. return;
  636. }
  637. _ui.m_newMaterial.target.x = itemList[i][j].x + _ui.m_rangeDown.x;
  638. _ui.m_newMaterial.target.y = itemList[i][j].y + _ui.m_rangeDown.y;
  639. _ui.m_newMaterial.target.visible = true;
  640. _ui.m_newMaterial.target.GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, idList[i][j]).resName,"MergeGame");
  641. _ui.m_newMaterial.m_t0.Play();
  642. }
  643. private void OnClickHideTips()
  644. {
  645. if(_ui.m_newMaterial.target.visible == true)
  646. {
  647. _ui.m_newMaterial.target.visible = false;
  648. }
  649. }
  650. private void ShowMergeRouteTips()
  651. {
  652. ViewManager.Show<MergeGameMaterialTipView>(new object[]{ _res });
  653. }
  654. private void ShowShopBtn()
  655. {
  656. ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_EXCHANGE, ConstStoreSubId.STORE_ACTIVITY_EXCHANGE });
  657. }
  658. private void UpdateItemData()
  659. {
  660. _ui.m_btnProp.target.visible = false;
  661. //ItemCfg itemcfg = ItemCfgArray.Instance.GetCfg(propID);
  662. //_ui.m_btnProp.target.icon = ResPathUtil.GetIconPath(itemcfg.res,"png");
  663. //ItemData item;
  664. //if (BagDataManager.Instance.GetBagData().TryGetValue(propID, out item))
  665. //{
  666. // _ui.m_btnProp.target.title = item.num.ToString();
  667. //}
  668. //else
  669. //{
  670. // _ui.m_btnProp.target.title = "0";
  671. //}
  672. }
  673. private void OnItemTips()
  674. {
  675. object[] sourceDatas = new object[] { propID, null };
  676. GoodsItemTipsController.ShowItemTips(propID, sourceDatas);
  677. }
  678. //private void CheckGuide(object param)
  679. //{
  680. // if (GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0)
  681. // {
  682. // UpdateCheckGuide(null);
  683. // }
  684. // else
  685. // {
  686. // Timers.inst.Remove(CheckGuide);
  687. // }
  688. //}
  689. //protected void UpdateCheckGuide(object param)
  690. //{
  691. // if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  692. // GuideController.TryGuide(guideDouBaoBtn, ConstGuideId.FIELD, 1, "点击豆包按钮获取材料!");
  693. // GuideController.TryGuide(guideAfuBtn, ConstGuideId.FIELD, 2, "点击阿福按钮获取材料!");
  694. // GuideController.TryGuide(null, ConstGuideId.FIELD, 3, "拖拽相同材料进行合成!", -1, true, _ui.target.height - 600);
  695. // GuideController.TryGuide(_ui.m_rewardGet, ConstGuideId.FIELD, 4, "提交对应材料获得物品!");
  696. // GuideController.TryCompleteGuide(ConstGuideId.FIELD, 5);
  697. //}
  698. }
  699. }