GameOverView.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-27 14:34:52
  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. import { DCHandler } from '../common/manager/DCHandler';
  17. const { ccclass, property } = _decorator;
  18. /** 显示对象控制 */
  19. @ccclass('GameOverView')
  20. export class GameOverView extends VMParent {
  21. data: any = {
  22. cd: 20,
  23. cdMax: 100,
  24. schedule: 0
  25. }
  26. protected start() {
  27. this.setButton();
  28. DCHandler.inst.reportData(3000601);
  29. //计算分数,取后两位小数*100
  30. let score = smc.game.GameModel.curScore;
  31. let targetScore = smc.game.GameModel.targetScore;
  32. let progress = score / targetScore;
  33. if (progress > 1) {
  34. progress = 1;
  35. }
  36. this.data.cd = score;
  37. this.data.cdMax = targetScore;
  38. //取整数
  39. let scoreInt = Math.floor(progress * 100);
  40. this.data.schedule = scoreInt;
  41. }
  42. private btn_restart() {
  43. ServerHandler.inst.RestartGame();
  44. oops.gui.remove(UIID.GameOver);
  45. DCHandler.inst.reportData(3000603);
  46. }
  47. private btn_resurrection() {
  48. smc.game.GameModel.viewType = "revive_reward";
  49. //复活 分数不清零
  50. ADHandler.inst.showAd(AD_TYPE.Resurrection);
  51. oops.gui.remove(UIID.GameOver);
  52. DCHandler.inst.reportData(3000602);
  53. }
  54. }