Commit d3dcdb90 authored by 任建锋's avatar 任建锋

rjf

parent 212389d9
{
"name": "sl",
"version": "1.0.9",
"description": "基于babylonjs的活动组件",
"main": "./dist/index.js",
"types": "./types/index.d.ts",
"scripts": {
},
"author": "",
"license": "ISC",
"dependencies": {
"duiba-yt": "git+ssh://git@gitlab2.dui88.com:renjianfeng/yt.git",
"duiba-tw": "git+ssh://git@gitlab2.dui88.com:clq/tw.git#1.0",
"duiba-tc": "git+ssh://git@gitlab2.dui88.com:clq/tc.git#1.0"
}
}
\ No newline at end of file
import {YtModule} from "duiba-yt";
import {YtSceneManager} from "duiba-yt";
import {YtModuleManager} from "duiba-yt";
import {YtModuleName} from "duiba-yt";
import {YtLang} from "duiba-yt";
import {SlModuleName} from "../../enum/SlModuleName";
import { GamePlayModel } from "duiba-tw";
export class SlGameSceneModule extends YtModule{
/**
* 是否校验积分
*/
protected checkScore: boolean;
/**
* 数据
*/
protected model: GamePlayModel;
protected initModel(): void {
this.model = new GamePlayModel();
}
/**
* 扩展数据
* */
protected other: any;
protected score=0;
//销毁
public dispose(){
var j;
for(j in this.display){
console.log(this.display[j])
if( this.display[j]){
this.display[j].dispose()
}
}
}
public show(){
this.resetGame()
YtSceneManager.ins.change(this.display);
}
protected resetGame(){
this.model.update();
}
protected gameOver(): void {
this.removeEvent();
//将最高纪录缓存
this.enableMouseEvt(false);
this.removeEvent();
this.model.cacheMaxScore(this.score);
this.model.submit(this.submit_result.bind(this), this.score);
}
/**
* 更新游戏积分
* @param type 1 增加, 2 简少, 3重置
* @param score 分值
*/
protected updateScore(type: number, score: number): void {
if (type == 1) {
this.score += score;
} else if (type == 2) {
this.score -= score;
this.score = Math.max(0, this.score);
} else {
this.score = score;
}
this.datapash();
}
/**
* 阶段性提交
*/
protected datapash(): void {
if (this.model.checkDatapash(this.score)) {
this.model.datapash();
}
}
protected submit_result(): void {
let moduleName: string;
if (this.model.gameIsWinning) {
moduleName = SlModuleName.GAME_WIN_PANEL;
} else {
moduleName = SlModuleName.GAME_LOSE_PANEL;
}
YtModuleManager.ins.openModule(moduleName);
this.enableMouseEvt(true);
}
/**
* 导入外部网格
* @param importMeshes 网格资源列表
* @param onSuccess 成功回调
*/
protected ImportMeshes(importMeshes,onSuccess){
var _length=importMeshes.length;
var _meshes=[]
var _skeletons=[]
var _loadCount=0;
importMeshes.forEach((list)=>{
BABYLON.SceneLoader.ImportMesh(
"",
list.rootUrl,
list.sceneFilename,
YtSceneManager.ins.scene,
(_mesh,_skeleton)=> {
try {
_meshes.push(_mesh)
_skeletons.push(_skeleton)
_loadCount++
if(_loadCount==_length){
onSuccess(_meshes,_skeletons)
}
} catch (e) {
console.error(e)
}
}
);
})
}
}
\ No newline at end of file
...@@ -36,8 +36,8 @@ var SlGameSceneModule = /** @class */ (function (_super) { ...@@ -36,8 +36,8 @@ var SlGameSceneModule = /** @class */ (function (_super) {
} }
}; };
SlGameSceneModule.prototype.show = function () { SlGameSceneModule.prototype.show = function () {
duiba_yt_2.YtSceneManager.ins.change(this.display);
this.resetGame(); this.resetGame();
duiba_yt_2.YtSceneManager.ins.change(this.display);
}; };
SlGameSceneModule.prototype.resetGame = function () { SlGameSceneModule.prototype.resetGame = function () {
this.model.update(); this.model.update();
......
{"version":3,"file":"SlGameSceneModule.js","sourceRoot":"","sources":["../../../src/module/game/SlGameSceneModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAkC;AAClC,qCAAwC;AACxC,qCAAyC;AAGzC,wDAAqD;AACrD,qCAAyC;AAEzC;IAAuC,qCAAQ;IAA/C;QAAA,qEA0HC;QArGa,WAAK,GAAC,CAAC,CAAC;;IAqGtB,CAAC;IA/Ga,qCAAS,GAAnB;QACI,IAAI,CAAC,KAAK,GAAG,IAAI,wBAAa,EAAE,CAAC;IACrC,CAAC;IAUD,IAAI;IACG,mCAAO,GAAd;QACI,IAAI,CAAC,CAAC;QACN,KAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAC;YAClB,OAAO,CAAC,GAAG,CAAC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AAI,UAAU,GAAC,CAAC,CAAC;QACjB,YAAY,CAAC,OAAO,CAAC,UAAC,IAAI;YACtB,OAAO,CAAC,WAAW,CAAC,UAAU,CAC1B,EAAE,EACF,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,aAAa,EAClB,yBAAc,CAAC,GAAG,CAAC,KAAK,EACxB,UAAC,KAAK,EAAC,SAAS;gBACZ,IAAI;oBACA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;oBACnB,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;oBAC1B,UAAU,EAAE,CAAA;oBACZ,IAAG,UAAU,IAAE,OAAO,EAAC;wBACnB,SAAS,CAAC,OAAO,EAAC,UAAU,CAAC,CAAA;qBAChC;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACR,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;iBACnB;YACL,CAAC,CACJ,CAAC;QACN,CAAC,CAAC,CAAA;IACN,CAAC;IAEL,wBAAC;AAAD,CAAC,AA1HD,CAAuC,mBAAQ,GA0H9C;AA1HY,8CAAiB"}
\ No newline at end of file \ No newline at end of file
{ {
"name": "sl", "name": "sl",
"version": "1.0.8", "version": "1.0.9",
"description": "基于babylonjs的活动组件", "description": "基于babylonjs的活动组件",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
......
...@@ -41,8 +41,8 @@ export class SlGameSceneModule extends YtModule{ ...@@ -41,8 +41,8 @@ export class SlGameSceneModule extends YtModule{
} }
public show(){ public show(){
YtSceneManager.ins.change(this.display);
this.resetGame() this.resetGame()
YtSceneManager.ins.change(this.display);
} }
protected resetGame(){ protected resetGame(){
......
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