123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- 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:');
- }
- }
|