wait_tongqian.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import { _decorator, Component, Node, Label } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { Constant, room_type } from '../constant';
  4. import { GameMng } from '../GameMng';
  5. import { UIButton } from '../gcommon/UIButton';
  6. import { UIManager } from '../gcommon/UIManager';
  7. import { msgManager } from '../socket/msgManager';
  8. import { roomData } from '../UserData/roomData';
  9. import GBoardChess from './ChessGame/GBoardChess';
  10. import { waitView } from './waitView';
  11. const { ccclass, property } = _decorator;
  12. @ccclass('wait_tongqian')
  13. export class wait_tongqian extends Component {
  14. @property(Node)
  15. lab_menpiao: Node = null;
  16. @property(Node)
  17. lab_duzhu: Node = null;
  18. @property(Node)
  19. btn_start: Node = null;
  20. @property(Node)
  21. onReady: Node = null;
  22. @property(Node)
  23. onReady_2: Node = null;
  24. @property(Node)
  25. btn_start_2: Node = null;
  26. @property(Node) //新的一盘
  27. node_newRound: Node = null;
  28. @property(Node) //最初的一盘
  29. node_initRound: Node = null;
  30. start() {
  31. if(GameMng._userData.room!=null){
  32. let self = this;
  33. if(GameMng._userData.room.game_number>1){
  34. this.node_newRound.active = true;
  35. this.node_initRound.active = false;
  36. }else{
  37. this.node_newRound.active = false;
  38. this.node_initRound.active = true;
  39. } //新的一局了
  40. if(GameMng._userData.room.roomtype===room_type._chuji_tongqian){
  41. this.lab_menpiao.getComponent(Label).string ="对局门票: "+1000
  42. this.lab_duzhu.getComponent(Label).string ="单局输赢: "+5000
  43. }else if(GameMng._userData.room.roomtype===room_type._zhongji_tongqian){
  44. this.lab_menpiao.getComponent(Label).string ="对局门票: "+3000
  45. this.lab_duzhu.getComponent(Label).string ="单局输赢: "+20000
  46. }
  47. UIButton.BindClick(this.btn_start,function(){
  48. self.ready()
  49. },this)
  50. UIButton.BindClick(this.btn_start_2,()=>{
  51. self.ready()
  52. },this)
  53. }
  54. ClientEvent.on(Constant.EVENT_TYPE.MSG_OPEN_MATCHING_5_10_20,this.openRoom,this)
  55. ClientEvent.on(Constant.EVENT_TYPE.MSG_FIND_MATCHING_5_10_20,this.findRoom,this)
  56. ClientEvent.on(Constant.EVENT_TYPE.MSG_CANCEL_MATCHING_5_10_20,this.cancelMatching,this)
  57. ClientEvent.on(Constant.UI_EVENT.UI_MSG_5_10_20_ready,this.ready,this)
  58. }
  59. onDestroy(){
  60. ClientEvent.off(Constant.EVENT_TYPE.MSG_OPEN_MATCHING_5_10_20,this.openRoom,this)
  61. ClientEvent.off(Constant.EVENT_TYPE.MSG_CANCEL_MATCHING_5_10_20,this.cancelMatching,this)
  62. ClientEvent.off(Constant.EVENT_TYPE.MSG_FIND_MATCHING_5_10_20,this.findRoom,this)
  63. ClientEvent.off(Constant.UI_EVENT.UI_MSG_5_10_20_ready,this.ready,this)
  64. }
  65. ready(){
  66. waitView.Show("正在匹配!")
  67. GBoardChess.instance.hideAllChess()
  68. msgManager.open_matching_5_10_20()
  69. }
  70. cancelMatching(){
  71. UIManager.removeWaitViewLayer()
  72. }
  73. findRoom(room:roomData){
  74. UIManager.removeWaitViewLayer()
  75. GameMng.updateRoomData(room)
  76. console.log("findRoom",room)
  77. }
  78. openRoom(room:roomData){
  79. this.onReady.active = true;
  80. this.btn_start.active = false;
  81. UIManager.removeWaitViewLayer()
  82. GameMng.updateRoomData(room)
  83. console.log("findRoom",room)
  84. }
  85. recvReady(room:roomData){
  86. console.log("fuck!",room)
  87. if(GameMng._userData.room.game_number>1){ //新的一局了
  88. if(room.wait_rival_startGame_status==3||room.wait_rival_startGame_status==1){
  89. this.btn_start_2.active = false;
  90. this.onReady_2.active = true;
  91. }else{
  92. this.btn_start_2.active = true;
  93. this.onReady_2.active = false;
  94. }
  95. }else{
  96. if(room.wait_rival_startGame_status==3||room.wait_rival_startGame_status==1){
  97. this.btn_start.active = false;
  98. this.onReady.active = true;
  99. }else{
  100. this.btn_start.active = true;
  101. this.onReady.active = false;
  102. }
  103. }
  104. }
  105. //新的一盘
  106. recvAgainRound(room:roomData){
  107. if(room!=null){
  108. this.node_newRound.active = true;
  109. this.node_initRound.active = false;
  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. }
  118. }
  119. }