waitJifen.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import { _decorator, Component, Node, Label } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { Constant } from '../constant';
  4. import { GameMng } from '../GameMng';
  5. import ScenceMng from '../gcommon/ScenceMng';
  6. import { UIButton } from '../gcommon/UIButton';
  7. import { UIManager } from '../gcommon/UIManager';
  8. import { msgManager } from '../socket/msgManager';
  9. import { Tools } from '../Tools';
  10. import { roomData } from '../UserData/roomData';
  11. import GBoardChess from './ChessGame/GBoardChess';
  12. import ChessMng, { ChessType } from './DiffSel/ChessMng';
  13. import { waitView } from './waitView';
  14. const { ccclass, property } = _decorator;
  15. @ccclass('waitJifen')
  16. export class waitJifen extends Component {
  17. @property(Node)
  18. lab_jushu:Node=null;
  19. @property(Node)
  20. lab_bushu: Node = null;
  21. @property(Node)
  22. lab_meibujiashi: Node = null;
  23. @property(Node)
  24. btn_start: Node = null;
  25. @property(Node)
  26. btn_huanzhuo: Node = null;
  27. @property(Node)
  28. btn_huanzhuo_2: Node = null;
  29. @property(Node)
  30. onReady: Node = null;
  31. @property(Node)
  32. onReady_2: Node = null;
  33. @property(Node)
  34. btn_start_2: Node = null;
  35. @property(Node) //新的一盘
  36. node_newRound: Node = null;
  37. @property(Node) //最初的一盘
  38. node_initRound: Node = null;
  39. start() {
  40. if(GameMng._userData.room!=null){
  41. let self = this;
  42. if(GameMng._userData.room.game_number>1){
  43. this.node_newRound.active = true;
  44. this.node_initRound.active = false;
  45. }else{
  46. this.node_newRound.active = false;
  47. this.node_initRound.active = true;
  48. } //新的一局了
  49. this.lab_jushu.getComponent(Label).string ="局时:"+Tools.time(GameMng._userData.room.totaltime)
  50. this.lab_bushu.getComponent(Label).string ="步时:"+Tools.time(GameMng._userData.room.everysteptime) +"前3步=30秒"
  51. this.lab_meibujiashi.getComponent(Label).string ="局时用完判胜负"
  52. UIButton.BindClick(this.btn_start,function(){
  53. self.ready()
  54. },this)
  55. UIButton.BindClick(this.btn_huanzhuo,function(){
  56. waitView.Show("寻找对局!",()=>{
  57. msgManager.cancel_matching_5_10_20()
  58. })
  59. GBoardChess.instance.hideAllChess()
  60. msgManager.find_matching_5_10_20()
  61. },this)
  62. UIButton.BindClick(this.btn_huanzhuo_2,function(){
  63. waitView.Show("寻找对局!",()=>{
  64. msgManager.cancel_matching_5_10_20()
  65. })
  66. GBoardChess.instance.hideAllChess()
  67. msgManager.find_matching_5_10_20()
  68. },this)
  69. UIButton.BindClick(this.btn_start_2,()=>{
  70. self.onReady_2.active = true;
  71. self.btn_start_2.active = false;
  72. GBoardChess.instance.hideAllChess()
  73. msgManager.open_matching_5_10_20()
  74. },this)
  75. }
  76. ClientEvent.on(Constant.EVENT_TYPE.MSG_OPEN_MATCHING_5_10_20,this.openRoom,this)
  77. ClientEvent.on(Constant.EVENT_TYPE.MSG_FIND_MATCHING_5_10_20,this.findRoom,this)
  78. ClientEvent.on(Constant.EVENT_TYPE.MSG_CANCEL_MATCHING_5_10_20,this.cancelMatching,this)
  79. ClientEvent.on(Constant.UI_EVENT.UI_MSG_5_10_20_ready,this.ready,this)
  80. }
  81. onDestroy(){
  82. ClientEvent.off(Constant.EVENT_TYPE.MSG_OPEN_MATCHING_5_10_20,this.openRoom,this)
  83. ClientEvent.off(Constant.EVENT_TYPE.MSG_CANCEL_MATCHING_5_10_20,this.cancelMatching,this)
  84. ClientEvent.off(Constant.EVENT_TYPE.MSG_FIND_MATCHING_5_10_20,this.findRoom,this)
  85. ClientEvent.off(Constant.UI_EVENT.UI_MSG_5_10_20_ready,this.ready,this)
  86. }
  87. ready(){
  88. this.btn_start.active = false;
  89. GBoardChess.instance.hideAllChess()
  90. msgManager.open_matching_5_10_20()
  91. }
  92. cancelMatching(){
  93. UIManager.removeWaitViewLayer()
  94. }
  95. findRoom(room:roomData){
  96. UIManager.removeWaitViewLayer()
  97. GameMng.updateRoomData(room)
  98. console.log("findRoom",room)
  99. }
  100. openRoom(room:roomData){
  101. this.onReady.active = true;
  102. this.btn_start.active = false;
  103. UIManager.removeWaitViewLayer()
  104. GameMng.updateRoomData(room)
  105. console.log("findRoom",room)
  106. }
  107. recvReady(room:roomData){
  108. console.log("fuck!",room)
  109. if(GameMng._userData.room.game_number>1){ //新的一局了
  110. if(room.wait_rival_startGame_status==3||room.wait_rival_startGame_status==1){
  111. this.btn_start_2.active = false;
  112. this.onReady_2.active = true;
  113. }else{
  114. this.btn_start_2.active = true;
  115. this.onReady_2.active = false;
  116. }
  117. }else{
  118. if(room.wait_rival_startGame_status==3||room.wait_rival_startGame_status==1){
  119. this.btn_start.active = false;
  120. this.onReady.active = true;
  121. }else{
  122. this.btn_start.active = true;
  123. this.onReady.active = false;
  124. }
  125. }
  126. }
  127. //新的一盘
  128. recvAgainRound(room:roomData){
  129. if(room!=null){
  130. this.node_newRound.active = true;
  131. this.node_initRound.active = false;
  132. if(room.wait_rival_startGame_status==3||room.wait_rival_startGame_status==1){
  133. this.btn_start_2.active = false;
  134. this.onReady_2.active = true;
  135. }else{
  136. this.btn_start_2.active = true;
  137. this.onReady_2.active = false;
  138. }
  139. }
  140. }
  141. update(deltaTime: number) {
  142. }
  143. }