chess_btns.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { _decorator, Component, Node, tween, Vec3 } from 'cc';
  2. import GBoardChess from '../Game/ChessGame/GBoardChess';
  3. import UIDialog from '../Game/UIDialog';
  4. import { GameMng } from '../GameMng';
  5. import AudioMng from '../gcommon/AudioMng';
  6. import ScenceMng from '../gcommon/ScenceMng';
  7. import { UIButton } from '../gcommon/UIButton';
  8. import { UIManager } from '../gcommon/UIManager';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('chess_btns')
  11. export class chess_btns extends Component {
  12. @property(Node)
  13. btn_caidan:Node=null; //菜单
  14. @property(Node)
  15. btn_huiqi:Node=null; //悔棋
  16. @property(Node)
  17. btn_tishi:Node=null;//提示
  18. @property(Node)
  19. btn_duiju:Node=null;//对局分析
  20. @property(Node)
  21. caidan_list:Node=null;//菜单列表
  22. @property(Node)
  23. cd_btn_quit:Node=null; //退出
  24. @property(Node)
  25. cd_btn_tihe:Node=null; //提和
  26. @property(Node)
  27. cd_btn_renshu:Node=null; //认输
  28. @property(Node)
  29. cd_btn_chonglai:Node=null; //重来
  30. @property(Node)
  31. cd_btn_shezhi:Node=null; //设置
  32. start() {
  33. UIButton.BindClick(this.btn_caidan,()=>{
  34. if(this.caidan_list.active){
  35. this.caidan_list.active= false;
  36. return
  37. }
  38. this.caidan_list.scale = new Vec3(0,0,0)
  39. this.caidan_list.active = true;
  40. tween()
  41. .target(this.caidan_list)
  42. .to(0.2,{scale:new Vec3(1.1,1.1,1)})
  43. .delay(0.2)
  44. .call(()=>{
  45. this.caidan_list.scale = new Vec3(1,1,1)
  46. })
  47. .start()
  48. },this);
  49. UIButton.BindClick(this.btn_huiqi,()=>{
  50. this.onClickQuit();
  51. GBoardChess.instance.retract()
  52. },this);
  53. UIButton.BindClick(this.btn_tishi,()=>{
  54. this.onClickQuit();
  55. GBoardChess.instance.tishi()
  56. },this);
  57. UIButton.BindClick(this.btn_duiju,()=>{
  58. },this);
  59. this.initCaiDanListBtsEvent();
  60. }
  61. initCaiDanListBtsEvent(){
  62. UIButton.BindClick(this.cd_btn_quit,()=>{
  63. this.onClickQuit();
  64. UIDialog.Show(()=>{
  65. GBoardChess.instance.recvQuit({type:0})
  66. },()=>{
  67. },"是否确定退出",GBoardChess.instance.uiLayer,true)
  68. },this);
  69. UIButton.BindClick(this.cd_btn_tihe,()=>{
  70. this.onClickQuit();
  71. GBoardChess.instance.heqi()
  72. },this);
  73. UIButton.BindClick(this.cd_btn_renshu,()=>{
  74. },this);
  75. UIButton.BindClick(this.cd_btn_chonglai,()=>{
  76. this.onClickQuit();
  77. GBoardChess.instance.restartGame()
  78. },this);
  79. UIButton.BindClick(this.cd_btn_shezhi,()=>{
  80. this.onClickQuit();
  81. UIManager.AddPrefab(GameMng.Instance.uiChessSettingView)
  82. },this);
  83. }
  84. onClickQuit(){
  85. this.caidan_list.active = false;
  86. }
  87. update(deltaTime: number) {
  88. }
  89. }