123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- (function () {
- 'use strict';
- class GameConfig {
- constructor() { }
- static init() {
- var reg = Laya.ClassUtils.regClass;
- }
- }
- GameConfig.width = 640;
- GameConfig.height = 1136;
- GameConfig.scaleMode = "fixedwidth";
- GameConfig.screenMode = "none";
- GameConfig.alignV = "top";
- GameConfig.alignH = "left";
- GameConfig.startScene = "";
- GameConfig.sceneRoot = "";
- GameConfig.debug = false;
- GameConfig.stat = false;
- GameConfig.physicsDebug = false;
- GameConfig.exportSceneToJson = true;
- GameConfig.init();
- class ResDic {
- constructor() {
- this._container = {};
- this._length = 0;
- }
- get container() {
- return this._container;
- }
- get size() {
- return this._length;
- }
- set(key, value) {
- if (!this._container.hasOwnProperty(key)) {
- this._length++;
- }
- this._container[key] = value;
- }
- has(key) {
- return this._container.hasOwnProperty(key) ? true : false;
- }
- get(key) {
- if (this._container.hasOwnProperty(key)) {
- return this._container[key];
- }
- else {
- return undefined;
- }
- }
- delete(key) {
- if (this._container.hasOwnProperty(key)) {
- delete this._container[key];
- this._length--;
- }
- }
- clear() {
- this._container = {};
- this._length = 0;
- }
- }
- class AssetManager {
- constructor() {
- this.Zombie = new ResDic();
- this.Police = new ResDic();
- this.People = new ResDic();
- AssetManager.ins = this;
- }
- static get Instance() {
- if (AssetManager.ins) {
- return AssetManager.ins;
- }
- else {
- return new AssetManager();
- }
- }
- Init() {
- Laya.stage.addChild(this.mainscene);
- this.maincamera = this.mainscene.getChildByName("MainCamera");
- }
- }
- class ResourcesPath {
- constructor() {
- ResourcesPath.ins = this;
- }
- static get Instance() {
- if (ResourcesPath.ins) {
- return ResourcesPath.ins;
- }
- else {
- return new ResourcesPath();
- }
- }
- }
- ResourcesPath.MainScene = "Game/res/MainScene/LayaScene_mainscene/Conventional/mainscene.ls";
- ResourcesPath.People = [
- "Game/res/Role/LayaScene_mainscene/Conventional/role1.lh",
- "Game/res/Role/LayaScene_mainscene/Conventional/role2.lh",
- "Game/res/Role/LayaScene_mainscene/Conventional/role3.lh"
- ];
- ResourcesPath.Police = "Game/res/Role/LayaScene_mainscene/Conventional/police.lh";
- ResourcesPath.Zombie = "Game/res/Role/LayaScene_mainscene/Conventional/Zombie.lh";
- var DispatcherState;
- (function (DispatcherState) {
- DispatcherState[DispatcherState["LoadComplete"] = 0] = "LoadComplete";
- DispatcherState[DispatcherState["SceneInit"] = 1] = "SceneInit";
- DispatcherState[DispatcherState["StageInit"] = 2] = "StageInit";
- DispatcherState[DispatcherState["StageCreateComplete"] = 3] = "StageCreateComplete";
- DispatcherState[DispatcherState["GoldGet"] = 4] = "GoldGet";
- DispatcherState[DispatcherState["PlayerRunning"] = 5] = "PlayerRunning";
- DispatcherState[DispatcherState["PlayerStand"] = 6] = "PlayerStand";
- DispatcherState[DispatcherState["ShowModel"] = 7] = "ShowModel";
- DispatcherState[DispatcherState["RefreshCityName"] = 8] = "RefreshCityName";
- })(DispatcherState || (DispatcherState = {}));
- class DispatcherControl {
- static DispatcherOn(_mode, caller, fun, args = []) {
- DispatcherControl.instance.on(DispatcherState[_mode], caller, fun, args);
- }
- static DispatcherOff(_mode, caller, fun, args = []) {
- DispatcherControl.instance.off(DispatcherState[_mode], caller, fun);
- }
- static DispatcherTrigger(_mode, args = []) {
- DispatcherControl.instance.event(DispatcherState[_mode], args);
- }
- }
- DispatcherControl.instance = new Laya.EventDispatcher();
- class CameraControl {
- constructor() {
- CameraControl.ins = this;
- DispatcherControl.DispatcherOn(DispatcherState.LoadComplete, this, this.Init);
- }
- static get Instance() {
- if (CameraControl.ins) {
- return CameraControl.ins;
- }
- else {
- return new CameraControl();
- }
- }
- Init() {
- this.maincamera = LoadView.Instance.maincamera;
- this.maincamera.transform.position = new Laya.Vector3(19.5, 100, 16.7);
- }
- }
- class LoadView {
- constructor() {
- LoadView.ins = this;
- new CameraControl();
- this.Init();
- }
- static get Instance() {
- if (LoadView.ins) {
- return LoadView.ins;
- }
- else {
- return new LoadView();
- }
- }
- Init() {
- this.LoadScene();
- }
- LoadScene() {
- Laya.Scene3D.load(ResourcesPath.MainScene, Laya.Handler.create(this, (scene) => {
- this.mainscene = scene;
- this.maincamera = this.mainscene.getChildByName("Main Camera");
- console.log(this.maincamera);
- Laya.stage.addChild(this.mainscene);
- console.log("场景加载完毕--");
- this.LoadZombie();
- }));
- }
- LoadZombie() {
- Laya.loader.create(ResourcesPath.Zombie, Laya.Handler.create(this, (zombie) => {
- AssetManager.Instance.Zombie.set(1, zombie);
- }));
- console.log("僵尸模型加载完毕--");
- this.LoadPolice();
- }
- LoadPolice() {
- Laya.loader.create(ResourcesPath.Police, Laya.Handler.create(this, (police) => {
- AssetManager.Instance.Police.set(1, police);
- console.log("警察模型加载完毕--");
- this.LoadPeople();
- }));
- }
- LoadPeople() {
- var path = [];
- for (let i = 0; i < ResourcesPath.People.length; i++) {
- path.push(ResourcesPath.People[i]);
- }
- Laya.loader.create(path, Laya.Handler.create(this, () => {
- for (var i = 0; i < ResourcesPath.People.length; i++) {
- var people = Laya.loader.getRes(ResourcesPath.People[i]);
- AssetManager.Instance.People.set(i + 1, people);
- Laya.loader.clearRes(ResourcesPath.People[i]);
- }
- console.log("平民模型加载完毕--");
- DispatcherControl.DispatcherTrigger(DispatcherState.LoadComplete);
- }));
- }
- }
- class CheckMain {
- }
- CheckMain.Create = false;
- class Main {
- constructor() {
- if (CheckMain.Create)
- return;
- CheckMain.Create = true;
- if (window["Laya3D"])
- Laya3D.init(GameConfig.width, GameConfig.height);
- else
- Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
- Laya["Physics"] && Laya["Physics"].enable();
- Laya["DebugPanel"] && Laya["DebugPanel"].enable();
- Laya.stage.scaleMode = GameConfig.scaleMode;
- Laya.stage.screenMode = GameConfig.screenMode;
- Laya.stage.alignV = GameConfig.alignV;
- Laya.stage.alignH = GameConfig.alignH;
- Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
- if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
- Laya.enableDebugPanel();
- if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
- Laya["PhysicsDebugDraw"].enable();
- if (GameConfig.stat)
- Laya.Stat.show();
- Laya.alertGlobalError = true;
- Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
- }
- onVersionLoaded() {
- Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
- }
- onConfigLoaded() {
- new LoadView();
- }
- }
- new Main();
- }());
- //# sourceMappingURL=bundle.js.map
|