MergeGameView.cs 28 KB

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