GameEndTip.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
  2. import { GameManager } from '../Manager/GameManager';
  3. import { AudioManage } from '../Manager/AudioManage';
  4. import { Global } from '../Common/Global';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('GameEndTip')
  7. export class GameEndTip extends Component {
  8. @property(SpriteFrame)
  9. successBg: SpriteFrame = null;
  10. @property(SpriteFrame)
  11. failBg: SpriteFrame = null;
  12. @property(Label)
  13. curLevelLabel: Label = null;
  14. @property(Label)
  15. curScoreLabel: Label = null;
  16. @property(Label)
  17. totalScoreLabel: Label = null;
  18. @property(Label)
  19. btnLabel: Label = null;
  20. @property(Node)
  21. reusltIcon: Node = null;
  22. result: boolean = false;
  23. start() {
  24. }
  25. showEndView(curLevel: number, curScore: number, totalScore: number, result: boolean, isTime: boolean) {
  26. if (result) {
  27. this.reusltIcon.getComponent(Sprite).spriteFrame = this.successBg;
  28. this.btnLabel.string = '下一关';
  29. } else {
  30. this.reusltIcon.getComponent(Sprite).spriteFrame = this.failBg;
  31. this.btnLabel.string = '继续';
  32. }
  33. this.result = result;
  34. if (isTime) {
  35. this.curLevelLabel.string = '超时游戏失败';
  36. } else {
  37. this.curLevelLabel.string = '当前关卡: 第' + curLevel + '关';
  38. }
  39. this.curScoreLabel.string = '本关得分: ' + curScore;
  40. this.totalScoreLabel.string = '总得分: ' + totalScore;
  41. console.log('curLevel:' + curLevel);
  42. }
  43. backHomeBtn() {
  44. this.node.active = false;
  45. // GameManager.getInstance().BackHomePage();
  46. }
  47. levelBtn() {
  48. this.node.active = false;
  49. if (this.result) {
  50. GameManager.getInstance().NextLevel();
  51. } else {
  52. GameManager.getInstance().RestartGame();
  53. }
  54. }
  55. }