MergeGameView.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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 && y == 0)
  357. {
  358. y = 1;
  359. }
  360. else if (x == 4 && y == 4)
  361. {
  362. y = 3;
  363. }
  364. idList[x][y] = num;
  365. itemList[x][y].data = num;
  366. itemList[x][y].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, num).resName, "MergeGame");
  367. itemList[x][y].draggable = true;
  368. UI_MergeGameItemUI itemUI = UI_MergeGameItemUI.Proxy(itemList[x][y]);
  369. itemUI.m_t1.Play();
  370. UI_MergeGameItemUI.ProxyEnd();
  371. idList = MiniGameDateManager.Instance.GetIdListToLL();
  372. }
  373. else
  374. {
  375. }
  376. }
  377. private async void OnClickDouBaoBtn()
  378. {
  379. if(!canBtn)
  380. {
  381. return;
  382. }
  383. canBtn = false;
  384. Timers.inst.Add(waitBtnTime, 1, UpdateBtnTimer);
  385. bool gameOver = false;
  386. for (int i = 0; i < itemNum; i++)
  387. {
  388. for (int j = 0; j < itemNum; j++)
  389. {
  390. if (idList[i][j] == 0)
  391. {
  392. gameOver = true;
  393. break;
  394. }
  395. }
  396. }
  397. if (!gameOver)
  398. {
  399. PromptController.Instance.ShowFloatTextPrompt("没有存放空间!");
  400. return;
  401. }
  402. bool result = await MiniGameProxy.ReqMergeGameBtn(1,taskId);
  403. if (result)
  404. {
  405. int x = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[1] / itemNum;
  406. int y = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[1] % itemNum;
  407. int num = MiniGameDateManager.Instance.GetIDListByString(MiniGameDateManager.Instance.ItemIdVPosition)[0];
  408. //if (idList[x][y] == 0)
  409. if(x == 4 && y == 0)
  410. {
  411. y = 1;
  412. }
  413. else if(x== 4 && y== 4)
  414. {
  415. y = 3;
  416. }
  417. idList[x][y] = num;
  418. itemList[x][y].data = num;
  419. itemList[x][y].draggable = true;
  420. itemList[x][y].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, num).resName, "MergeGame");
  421. UI_MergeGameItemUI itemUI = UI_MergeGameItemUI.Proxy(itemList[x][y]);
  422. itemUI.m_t1.Play();
  423. UI_MergeGameItemUI.ProxyEnd();
  424. idList = MiniGameDateManager.Instance.GetIdListToLL();
  425. }
  426. else
  427. {
  428. }
  429. }
  430. private void UpdateTask()
  431. {
  432. if(MiniGameDateManager.Instance.CurLevelStatus == true)
  433. {
  434. _ui.m_taskShow.visible = false;
  435. _ui.m_taskEnd.visible = true;
  436. }
  437. else
  438. {
  439. _ui.m_taskShow.visible = true;
  440. _ui.m_taskEnd.visible = false;
  441. }
  442. _ui.m_rewardNum.text = String.Format("+{0}", MergeGameArray.Instance.GetCfg(taskId).bonusWinArr[0][1]);
  443. ItemCfg itemReward = ItemCfgArray.Instance.GetCfg(MergeGameArray.Instance.GetCfg(taskId).bonusWinArr[0][0]);
  444. _ui.m_rewardIcon.url = ResPathUtil.GetCommonGameResPath(itemReward.res);
  445. for (int k = 0; k < MergeGameArray.Instance.GetCfg(taskId).targetIdArr.Length; k++)
  446. {
  447. int targetID = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][0];
  448. int targetNum = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][1];
  449. switch (k)
  450. {
  451. case 0:
  452. _ui.m_rewardOne.target.visible = true;
  453. _ui.m_rewardTwo.target.visible = false;
  454. _ui.m_rewardOne.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, targetID).resName, "MergeGame");
  455. _ui.m_rewardOne.m_Count.text = targetNum.ToString();
  456. break;
  457. case 1:
  458. _ui.m_rewardTwo.target.visible = true;
  459. _ui.m_rewardTwo.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, targetID).resName, "MergeGame");
  460. _ui.m_rewardTwo.m_Count.text = targetNum.ToString();
  461. break;
  462. default:
  463. break;
  464. }
  465. }
  466. if (InspectionTasks())
  467. {
  468. _ui.m_rewardGet.visible = true;
  469. }
  470. else
  471. {
  472. _ui.m_rewardGet.visible = false;
  473. }
  474. _ui.m_sellBtn.target.GetChild("sellGetNum").text = "";
  475. _ui.m_name.text = "";
  476. _ui.m_desc.text = "";
  477. materialID = 0;
  478. }
  479. private void UpdateShowList()
  480. {
  481. for (int i = 0; i < itemNum; i++)
  482. {
  483. for (int j = 0; j < itemNum; j++)
  484. {
  485. itemList[i][j].data = idList[i][j];
  486. if (idList[i][j] == 0)
  487. {
  488. itemList[i][j].GetChild("icon").icon = "";
  489. }
  490. else if (idList[i][j] > 0)
  491. {
  492. itemList[i][j].GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, idList[i][j]).resName, "MergeGame");
  493. }
  494. }
  495. }
  496. }
  497. //提交任务
  498. private async void SubmitTask()
  499. {
  500. if (!InspectionTasks())
  501. {
  502. PromptController.Instance.ShowFloatTextPrompt("提交材料不足!");
  503. return;
  504. }
  505. bool result = await MiniGameProxy.ReqMergeGameLevelPass(taskId);
  506. if(result)
  507. {
  508. //for (int k = 0; k < MergeGameArray.Instance.GetCfg(taskId).targetIdArr.Length; k++)
  509. //{
  510. // int targetID = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][0];
  511. // int targetNum = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][1];
  512. // for (int i = 0; i < itemNum; i++)
  513. // {
  514. // for (int j = 0; j < itemNum; j++)
  515. // {
  516. // if (idList[i][j] == targetID)
  517. // {
  518. // idList[i][j] = 0;
  519. // itemList[i][j].data = 0;
  520. // //UI_MergeGameItemUI itemUI = UI_MergeGameItemUI.Proxy(itemList[i][j]);
  521. // //itemUI.m_t2.Play();
  522. // //itemUI.m_t3.Play();
  523. // //UI_MergeGameItemUI.ProxyEnd();
  524. // targetNum--;
  525. // if (targetNum == 0)
  526. // {
  527. // break;
  528. // }
  529. // }
  530. // }
  531. // if (targetNum == 0)
  532. // {
  533. // break;
  534. // }
  535. // }
  536. //}
  537. //向后台发送任务ID,获得奖励
  538. taskId = MiniGameDateManager.Instance.taskID;
  539. idList = MiniGameDateManager.Instance.GetIdListToLL();
  540. UpdateTask();
  541. UpdateShowList();
  542. }
  543. else
  544. {
  545. }
  546. }
  547. //检查是否达到提交要求
  548. private bool InspectionTasks()
  549. {
  550. bool isTarged = true;
  551. for (int k = 0; k < MergeGameArray.Instance.GetCfg(taskId).targetIdArr.Length; k++)
  552. {
  553. int targetID = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][0];
  554. int targetNum = MergeGameArray.Instance.GetCfg(taskId).targetIdArr[k][1];
  555. int currentNum = 0;
  556. for (int i = 0; i < itemNum; i++)
  557. {
  558. for (int j = 0; j < itemNum; j++)
  559. {
  560. if (idList[i][j] == targetID)
  561. {
  562. currentNum++;
  563. if (currentNum == targetNum)
  564. {
  565. break;
  566. }
  567. }
  568. }
  569. if (currentNum == targetNum)
  570. {
  571. break;
  572. }
  573. }
  574. if (currentNum == targetNum && isTarged)
  575. {
  576. isTarged = true;
  577. }
  578. else
  579. {
  580. isTarged = false;
  581. }
  582. }
  583. return isTarged;
  584. }
  585. private void ShowNewMaterialView(int i ,int j)
  586. {
  587. //判断是否是新材料。再显示
  588. if(MiniGameDateManager.Instance.NewItemIdDic.ContainsKey(idList[i][j]))
  589. {
  590. return;
  591. }
  592. _ui.m_newMaterial.target.x = itemList[i][j].x + _ui.m_rangeDown.x;
  593. _ui.m_newMaterial.target.y = itemList[i][j].y + _ui.m_rangeDown.y;
  594. _ui.m_newMaterial.target.visible = true;
  595. _ui.m_newMaterial.target.GetChild("icon").icon = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, idList[i][j]).resName,"MergeGame");
  596. _ui.m_newMaterial.m_t0.Play();
  597. }
  598. private void OnClickHideTips()
  599. {
  600. if(_ui.m_newMaterial.target.visible == true)
  601. {
  602. _ui.m_newMaterial.target.visible = false;
  603. }
  604. }
  605. private void ShowMergeRouteTips()
  606. {
  607. ViewManager.Show<MergeGameMaterialTipView>(new object[]{ _res });
  608. }
  609. private void ShowShopBtn()
  610. {
  611. ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_EXCHANGE, ConstStoreSubId.STORE_ACTIVITY_EXCHANGE });
  612. }
  613. private void UpdateItemData()
  614. {
  615. _ui.m_btnProp.target.visible = false;
  616. //ItemCfg itemcfg = ItemCfgArray.Instance.GetCfg(propID);
  617. //_ui.m_btnProp.target.icon = ResPathUtil.GetIconPath(itemcfg.res,"png");
  618. //ItemData item;
  619. //if (BagDataManager.Instance.GetBagData().TryGetValue(propID, out item))
  620. //{
  621. // _ui.m_btnProp.target.title = item.num.ToString();
  622. //}
  623. //else
  624. //{
  625. // _ui.m_btnProp.target.title = "0";
  626. //}
  627. }
  628. private void OnItemTips()
  629. {
  630. object[] sourceDatas = new object[] { propID, null };
  631. GoodsItemTipsController.ShowItemTips(propID, sourceDatas);
  632. }
  633. //private void CheckGuide(object param)
  634. //{
  635. // if (GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0)
  636. // {
  637. // UpdateCheckGuide(null);
  638. // }
  639. // else
  640. // {
  641. // Timers.inst.Remove(CheckGuide);
  642. // }
  643. //}
  644. //protected void UpdateCheckGuide(object param)
  645. //{
  646. // if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  647. // GuideController.TryGuide(guideDouBaoBtn, ConstGuideId.FIELD, 1, "点击豆包按钮获取材料!");
  648. // GuideController.TryGuide(guideAfuBtn, ConstGuideId.FIELD, 2, "点击阿福按钮获取材料!");
  649. // GuideController.TryGuide(null, ConstGuideId.FIELD, 3, "拖拽相同材料进行合成!", -1, true, _ui.target.height - 600);
  650. // GuideController.TryGuide(_ui.m_rewardGet, ConstGuideId.FIELD, 4, "提交对应材料获得物品!");
  651. // GuideController.TryCompleteGuide(ConstGuideId.FIELD, 5);
  652. //}
  653. }
  654. }