ClubAndroidCreat.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. ctor:function(){
  6. },
  7. onLoad:function(){
  8. },
  9. OnShowView:function(){
  10. this.m_KindID = 0;
  11. this.m_RoomID = 0;
  12. this.ResetView();
  13. },
  14. OnSetInfo:function(info){
  15. this.$('Sub/t1/Name@Label').string = window.GameList[info.wKindID];
  16. this.m_KindID = info.wKindID;
  17. this.m_RoomID = info.dwRoomID;
  18. var GameDef = new window['CMD_GAME_' + info.wKindID]();
  19. this._MaxplayCnt = GameDef.GetPlayerCount(info.dwServerRules, info.dwRules);
  20. this.$('Sub/t2/PlayCnt@Label').string = this._MaxplayCnt;
  21. },
  22. OnClick_CreatAndroid:function(){
  23. var path = 'Sub/'
  24. var playingTableCnt = this.$(path+'t3/EdPlayingTableCnt@EditBox').string;
  25. if(parseInt(playingTableCnt) == 0 || parseInt(playingTableCnt) == NaN){
  26. this.ShowTips('同時開桌數設定無效,請重新設定!');
  27. return;
  28. }
  29. var totalTableCnt = this.$(path+'t6/EdTotalTableCnt@EditBox').string;
  30. if(parseInt(totalTableCnt) == 0 || parseInt(totalTableCnt) == NaN){
  31. this.ShowTips('總消耗桌數設定無效,請重新設定!');
  32. return;
  33. }
  34. var sitCnt = this.$(path+'t7/EdSitCnt@EditBox').string;
  35. if(parseInt(sitCnt) == 0||parseInt(sitCnt) == NaN){
  36. this.ShowTips('單桌最大人數設定無效,請重新設定!');
  37. return;
  38. }
  39. if(sitCnt>this._MaxplayCnt){
  40. this.ShowTips('設定無效,超過房間最大人數!');
  41. return;
  42. }
  43. window.gClubClientKernel.onSendCreatAndroidGroup(this,g_ShowClubInfo.dwClubID,this.m_KindID,this.m_RoomID,totalTableCnt,playingTableCnt,sitCnt);
  44. },
  45. ResetView:function(){
  46. var path = 'Sub/'
  47. this.$(path+'t3/EdPlayingTableCnt@EditBox').string = '';
  48. this.$(path+'t6/EdTotalTableCnt@EditBox').string = '';
  49. this.$(path+'t7/EdSitCnt@EditBox').string = '';
  50. },
  51. OnClick_Back:function(){
  52. this.m_SubNode.children[0].active = true;
  53. this.m_SubNode.children[1].active = false;
  54. },
  55. OnClick_ShowCreat:function(){
  56. this.m_SubNode.children[0].active = false;
  57. this.m_SubNode.children[1].active = true;
  58. },
  59. OnClick_GameKindClose:function(){
  60. this.m_GameKind.x = 2000;
  61. },
  62. OnClick_GameKindTag:function(tag){
  63. this.m_GameKind.x = 2000;
  64. var path = 'Sub/Sub_2/';
  65. this.$(path+'t1/btGamekind/Background/Label@Label').string = window.GameList[tag.node.name];
  66. this.m_Kind = parseInt(tag.node.name);
  67. },
  68. onCreatRes:function(code){
  69. if(code == 1){
  70. g_CurScene.ShowTips('權限不足!');
  71. }else if(code == 2){
  72. g_CurScene.ShowTips('機器人數量不足!');
  73. }else if(code == 3){
  74. g_CurScene.ShowTips('房間不存在!');
  75. }else if(code == 4){
  76. g_CurScene.ShowTips('已存在相同機器人組!');
  77. }else{
  78. g_CurScene.ShowTips('創建成功!');
  79. }
  80. if(code == 0) this.HideView();
  81. else this.ResetView();
  82. },
  83. });