(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 = "MainGameView.scene";
    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"
    ];
    ResourcesPath.Prop = [
        "Game/res/Prop/LayaScene_Prop/Conventional/Archer"
    ];

    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;
    var CharacterState;
    (function (CharacterState) {
        CharacterState[CharacterState["Run"] = 0] = "Run";
        CharacterState[CharacterState["Idle"] = 1] = "Idle";
        CharacterState[CharacterState["Die"] = 2] = "Die";
        CharacterState[CharacterState["Win"] = 3] = "Win";
        CharacterState[CharacterState["Shoot"] = 4] = "Shoot";
    })(CharacterState || (CharacterState = {}));
    class Runner extends Laya.Script3D {
        constructor() {
            super();
            this.canmove = false;
            this._speed = 1;
            this._press = false;
            this.DownHit = new Laya.HitResult();
            this.FowardHit = new Laya.HitResult();
            this.curspeed = 0;
            this.currotV = new Vector3$1();
            this.currot = new Laya.Quaternion;
            this.NormalizeSpeed = new Vector3$1();
            this.curpos = new Vector3$1();
            this.offest = new Vector3$1();
        }
        static get Instance() {
            if (Runner.ins) {
                return Runner.ins;
            }
            else {
                return new Runner();
            }
        }
        onAwake() {
            this.m_player = this.owner;
            this.m_animator = this.owner.getComponent(Laya.Animator);
            this.m_horseanimator = this.owner.getChildAt(1).getComponent(Laya.Animator);
            this.ChangeState(CharacterState.Idle);
            EventManager.StageOn(StageState.Start, this, this.Begin);
        }
        Begin() {
            this.canmove = true;
            this.ChangeState(CharacterState.Run);
        }
        onUpdate() {
            if (this.canmove) {
                if (this._press) {
                    this._speed = 2;
                }
                this.Move(new Vector3$1(0, 0, 1), this._speed);
            }
            this.RayCheck();
        }
        MoveX(_speed) {
            _speed *= 0.07;
            this.m_player.transform.translate(new Vector3$1(_speed, 0, 0));
        }
        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;
            }
        }
        Move(_dir, _speed) {
            var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
            this.curspeed = sp;
            Vector3$1.scale(_dir, this.curspeed, this.offest);
            Vector3$1.add(this.m_player.transform.position, this.offest, this.curpos);
            Vector3$1.lerp(this.m_player.transform.position, this.curpos, 0.15, this.curpos);
            this.curpos = new Vector3$1(this.curpos.x, this.curpos.y, this.curpos.z);
            this.m_player.transform.position = this.curpos;
        }
        ChangeState(_state) {
            if (this.m_characterstate == _state)
                return;
            this.m_characterstate = _state;
            switch (this.m_characterstate) {
                case CharacterState.Idle:
                    this.Idle();
                    break;
                case CharacterState.Run:
                    this.Run();
                    break;
                case CharacterState.Die:
                    this.Die();
                    break;
                case CharacterState.Win:
                    this.Win();
                    break;
                case CharacterState.Shoot:
                    this.Shoot();
                    break;
            }
        }
        Idle() {
            this.m_animator.play("Idle");
            this.m_horseanimator.play("Horse_Idle");
        }
        Run() {
            this.m_animator.play("Idle");
            this.m_horseanimator.play("Horse_Run");
        }
        Die() {
        }
        Win() {
        }
        Shoot() {
            this.m_animator.play("aimshoot");
            this.m_animator.play("Horse_Run");
        }
        RayCheck() {
            if (this.DownRayCheck) ;
            if (this.FowardRayCheck) {
                this.CrashBarrier();
            }
        }
        CrashBarrier() {
            var target = this.FowardHit.collider.owner;
            if (target.name == "") ;
            else if (target.name == "") ;
            else if (target.name == "") ;
            else if (target.name == "") ;
        }
        get DownRayCheck() {
            var isDownHit = false;
            var startPos = new Vector3$1(this.m_player.transform.position.x, this.m_player.transform.position.y + 1.5, this.m_player.transform.position.z + 0.5);
            var direction = new Vector3$1(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;
        }
        get FowardRayCheck() {
            var isFowardHit = false;
            var startPos = new Vector3$1(this.m_player.transform.position.x, this.m_player.transform.position.y + 1.5, this.m_player.transform.position.z + 0.5);
            var direction = new Vector3$1(0, 0, 1);
            var DownRay = new Laya.Ray(startPos, direction);
            if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
                if (this.FowardHit.collider.collisionGroup == 100) {
                    isFowardHit = true;
                }
            }
            return isFowardHit;
        }
    }

    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;
            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, -15);
            this.Camera.transform.localRotationEuler = new Vector3$2(-5, 0, 0);
            Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
            this.CameraFollow();
        }
        onMouseDown(e) {
            if (!this._runner.canmove)
                return;
            this._runner._press = true;
            this.mouseDownTime = Laya.Browser.now();
            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.curMousePos = this.startMousePos.clone();
            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;
            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);
            this._runner._press = false;
            if (!this.startMousePos)
                return;
            Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.onMouseMove);
            Laya.stage.off(Laya.Event.MOUSE_UP, this, this.onMouseUp);
            Laya.stage.off(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
            let now = Laya.Browser.now();
            let interval = now - this.mouseDownTime;
            this.endMousePos = new Vector3$2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
            let dist = Laya.Vector3.distance(this.endMousePos, this.startMousePos);
            if (dist < 50 && interval < 200) {
                console.log("shoot--");
            }
            this.mouseDownTime = now;
        }
        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;
        }
    }

    var REG = Laya.ClassUtils.regClass;
    var ui;
    (function (ui) {
        class InGameViewUI extends Laya.Scene {
            constructor() { super(); }
            createChildren() {
                super.createChildren();
                this.createView(InGameViewUI.uiView);
            }
        }
        InGameViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "loadList": [], "loadList3D": [] };
        ui.InGameViewUI = InGameViewUI;
        REG("ui.InGameViewUI", InGameViewUI);
        class MainGameViewUI extends Laya.Scene {
            constructor() { super(); }
            createChildren() {
                super.createChildren();
                this.createView(MainGameViewUI.uiView);
            }
        }
        MainGameViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Button", "props": { "y": 897, "x": 360, "width": 100, "var": "StartBtn", "stateNum": 1, "skin": "comp/button.png", "pivotY": 50, "pivotX": 50, "label": "label", "height": 100 }, "compId": 4 }], "loadList": ["comp/button.png"], "loadList3D": [] };
        ui.MainGameViewUI = MainGameViewUI;
        REG("ui.MainGameViewUI", MainGameViewUI);
    })(ui || (ui = {}));

    class MainGameView extends ui.MainGameViewUI {
        constructor() {
            super();
            MainGameView.ins = this;
        }
        static get Instance() {
            if (MainGameView.ins) {
                return MainGameView.ins;
            }
            else {
                return new MainGameView();
            }
        }
        Show() {
            this.StartBtn.clickHandler = Laya.Handler.create(this, this.ClickStart);
        }
        Close() {
        }
        ClickStart() {
            EventManager.StageTrigger(StageState.Start);
            ViewManager.Instance.ShowView(ViewType.IngameView);
        }
    }

    class InGameView extends ui.InGameViewUI {
        constructor() {
            super();
            InGameView.ins = this;
        }
        static get Instance() {
            if (InGameView.ins) {
                return InGameView.ins;
            }
            else {
                return new InGameView();
            }
        }
        Show() {
        }
        Close() {
        }
    }

    var ViewType;
    (function (ViewType) {
        ViewType[ViewType["MainView"] = 0] = "MainView";
        ViewType[ViewType["IngameView"] = 1] = "IngameView";
    })(ViewType || (ViewType = {}));
    class ViewManager {
        constructor() {
            this.showexportview = 0;
            this.popViewDic = [];
            this.ViewSprite = new Laya.Sprite();
            this.OtherViewSprite = new Laya.Sprite();
            ViewManager.ins = this;
            Laya.stage.addChild(this.ViewSprite);
            Laya.stage.addChild(this.OtherViewSprite);
        }
        static get Instance() {
            if (ViewManager.ins) {
                return ViewManager.ins;
            }
            else {
                return new ViewManager();
            }
        }
        ShowView(_viewtype, data = null) {
            if (this.curView != null) {
                this.curView.Close();
                this.curView.destroy();
                this.curView.removeSelf();
            }
            this.curView = this.CreateView(_viewtype);
            this.curView.name = ViewType[_viewtype];
            this.ViewSprite.addChild(this.curView);
            this.curView.Show(data);
        }
        CloseView() {
            if (this.curView != null) {
                this.curView.Close();
                this.curView.destroy();
                this.curView.removeSelf();
            }
        }
        OpenPopView(viewType, data = null) {
            var popView;
            if (this.popViewDic[viewType]) {
                popView = this.popViewDic[viewType];
                this.OtherViewSprite.setChildIndex(popView, this.OtherViewSprite.numChildren - 1);
                popView.visible = true;
            }
            else {
                popView = this.CreateView(viewType);
                this.OtherViewSprite.addChild(popView);
                this.popViewDic[viewType] = popView;
            }
            this.showexportview = 1;
            popView.OnOpen(data);
        }
        ClosePopView(viewType) {
            var popView = this.popViewDic[viewType];
            if (popView == null) {
                return;
            }
            popView.OnHide();
            popView.visible = false;
            this.showexportview = 0;
        }
        ClearPopViews() {
        }
        CreateView(_viewtype) {
            switch (_viewtype) {
                case ViewType.MainView:
                    return new MainGameView();
                case ViewType.IngameView:
                    return new InGameView();
            }
            return null;
        }
    }

    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);
            ViewManager.Instance.ShowView(ViewType.MainView);
        }
        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() {
        }
        EventListen() {
        }
    }

    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() {
            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
