GameEndInfo.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_LabTimes:cc.Label,
  5. m_LabRules:cc.Label,
  6. m_LabCount:cc.Label,
  7. m_LabRoom:cc.Label,
  8. m_LabHJH:cc.Label,
  9. },
  10. OnBtReturn:function(){
  11. this.m_Hook.OnBtReturn();
  12. this.m_Hook.ShowPrefabDLG('CustomLoading',this.m_Hook.node);
  13. // this.node.active = false;
  14. },
  15. OnShowView:function(){
  16. var pViewEngine = this.m_Hook.m_GameClientView;
  17. this.m_LabTimes.string = Time2Str(new Date().getTime()/1000);
  18. this.m_LabRules.string = pViewEngine.m_RulesText.string;
  19. this.m_LabCount.string = pViewEngine.m_subsumlun.string;
  20. this.m_LabRoom.string = pViewEngine.m_TableNumber.string;
  21. this.m_LabHJH.string = pViewEngine.m_ClubNum.string;
  22. this.ShowGamePrefab('GameEndView',GameDef.KIND_ID,this.node,function(Js){
  23. this.m_CustomEndView = Js;
  24. this.m_CustomEndView.SetEndInfo(this.m_Hook.m_RoomEnd)
  25. cc.share.InitShareInfo_H5_WX(this.GetShareInfo.bind(this));
  26. }.bind(this));
  27. this.$('Layout/BtAgain').active = this.m_Hook.m_dwClubID!=0;
  28. },
  29. //分享
  30. OnBtShowShare: function(){
  31. // if(cc.sys.isNative){
  32. // this.OnShareGameEnd();
  33. // }else{
  34. // ThirdPartyShareMessage(this.m_CustomEndView.GetShareInfo(),0);
  35. // }
  36. this.ShowPrefabDLG("SharePre", this.node, function(Js) {
  37. this.m_SharePre = Js;
  38. }.bind(this));
  39. },
  40. OnShareGameEnd:function(){
  41. // var ShareTex = cc.RenderTexture.create(window.SCENE_WIGHT,window.SCENE_HEIGHT);
  42. // this.node.setPosition(window.SCENE_WIGHT/2, window.SCENE_HEIGHT/2)
  43. // ShareTex.setVisible(false);
  44. // ShareTex.begin();
  45. // this.node._sgNode.visit();
  46. // ShareTex.end();
  47. // this.node.setPosition(0,0);
  48. // this.node.active = false;
  49. // var filename = "screenShot"+(new Date().getTime())+".PNG"
  50. // ShareTex.saveToFile(filename,cc.ImageFormat.PNG, true, function(){
  51. // this.node.active = true;
  52. // ThirdPartyShareImg(jsb.fileUtils.getWritablePath()+filename);
  53. // }.bind(this));
  54. var filePath = saveImage(this.node);
  55. if(filePath!='') {
  56. ThirdPartyShareImg(filePath);
  57. }else{
  58. this.ShowTips('截圖保存失敗');
  59. }
  60. },
  61. GetShareTex:function() {
  62. if(this.m_SharePre) this.m_SharePre.node.active = false;
  63. return saveImage(this.node);
  64. },
  65. GetShareInfo: function() {
  66. if (cc.share.IsH5_WX()) {
  67. var ShareInfo = null;
  68. if (this.m_CustomEndView && this.m_CustomEndView.GetShareInfo) ShareInfo = this.m_CustomEndView.GetShareInfo();
  69. ShareInfo.link = cc.share.MakeLink_GameEnd();
  70. return ShareInfo;
  71. }
  72. return null;
  73. },
  74. OnClick_GameAgain: function(){
  75. //g_Table.ShowLoading();
  76. var QueryGR = new CMD_GP_C_GetRoom();
  77. QueryGR.dwUserID = g_GlobalUserInfo.GetGlobalUserData().dwUserID;
  78. QueryGR.dwRoomID = parseInt(this.m_Hook.m_dwRoomID2);
  79. QueryGR.dwClubID = parseInt(this.m_Hook.m_dwClubID);
  80. window.gClubClientKernel.OnSendJoinRoom2(this, QueryGR);
  81. //var LoginMission = new CGPLoginMission(this, MDM_GP_GET_SERVER, SUB_GP_JOIN_ROOM2, QueryGR);
  82. },
  83. OnQueryFailed:function (FailedRes){
  84. //g_Table.StopLoading();
  85. this.ShowAlert(FailStr[FailedRes.byRes],Alert_Yes,function(Res){
  86. if(Res)g_Table.ExitGame();
  87. }.bind(this));
  88. },
  89. OnQueryRoomRes:function (ReturnServer){
  90. g_ServerListDataLast = new CGameServerItem();
  91. g_ServerListDataLast.wKindID = ReturnServer.wKindID;
  92. g_ServerListDataLast.wServerPort = ReturnServer.wServerPort;
  93. g_ServerListDataLast.szServerAddr = ReturnServer.szServerAddr;
  94. g_ServerListDataLast.wServerType = ReturnServer.wServerType;
  95. g_ServerListDataLast.llEnterScore = ReturnServer.llEnterScore;
  96. g_ServerListDataLast.szServerName = "";
  97. window.g_dwRoomID = ReturnServer.dwRoomID;
  98. window.g_dwClubID = ReturnServer.dwClubID;
  99. this.EnterGameScene(1);
  100. },
  101. //游戏入口
  102. EnterGameScene:function(Res){
  103. // 加载游戏
  104. if(Res && g_ServerListDataLast){
  105. if(window.LOG_NET_DATA)console.log("地址:", g_ServerListDataLast.szServerAddr+":"+g_ServerListDataLast.wServerPort);
  106. g_Table.m_Loading.active = true;
  107. this.ShowPrefabDLG("UpdateManager", g_Table.m_Loading, function (Js) {
  108. Js.StartPreload(0, g_ServerListDataLast.wKindID, function() {
  109. cc.gPreLoader.LoadRes(`${GameDef.BGPath}`, '' + GameDef.KIND_ID, function(res) {
  110. window.gGameBG = null;
  111. GameDef['setRule']&&GameDef.setRule(0);
  112. ChangeScene('Table');
  113. }.bind(this));
  114. }.bind(this));
  115. }.bind(this));
  116. }
  117. },
  118. });