GameOverView.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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:53:19
  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. @property(Label)
  23. private lab_bar: Label = null!; //分数
  24. @property(ProgressBar)
  25. private progressBar: ProgressBar = null!; //进度条
  26. data: any = {
  27. cd: 20,
  28. cdMax: 100,
  29. schedule: 0
  30. }
  31. protected start() {
  32. this.setButton();
  33. //计算分数,取后两位小数*100
  34. let score = smc.game.GameModel.curScore;
  35. let targetScore = smc.game.GameModel.targetScore;
  36. let progress = score / targetScore;
  37. if (progress > 1) {
  38. progress = 1;
  39. }
  40. this.data.cd = score;
  41. this.data.cdMax = targetScore;
  42. //取整数
  43. let scoreInt = Math.floor(progress);
  44. this.data.schedule = scoreInt * 100;
  45. }
  46. private btn_restart() {
  47. // oops.message.dispatchEvent(GameEvent.RestartGame);
  48. ServerHandler.inst.RestartGame();
  49. oops.gui.remove(UIID.GameOver);
  50. }
  51. private btn_resurrection() {
  52. //打开广告
  53. //我这调你登录,你登录后,返回给我,可以登录,我这边加载资源,userinfo-头像,UID nickname,关卡,还有配置,
  54. //复活
  55. smc.game.GameModel.viewType = "revive_reward";
  56. //复活 分数不清零
  57. ADHandler.inst.showAd(AD_TYPE.Resurrection);
  58. oops.gui.remove(UIID.GameOver);
  59. oops.message.dispatchEvent(GameEvent.Resurrection);
  60. }
  61. }