MergeGameView.cs 27 KB

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