UIEndChess.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import AudioMng from "../../gcommon/AudioMng";
  2. import { UIButton } from "../../gcommon/UIButton";
  3. import GameData from "../../gcommon/GameData";
  4. import ScenceMng from "../../gcommon/ScenceMng";
  5. import { GameMng } from "../../GameMng";
  6. import CanjuModel from "../ChessCanJuSel/CanjuModel";
  7. import UICanJuSel from "../ChessCanJuSel/UICanJuSel";
  8. import ChessMng, { ChessType } from "../DiffSel/ChessMng";
  9. import UIDiffSel from "../DiffSel/UIDiffSel";
  10. import GBoardChess from "./GBoardChess";
  11. import { Vec3,tween,UITransform ,_decorator ,Component,Label,Node,instantiate,Animation,Prefab,Sprite, director, Director} from "cc";
  12. const {ccclass, property} = _decorator;
  13. @ccclass
  14. export default class UIEndChess extends Component {
  15. @property(Animation)
  16. winAnimation:Animation=null;
  17. @property(Animation)
  18. failAnimation:Animation=null;
  19. @property(Node)
  20. btnRestart: Node = null;
  21. @property(Node)
  22. btnMoreLv: Node = null;
  23. @property(Node)
  24. btnback: Node = null;
  25. @property(Node)
  26. winSp: Node = null;
  27. @property(Node)
  28. failSp: Node = null;
  29. @property(Label)
  30. endtimelabel: Label = null;
  31. @property(Label)
  32. bushulabel: Label = null;
  33. start(){
  34. UIButton.BindClick(this.btnMoreLv, () => {
  35. if(ChessMng.Instance.chesstype==ChessType.renjiboyi)
  36. UIDiffSel.selectIndex++;
  37. else if(ChessMng.Instance.chesstype==ChessType.canju){
  38. CanjuModel.Instance.selectNextLv();
  39. }
  40. this.node.active=false;
  41. GBoardChess.instance.restartGame();
  42. }, this);
  43. UIButton.BindClick(this.btnRestart, () => {
  44. this.node.active=false;
  45. GBoardChess.instance.restartGame();
  46. }, this);
  47. }
  48. setData(result:number,time:string,bushu:number){
  49. this.endtimelabel.string=time;
  50. this.bushulabel.string=bushu.toString();
  51. if(result==0){
  52. AudioMng.Instance.PlaySoundByName(GameMng.Instance.winclip);
  53. this.winSp.active=true;
  54. this.failSp.active=false;
  55. this.winAnimation.play('win');
  56. if(ChessMng.Instance.chesstype==ChessType.renjiboyi)
  57. {
  58. if(UIDiffSel.selectIndex<UIDiffSel.lvArr.length-1)
  59. {
  60. this.btnMoreLv.active=true;
  61. }
  62. else this.btnMoreLv.active=false;
  63. }
  64. else if(ChessMng.Instance.chesstype==ChessType.canju)
  65. {
  66. if (CanjuModel.Instance.selectLv == CanjuModel.Instance.getCurMaxLevel()) {
  67. CanjuModel.Instance.updateMaxLevel()
  68. }
  69. this.btnMoreLv.active=true;
  70. }
  71. GameData.SaveGame();
  72. }
  73. else{
  74. AudioMng.Instance.PlaySoundByName(GameMng.Instance.failclip);
  75. this.winSp.active=false;
  76. this.failSp.active=true;
  77. this.failAnimation.play('win');
  78. this.btnMoreLv.active=false;
  79. }
  80. }
  81. }