MergeGameView.cs 29 KB

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