UIduizhan.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { GameMng, quit_chess_show_view } from "../GameMng";
  2. import { UIButton } from "../gcommon/UIButton";
  3. import GBaseUI from "../gcommon/GBaseUI";
  4. import { UIManager } from "../gcommon/UIManager";
  5. import { _decorator,Node, Label } from "cc";
  6. import { createFirendRoom } from "./createFirendRoom";
  7. const {ccclass, property} = _decorator;
  8. @ccclass
  9. export default class UIduizhan extends GBaseUI {
  10. @property(Node)
  11. btnClose: Node = null;
  12. @property(Node)
  13. btnRenji: Node = null;
  14. @property(Node)
  15. btnHaoyou: Node = null;
  16. @property(Node)
  17. btnJifen: Node = null;
  18. @property(Node)
  19. btnTongqian: Node = null;
  20. @property(Node)
  21. btnJoinRoom: Node = null;
  22. @property(Node)
  23. nodeRenji: Node = null;
  24. @property(Node)
  25. labName: Node = null;
  26. @property(Node)
  27. nodeJifen: Node = null;
  28. @property(Node)
  29. nodeTongqian: Node = null;
  30. static show_type:quit_chess_show_view = null;
  31. static Show(type?:quit_chess_show_view){
  32. UIduizhan.show_type = type
  33. UIManager.AddPrefab(GameMng.Instance.uiduizhan);
  34. }
  35. start () {
  36. UIButton.BindClick(this.btnClose,()=>{
  37. this.closeUI();
  38. },this);
  39. UIButton.BindClick(this.btnRenji,()=>{
  40. this.labName.getComponent(Label).string = "人机对战"
  41. this.nodeRenji.active = true;
  42. },this);
  43. UIButton.BindClick(this.btnJifen,()=>{
  44. this.labName.getComponent(Label).string = "积分场"
  45. this.nodeJifen.active = true;
  46. },this);
  47. UIButton.BindClick(this.btnTongqian,()=>{
  48. this.labName.getComponent(Label).string = "铜钱场"
  49. this.nodeTongqian.active = true;
  50. },this);
  51. UIButton.BindClick(this.btnJoinRoom,()=>{
  52. console.log("btnJoinRoom","btnJoinRoom")
  53. UIManager.AddPrefab(GameMng.Instance.joinRoom,this.node)
  54. },this);
  55. UIButton.BindClick(this.btnHaoyou,()=>{
  56. createFirendRoom.Show(this.node.parent)
  57. },this);
  58. if(UIduizhan.show_type!=null){
  59. switch(UIduizhan.show_type){
  60. case quit_chess_show_view.haoyou:{
  61. createFirendRoom.Show(this.node.parent)
  62. break;
  63. }
  64. case quit_chess_show_view.renji:{
  65. this.labName.getComponent(Label).string = "人机对战"
  66. this.nodeRenji.active = true;
  67. break;
  68. }
  69. case quit_chess_show_view.jifen:{
  70. this.labName.getComponent(Label).string = "积分场"
  71. this.nodeJifen.active = true;
  72. break;
  73. }
  74. case quit_chess_show_view.tongqian:{
  75. this.labName.getComponent(Label).string = "铜钱"
  76. this.nodeTongqian.active = true;
  77. break;
  78. }
  79. }
  80. }
  81. }
  82. closeUI(){
  83. let isQuit = true;
  84. if( this.nodeRenji.active === true){
  85. this.nodeRenji.active = false;
  86. isQuit = false;
  87. this.labName.getComponent(Label).string = "象棋"
  88. }
  89. if(this.nodeJifen.active === true){
  90. this.nodeJifen.active = false;
  91. isQuit = false;
  92. this.labName.getComponent(Label).string = "象棋"
  93. }
  94. if(this.nodeTongqian.active === true){
  95. isQuit = false;
  96. this.nodeTongqian.active = false;
  97. this.labName.getComponent(Label).string = "象棋"
  98. }
  99. if(isQuit){
  100. this.node.destroy()
  101. }
  102. }
  103. }