tongqianCreate.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { _decorator, Component, Node } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { Constant, matching_5_10_20_type, room_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 { native_manager } from '../native_manager';
  10. import { msgManager } from '../socket/msgManager';
  11. import { roomData } from '../UserData/roomData';
  12. const { ccclass, property } = _decorator;
  13. @ccclass('tongqianCreate')
  14. export class tongqianCreate extends Component {
  15. @property(Node)
  16. btn_chuji: Node = null; //
  17. @property(Node)
  18. btn_zhongji: Node = null; //
  19. @property(Node)
  20. btn_gaoji: Node = null; //
  21. @property(Node)
  22. btn_ads_tongqian: Node = null; //
  23. start() {
  24. let self = this;
  25. UIButton.BindClick(this.btn_chuji,()=>{
  26. this.sendMsg(room_type._chuji_tongqian)
  27. },this)
  28. UIButton.BindClick(this.btn_zhongji,()=>{
  29. this.sendMsg(room_type._zhongji_tongqian)
  30. },this)
  31. UIButton.BindClick(this.btn_ads_tongqian,()=>{
  32. native_manager.showRewardVideo()
  33. },this)
  34. ClientEvent.on(Constant.EVENT_TYPE.MSG_CREATE_ROOM,this.onRecvCreateRoom,this)
  35. }
  36. sendMsg(type:room_type){
  37. switch (type) {
  38. case room_type._chuji_tongqian:
  39. msgManager.createRoomByRoomType(room_type._chuji_tongqian)
  40. break;
  41. case room_type._zhongji_tongqian:
  42. msgManager.createRoomByRoomType(room_type._zhongji_tongqian)
  43. break;
  44. }
  45. UIManager.AddPrefab(GameMng.Instance.uiloading)
  46. }
  47. onDestroy(){
  48. ClientEvent.off(Constant.EVENT_TYPE.MSG_CREATE_ROOM,this.onRecvCreateRoom,this)
  49. }
  50. onRecvCreateRoom(room:roomData){
  51. console.log("room",room)
  52. UIManager.removeLoadingLayer()
  53. GameMng.updateRoomData(room);
  54. ScenceMng.Instance.load('Chess')
  55. }
  56. }