GameOverView.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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-17 18:55:23
  6. * @Description: 游戏结束界面
  7. */
  8. import { _decorator, Label, ProgressBar } from 'cc';
  9. import { oops } from 'db://oops-framework/core/Oops';
  10. import { GameComponent } from "db://oops-framework/module/common/GameComponent";
  11. import { AD_TYPE } from '../common/config/GameDefine';
  12. import { GameEvent } from '../common/config/GameEvent';
  13. import { UIID } from '../common/config/GameUIConfig';
  14. import { ADHandler } from '../common/manager/ADHandler';
  15. import { ServerHandler } from '../common/manager/ServerHandler';
  16. import { smc } from '../common/SingletonModuleComp';
  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: 20,
  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. 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);
  40. this.data.schedule = scoreInt * 100;
  41. }
  42. private btn_restart() {
  43. // oops.message.dispatchEvent(GameEvent.RestartGame);
  44. ServerHandler.inst.RestartGame();
  45. oops.gui.remove(UIID.GameOver);
  46. }
  47. private btn_resurrection() {
  48. //打开广告
  49. //我这调你登录,你登录后,返回给我,可以登录,我这边加载资源,userinfo-头像,UID nickname,关卡,还有配置,
  50. //复活
  51. smc.game.GameModel.viewType = "revive_reward";
  52. //复活 分数不清零
  53. ADHandler.inst.showAd(AD_TYPE.Resurrection);
  54. oops.gui.remove(UIID.GameOver);
  55. oops.message.dispatchEvent(GameEvent.Resurrection);
  56. }
  57. }