TableViewFrame.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. },
  5. ctor:function() {
  6. this.mTableViewArray = new Array();
  7. this.m_pTableViewCell = new Array();
  8. this.mServerItem = null;
  9. },
  10. ExitGame:function() {
  11. //退出游戏
  12. if(window.LOG_NET_DATA)console.log("退出游戏");
  13. this.mServerItem.IntermitConnect(true);
  14. },
  15. SetServerItem:function(pServerItem){
  16. this.mServerItem = pServerItem;
  17. },
  18. //配置函数
  19. ConfigTableFrame:function(wTableCount, wChairCount, dwServerRule, wServerType, wServerID){
  20. //设置变量
  21. this.mTableCount=wTableCount;
  22. this.mChairCount=wChairCount;
  23. this.mServerRule=dwServerRule;
  24. this.mServerType=wServerType;
  25. //创建桌子
  26. for (var i=0;i<this.mTableCount;i++){
  27. this.CreateTableView(i, wChairCount);
  28. }
  29. return true;
  30. },
  31. //椅子数目
  32. GetChairCount :function(){return this.mChairCount;},
  33. //创建桌子
  34. CreateTableView :function(dwIndex, wChairCount){
  35. this.mTableViewArray[dwIndex] = new CTableView();
  36. this.mTableViewArray[dwIndex].InitTableView(dwIndex, wChairCount, this);
  37. },
  38. //设置信息
  39. SetClientUserItem2 :function(wTableID, wChairID, pIClientUserItem) {
  40. var pITableView=this.GetTableViewItem(wTableID);
  41. if (pITableView!=0) pITableView.SetClientUserItem(wChairID,pIClientUserItem);
  42. return true;
  43. },
  44. //获取桌子
  45. GetTableViewItem :function(wTableID){
  46. //获取桌子
  47. if (wTableID!=INVALID_TABLE){
  48. //效验参数
  49. if (wTableID>=this.mTableViewArray.length) return 0;
  50. //获取桌子
  51. return this.mTableViewArray[wTableID];
  52. }
  53. return null;
  54. },
  55. //桌子状态
  56. SetTableStatus:function(wTableID, bPlaying, bLocker){
  57. //获取桌子
  58. var pITableView=this.GetTableViewItem(wTableID);
  59. //设置标志
  60. if (pITableView!=0) pITableView.SetTableStatus(bPlaying,bLocker);
  61. },
  62. //桌子状态
  63. SetTableStatus1 :function(bWaitDistribute){
  64. },
  65. //更新桌子
  66. UpdateTableView:function (wTableID){
  67. //获取桌子
  68. var pITableView=this.GetTableViewItem(wTableID);
  69. if (pITableView==0) return false;
  70. pITableView.UpdateView();
  71. return true;
  72. },
  73. //桌子可视
  74. VisibleTable :function(wTableID){
  75. //效验参数
  76. if (wTableID>=this.mTableCount) return false;
  77. return true;
  78. },
  79. //获取用户
  80. GetClientUserItem :function(wTableID, wChairID) {
  81. //获取桌子
  82. var pITableView = this.GetTableViewItem(wTableID);
  83. //获取用户
  84. if (pITableView!=null) return pITableView.GetClientUserItem(wChairID);
  85. return null;
  86. },
  87. });
  88. var CTableView = cc.Class({
  89. ctor :function() {
  90. this.mIClientUserItem = new Array();
  91. },
  92. //配置函数
  93. InitTableView :function(wTableID, wChairCount, pITableViewFrame){
  94. //设置属性
  95. this.mTableID=wTableID;
  96. this.mChairCount=wChairCount;
  97. //设置接口
  98. this.mITableViewFrame=pITableViewFrame;
  99. },
  100. //设置信息
  101. SetClientUserItem :function(wChairID, pIClientUserItem) {
  102. //效验参数
  103. if (wChairID>=this.mChairCount) return false;
  104. //设置用户
  105. this.mIClientUserItem[wChairID] = pIClientUserItem;
  106. return true;
  107. },
  108. //获取用户
  109. GetClientUserItem:function (wChairID) {
  110. //效验参数
  111. if (wChairID>=this.mChairCount) return 0;
  112. //获取用户
  113. return this.mIClientUserItem[wChairID];
  114. },
  115. //更新界面
  116. UpdateView :function(){
  117. },
  118. //桌子状态
  119. SetTableStatus :function(bPlaying, bLocker){
  120. //设置标志
  121. if ((this.mIsLocker!=bLocker)||(this.mIsPlaying!=bPlaying)){
  122. //设置变量
  123. this.mIsLocker=bLocker;
  124. this.mIsPlaying=bPlaying;
  125. //更新界面
  126. this.mITableViewFrame.UpdateTableView(this.mTableID);
  127. }
  128. },
  129. });