| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- import { BaseView } from "../lightMVC/core/base/BaseView";
- import SDK from "./sdk/SDK";
- import hallSceneMediator from "./hallSceneMediator";
- import { App } from "./Manager/App";
- import { SoundManager } from "./Manager/SoundManager";
- import TimeControl from "./TimeControl";
- import ChooseLevelPanel from "./view/chooseLevel/ChooseLevelPanel";
- import ChooseLevelPanelMediator from "./view/chooseLevel/ChooseLevelPanelMediator";
- import ChooseSkinPanel from "./view/chooseSkin/ChooseSkinPanel";
- import ChooseSkinPanelMediator from "./view/chooseSkin/ChooseSkinPanelMediator";
- import InsufficientPanel from "./view/insufficientPanel/InsufficientPanel";
- import InsufficientPanelMediator from "./view/insufficientPanel/InsufficientPanelMediator";
- import MissionPanel from "./view/missionPanel/MissionPanel";
- import MissionPanelMediator from "./view/missionPanel/MissionPanelMediator";
- import SetNormalPanel from "./view/setNormal/SetNormalPanel";
- import SetNormalPanelMediator from "./view/setNormal/SetNormalPanelMediator";
- import ShopPanel from "./view/shopView/ShopPanel";
- import ShopPanelMediator from "./view/shopView/ShopPanelMediator";
- import TipPanel from "./view/tipPanel/TipPanel";
- import TipPanelMediator from "./view/tipPanel/TipPanelMediator";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class hallScene extends BaseView {
- public static _instance;
- @property(cc.Button)
- public startGameBtn: cc.Button = null;
- @property(cc.Button)
- public setNormalBtn: cc.Button = null;
- // @property(cc.Button)
- // public chooseSkinBtn: cc.Button = null;
- @property(cc.Button)
- public missionBtn: cc.Button = null;
- // @property(cc.Button)
- // public btnVideo: cc.Button = null;
- // @property(cc.Button)
- // public btnShop: cc.Button = null;
- @property(cc.Button)
- public btnLeft: cc.Button = null;
- @property(cc.Button)
- public btnRight: cc.Button = null;
- @property(cc.PageView)
- public pageView: cc.PageView = null;
- @property(cc.Label)
- public labelTili: cc.Label = null;
- @property(cc.Label)
- public physicalTime: cc.Label = null;
-
- @property(cc.Label)
- public labelCoin: cc.Label = null;
- @property(cc.Label)
- public labelDiamond: cc.Label = null;
- private loadSceneName: string = "gameScene";
- private currientView = 0;
- public static get instance() {
- return hallScene._instance;
- }
- public static set instance(value) {
- hallScene._instance = value;
- }
- onLoad() {
- // cc.sys.localStorage.clear();
- hallScene.instance = this;
- this.registerMediator(hallSceneMediator, this, "主界面");
- SDK.Instance.showBanner();
- }
- start() {
-
- this.startGameBtn.node.on(cc.Node.EventType.TOUCH_END, this.ClickStartGame, this);
- this.setNormalBtn.node.on(cc.Node.EventType.TOUCH_END, this.ClickSetNormal, this);
- this.btnLeft.node.on(cc.Node.EventType.TOUCH_END, this.ClickLeft, this);
- this.btnRight.node.on(cc.Node.EventType.TOUCH_END, this.ClickRight, this);
- // this.btnVideo.node.on(cc.Node.EventType.TOUCH_END, this.ClickAddTili, this);
- this.missionBtn.node.on(cc.Node.EventType.TOUCH_END, this.ClickOpenMission, this);
- // this.chooseSkinBtn.node.on(cc.Node.EventType.TOUCH_END, this.ClickChooseSkin, this);
- // this.btnShop.node.on(cc.Node.EventType.TOUCH_END, this.ClickShop, this);
-
-
- // console.log('----------', TimeControl.instance.currentTili);
- // App.DataManager.TimeCountJudge();//全局倒计时判断
- // if (App.DataManager.TimeFlag) {
- // let data = { "isShow": true, 'timeStr': App.DataManager.TimeChange(TimeControl.instance.currentTimeCount) };
- // this.TiliCountShow(data);
- // }
-
- this.ShowPhysicalValue();
- this.ShowUserCoinValue();
- this.ShowUserDiamondValue();
- App.SoundManager.playBGM(SoundManager.hallBgm[0]);
- }
- public ClickOpenMission() {
- App.Facade.popView(MissionPanelMediator, MissionPanel, "打开任务界面", false);
- }
- /**
- * 体力显示设置
- */
- public ShowPhysicalValue(): void {
- console.log('############', TimeControl.instance.currentTili)
- if(hallScene.instance.labelTili){
- hallScene.instance.labelTili.string = TimeControl.instance.currentTili + "/" + TimeControl.instance.tiliMax;
- }
- }
- // 显示玩家金币
- public ShowUserCoinValue(): void {
- if(hallScene.instance.labelCoin){
- hallScene.instance.labelCoin.string = App.DataManager.UserCoin.toString();
- }
- }
- // 钻石
- public ShowUserDiamondValue(): void {
- if(hallScene.instance.labelDiamond){
- hallScene.instance.labelDiamond.string = App.DataManager.UserDiamond.toString();
- }
- }
- /**
- * 体力倒计时显示设置
- */
- public TiliCountShow(data: any): void {
- if (!this.physicalTime) return;
- this.physicalTime.node.active = data.isShow;
- if (data.timeStr) this.physicalTime.string = data.timeStr;
- }
-
- /**
- * 开始游戏
- */
- public StartGame(intoLevel: number) {
- console.log("aaa--------intoLevel----------", intoLevel);
- App.DataManager.UpdateTili(TimeControl.instance.consumeTili, (success) => {
- App.DataManager.CurrentIntoLevel = intoLevel;
- App.DataManager.PlayLevel = App.DataManager.CurrentIntoLevel;
- App.LocalStorageUtil.setNumber(App.LocalStorageUtil.lst_playLevel, App.DataManager.PlayLevel);
- if (success) App.Facade.runBundleScene("gameScene",this.loadSceneName);
- else App.Facade.popView(InsufficientPanelMediator, InsufficientPanel, "体力不足", false);
- });
- }
- /**
- * 点击开始游戏按钮直接开始
- */
- private ClickStartGame() {
- if(this.pageView.getCurrentPageIndex() == 1){
- App.Facade.popView(TipPanelMediator, TipPanel, "敬请期待!", false);
- }
- else{
- App.Facade.popView(ChooseLevelPanelMediator, ChooseLevelPanel, "关卡选择", false);
- }
- }
- /**
- * 点击观看视频加体力
- */
- private ClickAddTili() {
- console.log('点击观看视频加体力~');
- SoundManager.getInstance().VideoStartStop();
- SDK.Instance.showRewardVideo(() => {
-
- TimeControl.instance.currentTili = TimeControl.instance.tiliMax;
- this.ShowPhysicalValue();
- App.LocalStorageUtil.setNumber(App.LocalStorageUtil.lst_Tili, TimeControl.instance.currentTili);
- SoundManager.getInstance().VideoEndOpen();
- }, () => {
- SoundManager.getInstance().VideoEndOpen();
- }, () => {
- SoundManager.getInstance().VideoEndOpen();
- });
- }
- // 商城
- private ClickShop() {
- App.Facade.popView(ShopPanelMediator, ShopPanel, "商城", false);
- }
- /**
- * 打开关卡选择界面
- */
- private ClickChooseLevel() {
- App.Facade.popView(ChooseLevelPanelMediator, ChooseLevelPanel, "关卡选择", true);
- }
- /**
- * 打开选择皮肤界面
- */
- private ClickChooseSkin() {
- App.Facade.popView(ChooseSkinPanelMediator, ChooseSkinPanel, "皮肤选择", false);
- }
- /**
- * 打开设置界面
- */
- private ClickSetNormal() {
- App.Facade.popView(SetNormalPanelMediator, SetNormalPanel, "设置", false);
- }
- private ClickLeft(){
- this.currientView = this.pageView.getCurrentPageIndex() == 0 ? 1 : 0;
- this.pageView.scrollToPage(this.currientView, 0.5);
- }
- private ClickRight(){
- this.currientView = this.pageView.getCurrentPageIndex() == 0 ? 1 : 0;
- this.pageView.scrollToPage(this.currientView, 0.5);
- }
- onDisable() {
- this.startGameBtn.node.off(cc.Node.EventType.TOUCH_END, this.ClickStartGame, this);
- this.setNormalBtn.node.off(cc.Node.EventType.TOUCH_END, this.ClickSetNormal, this);
- this.btnLeft.node.off(cc.Node.EventType.TOUCH_END, this.ClickLeft, this);
- this.btnRight.node.off(cc.Node.EventType.TOUCH_END, this.ClickRight, this);
- this.missionBtn.node.off(cc.Node.EventType.TOUCH_END, this.ClickOpenMission, this);
- // this.btnVideo.node.off(cc.Node.EventType.TOUCH_END, this.ClickAddTili, this);
- // this.btnShop.node.off(cc.Node.EventType.TOUCH_END, this.ClickShop, this);
-
- // this.chooseSkinBtn.node.off(cc.Node.EventType.TOUCH_END, this.ClickChooseSkin, this);
- }
- // update (dt) {}
- }
|