LittleResultBG_21201.js 4.9 KB

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