GameOverView.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-03-27 18:19:53
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-21 18:10:36
  6. * @Description: 游戏结束界面
  7. */
  8. import { _decorator } from 'cc';
  9. import { oops } from 'db://oops-framework/core/Oops';
  10. import VMParent from 'db://oops-framework/libs/model-view/VMParent';
  11. import { AD_TYPE } from '../common/config/GameDefine';
  12. import { UIID } from '../common/config/GameUIConfig';
  13. import { ADHandler } from '../common/manager/ADHandler';
  14. import { ServerHandler } from '../common/manager/ServerHandler';
  15. import { smc } from '../common/SingletonModuleComp';
  16. const { ccclass, property } = _decorator;
  17. /** 显示对象控制 */
  18. @ccclass('GameOverView')
  19. export class GameOverView extends VMParent {
  20. data: any = {
  21. cd: 20,
  22. cdMax: 100,
  23. schedule: 0
  24. }
  25. protected start() {
  26. this.setButton();
  27. //计算分数,取后两位小数*100
  28. let score = smc.game.GameModel.curScore;
  29. let targetScore = smc.game.GameModel.targetScore;
  30. let progress = score / targetScore;
  31. if (progress > 1) {
  32. progress = 1;
  33. }
  34. this.data.cd = score;
  35. this.data.cdMax = targetScore;
  36. //取整数
  37. let scoreInt = Math.floor(progress * 100);
  38. this.data.schedule = scoreInt;
  39. }
  40. private btn_restart() {
  41. // oops.message.dispatchEvent(GameEvent.RestartGame);
  42. ServerHandler.inst.RestartGame();
  43. oops.gui.remove(UIID.GameOver);
  44. }
  45. private btn_resurrection() {
  46. smc.game.GameModel.viewType = "revive_reward";
  47. //复活 分数不清零
  48. ADHandler.inst.showAd(AD_TYPE.Resurrection);
  49. // oops.gui.remove(UIID.GameOver);
  50. }
  51. }