LittleResultBG_21201.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_RoomNumber: cc.Label,
  5. m_GameRound: cc.Label,
  6. m_Show: cc.Node,
  7. m_BtViewdesktop: cc.Node,
  8. m_BtChangeTable: cc.Node,
  9. m_BtContinu: cc.Node,
  10. m_BtExit: cc.Node,
  11. // m_Bao:cc.Node,
  12. // m_Hui:cc.Node,
  13. m_WinTitle: cc.Node,
  14. m_LoseTitle: cc.Node,
  15. m_DrawTitle: cc.Node,
  16. // m_BirdCard:[cc.Node],S
  17. },
  18. // use this for initialization
  19. start: function () {
  20. this.m_BtViewdesktop.on(cc.Node.EventType.TOUCH_START, (e) => {
  21. this.m_Show.active = false;
  22. });
  23. this.m_BtViewdesktop.on(cc.Node.EventType.TOUCH_END, (e) => {
  24. this.m_Show.active = true;
  25. });
  26. this.updateBtUI()
  27. },
  28. ctor: function () {
  29. },
  30. ResetData: function () {
  31. this.m_WeaveCard = new Array();
  32. },
  33. onLoad: function () {
  34. },
  35. updateBtUI() {
  36. if (GameDef.m_dwGameRuleArr[3] > 0) {
  37. this.m_BtChangeTable.active = true;
  38. this.m_BtExit.active = true;
  39. this.m_BtContinu.setPosition(200, -296);
  40. } else {
  41. this.m_BtChangeTable.active = false;
  42. this.m_BtExit.active = false;
  43. this.m_BtContinu.setPosition(0, -296);
  44. }
  45. },
  46. onClickBack: function () {
  47. cc.gSoundRes.PlaySound("Button");
  48. this.m_Hook.checkTotalEnd(true);
  49. this.HideView();
  50. },
  51. onClickContinue: function () {
  52. cc.gSoundRes.PlaySound("Button");
  53. this.m_Hook.checkTotalEnd(true);
  54. this.HideView();
  55. },
  56. onClickChangeTable: function () {
  57. this.HideView();
  58. this.m_Hook.OnBtChangeTable();
  59. },
  60. onClickExit: function () {
  61. this.HideView();
  62. this.m_Hook.OnBtReturn();
  63. },
  64. OnClickShare: function () {
  65. cc.gSoundRes.PlaySound('Button');
  66. if (cc.sys.isNative) {
  67. this.OnShareGameEnd(ThirdPartyShareImg);
  68. } else {
  69. this.ShowTips("H5遊戲無法分享!");
  70. }
  71. },
  72. OnShareGameEnd: function (callback) {
  73. var ShareTex = cc.RenderTexture.create(window.SCENE_WIGHT, window.SCENE_HEIGHT);
  74. this.node.setPosition(window.SCENE_WIGHT / 2, window.SCENE_HEIGHT / 2)
  75. ShareTex.setVisible(false);
  76. ShareTex.begin();
  77. this.node._sgNode.visit();
  78. ShareTex.end();
  79. this.node.setPosition(0, 0);
  80. this.node.active = false;
  81. var filename = "screenShot" + (new Date().getTime()) + ".PNG"
  82. ShareTex.saveToFile(filename, cc.ImageFormat.PNG, true, function () {
  83. this.node.active = true;
  84. ThirdPartyShareImg(jsb.fileUtils.getWritablePath() + filename);
  85. }.bind(this));
  86. },
  87. OnShowView: function () {
  88. this.m_Hook.m_GameClientView.m_CardView.ChangeCardBack(this.node, this.m_Hook.m_CardBack);
  89. this.m_RoomNumber.string = "" + this.m_Hook.m_GameClientView.m_LbTableID.string;
  90. this.m_GameRound.string = "" + this.m_Hook.m_GameClientView.m_LbGameProgress.string;
  91. var pGameEnd = this.m_Hook.m_GameEnd;
  92. if (this.m_ListCtrl == null) this.m_ListCtrl = this.node.getComponent('CustomListCtrl');
  93. this.m_ListCtrl.InitList(0, 'LittleResultItem_' + GameDef.KIND_ID);
  94. var wMeChairID = this.m_Hook.MyChairID;
  95. console.log("输赢背景", pGameEnd, wMeChairID);
  96. let aniNode = null;
  97. let aniName = "";
  98. if (pGameEnd.lGangScore[wMeChairID] > 0) {
  99. console.log(pGameEnd.lGangScore[wMeChairID], "win", wMeChairID)
  100. this.m_WinTitle.active = true;
  101. aniNode = this.m_WinTitle.getChildByName("ani");
  102. aniName = "shengli";
  103. this.m_LoseTitle.active = false;
  104. this.m_DrawTitle.active = false;
  105. } else if (pGameEnd.lGangScore[wMeChairID] < 0) {
  106. console.log(pGameEnd.lGangScore[wMeChairID], "lose", wMeChairID)
  107. this.m_WinTitle.active = false;
  108. this.m_LoseTitle.active = true;
  109. aniNode = this.m_LoseTitle.getChildByName("ani");
  110. aniName = "shibai";
  111. this.m_DrawTitle.active = false;
  112. } else {
  113. console.log(pGameEnd.lGangScore[wMeChairID], "draw", wMeChairID)
  114. this.m_WinTitle.active = false;
  115. this.m_LoseTitle.active = false;
  116. this.m_DrawTitle.active = true;
  117. aniNode = this.m_DrawTitle.getChildByName("ani");
  118. aniName = "jiesuan";
  119. }
  120. if (aniNode) {
  121. aniNode.getComponent("SpineAnimationCtrl")?.playAnimation(`${aniName}_in`, false, false, `${aniName}_loop`, true);
  122. let topAniNode = aniNode.parent.getChildByName("aniTop");
  123. if (topAniNode) {
  124. cc.tween(topAniNode)
  125. .set({ opacity: 0 })
  126. .to(10 / 60, { opacity: 255 })
  127. .start();
  128. }
  129. }
  130. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  131. if (pGameEnd.dwUserID[i] == 0) continue;
  132. this.m_ListCtrl.InsertListInfo(0, [i, pGameEnd, this.m_Hook.m_wBankerUser == i, this.m_Hook.m_dwRulesArr[0]]);
  133. }
  134. this.updateBtUI()
  135. },
  136. SetTrustee(bTrustee) {
  137. if (bTrustee == true) {
  138. var sequence = cc.sequence(
  139. cc.delayTime(3),
  140. cc.callFunc(function () {
  141. this.m_Hook.checkTotalEnd(true);
  142. this.HideView();
  143. }, this
  144. ));
  145. this.node.runAction(sequence);
  146. }
  147. }
  148. });