import { _decorator, Component, Label, Node, Prefab, sys } from 'cc'; import { SelectDifficultyPanel } from './SelectDifficultyPanel'; import { SelectSkinPanel } from './SelectSkinPanel'; import { SelectMapPanel } from './SelectMapPanel'; import { LevelContainer } from './LevelContainer'; import { clearSuperFindAllData, defaultSkin, Difficulty, LocalDataMgr, Skin, SuperFind} from '../../script/Manager/LocalDataMgr'; import EventMgr from '../../script/Manager/EventMgr'; import { AddCountPanel } from './AddCountPanel'; import { mainscene } from '../../script/mainscene'; import PlatformService from '../../script/Platform/PlatformService'; const { ccclass, property } = _decorator; @ccclass('SuperFindPanel') export class SuperFindPanel extends Component { @property(SelectDifficultyPanel) selDifPanel: SelectDifficultyPanel = null @property(SelectSkinPanel) selSkinPanel: SelectSkinPanel = null @property(SelectSkinPanel) selSkinPanel2: SelectSkinPanel = null @property(SelectMapPanel) selMapPanel: SelectMapPanel = null @property(LevelContainer) lvlContainer: LevelContainer = null @property(AddCountPanel) addCountPanel:AddCountPanel = null @property(Node) win:Node = null @property(Node) lose:Node = null @property(Node) editBtns:Node = null @property(Node) noEditBtns:Node = null @property(Label) tipLabel: Label = null @property(Label) tipLabel2: Label = null @property(Label) showOrHideScaleLabel: Label = null @property(Label) countDownLabel: Label = null @property(Node) showGmBtn:Node = null @property(Node) bottom: Node = null @property(Node) bottom2: Node = null _showScale:boolean = false _gameTime:number = 600 protected start(): void { this.init() EventMgr.ins.addEventListener("refreshLevelInfo",this.refreshInfo,this) EventMgr.ins.addEventListener("restart",this.restartCountDown,this) EventMgr.ins.addEventListener("win",this.OpenWin,this) this.restartCountDown() if(sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) { this.bottom.active = false this.bottom2.active = true } } init() { this.refreshInfo() this.countDownLabel.string = this._gameTime.toString()+"秒" let bgPath = SuperFind.superFindData.imgPath let selectSkins:string[] = Skin.getSelectSkinPath() selectSkins = selectSkins.length > 0?selectSkins:[defaultSkin] this.lvlContainer.genLvlContent(bgPath,selectSkins,Difficulty.difficutyData.difficutyCount,Difficulty.difficutyData.scales) } OpenselDifPanel() { this.selDifPanel.node.active = true; this.selDifPanel.init(); } OpenSelSkinPanel() { this.selSkinPanel.node.active = true; this.selSkinPanel.init(); } OpenSelSkinPanel2() { this.selSkinPanel2.node.active = true; this.selSkinPanel2.init(); } OpenSelMapPanel() { this.selMapPanel.node.active = true; this.selMapPanel.init(); } OpenEditBtns() { this.editBtns.active = true this.lvlContainer.swtichEditMode(true) this.noEditBtns.active = false } OpenAddCountPanel() { this.addCountPanel.node.active = true } OpenWin() { this.win.active = true } OpenLose() { this.lose.active = true } CloseWin() { this.win.active = false } CloseLose() { this.lose.active = false } CloseAddCountPanel() { this.addCountPanel.node.active = false } CloseEditBtns() { this.editBtns.active = false this.lvlContainer.swtichEditMode(false) this.noEditBtns.active = true } CloseSelDifPanel() { this.selDifPanel.node.active = false; } CloseSelSkinPanel() { this.selSkinPanel.node.active = false; } CloseSelMapPanel() { this.selMapPanel.node.active = false; } close() { this.node.destroy() EventMgr.ins.dispatchEvent("show_gm_btn") } onEditFinishClick() { this.CloseEditBtns() } onRegenerateClick() { this.lvlContainer.updateLevel() } onHideClick() { this.bottom.active = false this.bottom2.active = true this.showGmBtn.active = true } onShowGmClick() { this.bottom.active = true this.bottom2.active = false this.showGmBtn.active = false } onTipClick() { if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) { mainscene.instance.ge.track( "ad_show", //追踪事件的名称 { version: "123", ad_position: "小熊提示", level_id: SuperFind.superFindData.currentBgKey } //需要上传的事件属性 ); } PlatformService.getInstance().platformApi.loadAndShowVideoAd(() => { // PlatformService.getInstance().platformApi.reportAnalytics("tips", { // level: this.data.title // }) if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) { mainscene.instance.ge.track( "ad_showend", //追踪事件的名称 { version: "123", ad_position: "小熊提示", level_id: SuperFind.superFindData.currentBgKey } //需要上传的事件属性 ); this.lvlContainer.showOneHint() } }) } refreshInfo() { this.tipLabel.string = SuperFind.superFindData.title this.tipLabel2.string = SuperFind.superFindData.levelDesc } showOrHideScale() { this._showScale = !this._showScale this.lvlContainer.showOrHideScale(this._showScale) this.showOrHideScaleLabel.string = this._showScale?"隐藏缩放":"显示缩放" } countDown() { this._gameTime-- if (this._gameTime <= 0) { this.unschedule(this.countDown) this.countDownLabel.string = "0秒" this.OpenLose() return } this.countDownLabel.string = this._gameTime.toString() + "秒" } restartCountDown() { this._gameTime = 600 this.countDownLabel.string = this._gameTime.toString()+"秒" this.unschedule(this.countDown) this.schedule(this.countDown,1) } addTime() { this._gameTime += 60 this.countDownLabel.string = this._gameTime.toString() + "秒" this.unschedule(this.countDown) this.schedule(this.countDown, 1) } OnClickShare() { PlatformService.getInstance().platformApi.recordedGameScreenStop() PlatformService.getInstance().platformApi.shareRecordedGameScreen() } OnClickAddtime() { if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform ) { mainscene.instance.ge.track( "ad_show", //追踪事件的名称 { version: "123", ad_position: "小熊结算时加时", level_id: SuperFind.superFindData.currentBgKey } //需要上传的事件属性 ); } PlatformService.getInstance().platformApi.loadAndShowVideoAd(() => { if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) { mainscene.instance.ge.track( "ad_showend", //追踪事件的名称 { version: "123", ad_position: "小熊结算时加时", level_id: SuperFind.superFindData.currentBgKey } //需要上传的事件属性 ); this.addTime() } }) } }