GameOverView.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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-16 10:48:30
  6. * @Description: 游戏结束界面
  7. */
  8. import { _decorator } from 'cc';
  9. import { oops } from 'db://oops-framework/core/Oops';
  10. import { GameComponent } from "db://oops-framework/module/common/GameComponent";
  11. import { UIID } from '../common/config/GameUIConfig';
  12. import { GameEvent } from '../common/config/GameEvent';
  13. import { smc } from '../common/SingletonModuleComp';
  14. import { ADHandler } from '../common/manager/ADHandler';
  15. import { AD_TYPE } from '../common/config/GameDefine';
  16. import { ServerHandler } from '../common/manager/ServerHandler';
  17. import VMParent from 'db://oops-framework/libs/model-view/VMParent';
  18. const { ccclass, property } = _decorator;
  19. /** 显示对象控制 */
  20. @ccclass('GameOverView')
  21. export class GameOverView extends VMParent {
  22. data: any = {
  23. cd: 0,
  24. cdMax: 100,
  25. schedule: 0,
  26. }
  27. protected start() {
  28. this.setButton();
  29. //计算分数,取后两位小数*100
  30. let score = smc.game.GameModel.curScore;
  31. let targetScore = smc.game.GameModel.targetScore;
  32. //除,然后取后两位小数*100
  33. this.data.cd = Math.floor(score / targetScore);
  34. //计算进度条
  35. this.data.schedule = Math.floor((score / targetScore) * 100);
  36. }
  37. private btn_restart() {
  38. // oops.message.dispatchEvent(GameEvent.RestartGame);
  39. ServerHandler.inst.RestartGame();
  40. oops.gui.remove(UIID.GameOver);
  41. }
  42. private btn_resurrection() {
  43. //打开广告
  44. //我这调你登录,你登录后,返回给我,可以登录,我这边加载资源,userinfo-头像,UID nickname,关卡,还有配置,
  45. //复活
  46. smc.game.GameModel.viewType = "revive_reward";
  47. //复活 分数不清零
  48. ADHandler.inst.showAd(AD_TYPE.Resurrection);
  49. oops.gui.remove(UIID.GameOver);
  50. oops.message.dispatchEvent(GameEvent.Resurrection);
  51. }
  52. }