Commit 0f59b14e authored by unknown's avatar unknown

可以传出关卡数据的打包版

parent 86a9a25e
......@@ -23,17 +23,10 @@ export class ChallengeSuccView extends Component {
this.costTime = 0;
this.isClickOnce = false;
//把数据发给包裹游戏的容器
if(levelMgr.unLockCount >= levelMgr.getLevelCount(levelMgr.gameIdHead)) return;
// let sendOutData: GameEndDataItf = {
// gameId: levelMgr.gameIdHead * 100 + (),
// gameScore: this.curScore,
// gameEvaluation: this.getEvaluation(this.curScore),
// durTime: Math.floor(this.costTime * 1000),
// totalTime: Math.floor(this.costTime * 1000),
// finishRate: <number><any>(this.curScore / this.succScore).toFixed(4),
// type: "cocos_game"
// }
// htmlSendDataMgr.sendDataOut(JSON.stringify(sendOutData));
let sendOutData: GameEndDataItf = {
finishLevelCount: levelMgr.runLevel
}
htmlSendDataMgr.sendDataOut(JSON.stringify(sendOutData));
//************************** */
}
......
This diff is collapsed.
......@@ -6,13 +6,7 @@ import { viewMgr } from './common/ViewMgr';
const { ccclass, property } = _decorator;
export interface GameEndDataItf {
gameId: number, //游戏id
gameScore: number, //游戏分数
gameEvaluation: string, //评价
durTime: number, //游戏时间
totalTime: number, //游戏总时长
finishRate: number, //游戏完成率
type: string //
finishLevelCount: number
}
class HtmlSendDataMgr {
......
......@@ -75,7 +75,7 @@ export const levelCfg: OneVarLevelItf[] = [
comName: "SchulteCtr",
level: 6,
resData: {
totalTime: 40
totalTime: 400
}
}]
}
......
......@@ -28,8 +28,8 @@ export class LevelHomeCtr extends Component {
if(Utils.getValueFromHref("gameIdHead")){
levelMgr.gameIdHead = Number(Utils.getValueFromHref("gameIdHead"));
}
if(Utils.getValueFromHref("unLockCount")){
levelMgr.unLockCount = Number(Utils.getValueFromHref("unLockCount"));
if(Utils.getValueFromHref("finishLevelCount")){
levelMgr.unLockCount = Number(Utils.getValueFromHref("finishLevelCount")) + 1;
}
}
//
......
......@@ -6,82 +6,85 @@ const { ccclass, property } = _decorator;
class LevelMgr {
private constructor() {};
private constructor() { };
private static _instance: LevelMgr | null = null;
public static getInstance(){
if(!this._instance) this._instance = new LevelMgr();
public static getInstance() {
if (!this._instance) this._instance = new LevelMgr();
return this._instance;
}
//
public loadedOutData = false;
private _gameIdHead = 10;
public set gameIdHead(value: number){
public set gameIdHead(value: number) {
this._gameIdHead = value;
}
public get gameIdHead(){
return this._gameIdHead;
public get gameIdHead() {
return this._gameIdHead;
}
private _unLockCount = 1;
public set unLockCount(value: number){
if(value > this.getLevelCount(this._gameIdHead)) return;
public set unLockCount(value: number) {
if (value > this.getLevelCount(this._gameIdHead)) {
this._unLockCount = this.getLevelCount(this._gameIdHead) + 1;
return;
}
this._unLockCount = value;
}
public get unLockCount(){
return this._unLockCount;
public get unLockCount() {
return this._unLockCount;
}
private _runLevel = 1;
public set runLevel(value: number){
if(value > this.getLevelCount(this._gameIdHead)) return;
public set runLevel(value: number) {
if (value > this.getLevelCount(this._gameIdHead)) return;
this._runLevel = value;
}
public get runLevel(){
return this._runLevel;
public get runLevel() {
return this._runLevel;
}
public getLevelCount(gameIdHead: number){
for(let i = 0; i < levelCfg.length; ++ i){
if(levelCfg[i].gameIdHead == gameIdHead) return levelCfg[i].levelArr.length;
public getLevelCount(gameIdHead: number) {
for (let i = 0; i < levelCfg.length; ++i) {
if (levelCfg[i].gameIdHead == gameIdHead) return levelCfg[i].levelArr.length;
}
return 0;
}
public getLevelItfArr(gameIdHead: number){
for(let i = 0; i < levelCfg.length; ++ i){
if(levelCfg[i].gameIdHead == gameIdHead) return levelCfg[i].levelArr;
public getLevelItfArr(gameIdHead: number) {
for (let i = 0; i < levelCfg.length; ++i) {
if (levelCfg[i].gameIdHead == gameIdHead) return levelCfg[i].levelArr;
}
return [];
}
public getGameTitle(gameIdHead: number){
for(let i = 0; i < levelCfg.length; ++ i){
if(levelCfg[i].gameIdHead == gameIdHead) return levelCfg[i].title;
public getGameTitle(gameIdHead: number) {
for (let i = 0; i < levelCfg.length; ++i) {
if (levelCfg[i].gameIdHead == gameIdHead) return levelCfg[i].title;
}
return "未知游戏";
}
public backLevelHome(){
public backLevelHome() {
director.loadScene("LevelScene", () => {
});
}
public loadLevel(){
public loadLevel() {
let levelArr: OneLevelUnitItf[] = [];
for(let i = 0; i < levelCfg.length; ++ i){
if(levelCfg[i].gameIdHead == this._gameIdHead) {
for (let i = 0; i < levelCfg.length; ++i) {
if (levelCfg[i].gameIdHead == this._gameIdHead) {
levelArr = levelCfg[i].levelArr;
break;
}
}
let gameId = this._gameIdHead * 100 + this._runLevel;
console.log(`加载关卡`, gameId, this._runLevel);
for(let i = 0; i < levelArr.length; ++ i){
if(levelArr[i].gameId == gameId) {
for (let i = 0; i < levelArr.length; ++i) {
if (levelArr[i].gameId == gameId) {
sceneMgr.openScene(levelArr[i].sceneUnitIfo, (scene) => {
//@ts-ignore
find("Canvas")?.getComponent(levelArr[i].comName)?.setGameData(levelArr[i].resData);
......@@ -92,4 +95,4 @@ class LevelMgr {
}
}
export const levelMgr: LevelMgr = LevelMgr.getInstance();
export const levelMgr: LevelMgr = LevelMgr.getInstance();
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment