123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- import { _decorator, Component, Node, LabelComponent } from 'cc';
- import { GUIManager } from '../../../engines/gui/GUIManager';
- import { GUIMediator } from '../../../engines/gui/GUIMediator';
- import { NoticeManager } from '../../../engines/notices/NoticeManager';
- import { SceneManager } from '../../../engines/scenes/SceneManager';
- import { PlatformManager } from '../../../Platform/PlatformManager';
- import GameConfigManager from '../../models/GameConfigManager';
- import { GameModel } from '../../models/GameModel';
- import { GameController } from '../fightings/GameController';
- import { UIConst } from '../UIConst';
- const { ccclass, property } = _decorator;
- @ccclass('GameOverMediator')
- export class GameOverMediator extends GUIMediator {
- @property(Node)
- WinGroup: Node = null;
- @property({
- type: LabelComponent
- })
- WinAwardLabel: LabelComponent = null;
- @property(Node)
- DefeatedGroup: Node = null;
- private isWin: boolean;
- private award: number;
- onLoad() {
- PlatformManager.showBanner()
- }
- OnShow(data?: any): void {
- super.OnShow(data);
- this.isWin = data;
- this.WinGroup.active = this.isWin;
- this.DefeatedGroup.active = !this.isWin;
- //胜利
- if (this.isWin == true) {
- this.WinGroup.active = true;
- this.DefeatedGroup.active = false;
- let levelConfig: any = GameConfigManager.GetLevelConfig(GameModel.single.currentLevel - 1);
- //关卡基础奖励
- this.award = levelConfig.awards + levelConfig.killAward * GameModel.single.killCount;
- this.WinAwardLabel.string = this.award.toString();
- } else {//失败
- //失败不算奖励
- this.WinGroup.active = false;
- this.DefeatedGroup.active = true;
- }
- }
- /**
- * 开始下一关
- */
- PlayNextLevel(): void {
- this.AddAward();
- this.HideSelf();
- GameController.single.PlayNextLevel();
- }
- /**
- * 重玩
- */
- Replay(): void {
- PlatformManager.showRewardedVideo(() => {
- PlatformManager.hideBanner();
- this.AddAward();
- this.HideSelf();
- GameController.single.Replay();
- }, () => {
- NoticeManager.ShowPrompt("复活失败");
- })
- }
- /**
- * 返回主界面
- */
- BackToMain(): void {
- this.AddAward();
- SceneManager.single.Swicth("PrepareScene");
- GUIManager.single.Hide(UIConst.FIGHTING_UI);
- //关闭自身
- this.HideSelf();
- }
- /**
- * 去全屏幕界面
- */
- GoToFullOutput(): void {
- this.AddAward();
- GUIManager.single.Show(UIConst.FULL_OUTPUT_UI);
- this.HideSelf();
- }
- /**
- * 十倍之后去全屏界面
- */
- getTenAward():void{
- this.AddAdAward(10, ()=>{
- GUIManager.single.Show(UIConst.FULL_OUTPUT_UI);
- this.HideSelf();
- });
- }
- /**
- * 十倍奖励
- * @param value
- */
- private AddAdAward(value: number = 1, success): void {
- if (this.isWin) {
- PlatformManager.showRewardedVideo(() => {
- GameModel.single.gold += this.award * value;
- success();
- }, () => {
- NoticeManager.ShowPrompt("领取失败");
- })
- }
- }
- /**
- * 获取奖励
- */
- private AddAward(value: number = 1): void {
- if (this.isWin) {
- GameModel.single.gold += this.award * value;
- }
- }
- OnHide(): void {
- }
- }
|