| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- 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'
- }
|