import RewardNode from "../ui/RewardNode"; import RedPackageNode from "../ui/RedPackageNode"; import AdM from "./AdM"; import Main from "../Main"; import GameM from "./GameM"; import LogUtil from "../utils/LogUtil"; const { ccclass, property } = cc._decorator; @ccclass export default class UiM extends cc.Component { static Instance: UiM = null @property(cc.Node) onPanelPar: cc.Node = null; @property(cc.Node) hallNode: cc.Node = null; // @property(cc.Node) // guideNode: cc.Node = null; @property(cc.Node) giftNode: cc.Node = null; @property(cc.Node) taskNode: cc.Node = null; @property(RewardNode) rewardNode: RewardNode = null; @property(RedPackageNode) redPackageNode: RedPackageNode = null; shopNode: cc.Node = null; settingNode: cc.Node = null; cashNode: cc.Node = null; turntableNode: cc.Node = null; dailyNode: cc.Node = null; treasureNode: cc.Node = null; InvestNode: cc.Node = null; safeDepositBoxNode: cc.Node = null; officialNode: cc.Node = null; cashRecordNode: cc.Node = null; redCodeNode: cc.Node = null; ruleNode: cc.Node = null; CertificationNode: cc.Node = null; AntiAddictionNode: cc.Node = null; clubMainNode: cc.Node = null; moreGameNode: cc.Node = null; clubGuideNode: cc.Node = null; usualCaidanNode: cc.Node = null cashProNode: cc.Node = null downLoadUI: cc.Node = null nativeAdAwardNode: cc.Node = null normalCashProNode: cc.Node = null guideInstallApkNode: cc.Node = null moreGamePopNode: cc.Node = null panelFuns: Function[] = []; /** 右侧进入打开的界面数组 */ panelArr = [] /** 直接弹出打开界面数组 */ private onPanelArr = [] onLoad() { UiM.Instance = this } start() { } checkDelayShow(func) { // if (UiM.Instance.guideNode.active) { // UiM.Instance.panelFuns.push(func) // } // else { // } func() } displayPanel() { if (this.panelFuns.length > 0) { let tempFun = this.panelFuns.pop(); tempFun(); } } closePanelFromHome() { if (this.panelArr.length > 0) { let p = this.panelArr.pop() this.closePanel(p) } } closePanelM() { if (this.panelArr.length > 0) { let p = this.panelArr.pop() this.closePanel(p) AdM.popChange(-1) } } /** 右侧进入打开界面 */ openPanel(p, effect = true) { p.active = true this.panelArr.push(p) if (effect) { p.setPosition(750, 0) cc.tween(p) .to(0.3, { position: cc.v2(0, 0) }, cc.easeOut(3)) .start() } else { p.setPosition(0, 0) } AdM.popChange(1) } /** 左侧进入打开界面 */ openLeftPanel(p, effect = true) { p.active = true if (effect) { p.setPosition(-750, 0) cc.tween(p) .to(0.3, { position: cc.v2(0, 0) }, cc.easeOut(3)) .start() } else { p.setPosition(0, 0) } } /** 右侧移出关闭界面 */ private closePanel(p) { LogUtil.logV("closePanel", p.name) if (p.name == 'RedPackageNode') { p.getComponent(RedPackageNode).bgNode.active = false } cc.tween(p) .to(0.3, { position: cc.v2(750, 0) }, cc.easeOut(3)) .call(() => { p.active = false if (p.name == 'cashNode') { if (GameM.commonData.maxCarLevel >= 10) { if (GameM.commonData.backShowDaily) { GameM.commonData.backShowDaily = false UiM.Instance.hallNode.getComponent(Main).showDialyPanel() } else if (GameM.commonData.dailyFirstLogin) { GameM.commonData.dailyFirstLogin = false UiM.Instance.hallNode.getComponent(Main).showDialyPanel() } } UiM.Instance.cashNode = null p.removeFromParent() console.log(p) } if (p.name == "ClubTixianNode") { p.removeFromParent() } }) .start() } setPanelCool() { this.openLoading = true this.scheduleOnce(() => { this.openLoading = false }, 0.3) } //打开界面等待着 private openLoading = false onPanel(name, effect = false, callBack = null) { if (this.openLoading) { return } this.openLoading = true cc.loader.loadRes('panelNode/' + name, cc.Prefab, (err, assets) => { if (err) { cc.error(err); return; } let has = false let panel = null for (var i = 0; i < this.onPanelArr.length; i++) { panel = this.onPanelArr[i] if (panel.name == name) { has = true break } } if (!has) { panel = cc.instantiate(assets) this.onPanelArr.push(panel) this.onPanelPar.addChild(panel) } if (effect) { panel.setPosition(750, 0) cc.tween(panel) .to(0.3, { position: cc.v2(0, 0) }, cc.easeOut(3)) .delay(0.3) .call(() => { this.openLoading = false }) .start() } else { this.scheduleOnce(() => { this.openLoading = false }, 0.3) } if (name == PANEL_NAME.ShopNode) { this.shopNode = panel } else if (name == PANEL_NAME.CashNode) { this.cashNode = panel } else if (name == PANEL_NAME.TurnTableNode) { this.turntableNode = panel } else if (name == PANEL_NAME.DailyNode) { this.dailyNode = panel } else if (name == PANEL_NAME.TreasureNode) { this.treasureNode = panel } else if (name == PANEL_NAME.SettingNode) { this.settingNode = panel } else if (name == PANEL_NAME.InvestNode) { this.InvestNode = panel } else if (name == PANEL_NAME.SafeDepositBox) { this.safeDepositBoxNode = panel } else if (name == PANEL_NAME.OfficialNode) { this.officialNode = panel } else if (name == PANEL_NAME.CashRecordNode) { this.cashRecordNode = panel } else if (name == PANEL_NAME.RedCodeNode) { this.redCodeNode = panel } else if (name == PANEL_NAME.clubMainNode) { this.clubMainNode = panel } else if (name == PANEL_NAME.clubGuideNode) { this.clubGuideNode = panel } else if (name == PANEL_NAME.RuleNode) { this.ruleNode = panel } else if (name == PANEL_NAME.CertificationNode) { this.CertificationNode = panel } else if (name == PANEL_NAME.AntiAddictionNode) { this.AntiAddictionNode = panel } else if (name == PANEL_NAME.moreGameNode) { this.moreGameNode = panel } else if (name == PANEL_NAME.UsualCaidanNode) { this.usualCaidanNode = panel } else if (name == PANEL_NAME.CashProNode) { this.cashProNode = panel } else if (name == PANEL_NAME.DownLoadUI) { this.downLoadUI = panel } else if (name == PANEL_NAME.NativeAdAwardNode) { this.nativeAdAwardNode = panel } else if (name == PANEL_NAME.NormalCashProNode) { this.normalCashProNode = panel } else if (name == PANEL_NAME.GuideInstallApkNode) { this.guideInstallApkNode = panel } else if (name == PANEL_NAME.MoreGamePopNode) { this.moreGamePopNode = panel } if (callBack) { callBack() } }) } offPanel(name, effect = false, callBack = null) { if (this.openLoading && effect) { return } this.openLoading = true let panel = null for (var i = 0; i < this.onPanelArr.length; i++) { panel = this.onPanelArr[i] if (panel.name == name) { this.onPanelArr.splice(i, 1) break } } if (name == PANEL_NAME.ShopNode) { this.shopNode = null } else if (name == PANEL_NAME.CashNode) { this.cashNode = null } else if (name == PANEL_NAME.TurnTableNode) { this.turntableNode = null } else if (name == PANEL_NAME.DailyNode) { this.dailyNode = null } else if (name == PANEL_NAME.TreasureNode) { this.treasureNode = null } else if (name == PANEL_NAME.SettingNode) { this.settingNode = null } else if (name == PANEL_NAME.InvestNode) { this.InvestNode = null } else if (name == PANEL_NAME.SafeDepositBox) { this.safeDepositBoxNode = null } else if (name == PANEL_NAME.OfficialNode) { this.officialNode = null } else if (name == PANEL_NAME.CashRecordNode) { this.cashRecordNode = null } else if (name == PANEL_NAME.RedCodeNode) { this.redCodeNode = null } else if (name == PANEL_NAME.RuleNode) { this.ruleNode = null } else if (name == PANEL_NAME.CertificationNode) { this.CertificationNode = null } else if (name == PANEL_NAME.AntiAddictionNode) { this.AntiAddictionNode = null } else if (name == PANEL_NAME.clubMainNode) { this.clubMainNode = null } else if (name == PANEL_NAME.clubGuideNode) { this.clubGuideNode = null } else if (name == PANEL_NAME.moreGameNode) { this.moreGameNode = null } else if (name == PANEL_NAME.UsualCaidanNode) { this.usualCaidanNode = null } else if (name == PANEL_NAME.CashProNode) { this.cashProNode = null } else if (name == PANEL_NAME.DownLoadUI) { this.downLoadUI = null } else if (name == PANEL_NAME.NativeAdAwardNode) { this.nativeAdAwardNode = null } else if (name == PANEL_NAME.NormalCashProNode) { this.normalCashProNode = null } else if (name == PANEL_NAME.GuideInstallApkNode) { this.guideInstallApkNode = null } else if (name == PANEL_NAME.MoreGamePopNode) { this.moreGamePopNode = null } if (panel) { if (effect) { cc.tween(panel) .to(0.3, { position: cc.v2(750, 0) }, cc.easeOut(3)) .call(() => { if (panel.name == 'cashNode') { if (GameM.commonData.maxCarLevel >= 10) { if (GameM.commonData.backShowDaily) { GameM.commonData.backShowDaily = false UiM.Instance.hallNode.getComponent(Main).showDialyPanel() } else if (GameM.commonData.dailyFirstLogin) { GameM.commonData.dailyFirstLogin = false UiM.Instance.hallNode.getComponent(Main).showDialyPanel() } } } panel.removeFromParent() this.openLoading = false if (callBack) { callBack() } }) .start() } else { panel.removeFromParent() this.openLoading = false if (callBack) { callBack() } } } else { this.openLoading = false if (callBack) { callBack() } } } } export enum PANEL_NAME { SettingNode = 'SettingNode', InvestNode = 'InvestNode', ShopNode = 'ShopNode', TurnTableNode = 'TurnTableNode', CashNode = 'CashNode', RemindNode = 'RemindNode', DailyNode = 'DailyNode', TreasureNode = 'TreasureNode', PieceNode = 'PieceNode', SafeDepositBox = 'SafeDepositBox',//保险箱 OfficialNode = 'OfficialNode', CashRecordNode = 'CashRecordNode', RedCodeNode = 'RedCodeNode', RuleNode = 'RuleNode', CertificationNode = 'CertificationNode', AntiAddictionNode = 'AntiAddictionNode', clubMainNode = 'clubMainNode', clubGuideNode = 'clubGuideNode', moreGameNode = 'moreGameNode', CashPro = 'CashPro', UsualCaidanNode = 'UsualCaidanNode', CashProNode = 'CashProNode', DownLoadUI = 'DownLoadUI', NativeAdAwardNode = 'NativeAdAwardNode', NormalCashProNode = 'NormalCashProNode', CoinTipNode = 'CoinTipNode', GuideInstallApkNode = 'GuideInstallApkNode', RedeemNode = 'RedeemNode', MoreGamePopNode = 'MoreGamePopNode' }