123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /** @format */
- import {UI} from '../enums/UI'
- import {BaseUI} from './BaseUI'
- import {Data, Mgr} from '../GameControl'
- import {ccUtils} from '../utils/ccUtils'
- import {list, node, observer} from '../mobx/observer'
- import List from '../uiutils/List'
- import {idNum} from '../proto/typedef'
- import {IGameResult, IRewardNty, IStageChoose} from '../interface/UIInterface'
- import {AD_ID, GAME_TYPE, LANGUAGE_TYPE, LOCAL, MOD} from '../enums/Enum'
- import {MSG} from '../enums/MSG'
- import {msgCmd} from '../proto/msg_cmd'
- import {adventureAdAward, adventureAdAwardRsp, dailyDungeonsSweep, roleGetDataRsp} from '../proto/game'
- import {SOUND} from '../enums/Sound'
- import {RanksLevelConfig} from '../config/RanksLevelConfig'
- const {ccclass, property} = cc._decorator
- @ccclass
- @observer
- export class GameResultUI extends BaseUI {
- @list('rewards/goodsList')
- goodsList: List
- @node('victory')
- victory: cc.Node
- @node('lose')
- lose: cc.Node
- @node('btns/btn_strong')
- btnStrongNode: cc.Node
- @node('rewards')
- rewardsNode: cc.Node
- @node('time')
- timeNode: cc.Node
- @node('btns/btn_double')
- btnDouble: cc.Node
- rewards: idNum[]
- result: IGameResult
- onShow(args: IGameResult, fromUI: number) {
- Mgr.net.add(msgCmd.cmd_adventure_ad_award_rsp, this, this.onDoubleRsp)
- Mgr.net.add(msgCmd.cmd_role_get_data_rsp, this, this.onRoleGetDataRsp)
- this.result = args
- let isWin = args.isWin
- Mgr.audio.stopBGM()
- Mgr.audio.playSFX(isWin ? SOUND.win : SOUND.lose)
- this.victory.active = isWin
- this.lose.active = !isWin
- //this.btnStrongNode.active = !isWin
- this.rewards = args.rewardsNty ? Mgr.goods.getGoodsListByRewardNty(args.rewardsNty) : []
- this.goodsList.numItems = this.rewards.length
- this.rewardsNode.active = this.rewards.length > 0
- // this.timeNode.active = !this.rewardsNode.active
- // ccUtils.setLabel(
- // Mgr.i18n.getTimeLabel(Data.main.serverTime - args.startTime, LANGUAGE_TYPE.m, LANGUAGE_TYPE.s),
- // this.timeNode,
- // 'time',
- // )
- // this.btnDouble.active = GAME_TYPE.normal == Data.game.gameType && isWin
- // let doubleOpen = Mgr.global.checkModOpen(MOD.doubleADGameReward)
- // cc.find('adTip', this.node).active = this.btnDouble.active && doubleOpen
- // cc.find('lock', this.btnDouble).active = !doubleOpen
- // ccUtils.setAllGray(!doubleOpen, this.btnDouble)
- // if (!doubleOpen) {
- // ccUtils.setLabel(Mgr.global.getModLockTip(MOD.doubleADGameReward), this.btnDouble, 'lock/lb_notGray')
- // }
- // cc.find('guide', this.node).active = Mgr.global.tryShowUserGuide(['2013_1'])
- }
- onHide(): any {
- Mgr.event.removeAll(this)
- }
- //UI或者其他函数=======================================
- initGoodsItem(node: cc.Node, index: number) {
- Mgr.goods.initGoods([this.rewards[index]], [cc.find('goods', node)], this)
- }
- // 点击事件=======================================
- onStrongClick() {
- Mgr.ui.closeAll()
- Mgr.ui.show(UI.MainUI)
- Mgr.ui.show(UI.TeamUI)
- }
- onSureClick() {
- if (Data.game.gameType == GAME_TYPE.normal) {
- Mgr.net.send(msgCmd.cmd_role_get_data)
- } else {
- Mgr.game.exitGame(this.result)
- }
- }
- onDoubleClick() {
- Mgr.platform.playVideoAD(AD_ID.firstpass, () => {
- Mgr.net.send(msgCmd.cmd_adventure_ad_award)
- })
- }
- onDoubleRsp(data: adventureAdAwardRsp, rewardsNty: IRewardNty) {
- Mgr.ui.showReward(rewardsNty)
- this.btnDouble.active = false
- }
- onRoleGetDataRsp(data: roleGetDataRsp) {
- Data.user.level = data.level
- Data.user.exp = data.exp
- if (RanksLevelConfig[Data.user.level + 1] && data.exp >= RanksLevelConfig[Data.user.level + 1].exp) {
- Data.main.exitGame = true
- //返回主界面升级
- Data.main.exitGameLv = true
- Mgr.ui.closeAll()
- Mgr.ui.show(UI.MainUI)
- } else {
- Mgr.game.exitGame(this.result)
- }
- }
- }
|