import { _decorator, Component, Label, Node } from 'cc'; import { Global } from '../Common/Global'; import { GameEndTip } from './GameEndTip'; import { AudioManage } from '../Manager/AudioManage'; import { PlayClassAend } from './PlayClassAend'; import { GameMain } from '../Game/GameMain'; const { ccclass, property } = _decorator; @ccclass('GamePanel') export class GamePanel extends Component { @property(Node) fullRoot: Node = null; @property(Label) scoreLabel2: Label = null; @property(Label) timeLabel2: Label = null; @property(Label) levelLabel2: Label = null; @property(Node) gameEndTip: Node = null; @property(Node) playAEndTip: Node = null; @property(Node) GameMain: Node = null; protected onLoad(): void { setTimeout(() => { this.callAndroid('loading:over'); }, 500); this.node.on(Global.EventType_ShowTips, (e) => { this.ShowTips(e.data); e.propagationStopped = false; }); } start() { if (Global.IsDevelop) { this.fullRoot.active = true; }else{ this.fullRoot.active = false; } this.GameMain.getComponent(GameMain).initUI(); } /** * * 刷新UI */ RefreshTime(timer: number) { // const minutes = Math.floor(timer / 60); // const seconds = timer % 60; if (!Global.IsDevelop) { this.callAndroid('setTime:' + timer); }else{ this.timeLabel2.string = timer.toString(); } } RefreshScore(score: number) { if (!Global.IsDevelop) { this.callAndroid('setScore:' + score); }else{ this.scoreLabel2.string = score.toString(); } } RefreshLevel(level: number) { if (!Global.IsDevelop) { this.callAndroid('setLevel:' + level); }else{ this.levelLabel2.string = '第' + level + '关'; } } GameOver() { this.GameMain.getComponent(GameMain).gameOver(); } ShowTips(tip: string) { // this.tipLabelEffect.setText(tip); console.log('tip:'+tip);  AudioManage.instance.setBgVolume(0.5); if (!Global.IsDevelop) { this.callAndroid('voice:' + tip); } } callAndroid(data:string) { let ss: any = window; if (typeof ss.AndroidInterface !== 'undefined') { ss.AndroidInterface.performAndroidMethod(data); } else { console.log('安卓方法未定义'); } } showGameEndTip(curLevel: number, curScore: number, totalScore: number, result: boolean, isTime: boolean) { AudioManage.instance.pauseMusic(); if( result ){ //播放成功音效 AudioManage.instance.playSound(Global.Audio_nextLev); }else{ //播放失败音效 AudioManage.instance.playSound(Global.Audio_achieve); } this.scheduleOnce(function () { this.gameEndTip.active = true; AudioManage.instance.pauseMusic(); const gameEndTipScr = this.gameEndTip.getComponent(GameEndTip); gameEndTipScr.showEndView(curLevel, curScore, totalScore, result,isTime); }, 1.5); } showPlayAendTip(curScore: number) { this.scheduleOnce(function () { this.playAEndTip.active = true; //AudioManage.instance.pauseMusic(); const palyATipScr = this.playAEndTip.getComponent(PlayClassAend); palyATipScr.setResultScore(curScore); }, 1.5); } hideLevelUi() { // this.levelRoot.active = false; // console.log('leveRoot:'); } }