GameOverView.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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-23 17:49:45
  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. // oops.message.dispatchEvent(GameEvent.RestartGame);
  44. ServerHandler.inst.RestartGame();
  45. oops.gui.remove(UIID.GameOver);
  46. DCHandler.inst.reportData(3000603);
  47. }
  48. private btn_resurrection() {
  49. smc.game.GameModel.viewType = "revive_reward";
  50. //复活 分数不清零
  51. ADHandler.inst.showAd(AD_TYPE.Resurrection);
  52. oops.gui.remove(UIID.GameOver);
  53. DCHandler.inst.reportData(3000602);
  54. }
  55. }