jifenchangCreate.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { _decorator, Component, Node } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { Constant, matching_5_10_20_type } 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('jifenchangCreate')
  13. export class jifenchangCreate extends Component {
  14. @property(Node)
  15. btn_5: Node = null; //
  16. @property(Node)
  17. btn_10: Node = null; //
  18. @property(Node)
  19. btn_20: Node = null; //
  20. start() {
  21. let self = this;
  22. UIButton.BindClick(this.btn_5,()=>{
  23. this.sendMsg(matching_5_10_20_type._5)
  24. },this)
  25. UIButton.BindClick(this.btn_10,()=>{
  26. this.sendMsg(matching_5_10_20_type._10)
  27. },this)
  28. UIButton.BindClick(this.btn_20,()=>{
  29. this.sendMsg(matching_5_10_20_type._20)
  30. },this)
  31. ClientEvent.on(Constant.EVENT_TYPE.MSG_MATCHING_5_10_20,this.onCreate,this)
  32. }
  33. sendMsg(type:matching_5_10_20_type){
  34. switch (type) {
  35. case matching_5_10_20_type._5:
  36. msgManager.matching_5_10_20(matching_5_10_20_type._5)
  37. break;
  38. case matching_5_10_20_type._10:
  39. msgManager.matching_5_10_20(matching_5_10_20_type._10)
  40. break;
  41. case matching_5_10_20_type._20:
  42. msgManager.matching_5_10_20(matching_5_10_20_type._20)
  43. break;
  44. }
  45. UIManager.AddPrefab(GameMng.Instance.uiloading)
  46. }
  47. onDestroy(){
  48. ClientEvent.off(Constant.EVENT_TYPE.MSG_MATCHING_5_10_20,this.onCreate,this)
  49. }
  50. onCreate(room:roomData){
  51. console.log("room",room)
  52. UIManager.removeLoadingLayer()
  53. GameMng.updateRoomData(room)
  54. ScenceMng.Instance.load('Chess')
  55. }
  56. update(deltaTime: number) {
  57. }
  58. }