123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730 |
- (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;
- }
- }
- var EventState;
- (function (EventState) {
- EventState[EventState["LoadComplete"] = 0] = "LoadComplete";
- EventState[EventState["SceneInit"] = 1] = "SceneInit";
- EventState[EventState["StageInit"] = 2] = "StageInit";
- EventState[EventState["StageCreateComplete"] = 3] = "StageCreateComplete";
- EventState[EventState["AnimatorEnd"] = 4] = "AnimatorEnd";
- })(EventState || (EventState = {}));
- var StageState;
- (function (StageState) {
- StageState[StageState["Win"] = 0] = "Win";
- StageState[StageState["Lose"] = 1] = "Lose";
- StageState[StageState["Start"] = 2] = "Start";
- StageState[StageState["StageCreateComPlete"] = 3] = "StageCreateComPlete";
- StageState[StageState["Over"] = 4] = "Over";
- })(StageState || (StageState = {}));
- class EventManager {
- static EventOn(_mode, caller, fun, args = []) {
- EventManager.instance.on(EventState[_mode], caller, fun, args);
- }
- static EventOff(_mode, caller, fun, args = []) {
- EventManager.instance.off(EventState[_mode], caller, fun);
- }
- static EventTrigger(_mode, args = []) {
- EventManager.instance.event(EventState[_mode], args);
- }
- static StageOn(_mode, caller, fun, args = []) {
- EventManager.instance.on(StageState[_mode], caller, fun, args);
- }
- static StageOff(_mode, caller, fun, args = []) {
- EventManager.instance.off(StageState[_mode], caller, fun);
- }
- static StageTrigger(_mode, args = []) {
- EventManager.instance.event(StageState[_mode], args);
- }
- }
- EventManager.instance = new Laya.EventDispatcher();
- class GameTools {
- constructor() {
- GameTools.ins = this;
- }
- static get Instance() {
- if (GameTools.ins) {
- return GameTools.ins;
- }
- else {
- return new GameTools();
- }
- }
- lerp(form, to, t) {
- if (t <= 0) {
- return form;
- }
- else if (t >= 1) {
- return to;
- }
- var a = t * to + (1 - t) * form;
- return a;
- }
- SetCollider(setNode, CollisionGroup) {
- var numchild = setNode.numChildren;
- for (var i = 0; i < setNode.numChildren; i++) {
- var numchild2 = setNode.getChildAt(i).numChildren;
- if (numchild2 > 1) {
- this.SetCollider(setNode.getChildAt(i), CollisionGroup);
- }
- var physicsCollider = setNode.getChildAt(i).getComponent(Laya.PhysicsCollider);
- if (physicsCollider) {
- physicsCollider.collisionGroup = CollisionGroup;
- }
- }
- }
- static RandomNumber(from, to) {
- if (from >= to) {
- return 0;
- }
- var size = to - from;
- var curNumber = Math.random() * size + from;
- return curNumber;
- }
- static RandomANumber(from, to) {
- if (from >= to) {
- return 0;
- }
- var size = to - from;
- var curNumber = Math.random() * size + from;
- return Math.floor(curNumber);
- }
- static GetMoney(_num, _pos = null, _completeHandle = null) {
- if (_num == 0)
- return;
- var fafaafsfa = new Laya.Box;
- fafaafsfa.width = 400;
- fafaafsfa.height = 100;
- fafaafsfa.pivotX = fafaafsfa.width / 2;
- fafaafsfa.pivotY = fafaafsfa.height / 2;
- if (_pos == null) {
- _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2);
- }
- fafaafsfa.pos(_pos.x, _pos.y);
- var aafafaffa = new Laya.Image;
- aafafaffa.skin = "game/qiandao_1_7.png";
- aafafaffa.width = 60;
- aafafaffa.height = 60;
- aafafaffa.left = 50;
- aafafaffa.y = 10;
- fafaafsfa.addChild(aafafaffa);
- var faasfafsafs = new Laya.Text;
- faasfafsafs.width = 300;
- faasfafsafs.height = 50;
- faasfafsafs.align = "center";
- faasfafsafs.valign = "middle";
- faasfafsafs.font = "Microsoft YaHei";
- faasfafsafs.fontSize = 40;
- faasfafsafs.color = "#FFFFFF";
- faasfafsafs.bold = true;
- faasfafsafs.font = "Microsoft YaHei";
- faasfafsafs.text = "金币 +" + _num;
- faasfafsafs.x = 60;
- faasfafsafs.y = 10;
- fafaafsfa.addChild(faasfafsafs);
- Laya.stage.addChild(fafaafsfa);
- var faasfsaf = Laya.Tween.to(fafaafsfa, { y: fafaafsfa.y - 200 }, 1500, Laya.Ease.expoInOut, Laya.Handler.create(this, () => {
- faasfsaf.clear();
- fafaafsfa.destroy();
- if (_completeHandle) {
- _completeHandle.run();
- }
- }), 100);
- }
- static TweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
- var afasafsafsfa = new Laya.Text();
- afasafsafsfa.width = faafssfafsa.size.x;
- afasafsafsfa.height = faafssfafsa.size.y;
- afasafsafsfa.align = "center";
- afasafsafsfa.valign = "middle";
- afasafsafsfa.font = "Microsoft YaHei";
- afasafsafsfa.fontSize = faafssfafsa.fontSize;
- afasafsafsfa.pivotX = afasafsafsfa.width / 2;
- afasafsafsfa.pivotY = afasafsafsfa.height / 2;
- afasafsafsfa.color = "#5ad122";
- afasafsafsfa.bold = true;
- afasafsafsfa.stroke = 5;
- afasafsafsfa.strokeColor = "#ffffff";
- if (faafssfafsa.color) {
- faafssfafsa.color = faafssfafsa.color;
- }
- afasafsafsfa.text = faafssfafsa.message;
- afasafsafsfa.zOrder = 1;
- Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
- afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
- var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
- }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
- tween.clear();
- if (hide) {
- afasafsafsfa.destroy();
- }
- if (_completeHandle) {
- _completeHandle.run();
- }
- }));
- if (hide) {
- Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 500);
- }
- return afasafsafsfa;
- }
- static StationTweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
- var afasafsafsfa = new Laya.Text();
- afasafsafsfa.width = faafssfafsa.size.x;
- afasafsafsfa.height = faafssfafsa.size.y;
- afasafsafsfa.align = "center";
- afasafsafsfa.valign = "middle";
- afasafsafsfa.font = "Microsoft YaHei";
- afasafsafsfa.fontSize = 50;
- afasafsafsfa.pivotX = afasafsafsfa.width / 2;
- afasafsafsfa.pivotY = afasafsafsfa.height / 2;
- afasafsafsfa.color = "#5ad122";
- afasafsafsfa.bold = true;
- afasafsafsfa.stroke = 5;
- afasafsafsfa.strokeColor = "#ffffff";
- if (faafssfafsa.color) {
- faafssfafsa.color = faafssfafsa.color;
- }
- afasafsafsfa.text = faafssfafsa.message;
- afasafsafsfa.zOrder = 1;
- Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
- afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
- var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
- }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
- tween.clear();
- if (hide) {
- afasafsafsfa.destroy();
- }
- if (_completeHandle) {
- _completeHandle.run();
- }
- }));
- if (hide) {
- Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 10000);
- }
- return afasafsafsfa;
- }
- static tweenMove(transform, targPos, delay, ease, complete) {
- let curPos = transform.position.clone();
- return Laya.Tween.to(curPos, {
- x: targPos.x,
- y: targPos.y,
- z: targPos.z,
- update: new Laya.Handler(this, () => {
- transform.position = curPos.clone();
- })
- }, delay, ease, complete);
- }
- static tweenRotate(transform, targEuler, delay, ease, complete) {
- let curEuler = transform.rotationEuler.clone();
- return Laya.Tween.to(curEuler, {
- x: targEuler.x,
- y: targEuler.y,
- z: targEuler.z,
- update: new Laya.Handler(this, () => {
- transform.rotationEuler = curEuler.clone();
- })
- }, delay, ease, complete);
- }
- }
- class AssetManager {
- constructor() {
- this.Player = new ResDic();
- this.Enemy = new ResDic();
- this.Horse = new ResDic();
- this.Prop = new ResDic();
- AssetManager.ins = this;
- EventManager.EventOn(EventState.LoadComplete, this, this.Init);
- }
- static get Instance() {
- if (AssetManager.ins) {
- return AssetManager.ins;
- }
- else {
- return new AssetManager();
- }
- }
- Init() {
- this.maincamera = this.mainscene.getChildByName("Main Camera");
- this.Plane = this.mainscene.getChildByName("Plane");
- GameTools.Instance.SetCollider(this.Plane, 100);
- EventManager.EventTrigger(EventState.SceneInit);
- }
- }
- class ResourcesPath {
- }
- ResourcesPath.MainScene = "Game/res/MainScene/LayaScene_Mainscene/Conventional/Mainscene.ls";
- ResourcesPath.Horse = [
- "Game/res/Role/LayaScene_Role/Conventional/Horse.lh"
- ];
- ResourcesPath.Player = [
- "Game/res/Role/LayaScene_Role/Conventional/player.lh"
- ];
- ResourcesPath.Enemy = [
- "Game/res/Role/LayaScene_Role/Conventional/enemy.lh"
- ];
- var Sprite3D = Laya.Sprite3D;
- var Vector3 = Laya.Vector3;
- class modelConfig {
- constructor(model) {
- this.modelcur = model;
- this.modelPos = model.transform.position.clone();
- this.modelRot = model.transform.rotation.clone();
- this.modelSca = model.transform.scale.clone();
- }
- }
- class GamePool {
- constructor() {
- this.modelpool = {};
- this.maxAcount = 30;
- GamePool.Ins = this;
- }
- static get Instance() {
- if (GamePool.Ins) {
- return GamePool.Ins;
- }
- else {
- return new GamePool();
- }
- }
- GetModel(_model, title) {
- var poolname = title + _model.name;
- if (this.modelpool[poolname] != null && this.modelpool[poolname] != undefined) {
- if (this.modelpool[poolname].length > 0) {
- var model1 = this.modelpool[poolname][0];
- this.modelpool[poolname].splice(0, 1);
- if (model1.modelcur.destroyed) {
- model1.modelcur = Sprite3D.instantiate(_model);
- if (!model1.modelcur.active) {
- model1.modelcur.active = true;
- }
- }
- model1.modelcur.active = true;
- model1.modelcur.transform.position = _model.transform.position.clone();
- model1.modelcur.transform.rotation = _model.transform.rotation.clone();
- model1.modelcur.transform.scale = _model.transform.scale.clone();
- return model1.modelcur;
- }
- else {
- var model = Sprite3D.instantiate(_model);
- model.active = true;
- return model;
- }
- }
- else {
- var model = Sprite3D.instantiate(_model);
- model.active = true;
- return model;
- }
- }
- RecoveryModel(model, title = "", modelstate = false) {
- if (model.destroyed) {
- return;
- }
- if (!modelstate && model.active == false) {
- return;
- }
- var poolname = title + model.name;
- if (this.modelpool[poolname] != null && this.modelpool[poolname] != undefined) {
- var modelnum = this.modelpool[poolname];
- if (modelnum.length > this.maxAcount) {
- model.destroy();
- return;
- }
- else {
- modelnum.push(new modelConfig(model));
- }
- }
- else {
- modelnum = [];
- modelnum.push(new modelConfig(model));
- this.modelpool[poolname] = modelnum;
- }
- model.transform.position = new Vector3(0, 0, -10000);
- model.removeSelf();
- model.active = false;
- }
- ResetsModelPool() {
- for (var Key in this.modelpool) {
- var model = this.modelpool[Key];
- for (var i = 0; i < model.length; i++) {
- model[i].modelcur.destroy();
- }
- }
- this.modelpool = {};
- }
- }
- var Vector3$1 = Laya.Vector3;
- class Runner extends Laya.Script3D {
- constructor() {
- super();
- this.currotV = new Vector3$1();
- this.currot = new Laya.Quaternion;
- this.NormalizeSpeed = new Vector3$1();
- this.turndir = new Vector3$1(1, 0, 0);
- }
- static get Instance() {
- if (Runner.ins) {
- return Runner.ins;
- }
- else {
- return new Runner();
- }
- }
- onAwake() {
- this.m_player = this.owner;
- }
- onUpdate() {
- }
- MoveX(_speed) {
- _speed *= 0.07;
- this.m_player.transform.translate(new Vector3$1(_speed, 0, 0));
- this.m_player.transform.position = this.m_player.transform.position.x < -4.5 ? new Vector3$1(-4.5, this.m_player.transform.position.y, this.m_player.transform.position.z) : this.m_player.transform.position;
- this.m_player.transform.position = this.m_player.transform.position.x > 4.5 ? new Vector3$1(4.5, this.m_player.transform.position.y, this.m_player.transform.position.z) : this.m_player.transform.position;
- }
- TurnDir(_dir) {
- if (_dir.x != 0) {
- Vector3$1.lerp(this.currotV, _dir, 0.35, _dir);
- this.currotV = _dir;
- Laya.Quaternion.rotationLookAt(_dir, new Vector3$1(0, 1, 0), this.currot);
- Laya.Quaternion.slerp(this.m_player.transform.rotation, this.currot, 0.025, this.currot);
- this.currot = new Laya.Quaternion(0, this.currot.y, 0);
- this.m_player.transform.rotation = this.currot;
- }
- else {
- Laya.Quaternion.slerp(this.m_player.transform.rotation, new Laya.Quaternion(0, 0, 0, 0), 0.1, this.currot);
- this.currot = new Laya.Quaternion(0, this.currot.y, 0);
- this.m_player.transform.rotation = this.currot;
- }
- }
- }
- var Vector2 = Laya.Vector2;
- var Vector3$2 = Laya.Vector3;
- class PlayerControl {
- constructor() {
- this.DownHit = new Laya.HitResult();
- this.canmove = true;
- this.speed = 1;
- this.press = false;
- this.offset = new Vector3$2(0, 0, 0);
- this.offestx = 0;
- this.poschazhi = new Vector3$2();
- this.gengsuipos = new Vector3$2();
- this.lllpos = new Vector3$2();
- this.hights = 0;
- this.wights = 0;
- this.rolepos = new Vector3$2;
- this.rundir = new Vector3$2;
- this.curspeed = 0;
- PlayerControl.ins = this;
- }
- static get Instance() {
- if (PlayerControl.ins) {
- return PlayerControl.ins;
- }
- else {
- return new PlayerControl();
- }
- }
- Init(_player) {
- this.Player = _player;
- this._runner = this.Player.addComponent(Runner);
- this.Player.transform.position = new Vector3$2();
- this.Camera = AssetManager.Instance.maincamera;
- this.Camera.transform.position = new Vector3$2(0, 10, -10);
- this.Camera.transform.localRotationEuler = new Vector3$2(-5, 0, 0);
- Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
- Laya.timer.frameLoop(1, this, this.LateUpdate);
- this.CameraFollow();
- }
- MouseListen() {
- }
- onMouseDown(e) {
- this.startMousePos = new Vector3$2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
- var startpoint = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
- this.curMousePos1 = startpoint.clone();
- Laya.timer.frameLoop(1, this, this.onMouseMove);
- Laya.stage.on(Laya.Event.MOUSE_UP, this, this.onMouseUp);
- Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
- }
- onMouseMove() {
- var MousePos = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
- var offestX = MousePos.x - this.curMousePos1.x;
- offestX = offestX > 100 ? 100 : offestX;
- offestX = offestX < -100 ? -100 : offestX;
- this.offestx = GameTools.Instance.lerp(this.offestx, offestX, 0.015);
- this._runner.MoveX(-this.offestx);
- var dir = new Vector3$2(-offestX * 0.005, 0, 0);
- this._runner.TurnDir(dir);
- this.curMousePos1 = new Vector2(MousePos.x, MousePos.y);
- }
- onMouseUp() {
- this.offestx = 0;
- Laya.timer.clear(this, this.onMouseMove);
- }
- CameraFollow() {
- this.hights = 0;
- this.wights = 0;
- Vector3$2.subtract(this.Player.transform.position, this.Camera.transform.position, this.poschazhi);
- Laya.timer.frameLoop(1, this, this.GenSui);
- }
- GenSui() {
- Vector3$2.subtract(this.Player.transform.position, this.poschazhi, this.gengsuipos);
- this.hights = GameTools.Instance.lerp(this.hights, 1.0, 0.03);
- this.wights = GameTools.Instance.lerp(this.wights, 0.8, 0.02);
- this.gengsuipos = new Vector3$2(this.gengsuipos.x, this.gengsuipos.y, this.gengsuipos.z - this.wights);
- Vector3$2.lerp(this.Camera.transform.position, this.gengsuipos, 0.25, this.lllpos);
- this.lllpos = new Vector3$2(this.gengsuipos.x, this.gengsuipos.y, this.lllpos.z);
- this.lllpos = new Vector3$2(this.gengsuipos.x, this.lllpos.y, this.lllpos.z);
- this.Camera.transform.position = this.lllpos;
- var qqqwe = new Laya.Quaternion();
- var eyePos = new Vector3$2(this.gengsuipos.x, this.gengsuipos.y - 0.8, this.gengsuipos.z);
- Laya.Quaternion.lookAt(eyePos, this.Player.transform.position, new Vector3$2(0, 1, 0), qqqwe);
- qqqwe.invert(qqqwe);
- Laya.Quaternion.slerp(this.Camera.transform.rotation, qqqwe, 0.1, qqqwe);
- this.Camera.transform.rotation = qqqwe;
- }
- get DownRayCheck() {
- var isDownHit = false;
- var startPos = new Vector3$2(this.Player.transform.position.x, this.Player.transform.position.y + 1.5, this.Player.transform.position.z + 0.5);
- var direction = new Vector3$2(0, -1, 0);
- var DownRay = new Laya.Ray(startPos, direction);
- if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.DownHit, 100)) {
- if (this.DownHit.collider.collisionGroup == 100) {
- isDownHit = true;
- }
- }
- return isDownHit;
- }
- Move() {
- if (this.canmove) {
- this.speed = this.press ? 1 : 0.5;
- this.curspeed = GameTools.Instance.lerp(this.curspeed, this.speed, 0.04);
- Vector3$2.scale(new Vector3$2(0, 0, 1), this.curspeed, this.rundir);
- Vector3$2.add(this.Player.transform.position, this.rundir, this.rolepos);
- Vector3$2.lerp(this.Player.transform.position, this.rolepos, 0.15, this.rolepos);
- this.Player.transform.position = this.rolepos;
- }
- }
- RayCheck() {
- if (this.DownRayCheck) {
- this.Player.transform.position = new Laya.Vector3(this.Player.transform.position.x, this.DownHit.point.y, this.Player.transform.position.z);
- }
- }
- LateUpdate() {
- }
- }
- class GameManager {
- constructor() {
- this.EnemyArray = [];
- GameManager.ins = this;
- EventManager.EventOn(EventState.SceneInit, this, this.Init);
- }
- static get Instance() {
- if (GameManager.ins) {
- return GameManager.ins;
- }
- else {
- return new GameManager();
- }
- }
- Init() {
- this.CreatCharacter();
- this.mainscene = AssetManager.Instance.mainscene;
- Laya.stage.addChildAt(this.mainscene, 0);
- }
- CreatCharacter() {
- this.CreatPlayer();
- this.CreatEnemy();
- }
- CreatPlayer() {
- var playermodel = GamePool.Instance.GetModel(AssetManager.Instance.Player.get(1), "");
- var horsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(1), "");
- playermodel.addChild(horsemodel);
- playermodel.transform.position = new Laya.Vector3(0, 0, 0);
- horsemodel.transform.localScale = new Laya.Vector3(1, 1, 1);
- horsemodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
- PlayerControl.Instance.Init(playermodel);
- AssetManager.Instance.mainscene.addChild(playermodel);
- }
- CreatEnemy() {
- }
- }
- class LoadView {
- constructor() {
- LoadView.ins = this;
- this.Init();
- }
- static get Instance() {
- if (LoadView.ins) {
- return LoadView.ins;
- }
- else {
- return new LoadView();
- }
- }
- Init() {
- new GameManager();
- this.LoadScene();
- }
- LoadComplete() {
- console.log("加载完毕--");
- EventManager.EventTrigger(EventState.LoadComplete);
- }
- LoadScene() {
- let abc = 0.15 * 18;
- console.log("abc---", abc);
- Laya.Scene3D.load(ResourcesPath.MainScene, Laya.Handler.create(this, (scene) => {
- this.scene = scene;
- AssetManager.Instance.mainscene = this.scene;
- console.log("场景加载完毕");
- this.LoadEnemy();
- }));
- }
- LoadEnemy() {
- var path = [];
- for (let i = 0; i < ResourcesPath.Enemy.length; i++) {
- path.push(ResourcesPath.Enemy[i]);
- }
- Laya.loader.create(path, Laya.Handler.create(this, () => {
- for (let i = 0; i < ResourcesPath.Enemy.length; i++) {
- var model = Laya.loader.getRes(ResourcesPath.Enemy[i]);
- AssetManager.Instance.Enemy.set(i + 1, model);
- Laya.loader.clearRes(ResourcesPath.Enemy[i]);
- }
- console.log("敌人模型资源加载完毕---");
- this.LoadPlayer();
- }));
- }
- LoadPlayer() {
- var path = [];
- for (let i = 0; i < ResourcesPath.Player.length; i++) {
- path.push(ResourcesPath.Player[i]);
- }
- Laya.loader.create(path, Laya.Handler.create(this, () => {
- for (let i = 0; i < ResourcesPath.Player.length; i++) {
- var model = Laya.loader.getRes(ResourcesPath.Player[i]);
- AssetManager.Instance.Player.set(i + 1, model);
- Laya.loader.clearRes(ResourcesPath.Player[i]);
- }
- console.log("玩家模型资源加载完毕---");
- this.LoadHorse();
- }));
- }
- LoadHorse() {
- var path = [];
- for (let i = 0; i < ResourcesPath.Horse.length; i++) {
- path.push(ResourcesPath.Horse[i]);
- }
- Laya.loader.create(path, Laya.Handler.create(this, () => {
- for (let i = 0; i < ResourcesPath.Horse.length; i++) {
- var model = Laya.loader.getRes(ResourcesPath.Horse[i]);
- AssetManager.Instance.Horse.set(i + 1, model);
- Laya.loader.clearRes(ResourcesPath.Horse[i]);
- }
- console.log("马模型资源加载完毕---");
- this.LoadComplete();
- }));
- }
- }
- class Main {
- constructor() {
- 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
|