| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import { _decorator, Component, Label, Node,Animation, VideoPlayer, RichText, WebView } from 'cc';
- import { GameManager } from '../Manager/GameManager';
- import { HttpManager } from '../Manager/HttpManager';
- import { Global } from '../Common/Global';
- import { ResponseData } from '../Data/ResponseData';
- const { ccclass, property } = _decorator;
- @ccclass('StartPanel')
- export class StartPanel extends Component {
- @property(WebView)
- videoPlayer:WebView=null;
- @property(Label)
- gameNameLabel:Label=null;
- @property(Label)
- gameDesnLabel:Label=null;
- @property(Label)
- startBtnLabel:Label=null;
- @property(Label)
- bestRecord:Label=null;
- @property(Label)
- sortLabel:Label=null;
- @property(Node)
- countDownPanel:Node=null;
- @property(Node)
- exitPanel:Node=null;
- @property(Animation)
- countDownAni:Animation=null;
- start() {
- if(!Global.IsDevelop)
- {
- this.initGameData();
- }
-
- }
- //初始化游戏内容数据
- initGameData()
- {
- let playClass = this.getParameterByName('playClass');
- const requestData = { gameCode:Global.GameCode,playClass};
- const jsonRequestData = JSON.stringify(requestData);
- HttpManager.Instanct().httpPost(Global.Net_DetailUrl, jsonRequestData)
- .then(data => {
- console.log('responseData0:'+JSON.stringify(data));
- const jsonData=data as ResponseData;
- if(jsonData.success===true)
- {
- this.gameNameLabel.string=jsonData.data.gameName;
- this.gameDesnLabel.string=jsonData.data.desn
- this.videoPlayer.url=jsonData.data.gameVideoUrl;
- this.sortLabel.string=jsonData.data.gameType;
- this.bestRecord.string='最佳记录:'+jsonData.data.gameMaxScore;
- GameManager.getInstance().gameTotalTime= jsonData.data.gameTotalTime;
- GameManager.getInstance().gameTotalScore= parseInt(jsonData.data.gameTotalScore);
- //this.scheduleOnce(this.playDesnVideo,1);
- }else{
- console.log('请求失败');
- }
-
- })
- .catch(error => {
- console.error(error);
- });
- }
- //得到url参数值
- getParameterByName(name) {
- let url = window.location.href;
- name = name.replace(/[\[\]]/g, '\\$&');
- let regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
- results = regex.exec(url);
- if (!results) return null;
- if (!results[2]) return '';
- return decodeURIComponent(results[2].replace(/\+/g, ' '));
- }
- playDesnVideo()
- {
- // this.videoPlayer.play();
- }
- quitBtn()
- {
- GameManager.getInstance().saveDataToServer(0);
- let ss:any=window;
- if (typeof ss.AndroidInterface !== 'undefined') {
- ss.AndroidInterface.performAndroidMethod('finishActivity');
- } else {
- console.log('安卓方法未定义');
- }
- }
-
- setBestRecord(num:number)
- {
- this.bestRecord.string='最佳记录:'+num;
- }
- cancelBtn()
- {
- this.exitPanel.active=false;
- this.videoPlayer.node.active=true;
- }
- showExitPanel()
- {
- this.exitPanel.active=true;
- this.videoPlayer.node.active=false;
-
- }
- startGameBtn()
- {
-
- this.node.active=false;
- if(!Global.IsFirstGame)
- {
- this.countDownPanel.active=true;
- this.countDownAni.play('counDownAni');
- this.scheduleOnce(this.showGamePanel,3);
- this.startBtnLabel.string='继续游戏';
- }else{
- GameManager.getInstance().ContinueGame();
- }
- }
- showGamePanel()
- {
- this.countDownPanel.active=false;
- Global.IsFirstGame=true;
- GameManager.getInstance().EnterGameScene();
-
- }
-
- }
|