MergeGameView.cs 28 KB

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