joinRoom.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { _decorator, Component, Node, Label } from 'cc';
  2. import { ClientEvent } from './clientEvent';
  3. import { Constant } from './constant';
  4. import ChessMng, { ChessType } from './Game/DiffSel/ChessMng';
  5. import { GameMng } from './GameMng';
  6. import ScenceMng from './gcommon/ScenceMng';
  7. import { UIButton } from './gcommon/UIButton';
  8. import { UIManager } from './gcommon/UIManager';
  9. import { msgManager } from './socket/msgManager';
  10. import { roomData } from './UserData/roomData';
  11. const { ccclass, property } = _decorator;
  12. @ccclass('joinRoom')
  13. export class joinRoom extends Component {
  14. @property(Node)
  15. btnClose: Node = null;
  16. @property(Node)
  17. btnReStart: Node = null;
  18. @property(Node)
  19. btnDelete: Node = null;
  20. @property(Node)
  21. btnSure: Node = null;
  22. @property(Node)
  23. labNumber: Node = null;
  24. @property(Node)
  25. numberNodeParent: Node = null;
  26. num:string = "";
  27. start() {
  28. for (let index = 0; index < 10; index++) {
  29. var btn = this.numberNodeParent.getChildByName("number_"+index)
  30. UIButton.BindClick(btn,()=>{
  31. this.updateLab(index+"")
  32. },this)
  33. }
  34. UIButton.BindClick(this.btnClose,()=>{
  35. this.node.destroy()
  36. },this)
  37. UIButton.BindClick(this.btnReStart,()=>{
  38. this.num = ""
  39. this.labNumber.getComponent(Label).string=this.num
  40. },this)
  41. UIButton.BindClick(this.btnDelete,()=>{
  42. this.num = this.num.substring(0,this.num.length-1);
  43. this.labNumber.getComponent(Label).string = this.num
  44. },this)
  45. UIButton.BindClick(this.btnSure,()=>{
  46. UIManager.AddPrefab(GameMng.Instance.uiloading)
  47. msgManager.joinRoom(this.num)
  48. },this)
  49. }
  50. onDestroy(){
  51. }
  52. updateLab(number){
  53. this.num=this.num+number
  54. this.labNumber.getComponent(Label).string = this.num
  55. }
  56. update(deltaTime: number) {
  57. }
  58. }