MergeGameView.cs 28 KB

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