import { GameUIScene } from './GameUIScene'; import { GameUIObject } from './GameUIObject'; export class Project { static sourceRelativePath: string = "runtime/resource"; static rootRelativePath: string = "runtime"; static projectExtentionName: string = "/project.lsp"; name: string; screenWidth: number = 1708; screenHeight: number = 960; nativePath: string; basePath: string; fps: number = 60; showfps: boolean = true; version: string = "0.1.0"; backgroundColor: number = 0; orientation: number = 0; renderMode: number = 0; plugins: any = {}; uiScenes: GameUIScene[] = []; currentSceneName: string = "scene1"; currentScene: els.Scene; /** * 根据场景名获取场景配置数据 * @sceneName 场景名 */ getGameUIScene(sceneName: string):GameUIScene { if (!sceneName || !this.uiScenes) return null; for (let i: number = 0, l: number = this.uiScenes.length; i < l; i++){ let scene: GameUIScene = this.uiScenes[i]; if (scene.name === sceneName) return scene; } return null; } get maxUID() { let list: number[] = []; this._maxUID(list); list.sort((a, b) => { if (a > b) return -1; else if (a < b) return 1; return 0; }) if(list.length>0) return list[0]; return 0; } private _maxUID(list:number[]) { for (let i: number = 0, l: number = this.uiScenes.length; i < l; i++){ let scene: GameUIScene = this.uiScenes[i]; let gameobjects: GameUIObject[] = scene.children; for (let j: number = 0, jl: number = gameobjects.length; j < jl; j++){ this.__maxUID(gameobjects[j], list); } } } private __maxUID(uiGameobject:GameUIObject,list:number[]){ list.push(uiGameobject.UID); if (uiGameobject.children) { for (let i: number = 0, l: number = uiGameobject.children.length; i < l; i++){ this.__maxUID(uiGameobject.children[i], list); } } } }