var laya = (function (exports) {
  'use strict';

  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["Select"] = 5] = "Select";
  })(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["Shoot"] = 5] = "Shoot";
      StageState[StageState["CreatArrow"] = 6] = "CreatArrow";
      StageState[StageState["Revive"] = 7] = "Revive";
      StageState[StageState["Restart"] = 8] = "Restart";
      StageState[StageState["Press"] = 9] = "Press";
      StageState[StageState["UnPress"] = 10] = "UnPress";
  })(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 AssetManager {
      constructor() {
          this.Boss = new ResDic();
          this.Player = new ResDic();
          this.Horse = new ResDic();
          this.Cap = new ResDic();
          this.Prop = new ResDic();
          this.Plane = new ResDic();
          this.Stone = new ResDic();
          this.Tree = new ResDic();
          this.Small_Fence = 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.maincamera.transform.position = new Laya.Vector3(0, 10, -12);
          this.maincamera.transform.rotationEuler = new Laya.Vector3(-35.7, 180, 0);
          this.maincamera.enableHDR = false;
          this.Light = this.mainscene.getChildByName("Directional light");
          this.Light.intensity = 0.7;
          EventManager.EventTrigger(EventState.SceneInit);
      }
  }
  class ResourcesPath {
  }
  ResourcesPath.MainScene = "Game/res/MainScene/LayaScene_Mainscene/Conventional/Mainscene.ls";
  ResourcesPath.Boss = [
      "Game/res/Role/LayaScene_Role/Conventional/boss.lh"
  ];
  ResourcesPath.Player = [
      "Game/res/Role/LayaScene_Role/Conventional/player.lh"
  ];
  ResourcesPath.Horse = [
      "Game/res/Horse/LayaScene_Horse/Conventional/horse1.lh",
      "Game/res/Horse/LayaScene_Horse/Conventional/horse2.lh",
      "Game/res/Horse/LayaScene_Horse/Conventional/horse3.lh",
      "Game/res/Horse/LayaScene_Horse/Conventional/horse4.lh",
      "Game/res/Horse/LayaScene_Horse/Conventional/horse5.lh"
  ];
  ResourcesPath.Cap = [
      "Game/res/Cap/LayaScene_Cap/Conventional/cap1.lh",
      "Game/res/Cap/LayaScene_Cap/Conventional/cap2.lh",
      "Game/res/Cap/LayaScene_Cap/Conventional/cap3.lh",
      "Game/res/Cap/LayaScene_Cap/Conventional/cap4.lh",
      "Game/res/Cap/LayaScene_Cap/Conventional/cap5.lh"
  ];
  ResourcesPath.Prop = "Game/res/Prop/LayaScene_Prop/Conventional/Prop.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 Transform3DHelper {
      static getForward(transform) {
          let forward = new Vector3$1();
          transform.getForward(forward);
          Laya.Vector3.scale(forward, -1, forward);
          Laya.Vector3.normalize(forward, forward);
          return forward;
      }
  }
  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;
              }
          }
      }
      EnemySetCollider(setNode, collisionGroup) {
          var collider = setNode.getChildByName("npcfrontcollider");
          var collider2 = setNode.getChildByName("npcrearcollider");
          var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
          var physicsCollider2 = collider2.getComponent(Laya.PhysicsCollider);
          if (physicsCollider) {
              physicsCollider.collisionGroup = collisionGroup;
          }
          if (physicsCollider2) {
              physicsCollider2.collisionGroup = collisionGroup;
          }
      }
      PlayerSetCollider(setNode, collisionGroup) {
          var collider = setNode.getChildByName("playercollider");
          var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
          if (physicsCollider) {
              physicsCollider.collisionGroup = collisionGroup;
          }
      }
      HostageSetCollider(setNode, collisionGroup) {
          var collider = setNode.getChildByName("hostagecollider");
          var physicsCollider = collider.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);
      }
  }

  var AccountUser;
  (function (AccountUser) {
      AccountUser[AccountUser["buyed_kun"] = 0] = "buyed_kun";
      AccountUser[AccountUser["diamond"] = 1] = "diamond";
      AccountUser[AccountUser["equip_themes"] = 2] = "equip_themes";
      AccountUser[AccountUser["favorite_times"] = 3] = "favorite_times";
      AccountUser[AccountUser["game_times"] = 4] = "game_times";
      AccountUser[AccountUser["get_themes"] = 5] = "get_themes";
      AccountUser[AccountUser["list_kun"] = 6] = "list_kun";
      AccountUser[AccountUser["moeny"] = 7] = "moeny";
      AccountUser[AccountUser["progress_themes"] = 8] = "progress_themes";
      AccountUser[AccountUser["revival"] = 9] = "revival";
      AccountUser[AccountUser["stage"] = 10] = "stage";
  })(AccountUser || (AccountUser = {}));
  class PlayerData {
      constructor(_token, _config, _appSetting, _user, _userbase, _useInvite, _user_stage = null, _user_sign, _user_achievement, lottery) {
          this.openid = "";
          this.userId = "";
          this.zhengshu = _token;
          this.netzheshe = _appSetting;
          this.account = _user;
          this.accountssss = _userbase;
          this.qiandao = _user_sign;
          this.renwu = _user_achievement;
          this.userId = this.account["user_id"];
          this.openid = this.accountssss["openid"];
          this.m_invite = _useInvite;
          this.lottery = lottery;
          console.log("user_id:" + this.userId);
      }
      GainCollocation(_type) {
          return this.peizhis[_type];
      }
      GainAccount(_type) {
          return this.account[_type];
      }
      get fenxiang() {
          return this.netzheshe["share"] == "1";
      }
      get Invincible() {
          return Number(this.netzheshe["Invincible"]);
      }
      get CheckScene() {
          return this.netzheshe["checkscene"] == "1";
      }
      get Cheat() {
          return this.netzheshe["cheat"] == "1";
      }
      get Banner() {
          return this.netzheshe["Banner"] == "1";
      }
      get wudaoshijian() {
          return Number(this.netzheshe["wudaoshijian"]);
      }
      GetUser(_type) {
          var type = AccountUser[_type];
          return this.account[type];
      }
      get NpcRunDistance() {
          return Number(this.netzheshe["NpcRunDistance"]);
      }
      get NpcAtkDistance() {
          return Number(this.netzheshe["NpcAtkDistance"]);
      }
      get NpcChaseDistance() {
          return Number(this.netzheshe["NpcChaseDistance"]);
      }
      get NpcRushDistance() {
          return Number(this.netzheshe["NpcRushDistance"]);
      }
      get BossAtkInterval() {
          return Number(this.netzheshe["BossAtkInterval"]);
      }
      get NpcSpeed() {
          return Number(this.netzheshe["NpcSpeed"]);
      }
      get HostageSpeed() {
          return Number(this.netzheshe["HostageSpeed"]);
      }
      get ArrowSpeed() {
          return Number(this.netzheshe["ArrowSpeed"]);
      }
      get BossDistance() {
          return Number(this.netzheshe["ArrowSpeed"]);
      }
      get BossSpeed() {
          return Number(this.netzheshe["BossSpeed"]);
      }
      get PlayerDamage() {
          return Number(this.netzheshe["PlayerDamage"]);
      }
      get MaxBossDistance() {
          return Number(this.netzheshe["MaxBossDistance"]);
      }
      get MinBossDistance() {
          return Number(this.netzheshe["MinBossDistance"]);
      }
      get ShareContent() {
          return this.netzheshe["sharecontent"];
      }
      get DirRoatationLerp() {
          return Number(this.netzheshe["DirRoatationLerp"]);
      }
      get DirMoveLerp() {
          return Number(this.netzheshe["DirMoveLerp"]);
      }
      get CurTouchsmoothness() {
          return Number(this.netzheshe["curtouchsmoothness"]);
      }
      get CurTouchsize() {
          return Number(this.netzheshe["curtouchsize"]);
      }
      get NPCRushSpeed() {
          return Number(this.netzheshe["NPCRushSpeed"]);
      }
      get Range() {
          return Number(this.netzheshe["Range"]);
      }
      get CanStageShake() {
          return this.netzheshe["canstageshake"] == "1";
      }
      GlobalData(_key) {
          var dataarray = [];
          var _global = this.GainCollocation("global");
          for (var key in _global) {
              dataarray.push(_global[key]);
          }
          for (let i = 0; i < dataarray.length; i++) {
              if (_key == dataarray[i].key) {
                  return Number(dataarray[i].value);
              }
          }
      }
      HasEquip(_id) {
          var data = this.GainAccount("get_themes");
          for (var i = 0; i < data.length; i++) {
              var hd = data[i];
              if (_id == hd) {
                  return true;
              }
          }
          return false;
      }
      GetProgress(_id) {
          var config = this.account["progress_themes"];
          var progress = config[_id] ? config[_id] : 0;
          return progress;
      }
  }

  class CheckMain {
  }
  CheckMain.Creat = false;
  CheckMain.ZSSdkCreat = false;

  class FengXiang {
      constructor() {
          FengXiang.instance = this;
      }
      static get Instance() {
          if (FengXiang.instance == null) {
              FengXiang.instance = new FengXiang();
          }
          return FengXiang.instance;
      }
      ;
      kaishifengxiang(callBack) {
          FengXiang.kaishifengxiangshijian = new Date().getTime();
          FengXiang.fengxiangzhong = true;
          FengXiang.callback = callBack;
      }
      RegFenxiang() {
          if (Laya.Browser.window.wx == null) {
              return;
          }
          Laya.Browser.window.wx.onShow(function (option) {
              if (FengXiang.fengxiangzhong) {
                  FengXiang.fengxiangzhong = false;
                  let time = new Date().getTime();
                  let wait = (time - FengXiang.kaishifengxiangshijian) / 1000;
                  let shareSuccess = false;
                  if (wait >= 4) {
                      if (wait < 6) {
                          shareSuccess = (Math.random() > 0.7) ? false : true;
                      }
                      else {
                          shareSuccess = true;
                      }
                  }
                  else {
                      shareSuccess = false;
                  }
                  if (shareSuccess == false) {
                      Laya.Browser.window.wx.showToast({ title: "请重试一次" });
                      FengXiang.callback(false);
                  }
                  else {
                      Laya.Browser.window.wx.showToast({ title: "分享成功" });
                      FengXiang.callback(true);
                  }
              }
          });
      }
  }
  FengXiang.fengxiangchenggongshijian = 0;
  FengXiang.fengxiangzhong = false;

  class WXSDK {
      constructor() {
          WXSDK.ins = this;
      }
      static get Instance() {
          if (WXSDK.ins) {
              return WXSDK.ins;
          }
          else {
              return new WXSDK();
          }
      }
      static Init() {
      }
      static DengLu(_complete) {
          var that = this;
          Laya.Browser.window.wx.login({
              success: function (res) {
                  if (res.code) {
                      FengXiang.Instance.RegFenxiang();
                      console.log("微信登陆成功----");
                      that.codeValue = res.code;
                      console.log("shareid:" + WXSDK.shareOpenId);
                      new AccountManager(res.code, "", "", "", 0, "", "", "", "", WXSDK.shareOpenId, WXSDK.shareOpenId, Main.Ver);
                      _complete(res);
                  }
                  else {
                      WXSDK.DengLu(WXSDK.DengLu);
                      console.log('wx no code' + res.errMsg);
                  }
              },
              fail: function (res) { console.log("wx.login: failed, res=" + res); }
          });
      }
      static ShowTxt(text) {
          if (Laya.Browser.onWeiXin) {
              Laya.Browser.window.wx.showToast({ title: text });
          }
          else {
              console.log(text);
          }
      }
      static OnShow(cb) {
          if (!Laya.Browser.onWeiXin)
              return;
          Laya.Browser.window.wx.onShow(cb);
      }
      static OffShow(cb) {
          if (!Laya.Browser.onWeiXin)
              return;
          Laya.Browser.window.wx.offShow(cb);
      }
      static ShortShake() {
          Laya.Browser.window.wx.vibrateShort({});
      }
      static LongShake() {
          Laya.Browser.window.wx.vibrateLong({});
      }
      static Shake(_short = true) {
          if (Laya.Browser.onWeiXin && WXSDK.shake) {
              if (_short) {
                  this.ShortShake();
              }
              else {
                  this.LongShake();
              }
          }
      }
      static LoadSubPackage(name, _complete) {
          if (Laya.Browser.onWeiXin) {
              const loadTask = Laya.Browser.window.wx.loadSubpackage({
                  name: 'Game',
                  success: function (res) {
                      _complete && _complete(true);
                      console.log("分包加载成功");
                  },
                  fail: function (res) {
                      _complete && _complete(false);
                      console.log("分包加载失败");
                  }
              });
          }
          else {
              console.log("未进行分包加载");
              _complete && _complete(true);
          }
      }
      static stageShake(callBack = null, speed = 32) {
          if (this.isShake || !this.canshakestage)
              return;
          this.isShake = true;
          var point = new Laya.Vector2(Laya.stage.x, Laya.stage.y);
          Laya.stage.timerLoop(speed, this, this.shakeObject, [point, callBack]);
      }
      static shakeObject(_point, _callBack) {
          var count = (this.num++) % 4;
          this.offsetArr[this.num % 2] = count < 2 ? 0 : this.offset;
          Laya.stage.x = this.offsetArr[0] + _point.x;
          Laya.stage.y = this.offsetArr[1] + _point.y;
          if (this.num > (this.times * 4 + 1)) {
              Laya.stage.clearTimer(this, this.shakeObject);
              Laya.stage.pos(0, 0);
              this.num = 0;
              this.isShake = false;
              if (_callBack != null) {
                  _callBack();
              }
          }
      }
      static UpdateGuide(ShowGuide = 0) {
          var kvDataList = new Array();
          let date = new Date().getTime();
          var myValue = JSON.stringify({
              "guide": {
                  "ShowGuide": ShowGuide,
                  "update_time": date.toString()
              }
          });
          kvDataList.push({ key: "ShowGuide", value: myValue });
          if (Laya.Browser.window.wx) {
              Laya.Browser.window.wx.setUserCloudStorage({
                  KVDataList: kvDataList,
                  success: r => {
                      console.log("KVDATALIST---", kvDataList);
                      console.log("上传新手指引成功:" + ShowGuide);
                  }
              });
          }
      }
      static UpdateScore(max_score) {
          var kvDataList = new Array();
          let date = new Date().getTime();
          var myValue = JSON.stringify({
              "wxgame": {
                  "max_score": max_score,
                  "update_time": date.toString(),
              }
          });
          kvDataList.push({ key: "max_score", value: myValue });
          if (Laya.Browser.window.wx) {
              Laya.Browser.window.wx.setUserCloudStorage({
                  KVDataList: kvDataList,
                  success: r => {
                      console.log("KVDATALIST---", kvDataList);
                      console.log("上传分数成功:" + max_score);
                  }
              });
          }
      }
      static fengxiangtupian(callback) {
          if (Laya.Browser.window.wx == null) {
              return;
          }
          var _title = "有人@你，一起骑马仗箭走天涯";
          var t = AccountManager.Instance.ServerTime;
          Laya.Browser.window.wx.aldShareAppMessage({
              title: _title,
              imageUrl: "Game/res/textrue/share.jpg",
              query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
          });
      }
      static ShareContent() {
          return AccountManager.Instance.curplayerData.ShareContent;
      }
      static AldEvent(eventName, key = "用户id", value = "") {
          if (!Laya.Browser.onWeiXin)
              return;
          Laya.Browser.window.wx.aldSendEvent(eventName, { key: value });
      }
      static AldStart(stageId) {
          if (!Laya.Browser.onWeiXin)
              return;
          Laya.Browser.window.wx.aldStage.onStart({
              stageId: stageId,
              stageName: "第" + stageId + "关",
          });
      }
      static AldEnd(stageId, isComplete) {
          if (!Laya.Browser.onWeiXin)
              return;
          let event = isComplete ? "complete" : "fail";
          let desc = isComplete ? "关卡完成" : "关卡失败";
          Laya.Browser.window.wx.aldStage.onEnd({
              stageId: stageId,
              stageName: "第" + stageId + "关",
              event: event,
              params: {
                  desc: desc
              }
          });
      }
  }
  WXSDK.codeValue = "";
  WXSDK.shareOpenId = "";
  WXSDK.openId = 0;
  WXSDK.shareScene = "";
  WXSDK.uid = "123";
  WXSDK.querychannel = "";
  WXSDK.referrerInfoappId = "";
  WXSDK.shake = true;
  WXSDK.times = 1.3;
  WXSDK.num = 0;
  WXSDK.offsetArr = [0, 0];
  WXSDK.offset = 14;
  WXSDK.canshakestage = false;

  var REG = Laya.ClassUtils.regClass;
  var ui;
  (function (ui) {
      class CompleteViewUI extends Laya.Scene {
          constructor() { super(); }
          createChildren() {
              super.createChildren();
              this.createView(CompleteViewUI.uiView);
          }
      }
      CompleteViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,14,15,10", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 14 }, { "type": "Image", "props": { "y": 156, "x": 360, "width": 193, "var": "winimage", "skin": "Main/shenglijiemian-1-1.png", "pivotY": 114, "pivotX": 97, "height": 227 }, "compId": 4 }, { "type": "Image", "props": { "y": 156, "x": 360, "width": 191, "var": "loseimage", "skin": "Main/shibai-1-1.png", "pivotY": 114, "pivotX": 96, "height": 227 }, "compId": 5 }, { "type": "Image", "props": { "y": 220, "x": 360, "width": 152, "var": "reviveimage", "skin": "Main/fuhuo-1-1.png", "pivotY": 37, "pivotX": 76, "height": 74 }, "compId": 7 }, { "type": "Box", "props": { "y": 327, "x": 360, "width": 249, "pivotY": 43, "pivotX": 125, "height": 85 }, "compId": 12, "child": [{ "type": "Image", "props": { "y": 11.5, "x": 0, "skin": "Main/zhujiemian-1-8.png" }, "compId": 11 }, { "type": "Text", "props": { "y": 41, "x": 156, "width": 201, "var": "goldnum", "valign": "middle", "text": "999", "pivotY": 31, "pivotX": 101, "height": 62, "fontSize": 50, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 13 }] }, { "type": "Box", "props": { "y": 591, "x": 360, "width": 623, "visible": true, "height": 440, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 16, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "13,13,14,12", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 17 }, { "type": "List", "props": { "y": 220, "x": 312, "width": 534, "var": "PushList", "spaceY": 40, "spaceX": 40, "pivotY": 221, "pivotX": 267, "height": 441 }, "compId": 18, "child": [{ "type": "Box", "props": { "y": 14, "x": 0, "width": 150, "renderType": "render", "height": 185 }, "compId": 19, "child": [{ "type": "Image", "props": { "y": 75, "x": 75, "width": 150, "pivotY": 75, "pivotX": 75, "name": "icon", "height": 150 }, "compId": 20 }, { "type": "Image", "props": { "y": 149, "x": 0, "width": 151, "name": "bottom", "height": 35 }, "compId": 23 }, { "type": "Text", "props": { "y": 166, "x": 76, "width": 151, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 18, "pivotX": 76, "name": "name", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 21 }, { "type": "Button", "props": { "y": 90, "x": 76, "width": 151, "pivotY": 90, "pivotX": 76, "name": "btn", "height": 184 }, "compId": 22 }, { "type": "Image", "props": { "y": -8, "x": 76, "skin": "Push/icon-hot.png", "name": "remen" }, "compId": 24 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 27 }] }] }] }, { "type": "Box", "props": { "x": 363, "width": 330, "var": "BtnBox", "pivotY": 124, "pivotX": 165, "height": 222, "bottom": 350 }, "compId": 28, "child": [{ "type": "Button", "props": { "y": 84, "x": 162, "width": 313, "var": "NextLevelBtn", "stateNum": 1, "skin": "Main/shenglijiemian-1-2.png", "pivotY": 58, "pivotX": 157, "height": 116 }, "compId": 8 }, { "type": "Button", "props": { "y": 84, "x": 165, "width": 313, "var": "ReviveBtn", "stateNum": 1, "skin": "Main/fuhuo-1-2.png", "pivotY": 58, "pivotX": 157, "height": 116 }, "compId": 9 }, { "type": "Button", "props": { "y": 84, "x": 165, "width": 313, "var": "TryAgainBtn", "stateNum": 1, "skin": "Main/shibai-1-2.png", "pivotY": 58, "pivotX": 157, "height": 116 }, "compId": 10 }, { "type": "Button", "props": { "y": 181, "x": 162, "var": "NoBtn", "stateNum": 1, "skin": "Main/no.png", "anchorY": 0.5, "anchorX": 0.5 }, "compId": 15 }] }], "loadList": ["Main/chunhei.png", "Main/shenglijiemian-1-1.png", "Main/shibai-1-1.png", "Main/fuhuo-1-1.png", "Main/zhujiemian-1-8.png", "Push/icon-hot.png", "Main/shenglijiemian-1-2.png", "Main/fuhuo-1-2.png", "Main/shibai-1-2.png", "Main/no.png"], "loadList3D": [] };
      ui.CompleteViewUI = CompleteViewUI;
      REG("ui.CompleteViewUI", CompleteViewUI);
      class ExportViewUI extends Laya.Scene {
          constructor() { super(); }
          createChildren() {
              super.createChildren();
              this.createView(ExportViewUI.uiView);
          }
      }
      ExportViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei2.png", "sizeGrid": "25,16,29,14", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 3 }, { "type": "Box", "props": { "y": 223, "right": 25, "name": "HBox", "left": 25, "height": 150, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 0, "skin": "Push/bg-box.png", "sizeGrid": "33,35,44,42", "right": 0, "left": 0, "height": 149 }, "compId": 11 }, { "type": "Image", "props": { "y": -32, "x": 335, "width": 230, "skin": "Push/title-friend.png", "pivotY": 16, "pivotX": 115, "height": 32 }, "compId": 5 }, { "type": "List", "props": { "var": "HList", "spaceX": 16, "right": 0, "repeatY": 1, "left": 0, "height": 150 }, "compId": 6, "child": [{ "type": "Box", "props": { "width": 120, "renderType": "render", "height": 150 }, "compId": 7, "child": [{ "type": "Image", "props": { "width": 120, "name": "icon", "height": 120 }, "compId": 8 }, { "type": "Text", "props": { "y": 135, "x": 60, "width": 121, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 15, "pivotX": 61, "name": "name", "height": 30, "fontSize": 20, "font": "Microsoft YaHei", "align": "center", "runtime": "laya.display.Text" }, "compId": 9 }, { "type": "Button", "props": { "y": 0, "x": 0, "width": 120, "name": "btn", "height": 141 }, "compId": 10 }, { "type": "Script", "props": { "y": 0, "x": 0, "runtime": "Tools/ListItem.ts" }, "compId": 26 }] }] }] }, { "type": "Box", "props": { "top": 400, "right": 25, "name": "VBox", "left": 25, "bottom": 0, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 12, "child": [{ "type": "Image", "props": { "y": -32, "x": 335, "width": 230, "skin": "Push/title-recommend.png", "pivotY": 16, "pivotX": 115, "height": 32 }, "compId": 13 }, { "type": "List", "props": { "var": "VList", "top": 0, "spaceY": 40, "spaceX": 30, "right": 0, "left": 0, "bottom": 0 }, "compId": 14, "child": [{ "type": "Box", "props": { "y": 10, "x": 0, "width": 200, "renderType": "render", "height": 240 }, "compId": 15, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Push/bg-box.png", "sizeGrid": "24,27,42,16", "right": 0, "left": 0, "bottom": 0 }, "compId": 16 }, { "type": "Image", "props": { "y": 221, "x": 100, "width": 200, "pivotY": 21, "pivotX": 100, "name": "bottom", "height": 41 }, "compId": 20 }, { "type": "Image", "props": { "y": 90, "x": 90, "width": 200, "pivotY": 90, "pivotX": 90, "name": "icon", "height": 200 }, "compId": 17 }, { "type": "Text", "props": { "y": 220, "x": 101, "width": 199, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 20, "pivotX": 100, "name": "name", "height": 40, "fontSize": 25, "font": "Microsoft YaHei", "align": "center", "runtime": "laya.display.Text" }, "compId": 18 }, { "type": "Button", "props": { "y": 121, "x": 100, "width": 200, "pivotY": 121, "pivotX": 100, "name": "btn", "height": 241 }, "compId": 19 }, { "type": "Image", "props": { "y": 17, "x": 170.5, "width": 82, "skin": "Push/icon-hot.png", "pivotY": 24, "pivotX": 41, "name": "remen", "height": 47 }, "compId": 21 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 25 }] }] }] }, { "type": "Button", "props": { "x": 371, "width": 349, "var": "CloseExportBtn", "stateNum": 1, "skin": "Push/btn-continue-new.png", "pivotY": 80, "pivotX": 175, "height": 160, "bottom": 200 }, "compId": 22 }], "loadList": ["Main/chunhei2.png", "Push/bg-box.png", "Push/title-friend.png", "Push/title-recommend.png", "Push/icon-hot.png", "Push/btn-continue-new.png"], "loadList3D": [] };
      ui.ExportViewUI = ExportViewUI;
      REG("ui.ExportViewUI", ExportViewUI);
      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, "child": [{ "type": "ProgressBar", "props": { "y": 107, "x": 47, "var": "GoalProgress", "skin": "Main/zhujiemian-1-4.png" }, "compId": 7, "child": [{ "type": "Text", "props": { "y": 0, "x": 0, "width": 120, "valign": "middle", "text": "0", "strokeColor": "#050404", "stroke": 2, "name": "goal", "height": 46, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 10 }, { "type": "Image", "props": { "y": 0, "x": -18, "skin": "Main/zhujiemian-1-10.png" }, "compId": 11 }] }, { "type": "Box", "props": { "y": 137, "x": 620, "width": 201, "pivotY": 25, "pivotX": 101, "height": 50 }, "compId": 9, "child": [{ "type": "Image", "props": { "y": 23, "x": 121, "width": 160, "skin": "Main/zhujiemian-1-9.png", "pivotY": 23, "pivotX": 80, "height": 46 }, "compId": 14 }, { "type": "Image", "props": { "y": -4, "x": 12, "skin": "Main/zhujiemian-1-8.png" }, "compId": 15 }, { "type": "Text", "props": { "y": 0, "x": 65, "width": 137, "var": "GoldNum", "valign": "middle", "text": "9999", "height": 46, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 16 }] }, { "type": "Box", "props": { "x": 360, "width": 568, "var": "Guide1", "height": 282, "bottom": 350, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 17, "child": [{ "type": "Image", "props": { "y": 141, "x": 284, "width": 506, "skin": "Main/-2.png", "pivotY": 9, "pivotX": 253, "height": 18 }, "compId": 19 }, { "type": "Image", "props": { "y": 208, "x": 55, "width": 348, "skin": "Main/Hand.png", "scaleY": 0.3, "scaleX": 0.3, "pivotY": 258, "pivotX": 174, "height": 485 }, "compId": 18 }, { "type": "Text", "props": { "y": 65, "x": 284, "width": 416, "valign": "middle", "text": "左右滑动控制人物移动", "strokeColor": "01361e", "stroke": 3, "pivotY": 51, "pivotX": 208, "height": 102, "fontSize": 40, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 20 }] }, { "type": "Box", "props": { "x": 360, "width": 510, "var": "Guide2", "pivotY": 96, "pivotX": 255, "height": 192, "bottom": 341 }, "compId": 21, "child": [{ "type": "Text", "props": { "y": 118, "x": 255, "wordWrap": true, "width": 279, "valign": "middle", "text": "左右移动瞄准松开手指射箭", "strokeColor": "01361e", "stroke": 3, "pivotY": 74, "pivotX": 140, "overflow": "hidden", "leading": 15, "height": 148, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 24 }] }, { "type": "Box", "props": { "x": 360, "width": 510, "var": "Guide3", "pivotY": 96, "pivotX": 255, "height": 192, "bottom": 350 }, "compId": 27, "child": [{ "type": "Text", "props": { "y": 127, "x": 255, "wordWrap": true, "width": 297, "valign": "middle", "text": "射箭击倒栅栏可以继续前进", "strokeColor": "01361e", "stroke": 3, "pivotY": 74, "pivotX": 149, "overflow": "hidden", "leading": 15, "height": 148, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 28 }] }, { "type": "Box", "props": { "x": 360, "width": 510, "var": "Guide4", "pivotY": 96, "pivotX": 255, "height": 192, "bottom": 350 }, "compId": 30, "child": [{ "type": "Text", "props": { "y": 127, "x": 255, "wordWrap": true, "width": 297, "valign": "middle", "text": "保护蓝色友方射击黄色敌人", "strokeColor": "01361e", "stroke": 3, "pivotY": 74, "pivotX": 149, "overflow": "hidden", "leading": 15, "height": 148, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 31 }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "visible": true, "right": 0, "name": "BottomBox", "left": 0, "height": 177, "bottom": 0 }, "compId": 32, "child": [{ "type": "Image", "props": { "width": 720, "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,11,13,10", "right": 0, "name": "BG", "left": 0, "height": 183, "bottom": 0 }, "compId": 33 }, { "type": "List", "props": { "width": 720, "var": "BottomList", "spaceX": 30, "right": 0, "repeatY": 1, "left": 0, "height": 176, "bottom": 0 }, "compId": 34, "child": [{ "type": "Box", "props": { "y": 8, "x": 18, "width": 130, "renderType": "render", "height": 160 }, "compId": 35, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "width": 129, "skin": "Push/bg-box.png", "sizeGrid": "27,27,37,20", "name": "BG", "height": 159 }, "compId": 36 }, { "type": "Image", "props": { "y": 0, "x": 0, "width": 130, "name": "icon", "height": 130 }, "compId": 37 }, { "type": "Text", "props": { "y": 130, "x": 0, "width": 126, "valign": "middle", "text": "冲冲冲冲冲冲", "name": "name", "height": 29, "fontSize": 20, "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 38 }, { "type": "Button", "props": { "y": 0, "x": 0, "width": 130, "name": "btn", "height": 160 }, "compId": 39 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 40 }] }] }] }], "animations": [{ "nodes": [{ "target": 18, "keyframes": { "y": [{ "value": 208, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 0 }, { "value": 209, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 5 }, { "value": 210, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 10 }, { "value": 209, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 15 }, { "value": 210, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 25 }, { "value": 209, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 30 }, { "value": 210, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 35 }], "x": [{ "value": 55, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 0 }, { "value": 144, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 5 }, { "value": 272, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 10 }, { "value": 394, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 15 }, { "value": 537, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 20 }, { "value": 453, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 25 }, { "value": 344, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 30 }, { "value": 212, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 35 }, { "value": 55, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 40 }] } }], "name": "ani1", "id": 1, "frameRate": 24, "action": 0 }], "loadList": ["Main/zhujiemian-1-4.png", "Main/zhujiemian-1-10.png", "Main/zhujiemian-1-9.png", "Main/zhujiemian-1-8.png", "Main/-2.png", "Main/Hand.png", "Main/chunhei.png", "Push/bg-box.png"], "loadList3D": [] };
      ui.InGameViewUI = InGameViewUI;
      REG("ui.InGameViewUI", InGameViewUI);
      class LoadViewUI extends Laya.Scene {
          constructor() { super(); }
          createChildren() {
              super.createChildren();
              this.createView(LoadViewUI.uiView);
          }
      }
      LoadViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Load/jiazai-1-4.png", "sizeGrid": "13,13,15,13", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 3 }, { "type": "Image", "props": { "y": 357, "x": 360, "width": 445, "skin": "Load/jiazai-1-1.png", "pivotY": 74, "pivotX": 223, "name": "title", "height": 147 }, "compId": 5 }, { "type": "ProgressBar", "props": { "y": 842, "x": 360, "width": 506, "var": "LoadProgress", "value": 0, "skin": "Load/jiazai-1-3.png", "pivotY": 9, "pivotX": 253, "height": 18 }, "compId": 6 }], "loadList": ["Load/jiazai-1-4.png", "Load/jiazai-1-1.png", "Load/jiazai-1-3.png"], "loadList3D": [] };
      ui.LoadViewUI = LoadViewUI;
      REG("ui.LoadViewUI", LoadViewUI);
      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": 839, "x": 370, "width": 313, "visible": true, "var": "StartBtn", "stateNum": 1, "skin": "Main/zhujiemian-1-3.png", "pivotY": 58, "pivotX": 157, "height": 116 }, "compId": 7 }, { "type": "Button", "props": { "y": 821, "width": 156, "var": "SkinBtn", "stateNum": 1, "skin": "Main/zhujiemian-1-2.png", "right": 0, "pivotY": 77, "pivotX": 78, "height": 153 }, "compId": 9 }, { "type": "Button", "props": { "y": 828, "width": 140, "var": "MoreFunBtn", "stateNum": 1, "skin": "Main/zhujiemian-1-1.png", "pivotY": 70, "pivotX": 70, "left": 0, "height": 139 }, "compId": 10 }, { "type": "ProgressBar", "props": { "y": 107, "x": 47, "var": "GoalProgress", "value": 0, "skin": "Main/zhujiemian-1-4.png" }, "compId": 11, "child": [{ "type": "Text", "props": { "y": 0, "x": 0, "width": 120, "valign": "middle", "text": "5", "strokeColor": "#050404", "stroke": 2, "name": "goal", "height": 46, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 12 }, { "type": "Image", "props": { "y": 0, "x": -18, "skin": "Main/zhujiemian-1-10.png" }, "compId": 13 }] }, { "type": "Box", "props": { "y": 229.5, "x": 70, "width": 100, "var": "SoundBox", "pivotY": 50, "pivotX": 50, "height": 100 }, "compId": 16, "child": [{ "type": "Image", "props": { "y": 50, "x": 50, "width": 83, "visible": false, "skin": "Main/zhujiemian-1-6.png", "pivotY": 42, "pivotX": 42, "name": "shake", "height": 83 }, "compId": 17 }, { "type": "Image", "props": { "y": 50, "x": 50, "width": 83, "skin": "Main/zhujiemian-1-7.png", "pivotY": 42, "pivotX": 42, "name": "sound", "height": 83 }, "compId": 18 }] }, { "type": "Box", "props": { "y": 137, "x": 620, "width": 201, "pivotY": 25, "pivotX": 101, "height": 50 }, "compId": 19, "child": [{ "type": "Image", "props": { "y": 23, "x": 121, "width": 160, "skin": "Main/zhujiemian-1-9.png", "pivotY": 23, "pivotX": 80, "height": 46 }, "compId": 20 }, { "type": "Image", "props": { "y": -4, "x": 12, "skin": "Main/zhujiemian-1-8.png" }, "compId": 21 }, { "type": "Text", "props": { "y": 0, "x": 65, "width": 137, "var": "GoldNum", "valign": "middle", "text": "9999", "height": 46, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 22 }] }, { "type": "Box", "props": { "y": 129.5, "x": 360, "width": 208, "pivotY": 50, "pivotX": 104, "height": 100 }, "compId": 23, "child": [{ "type": "Text", "props": { "y": 50, "x": 108, "width": 190, "valign": "middle", "text": "第      关", "strokeColor": "033f22", "stroke": 4, "pivotY": 33, "pivotX": 95, "height": 66, "fontSize": 50, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 24 }, { "type": "Text", "props": { "y": 46, "x": 107, "width": 69, "var": "LevelNum", "valign": "middle", "text": "99", "strokeColor": "033f22", "stroke": 4, "pivotY": 21, "pivotX": 35, "height": 42, "fontSize": 50, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 25 }] }, { "type": "Box", "props": { "width": 720, "visible": true, "right": 0, "name": "BottomBox", "left": 0, "height": 177, "bottom": 0 }, "compId": 27, "child": [{ "type": "Image", "props": { "width": 720, "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,11,13,10", "right": 0, "name": "BG", "left": 0, "height": 183, "bottom": 0 }, "compId": 28 }, { "type": "List", "props": { "width": 720, "var": "BottomList", "spaceX": 30, "right": 0, "repeatY": 1, "left": 0, "height": 176, "bottom": 0 }, "compId": 26, "child": [{ "type": "Box", "props": { "y": 8, "x": 18, "width": 130, "renderType": "render", "height": 160 }, "compId": 30, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "width": 129, "skin": "Push/bg-box.png", "sizeGrid": "27,27,37,20", "name": "BG", "height": 159 }, "compId": 32 }, { "type": "Image", "props": { "y": 0, "x": 0, "width": 130, "name": "icon", "height": 130 }, "compId": 31 }, { "type": "Text", "props": { "y": 130, "x": 0, "width": 126, "valign": "middle", "text": "冲冲冲冲冲冲", "name": "name", "height": 29, "fontSize": 20, "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 33 }, { "type": "Button", "props": { "y": 0, "x": 0, "width": 130, "name": "btn", "height": 160 }, "compId": 34 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 50 }] }] }] }, { "type": "Button", "props": { "y": 640, "width": 140, "var": "LeftPushIcon", "skin": "Main/white.png", "sizeGrid": "5,16,5,11", "pivotY": 88, "pivotX": 70, "left": 20, "height": 175 }, "compId": 53, "child": [{ "type": "Image", "props": { "width": 140, "name": "icon", "height": 140 }, "compId": 54 }, { "type": "Text", "props": { "y": 159, "x": 70, "width": 140, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 19, "pivotX": 70, "name": "name", "height": 37, "fontSize": 22, "font": "Microsoft YaHei", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 55 }] }, { "type": "Button", "props": { "y": 640, "width": 140, "var": "RightPushIcon", "skin": "Main/white.png", "sizeGrid": "5,16,5,11", "right": 20, "pivotY": 88, "pivotX": 70, "height": 175 }, "compId": 56, "child": [{ "type": "Image", "props": { "width": 140, "name": "icon", "height": 140 }, "compId": 57 }, { "type": "Text", "props": { "y": 159, "x": 70, "width": 140, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 19, "pivotX": 70, "name": "name", "height": 37, "fontSize": 22, "font": "Microsoft YaHei", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 58 }] }, { "type": "Image", "props": { "y": 640, "x": 360, "visible": false, "var": "BaoKuan", "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "10,12,16,9", "right": 0, "left": 0, "bottom": 0, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 38, "child": [{ "type": "Image", "props": { "y": 560, "x": -267.5, "width": 535, "skin": "Push/index-box.png", "sizeGrid": "28,33,48,26", "height": 573, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 35, "child": [{ "type": "Image", "props": { "y": 40, "x": 267.5, "width": 228, "skin": "Push/index-hot.png", "pivotY": 22, "pivotX": 114, "height": 44 }, "compId": 36 }, { "type": "Button", "props": { "y": 40, "x": 477.5, "width": 36, "var": "CloseBaoKuan", "stateNum": 1, "skin": "Push/index-close.png", "pivotY": 18, "pivotX": 18, "height": 36 }, "compId": 37 }, { "type": "List", "props": { "y": 313, "x": 267.5, "width": 493, "var": "BaoKuanList", "spaceY": 8, "spaceX": 35, "height": 469, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 39, "child": [{ "type": "Box", "props": { "y": 0, "x": 23, "width": 126, "renderType": "render", "height": 150 }, "compId": 40, "child": [{ "type": "Image", "props": { "width": 125, "name": "icon", "height": 125 }, "compId": 41 }, { "type": "Text", "props": { "y": 138, "x": 64, "width": 142, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 15, "pivotX": 71, "name": "name", "height": 34, "fontSize": 20, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 42 }, { "type": "Button", "props": { "y": 84, "x": 71, "width": 141, "pivotY": 84, "pivotX": 71, "name": "btn", "height": 167 }, "compId": 43 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 49 }] }] }] }] }, { "type": "Button", "props": { "y": 338, "x": 0, "visible": true, "var": "BaoKuanBtn", "stateNum": 1, "skin": "Push/img_cover_slide_ad_btn.png", "left": 0 }, "compId": 44 }], "animations": [{ "nodes": [{ "target": 35, "keyframes": { "y": [{ "value": 560, "tweenMethod": "linearNone", "tween": true, "target": 35, "key": "y", "index": 0 }], "x": [{ "value": -267.5, "tweenMethod": "linearNone", "tween": true, "target": 35, "key": "x", "index": 0 }, { "value": 360, "tweenMethod": "linearNone", "tween": true, "target": 35, "key": "x", "index": 15 }] } }], "name": "chouti", "id": 1, "frameRate": 24, "action": 0 }, { "nodes": [{ "target": 53, "keyframes": { "rotation": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 0 }, { "value": 15, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 5 }, { "value": -15, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 10 }, { "value": 15, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 15 }, { "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 20 }] } }], "name": "lefticon", "id": 2, "frameRate": 24, "action": 0 }, { "nodes": [{ "target": 56, "keyframes": { "rotation": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 0 }, { "value": 15, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 5 }, { "value": -15, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 10 }, { "value": 15, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 15 }, { "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 20 }] } }], "name": "righticon", "id": 3, "frameRate": 24, "action": 0 }], "loadList": ["Main/zhujiemian-1-3.png", "Main/zhujiemian-1-2.png", "Main/zhujiemian-1-1.png", "Main/zhujiemian-1-4.png", "Main/zhujiemian-1-10.png", "Main/zhujiemian-1-6.png", "Main/zhujiemian-1-7.png", "Main/zhujiemian-1-9.png", "Main/zhujiemian-1-8.png", "Main/chunhei.png", "Push/bg-box.png", "Main/white.png", "Push/index-box.png", "Push/index-hot.png", "Push/index-close.png", "Push/img_cover_slide_ad_btn.png"], "loadList3D": [] };
      ui.MainGameViewUI = MainGameViewUI;
      REG("ui.MainGameViewUI", MainGameViewUI);
      class SkinViewUI extends Laya.Scene {
          constructor() { super(); }
          createChildren() {
              super.createChildren();
              this.createView(SkinViewUI.uiView);
          }
      }
      SkinViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "10,13,13,9", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 22 }, { "type": "Image", "props": { "y": 875, "x": 362, "width": 658, "skin": "Main/pifu-1-1.png", "sizeGrid": "63,62,62,55", "height": 765, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 64, "x": 24, "width": 615, "skin": "Main/pifu-1-2.png", "sizeGrid": "42,33,67,30", "height": 675 }, "compId": 5 }, { "type": "Button", "props": { "y": 3, "x": 148.5, "width": 183, "var": "CharacterBtn", "height": 61 }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 1, "x": 0, "skin": "Main/pifu-1-4.png", "name": "grey" }, "compId": 10 }, { "type": "Image", "props": { "y": 1, "x": 0, "skin": "Main/pifu-1-3.png", "name": "light" }, "compId": 9 }, { "type": "Text", "props": { "y": 0, "x": 0, "width": 182, "valign": "middle", "text": "帽子", "strokeColor": "#060606", "stroke": 2, "height": 63, "fontSize": 40, "font": "Microsoft YaHei", "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 15 }] }, { "type": "Button", "props": { "y": 3, "x": 332, "width": 181, "var": "HorseBtn", "height": 60 }, "compId": 8, "child": [{ "type": "Image", "props": { "y": 1, "x": 0, "skin": "Main/pifu-1-4.png", "name": "grey" }, "compId": 14 }, { "type": "Image", "props": { "y": 1, "x": 0, "visible": false, "skin": "Main/pifu-1-3.png", "name": "light" }, "compId": 13 }, { "type": "Text", "props": { "y": 0, "x": 0, "width": 182, "valign": "middle", "text": "马", "strokeColor": "#060606", "stroke": 2, "height": 63, "fontSize": 40, "font": "Microsoft YaHei", "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 16 }] }] }, { "type": "List", "props": { "y": 800, "x": 362, "width": 532, "var": "ItemList", "spaceY": 10, "spaceX": 12, "repeatY": 2, "repeatX": 3, "height": 415, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 17, "child": [{ "type": "Box", "props": { "y": 0, "x": 0, "width": 167, "renderType": "render", "height": 199 }, "compId": 18, "child": [{ "type": "Image", "props": { "y": 0, "x": 2, "width": 165, "skin": "Main/pifu-1-6.png", "sizeGrid": "37,27,50,28", "height": 197 }, "compId": 19 }, { "type": "Image", "props": { "y": 0, "x": 0, "width": 170, "skin": "Main/pifu-1-5.png", "sizeGrid": "39,33,41,36", "name": "choose", "height": 198 }, "compId": 20 }, { "type": "Image", "props": { "y": 78, "x": 83.5, "width": 127, "pivotY": 61, "pivotX": 64, "name": "icon", "height": 121 }, "compId": 47 }, { "type": "Button", "props": { "y": 0, "x": 0, "width": 169, "name": "btn", "height": 197 }, "compId": 43 }, { "type": "Image", "props": { "y": 154, "x": 51, "skin": "Main/pifu-1-10.png", "name": "used" }, "compId": 45 }, { "type": "Script", "props": { "runtime": "Tools/ShopItem.ts" }, "compId": 46 }] }] }, { "type": "Button", "props": { "y": 114, "x": 46, "var": "BackBtn", "stateNum": 1, "skin": "Main/pifu-1-7.png" }, "compId": 21 }, { "type": "Button", "props": { "y": 1144, "x": 498, "width": 243, "var": "VideoGetCoinBtn", "stateNum": 1, "skin": "Main/pifu-1-9.png", "pivotY": 46, "pivotX": 122, "height": 92 }, "compId": 23, "child": [{ "type": "Text", "props": { "y": 46, "x": 180, "width": 102, "valign": "middle", "text": "200", "stroke": 2, "pivotY": 33, "pivotX": 51, "name": "CoinNum", "height": 65, "fontSize": 45, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 24 }] }, { "type": "Button", "props": { "y": 1144, "x": 218, "var": "GetBtn", "stateNum": 1, "skin": "Main/pifu-1-8.png", "anchorY": 0.5, "anchorX": 0.5 }, "compId": 25, "child": [{ "type": "Image", "props": { "y": 45, "x": 122, "width": 235, "name": "GetByCoin", "height": 84, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 26, "child": [{ "type": "Image", "props": { "y": 13, "x": 22, "skin": "Main/zhujiemian-1-8.png" }, "compId": 27 }, { "type": "Text", "props": { "y": 42, "x": 150, "width": 142, "valign": "middle", "text": "99999", "strokeColor": "#030303", "stroke": 2, "pivotY": 26, "pivotX": 71, "name": "CoinNum", "height": 51, "fontSize": 45, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 28 }] }, { "type": "Image", "props": { "y": 45, "x": 122, "width": 235, "name": "GetByVideo", "height": 84, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 30, "child": [{ "type": "Image", "props": { "y": 21.5, "x": 56, "skin": "Main/pifu-1-11.png" }, "compId": 31 }, { "type": "Text", "props": { "y": 42, "x": 150, "width": 142, "valign": "middle", "text": "1/3", "strokeColor": "#030303", "stroke": 2, "pivotY": 26, "pivotX": 71, "name": "VideoNum", "height": 51, "fontSize": 45, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 32 }] }, { "type": "Image", "props": { "y": 46, "x": 122, "width": 243, "name": "GetByActive", "height": 91, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 33, "child": [{ "type": "Text", "props": { "y": 42, "x": 117, "width": 232, "valign": "middle", "text": "活动领取", "strokeColor": "#030303", "stroke": 2, "pivotY": 33, "pivotX": 116, "name": "ByActive", "height": 76, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 35 }] }, { "type": "Image", "props": { "y": 45, "x": 122, "width": 235, "name": "Geted", "height": 84, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 39, "child": [{ "type": "Text", "props": { "y": 42, "x": 117, "width": 232, "valign": "middle", "text": "使用", "strokeColor": "#030303", "stroke": 2, "pivotY": 33, "pivotX": 116, "name": "Get", "height": 76, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 40 }] }, { "type": "Text", "props": { "y": 51, "x": 122, "width": 232, "valign": "middle", "text": "已装备", "strokeColor": "#030303", "stroke": 2, "pivotY": 43, "pivotX": 116, "name": "Using", "height": 80, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 42 }] }], "loadList": ["Main/chunhei.png", "Main/pifu-1-1.png", "Main/pifu-1-2.png", "Main/pifu-1-4.png", "Main/pifu-1-3.png", "Main/pifu-1-6.png", "Main/pifu-1-5.png", "Main/pifu-1-10.png", "Main/pifu-1-7.png", "Main/pifu-1-9.png", "Main/pifu-1-8.png", "Main/zhujiemian-1-8.png", "Main/pifu-1-11.png"], "loadList3D": [] };
      ui.SkinViewUI = SkinViewUI;
      REG("ui.SkinViewUI", SkinViewUI);
      class TrialViewUI extends Laya.Scene {
          constructor() { super(); }
          createChildren() {
              super.createChildren();
              this.createView(TrialViewUI.uiView);
          }
      }
      TrialViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "9,17,14,11", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 4 }, { "type": "Image", "props": { "y": 213, "x": 108.5, "skin": "Main/shiyong-1-3.png" }, "compId": 5, "child": [{ "type": "Image", "props": { "y": -58.5, "x": 40, "skin": "Main/shiyong-1-1.png" }, "compId": 6 }] }, { "type": "Button", "props": { "y": 672, "x": 219, "var": "TrialBtn", "stateNum": 1, "skin": "Main/shiyong-1-2.png" }, "compId": 7 }, { "type": "Button", "props": { "y": 824, "x": 309, "var": "NoTrialBtn", "stateNum": 1, "skin": "Main/shiyong-1-4.png" }, "compId": 8 }, { "type": "Image", "props": { "y": 276, "x": 161, "width": 398, "var": "SceneViewPort", "height": 383 }, "compId": 9 }], "loadList": ["Main/chunhei.png", "Main/shiyong-1-3.png", "Main/shiyong-1-1.png", "Main/shiyong-1-2.png", "Main/shiyong-1-4.png"], "loadList3D": [] };
      ui.TrialViewUI = TrialViewUI;
      REG("ui.TrialViewUI", TrialViewUI);
  })(ui || (ui = {}));

  var MusicType;
  (function (MusicType) {
      MusicType[MusicType["click"] = 0] = "click";
      MusicType[MusicType["hit"] = 1] = "hit";
      MusicType[MusicType["shoot"] = 2] = "shoot";
      MusicType[MusicType["OpenView"] = 3] = "OpenView";
      MusicType[MusicType["Lose"] = 4] = "Lose";
      MusicType[MusicType["Win"] = 5] = "Win";
      MusicType[MusicType["die"] = 6] = "die";
  })(MusicType || (MusicType = {}));
  var BGMType;
  (function (BGMType) {
      BGMType[BGMType["BGM"] = 0] = "BGM";
  })(BGMType || (BGMType = {}));
  class AudioManager {
      constructor() { }
      static musicres(_type) {
          return "Game/res/music/" + MusicType[_type] + ".mp3";
      }
      static bgmres(_type) {
          return "Game/res/music/" + BGMType[_type] + ".mp3";
      }
      static playMusic(_type) {
          if (!this.open)
              return;
          Laya.SoundManager.playSound(this.musicres(_type));
      }
      static StopMusic() {
          Laya.SoundManager.stopMusic();
      }
      static PlayBGM(_type) {
          if (!this.open)
              return;
          Laya.SoundManager.playMusic(this.bgmres(_type), 0);
      }
  }
  AudioManager.open = true;

  class MainGameView extends ui.MainGameViewUI {
      constructor() {
          super();
          MainGameView.ins = this;
      }
      static get Instance() {
          if (MainGameView.ins) {
              return MainGameView.ins;
          }
          else {
              return new MainGameView();
          }
      }
      Show() {
          WXSDK.AldEvent("打开主界面");
          AudioManager.PlayBGM(BGMType.BGM);
          this.BaoKuan.visible = false;
          this.StartBtn.clickHandler = Laya.Handler.create(this, this.ClickStart);
          this.SkinBtn.clickHandler = Laya.Handler.create(this, this.ClickSkin);
          this.MoreFunBtn.clickHandler = new Laya.Handler(this, this.ClickMoreFun);
          this.BaoKuanBtn.clickHandler = new Laya.Handler(this, this.OpenChouTi);
          this.goaltext = this.GoalProgress.getChildByName("goal");
          this.goaltext.text = GameManager.Instance.KillNum.toString();
          this.GoldNum.text = AccountManager.Instance.curplayerData.GainAccount("money");
          this.LevelNum.text = AccountManager.Instance.curplayerData.GainAccount("stage");
          this.SoundBox.on(Laya.Event.CLICK, this, this.ClickSound);
          this.sound = this.SoundBox.getChildByName("sound");
          this.shake = this.SoundBox.getChildByName("shake");
          this.sound.visible = AudioManager.open;
          this.shake.visible = WXSDK.shake;
          this.SetData();
          this.SetTopAd();
          this.height = Laya.stage.height;
          Laya.stage.on(Laya.Event.RESIZE, this, () => {
              this.height = Laya.stage.height;
          });
      }
      Close() {
          Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.ClickStart);
      }
      ClickStart() {
          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          if (stage > 2) {
              AudioManager.playMusic(MusicType.click);
              ViewManager.Instance.ShowView(ViewType.TrialView);
          }
          else {
              var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
              ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.GameStart), null);
          }
      }
      ClickSkin() {
          AudioManager.playMusic(MusicType.click);
          ViewManager.Instance.ShowView(ViewType.ShopView);
      }
      ClickMoreFun() {
          ViewManager.Instance.OpenPopView(ViewType.ExportView);
      }
      ClickSound() {
          if (this.sound.visible) {
              this.sound.visible = false;
              this.shake.visible = true;
              AudioManager.open = false;
              WXSDK.shake = true;
              AudioManager.StopMusic();
              console.log("关闭声音，打开震动---");
          }
          else {
              this.sound.visible = true;
              this.shake.visible = false;
              AudioManager.open = true;
              WXSDK.shake = true;
              AudioManager.PlayBGM(BGMType.BGM);
              console.log("打开声音，关闭震动");
          }
      }
      GameStart(_data) {
          let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
          WXSDK.AldStart(stage);
          AudioManager.playMusic(MusicType.click);
          this.play_id = _data.play_id;
          EventManager.StageTrigger(StageState.Start);
          ViewManager.Instance.ShowView(ViewType.IngameView);
      }
      OpenChouTi() {
          this.BaoKuanBtn.visible = false;
          this.BaoKuan.visible = true;
          this.CloseBaoKuan.clickHandler = Laya.Handler.create(this, this.CloseChouTi);
          this.chouti.play(null, false);
          this.InitAd();
      }
      CloseChouTi() {
          this.BaoKuan.visible = false;
          this.BaoKuanBtn.visible = true;
          this.CloseBaoKuan.clickHandler = null;
      }
      InitAd() {
          SDKZS.SetHuTuiList(this.BaoKuanList, 1, "");
          this.GunGun2();
      }
      GunGun2() {
          this.BaoKuanList.scrollBar.value = 0;
          var maxTop = this.BaoKuanList.scrollBar.max;
          var tempTop = 1;
          Laya.timer.frameLoop(1, this, () => {
              this.BaoKuanList.scrollBar.value += tempTop;
              if (this.BaoKuanList.scrollBar.value >= maxTop || this.BaoKuanList.scrollBar.value <= 0) {
                  tempTop = -tempTop;
              }
          });
      }
      SetData() {
          SDKZS.SetHuTuiList(this.BottomList, 2, "");
          this.GunGun();
      }
      GunGun() {
          var maxBtm;
          try {
              this.BottomList.scrollBar.value = 0;
              maxBtm = this.BottomList.scrollBar.max;
          }
          catch (error) {
              console.error(error);
              return;
          }
          var tempBtm = 1;
          Laya.timer.frameLoop(1, this, () => {
              this.BottomList.scrollBar.value += tempBtm;
              if (this.BottomList.scrollBar.value >= maxBtm || this.BottomList.scrollBar.value <= 0) {
                  tempBtm = -tempBtm;
              }
          });
      }
      SetTopAd() {
          this.topAdData = SDKZS.data.promotion || [];
          this.LeftPushIcon.visible = this.RightPushIcon.visible = this.topAdData.length >= 2;
          if (this.topAdData.length < 2)
              return;
          this.topLeftAdIndex = { index: 0 };
          this.topRightAdIndex = { index: 1 };
          this._setTopAd(this.LeftPushIcon, this.topLeftAdIndex);
          this._setTopAd(this.RightPushIcon, this.topRightAdIndex);
      }
      _setTopAd(topAd, adIndex) {
          let _icon = topAd.getChildByName("icon");
          let _name = topAd.getChildByName("name");
          topAd.clickHandler = new Laya.Handler(this, () => {
              SDKZS.navigate2Mini(this.topAdData[adIndex.index]);
          });
          this._setIcon(_icon, _name, adIndex);
          Laya.timer.loop(5000, this, () => {
              this._setIcon(_icon, _name, adIndex);
              this.lefticon.play(null, false);
              this.righticon.play(null, false);
          });
      }
      _setIcon(_icon, _name, adIndex) {
          adIndex.index = (adIndex.index + 2) % this.topAdData.length;
          _icon.skin = this.topAdData[adIndex.index].app_icon;
          _name.text = this.topAdData[adIndex.index].app_title;
      }
  }

  class DataManager {
      constructor() {
          DataManager.ins = this;
      }
      static get Instance() {
          if (DataManager.ins) {
              return DataManager.ins;
          }
          else {
              return new DataManager();
          }
      }
  }
  DataManager.DoorArray = [];

  var Sprite3D$1 = Laya.Sprite3D;
  var Vector3$2 = Laya.Vector3;
  class Prop {
      constructor(_id) {
          this.id = _id;
      }
  }
  class Plane {
      constructor(_index, _id, pos, data, proppos, propoffest) {
          this.things = [];
          this.thinghight = 0;
          this.thingwight = 0;
          this.index = _index;
          this.planeid = _id;
          this.position = pos;
          this.GetProp(data, proppos, propoffest);
      }
      GetProp(data, pos, offset) {
          var config = AccountManager.Instance.curplayerData.GainCollocation("things");
          var datas = data.split(";");
          var poss = pos.split(";");
          var offestX = offset.split(";");
          for (var i = 0; i < datas.length; i++) {
              if (datas[i] == "0")
                  continue;
              var prop = new Prop(Number(datas[i]));
              var configid = prop.id - 1;
              var curconfig = config[configid.toString()];
              var ps = (i <= poss.length - 1) ? Number(poss[i]) : this.long;
              var hs = (i <= poss.length - 1) ? Number(offestX[i]) : this.long;
              prop.pos = new Vector3$2(this.position.x, this.position.y, this.position.z + ps);
              prop.type = Number(curconfig.type);
              this.things.push(prop);
          }
      }
  }
  class Grade {
      constructor(_index, _id) {
          this.startpoint = new Vector3$2(0, 0, 0);
          this.planes = [];
          this.scencerys = [];
          this.MaxLength = 0;
          this.MaxHight = 0;
          this.fencearray = [];
          this.fencepos = 0;
          this.fencepos2 = 0;
          this.fencenum = 0;
          this.fenceleftpos = 0;
          this.fencerightpos = 0;
          this.creat = false;
          this.floorarray = [];
          this.floornum = 0;
          this.floorpos = 0;
          this.treenum = 0;
          this.treepos = 0;
          this.treepos2 = 0;
          this.creatnum = 0;
          this.index = _index;
          this.gradeid = _id;
      }
      Init() {
          this.GetPlane();
          this.endpointpoint = new Vector3$2(0, this.MaxHight, this.MaxLength);
      }
      GetPlane() {
          var config = AccountManager.Instance.curplayerData.GainCollocation("road");
          for (var key in config) {
              if (Number(config[key].road_id) == this.gradeid) {
                  var planedata = config[key];
                  var long = Number(planedata.long);
                  var posz = this.startpoint.z;
                  var roadid = Number(planedata.street);
                  var planepos = new Vector3$2(9 - (roadid * 1.65), 0, posz);
                  var plane = new Plane(Number(planedata.street), Number(planedata.road_id), planepos, planedata.things, planedata.position, planedata.offset);
                  plane.long = Number(planedata.long);
                  this.MaxHight = (plane.thinghight) < this.MaxHight ? plane.thinghight : this.MaxHight;
                  if (long != 0) {
                      this.MaxLength = posz + long > this.MaxLength ? posz + long : this.MaxLength;
                  }
                  this.planes.push(plane);
              }
          }
      }
      Clear() {
          for (var j = 0; j < this.planes.length; j++) {
              var model = this.planes[j].model;
              if (model && model.active && !model.destroyed) {
                  GamePool.Instance.RecoveryModel(model);
              }
              this.planes[j].model = null;
              var things = this.planes[j].things;
              for (var k = 0; k < things.length; k++) {
                  model = things[k].model;
                  if (model && model.active && !model.destroyed)
                      GamePool.Instance.RecoveryModel(model);
                  things[k].model = null;
              }
          }
          for (var i = 0; i < this.scencerys.length; i++) {
              var scencery = this.scencerys[i];
              if (scencery && scencery.active && !scencery.destroyed)
                  GamePool.Instance.RecoveryModel(scencery);
              this.scencerys[i] = null;
          }
          this.scencerys.splice(0, this.scencerys.length);
          for (let k = 0; k < this.fencearray.length; k++) {
              var _fence = this.fencearray[k];
              if (_fence && _fence.active && !_fence.destroyed)
                  GamePool.Instance.RecoveryModel(_fence);
              this.fencearray[k] = null;
          }
          this.fencearray.splice(0, this.fencearray.length);
          if (this.spr)
              this.spr.destroy();
      }
      Creat(_stage = null, _id) {
          if (_stage == null)
              _stage = StageControl.Instance.curstage;
          this.spr = new Sprite3D$1();
          for (var j = 0; j < this.planes.length; j++) {
              var plane = this.planes[j];
              if (plane.long > 0) {
                  var res = AssetManager.Instance.Plane.get(1);
                  plane.model = GamePool.Instance.GetModel(res, "");
                  this.spr.addChild(plane.model);
                  plane.model.transform.position = plane.position;
                  plane.model.transform.scale = new Laya.Vector3(plane.model.transform.scale.x, plane.model.transform.scale.y, plane.long);
                  GameTools.Instance.SetCollider(plane.model, 100);
                  var things = plane.things;
                  for (var k = 0; k < things.length; k++) {
                      var thingdata = things[k];
                      var tre = AssetManager.Instance.Prop.get(thingdata.id);
                      thingdata.model = GamePool.Instance.GetModel(tre, "");
                      if (thingdata.id == 1) {
                          DataManager.DoorArray.push(thingdata.model);
                      }
                      if (thingdata.id == 13) {
                          GameManager.Instance.CreatEnemy(thingdata.model);
                      }
                      else if (thingdata.id == 14) {
                          GameManager.Instance.CreatChaseCharacter(thingdata.model);
                      }
                      else {
                          GameTools.Instance.SetCollider(thingdata.model, 100);
                      }
                      this.spr.addChild(thingdata.model);
                      thingdata.model.transform.position = thingdata.pos;
                  }
              }
              else {
                  if (plane.things.length > 0) {
                      for (var k = 0; k < plane.things.length; k++) {
                          var thingdata = plane.things[k];
                          var tre = AssetManager.Instance.Prop.get(thingdata.id);
                          thingdata.model = GamePool.Instance.GetModel(tre, "");
                          GameTools.Instance.SetCollider(thingdata.model, 100);
                          this.spr.addChild(thingdata.model);
                          thingdata.model.transform.position = thingdata.pos;
                      }
                  }
              }
              AssetManager.Instance.mainscene.addChild(this.spr);
          }
      }
  }
  class GK {
      constructor(_id) {
          this.curgrades = [];
          this.ChooseGrade = [];
          this.Id = Number(_id);
          this.scenery = GameTools.RandomANumber(1, 5);
          this.GetGrade();
      }
      GetGrade() {
          var config = AccountManager.Instance.curplayerData.GainCollocation("mission");
          var gradedatas = config[this.Id - 1].roads.split(";");
          var roadnum = Number(config[this.Id - 1].road_num);
          this.mainrolespeed = Number(config[this.Id - 1].PlayerSpeed);
          this.npcspeed = Number(config[this.Id - 1].NpcSpeed);
          this.hostspeed = Number(config[this.Id - 1].HostageSpeed);
          this.BossHp = Number(config[this.Id - 1].boss_HP);
          this.Goal = Number(config[this.Id - 1].goal);
          this.Modulus = Number(config[this.Id - 1].modulus);
          this.isboss = Number(config[this.Id - 1].boss);
          let GradeArray = [];
          let num = 0;
          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          if (stage != 1) {
              while (num == 0) {
                  var random = GameTools.RandomANumber(0, gradedatas.length);
                  var value = Number(gradedatas[random]);
                  gradedatas.splice(random, 1);
                  GradeArray.push(value);
                  if (GradeArray.length == roadnum) {
                      num = 1;
                  }
              }
              var endpos = new Vector3$2();
              for (var i = 0; i < GradeArray.length; i++) {
                  var gradeid = Number(GradeArray[i]);
                  var grade = new Grade(i, gradeid);
                  if (i > 0)
                      grade.startpoint = endpos;
                  grade.Init();
                  endpos = grade.endpointpoint;
                  this.curgrades.push(grade);
              }
              this.endposition = endpos;
              this.ChooseGrade = GradeArray;
          }
          else {
              var endpos = new Vector3$2();
              for (var i = 0; i < gradedatas.length; i++) {
                  var gradeid = Number(gradedatas[i]);
                  var grade = new Grade(i, gradeid);
                  if (i > 0)
                      grade.startpoint = endpos;
                  grade.Init();
                  endpos = grade.endpointpoint;
                  this.curgrades.push(grade);
              }
              this.endposition = endpos;
          }
      }
  }

  var Vector3$3 = Laya.Vector3;
  class StageControl {
      constructor() {
          this.floorarray = [];
          this.treearray = [];
          this.fencearray = [];
          this.num = 1;
          this.curstagedic = {};
          StageControl.ins = this;
          EventManager.EventOn(EventState.SceneInit, this, this.StageInit);
          EventManager.StageOn(StageState.Restart, this, this.RessetStage);
      }
      static get Instance() {
          if (StageControl.ins) {
              return StageControl.ins;
          }
          else {
              return new StageControl();
          }
      }
      StageInit() {
          var config = AccountManager.Instance.curplayerData.GainCollocation("mission");
          for (var index in config) {
              var data = config[index];
              var gk = new GK(data.id);
              this.curstagedic[gk.Id] = gk;
          }
          EventManager.EventTrigger(EventState.StageInit);
      }
      RessetStage() {
          GameManager.Instance.KillNum = 0;
          GameManager.Instance.ReviveNum = 1;
          GameManager.Instance.fenceleftpos = 0;
          GameManager.Instance.fencerightpos = 0;
          GameManager.Instance.treeleftpos = 0;
          GameManager.Instance.treerightpos = 0;
          GameManager.Instance.GuideKill = 0;
          if (this.curstage)
              this.ClearStageResources();
          var level = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          this.curstage = this.CreatStage(level);
          console.log("本关卡为---", this.curstage.Id);
          for (let i = 0; i < this.curstage.ChooseGrade.length; i++) {
              console.log("选中路段为---", this.curstage.ChooseGrade[i]);
          }
          EventManager.EventTrigger(EventState.StageCreateComplete);
      }
      ClearStageResources() {
          var stage = this.curstage;
          console.log("舞台id为：--------", this.curstage.Id);
          for (let j = 0; j < this.floorarray.length; j++) {
              let floor = this.floorarray[j];
              if (floor && floor.active && !floor.destroyed) {
                  GamePool.Instance.RecoveryModel(floor);
              }
              this.floorarray[j] = null;
          }
          this.floorarray.slice(0, this.floorarray.length);
          for (let k = 0; k < this.treearray.length; k++) {
              let tree = this.treearray[k];
              if (tree && tree.active && !tree.destroyed) {
                  GamePool.Instance.RecoveryModel(tree);
              }
              this.treearray[k] = null;
          }
          this.treearray.splice(0, this.treearray.length);
          for (let l = 0; l < this.fencearray.length; l++) {
              let fence = this.fencearray[l];
              if (fence && fence.active && !fence.destroyed) {
                  GamePool.Instance.RecoveryModel(fence);
              }
              this.fencearray[l] = null;
          }
          this.fencearray.splice(0, this.fencearray.length);
          for (var i = 0; i < stage.curgrades.length; i++) {
              stage.curgrades[i].Clear();
          }
          GameManager.Instance.RecoveryCharacter();
      }
      CreatStage(_id) {
          var stage = this.curstagedic[_id];
          if (!stage) {
              var config = AccountManager.Instance.curplayerData.GainCollocation("road");
              var from = Math.floor(config.length * 0.8);
              stage = this.curstagedic[GameTools.RandomANumber(from, config.length - 1)];
              stage.Id = _id;
          }
          this.CreatStageResources(stage, _id);
          return stage;
      }
      CreatStageResources(_stage, _id) {
          for (var i = 0; i < _stage.curgrades.length; i++) {
              _stage.curgrades[i].Creat(_stage, _id);
          }
          let stage = StageControl.Instance.curstagedic[_id];
          let floornum = Math.floor(stage.endposition.z * 1.65 / 8.23) + 13;
          let floorpos = -8.24;
          for (let i = 0; i < floornum; i++) {
              var _floor = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(19), "");
              if (i > 0) {
                  _floor.transform.position = new Vector3$3(0, -0.5, floorpos);
                  floorpos += 8.24;
              }
              else {
                  _floor.transform.position = new Vector3$3(0, -0.5, -16.48);
              }
              AssetManager.Instance.mainscene.addChild(_floor);
              this.floorarray.push(_floor);
              this.LastGround = _floor.transform.position.z;
          }
          let planearray = [];
          for (let i = 0; i < StageControl.Instance.curstagedic[_id].curgrades[0].planes.length; i++) {
              if (StageControl.Instance.curstagedic[_id].curgrades[0].planes[i].long > 0) {
                  planearray.push(StageControl.Instance.curstagedic[_id].curgrades[0].planes[i]);
              }
          }
          let first_plane = planearray[0].index;
          let last_plane = planearray[planearray.length - 1].index;
          let fenceLeft = (9 - (first_plane * 1.65)) + 1;
          GameManager.Instance.fenceleftpos = fenceLeft;
          let fenceRight = (9 - (last_plane * 1.65)) - 1;
          GameManager.Instance.fencerightpos = fenceRight;
          let treeLeft = (9 - (first_plane * 1.65)) + 5;
          GameManager.Instance.treeleftpos = treeLeft;
          let treeRight = (9 - (last_plane * 1.65)) - 4;
          GameManager.Instance.treerightpos = treeRight;
          let fencepos = -13.35;
          let fencenum = _stage.endposition.z + 60;
          for (let i = 0; i < fencenum; i++) {
              var _fence = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
              if (i > 0) {
                  _fence.transform.position = new Vector3$3(fenceLeft, 0, fencepos);
              }
              else {
                  _fence.transform.position = new Vector3$3(fenceLeft, 0, -15);
              }
              _fence.transform.rotationEuler = new Vector3$3(0, -90, 0);
              AssetManager.Instance.mainscene.addChild(_fence);
              GameTools.Instance.SetCollider(_fence, 100);
              this.fencearray.push(_fence);
              var _fence2 = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
              if (i > 0) {
                  _fence2.transform.position = new Vector3$3(fenceRight, 0, fencepos);
              }
              else {
                  _fence2.transform.position = new Vector3$3(fenceRight, 0, -15);
              }
              _fence2.transform.rotationEuler = new Vector3$3(fenceRight, 90, 0);
              fencepos += 1.65;
              AssetManager.Instance.mainscene.addChild(_fence2);
              GameTools.Instance.SetCollider(_fence2, 100);
              this.fencearray.push(_fence2);
          }
          let treepos = 0;
          let treenum = _stage.endposition.z * 1.65 / 5 + 65;
          for (let i = 0; i < treenum; i++) {
              var _random = GameTools.RandomANumber(1, 5);
              var tree = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
              if (i > 0) {
                  tree.transform.position = new Vector3$3(treeLeft, 0, treepos);
              }
              else {
                  tree.transform.position = new Vector3$3(treeLeft, 0, -20);
              }
              AssetManager.Instance.mainscene.addChild(tree);
              this.treearray.push(tree);
              var _random2 = GameTools.RandomANumber(1, 5);
              var tree2 = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random2), "");
              if (i > 0) {
                  tree2.transform.position = new Vector3$3(treeRight, 0, treepos);
              }
              else {
                  tree2.transform.position = new Vector3$3(treeRight, 0, -20);
              }
              AssetManager.Instance.mainscene.addChild(tree2);
              this.treearray.push(tree2);
              treepos += 3;
          }
          let STAGE = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          let boss = _stage.isboss == 1 ? true : false;
          if (boss) {
              let EndZ = _stage.curgrades[_stage.curgrades.length - 1].endpointpoint.z * 1.2;
              let EndX = GameTools.RandomANumber(-2, 2);
              GameManager.Instance.CreatBoss(new Vector3$3(EndX, 0, EndZ));
          }
      }
      CreatGround(num) {
          var startZ = this.LastGround;
          var floorarr = [];
          for (let i = 0; i < num; i++) {
              var floor = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(19), "");
              if (i > 0) {
                  floor.transform.position = new Vector3$3(0, -0.5, startZ);
              }
              else {
                  floor.transform.position = new Vector3$3(0, -0.5, startZ);
              }
              AssetManager.Instance.mainscene.addChild(floor);
              this.floorarray.push(floor);
              floorarr.push(floor);
              startZ += 8.24;
          }
          this.LastGround = startZ;
          var first = floorarr[0].transform.position.z;
          var last = floorarr[floorarr.length - 1].transform.position.z;
          this.CreatFence(first, last);
          this.CreatTree(first, last);
      }
      CreatFence(_start, _end) {
          var Fir = _start;
          var End_Fence = this.curstage.curgrades[this.curstage.curgrades.length - 1].fencearray;
          let fencenum = Math.floor((_end - _start) / 1.65) + 8;
          for (let i = 0; i < fencenum; i++) {
              var _fence = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
              if (i > 0) {
                  _fence.transform.position = new Vector3$3(GameManager.Instance.fenceleftpos, 0, Fir);
              }
              else {
                  _fence.transform.position = new Vector3$3(GameManager.Instance.fenceleftpos, 0, Fir - 8.3);
              }
              AssetManager.Instance.mainscene.addChild(_fence);
              End_Fence.push(_fence);
              var _fence2 = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
              if (i > 0) {
                  _fence2.transform.position = new Vector3$3(GameManager.Instance.fencerightpos, 0, Fir);
              }
              else {
                  _fence2.transform.position = new Vector3$3(GameManager.Instance.fencerightpos, 0, Fir - 8.3);
              }
              AssetManager.Instance.mainscene.addChild(_fence2);
              End_Fence.push(_fence2);
              Fir += 1.65;
          }
      }
      CreatTree(_start, _end) {
          var End_Fence = this.curstage.curgrades[this.curstage.curgrades.length - 1].scencerys;
          let treenum = Math.floor((_end - _start) / 3) + 1;
          for (let i = 0; i < treenum; i++) {
              let _random = GameTools.RandomANumber(1, 5);
              var _tree = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
              _tree.transform.position = new Vector3$3(GameManager.Instance.treeleftpos, 0, _start);
              AssetManager.Instance.mainscene.addChild(_tree);
              End_Fence.push(_tree);
              var _tree2 = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
              _tree2.transform.position = new Vector3$3(GameManager.Instance.treerightpos, 0, _start);
              AssetManager.Instance.mainscene.addChild(_tree2);
              End_Fence.push(_tree2);
              _start += 3;
          }
      }
  }

  class InGameView extends ui.InGameViewUI {
      constructor() {
          super();
          InGameView.ins = this;
      }
      static get Instance() {
          if (InGameView.ins) {
              return InGameView.ins;
          }
          else {
              return new InGameView();
          }
      }
      Show() {
          WXSDK.AldEvent("进入游戏内界面");
          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          if (stage == 1) {
              this.Guide1.visible = true;
              this.ani1.play(0, true);
              this.Guide2.visible = false;
              this.Guide3.visible = false;
              this.Guide4.visible = false;
          }
          else if (stage == 2) {
              this.Guide1.visible = false;
              this.Guide2.visible = false;
              this.Guide3.visible = false;
              this.Guide4.visible = false;
          }
          else {
              this.Guide1.visible = false;
              this.Guide2.visible = false;
              this.Guide3.visible = false;
              this.Guide4.visible = false;
          }
          this.GoldNum.text = AccountManager.Instance.curplayerData.GainAccount("money");
          this.goaltext = this.GoalProgress.getChildByName("goal");
          this.SetData();
          this.InitUI();
          this.height = Laya.stage.height;
          Laya.stage.on(Laya.Event.RESIZE, this, () => {
              this.height = Laya.stage.height;
          });
      }
      Close() {
      }
      InitUI() {
          this.goaltext.text = GameManager.Instance.KillNum.toString();
          this.GoalProgress.value = GameManager.Instance.KillNum / StageControl.Instance.curstage.Goal;
      }
      SetData() {
          SDKZS.SetHuTuiList(this.BottomList, 2, "");
          this.GunGun();
      }
      GunGun() {
          var maxBtm;
          try {
              this.BottomList.scrollBar.value = 0;
              maxBtm = this.BottomList.scrollBar.max;
          }
          catch (error) {
              console.error(error);
              return;
          }
          var tempBtm = 1;
          Laya.timer.frameLoop(1, this, () => {
              this.BottomList.scrollBar.value += tempBtm;
              if (this.BottomList.scrollBar.value >= maxBtm || this.BottomList.scrollBar.value <= 0) {
                  tempBtm = -tempBtm;
              }
          });
      }
  }

  class GuangGao {
      constructor() {
          this.isVideoLoadCom = false;
          GuangGao.ins = this;
      }
      static get Instance() {
          if (GuangGao.ins) {
              return GuangGao.ins;
          }
          else {
              return new GuangGao();
          }
      }
      static InitId() {
      }
      static JiaZaiShiPin() {
          if (this.afsfsaafsfsa)
              return;
          if (!Laya.Browser.onWeiXin)
              return;
          this.fsaasfafssfa = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: this.videlAdUnitId });
          this.fsaasfafssfa.onLoad(() => {
              console.log('激励视频 广告加载成功');
              this.asfasfsaffsa = true;
          });
          this.fsaasfafssfa.onError(err => {
              console.log("激励视屏加载失败:" + err);
              this.asfasfsaffsa = false;
          });
          this.afsfasfasasf = 0;
          this.afsfsaafsfsa = true;
      }
      static fassfafasafs(callback) {
          this.fsaasfafssfa.offClose();
          this.fsaasfafssfa.onClose(res => {
              console.log("激励视频关闭:" + res.isEnded);
              if (res && res.isEnded || res === undefined) {
                  callback && callback(true);
              }
              else {
                  callback && callback(false);
              }
              this.fsaasfafssfa.offClose();
          });
      }
      showBanner(success = null, fail = null) {
          if (!Laya.Browser.onWeiXin)
              return;
          let ad = GuangGao.bannerAdUnitId;
          let bannerAd = Laya.Browser.window.wx.createBannerAd({
              adUnitId: ad,
              style: {
                  left: 0,
                  top: 0,
                  width: 460
              }
          });
          bannerAd.onLoad(() => {
              console.log("[LOG] Banner广告加载成功");
              this.hideBanner();
              this._bannerAd = bannerAd;
              let info = Laya.Browser.window.wx.getSystemInfoSync();
              this._bannerAd.style.width = info.windowWidth;
              this._bannerAd.style.top = info.windowHeight - this._bannerAd.style.realHeight - 20;
              this._bannerAd.show();
              success && success(this._bannerAd);
          });
          bannerAd.onError(err => {
              console.log("[LOG] Banner广告加载失败");
              console.log(err);
              fail && fail();
          });
      }
      hideBanner() {
          if (!Laya.Browser.onWeiXin)
              return;
          if (this._bannerAd) {
              this._bannerAd.hide();
              this._bannerAd.destroy();
              this._bannerAd = null;
          }
      }
      static OpenBanner(gap = 0, callVack = null, iswait = false) {
          if (!Laya.Browser.onWeiXin)
              return;
          if (this.afsfasfasasf >= 10000) {
              var hh = this.gasagsgasgsa(gap);
              if (iswait) {
                  this.asgagassga.hide();
                  Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
                      if (callVack != null) {
                          callVack(hh);
                      }
                      this.asgagassga.show();
                  });
              }
              else {
                  if (callVack != null) {
                      callVack(hh);
                  }
                  this.asgagassga.show();
              }
          }
          else {
              var idd = this.bannerAdUnitId;
              console.log("adUnitId:" + idd);
              let newBanner = Laya.Browser.window.wx.createBannerAd({
                  adUnitId: idd,
                  style: {
                      left: 0,
                      top: 0,
                      width: 460
                  }
              });
              newBanner.onError(err => {
                  console.log("没有拉到banner--");
                  console.log(err);
                  newBanner = Laya.Browser.window.wx.createBannerAd({
                      adUnitId: idd,
                      style: {
                          left: 0,
                          top: 0,
                          width: 460
                      }
                  });
                  this.gasagsgasgsa(gap);
              });
              newBanner.onLoad(() => {
                  this.afsfasfasasf++;
                  if (this.asgagassga)
                      this.asgagassga.destroy();
                  this.asgagassga = newBanner;
                  var hight = this.gasagsgasgsa(gap);
                  if (iswait) {
                      this.asgagassga.hide();
                      Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
                          if (callVack != null) {
                              callVack(hight);
                          }
                          this.asgagassga.show();
                      });
                  }
                  else {
                      if (callVack != null) {
                          callVack(hight);
                      }
                      this.asgagassga.show();
                  }
              });
          }
      }
      static gasagsgasgsa(gap) {
          if (this.asgagassga) {
              let info = Laya.Browser.window.wx.getSystemInfoSync();
              this.asgagassga.style.width = info.windowWidth;
              this.asgagassga.style.top = info.windowHeight - this.asgagassga.style.realHeight - gap - 20;
              return Laya.stage.height / info.windowHeight * this.asgagassga.style.realHeight;
          }
      }
      static Clear() {
          Laya.timer.clearAll(this);
          if (!Laya.Browser.onWeiXin)
              return;
          if (this.asgagassga)
              this.asgagassga.hide();
      }
      static agagsagags() {
          if (!Laya.Browser.onWeiXin)
              return;
          if (this.asgagassga)
              this.asgagassga.hide();
      }
      static gasagsasg() {
          if (!Laya.Browser.onWeiXin)
              return;
          if (this.asgagassga)
              this.asgagassga.show();
      }
      static get keyiwudao() {
          var wudao = AccountManager.Instance.curplayerData.Cheat;
          if (wudao == false) {
              console.log("cheat:" + wudao);
              return false;
          }
          if (Main.SceneNum == "1037" || Main.SceneNum == "1058"
              || Main.SceneNum == "1067" || Main.SceneNum == "1095") {
              console.log("cheat:true-> " + Main.SceneNum);
              return true;
          }
          else {
              var checkscence = AccountManager.Instance.curplayerData.CheckScene;
              if (checkscence == false) {
                  console.log("cheat:true->checkscence: " + checkscence);
                  return true;
              }
          }
          console.log("cheat:false-> " + Main.SceneNum);
          return false;
      }
      static WudaoAnNiu(btn, ShowBanner = true, complete = null, gap = 0) {
          if (AccountManager.Instance.curplayerData.Banner) {
              GuangGao.agagsagags();
              if (GuangGao.keyiwudao == false) {
                  btn.bottom = 350;
                  GuangGao.OpenBanner();
              }
              else {
                  if (ShowBanner) {
                      btn.bottom = 100;
                      btn.mouseEnabled = false;
                      console.log("bottom:100");
                      GuangGao.OpenBanner(gap, (height) => {
                          if (height == null) {
                              console.log("展示互推位");
                              var end = Laya.stage.height - height - btn.height;
                              btn.y = end;
                              btn.bottom = NaN;
                          }
                          else {
                              var end = Laya.stage.height - height - btn.height;
                              btn.y = end - 100;
                              btn.bottom = NaN;
                              console.log("y:" + end);
                          }
                      }, true);
                      Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
                          btn.mouseEnabled = true;
                          if (complete != null) {
                              complete();
                          }
                      });
                  }
                  else {
                      if (complete != null) {
                          complete();
                      }
                  }
              }
          }
      }
      loadVideo(cb) {
          if (!Laya.Browser.onWeiXin) {
              if (cb)
                  cb(true);
              return;
          }
          this._onLoadVideo = cb;
          if (!this._rewardedVideoAd) {
              let index = GuangGao.videlAdUnitId;
              this._rewardedVideoAd = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: index });
              var isc = false;
              this._rewardedVideoAd.onLoad(() => {
                  console.log("[LOG] 激励视频广告加载成功");
                  this.isVideoLoadCom = true;
                  if (isc)
                      return;
                  isc = true;
                  this._onLoadVideo && this._onLoadVideo(true);
                  this._onLoadVideo = null;
              });
              this._rewardedVideoAd.onError(err => {
                  console.log("[LOG] 激励视频广告加载失败");
                  console.log(err);
                  this.isVideoLoadCom = false;
                  this._onLoadVideo && this._onLoadVideo(false);
                  this._onLoadVideo = null;
              });
              this._rewardedVideoAd.onClose(res => {
                  if (!res || res.isEnded) {
                      this._onVideoClose && this._onVideoClose(true);
                      this._onVideoClose = null;
                  }
                  else {
                      this._onVideoClose && this._onVideoClose(false);
                      this._onVideoClose = null;
                  }
              });
          }
          else {
              if (this.isVideoLoadCom) {
                  this._onLoadVideo && this._onLoadVideo(true);
                  this._onLoadVideo = null;
              }
              else {
                  this._onLoadVideo && this._onLoadVideo(false);
                  this._onLoadVideo = null;
              }
          }
      }
      showVideo(cb) {
          if (!Laya.Browser.onWeiXin) {
              if (cb)
                  cb(true);
              return;
          }
          this._onVideoClose = cb;
          this._rewardedVideoAd.show().catch(err => {
              this._rewardedVideoAd.load().then(() => {
                  this._rewardedVideoAd.show();
              });
          });
      }
  }
  GuangGao.videlAdUnitId = "adunit-40ac03a5538e8de0";
  GuangGao.bannerAdUnitId = "adunit-dc3e1cfa3ac69be3";
  GuangGao.afsfsaafsfsa = false;
  GuangGao.asfasfsaffsa = false;
  GuangGao.afsfasfasasf = 0;

  class ShopItem extends Laya.Script {
      constructor() {
          super();
          this.use = false;
          ShopItem.ins = this;
      }
      static get Instance() {
          if (ShopItem.ins) {
              return ShopItem.ins;
          }
          else {
              return new ShopItem();
          }
      }
      onAwake() {
          this.selfobj = this.owner;
          this._select = this.selfobj.getChildByName("choose");
          this._skin = this.selfobj.getChildByName("icon");
          this.using = this.selfobj.getChildByName("used");
          this.click1_btn = this.selfobj.getChildByName("btn");
          this.click1_btn.clickHandler = new Laya.Handler(this, this._ClickHander);
          EventManager.EventOn(EventState.Select, this, this.ShowSelect);
      }
      RefreshItem(any, comeType) {
          this.comeType = comeType;
          if (any)
              this.instance = any;
          else
              this.instance = ShopView.Instance;
          this._data = (this.selfobj.dataSource);
          var _id = this._data.id;
          var usingId = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"];
          var usingId2 = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"];
          var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
          var require_type = this._data.require_type;
          this._skin.skin = "Game/res/Skin/" + this._data.icon + ".png";
          this._skin.rotation = 0;
          if (usingId == _id || usingId2 == _id) {
              this.skinGetForType = SkinGetForType.Using;
              this.showui();
              return;
          }
          if (hasequip) {
              this.skinGetForType = SkinGetForType.Geted;
              this.showui();
              return;
          }
          if (require_type == 2) {
              this.skinGetForType = SkinGetForType.Bycoin;
              this.showui();
              return;
          }
          if (require_type == 4) {
              this.skinGetForType = SkinGetForType.GetByActivity;
              this.showui();
              return;
          }
          if (require_type == 3) {
              this.skinGetForType = SkinGetForType.GetByVideo;
              this.showui();
              return;
          }
      }
      showui() {
          var type = this.skinGetForType;
          if (this._data.id == 1 || this._data.id == 50) {
              this._select.visible = true;
          }
          else {
              this._select.visible = false;
          }
          if (this.skinGetForType == SkinGetForType.Using) {
              this.using.visible = true;
          }
          else {
              this.using.visible = false;
          }
      }
      ShowUi() {
          var type = this.skinGetForType;
          this._select.visible = type == SkinGetForType.Using;
          if (this.skinGetForType == SkinGetForType.Using) {
              this.using.visible = true;
          }
          else {
              this.using.visible = false;
          }
      }
      _ClickHander() {
          this.instance._data = this._data;
          ShopView.Instance.RefreshButton(this.skinGetForType);
          this.instance.showroleId = this._data.id;
          this.ShowUi();
          this.ShowModel();
      }
      ShowModel() {
          EventManager.EventTrigger(EventState.Select);
      }
      ShowSelect() {
          if (!this._data) {
              return;
          }
          this._select.visible = this.instance.showroleId == this._data.id;
      }
  }

  var SkinGetForType;
  (function (SkinGetForType) {
      SkinGetForType[SkinGetForType["Geted"] = 1] = "Geted";
      SkinGetForType[SkinGetForType["Bycoin"] = 2] = "Bycoin";
      SkinGetForType[SkinGetForType["GetByVideo"] = 3] = "GetByVideo";
      SkinGetForType[SkinGetForType["GetByActivity"] = 4] = "GetByActivity";
      SkinGetForType[SkinGetForType["Using"] = -1] = "Using";
  })(SkinGetForType || (SkinGetForType = {}));
  class ShopView extends ui.SkinViewUI {
      constructor() {
          super();
          this.firstopen = true;
          this.showroleId = 0;
          this.uiArr = [];
          this.CapArray = [];
          this.HorseArray = [];
          ShopView.ins = this;
      }
      static get Instance() {
          if (ShopView.ins == null) {
              console.log("new  shopview");
              return new ShopView();
          }
          return ShopView.ins;
      }
      Show() {
          WXSDK.AldEvent("打开皮肤商店界面");
          let data = AccountManager.Instance.curplayerData.GainCollocation("theme");
          for (let i = 0; i < data.length; i++) {
              if (i < 5) {
                  this.CapArray.push(data[i]);
              }
              else {
                  this.HorseArray.push(data[i]);
              }
          }
          this.BackBtn.clickHandler = new Laya.Handler(this, this.ClickClose);
          this.CharacterBtn.clickHandler = new Laya.Handler(this, this.ClickCap);
          this.HorseBtn.clickHandler = new Laya.Handler(this, this.ClickHorse);
          this.GetBtn.clickHandler = new Laya.Handler(this, this.ClickGet);
          this.VideoGetCoinBtn.clickHandler = new Laya.Handler(this, this.VideoGet);
          this.CharacterLightImage = this.CharacterBtn.getChildByName("light");
          this.HorseLightImage = this.HorseBtn.getChildByName("light");
          this.GetByCoin = this.GetBtn.getChildByName("GetByCoin");
          this.RequireCoinNum = this.GetByCoin.getChildByName("CoinNum");
          this.GetByVideo = this.GetBtn.getChildByName("GetByVideo");
          this.RequireVideoNum = this.GetByVideo.getChildByName("VideoNum");
          this.GetByActive = this.GetBtn.getChildByName("GetByActive");
          this.Geted = this.GetBtn.getChildByName("Geted");
          this.Using = this.GetBtn.getChildByName("Using");
          this.uiArr.push(this.Using);
          this.uiArr.push(this.Geted);
          this.uiArr.push(this.GetByCoin);
          this.uiArr.push(this.GetByVideo);
          this.uiArr.push(this.GetByActive);
          this.equip_Horse = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"];
          this.equip_Cap = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"];
          this.showroleId = 1;
          this.ItemList.selectEnable = false;
          this.ItemList.vScrollBarSkin = "";
          this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
          this.ItemList.array = this.CapArray;
          this.ItemList.refresh();
          this.ShowButton(1);
          this.height = Laya.stage.height;
          Laya.stage.on(Laya.Event.RESIZE, this, () => {
              this.height = Laya.stage.height;
          });
      }
      Close() {
          WXSDK.AldEvent("关闭皮肤商城界面");
      }
      ClickClose() {
          var equiphorseid = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
          var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
          if (equipcap) {
              if (equipcap != this.equip_Cap) {
                  GameManager.Instance.SetCap(equipcap);
              }
          }
          if (equiphorseid != this.equip_Horse) {
              GameManager.Instance.SetHorse(equiphorseid);
          }
          ViewManager.Instance.ShowView(ViewType.MainView);
      }
      UpdateItem(cell, index) {
          let item = cell.getComponent(ShopItem);
          item.RefreshItem();
      }
      RefreshItem() {
          this.ItemList.refresh();
      }
      ClickCap() {
          this.firstopen = true;
          if (this.equip_Cap) {
              this.showroleId = this.equip_Cap;
          }
          else {
              this.showroleId = 1;
          }
          this.ShowButton(1);
          this.CharacterLightImage.visible = true;
          this.HorseLightImage.visible = false;
          this.ItemList.vScrollBarSkin = "";
          this.ItemList.array = this.CapArray;
          this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
      }
      ClickHorse() {
          this.firstopen = true;
          this.showroleId = this.equip_Horse;
          this.ShowButton(2);
          this.CharacterLightImage.visible = false;
          this.HorseLightImage.visible = true;
          this.ItemList.vScrollBarSkin = "";
          this.ItemList.array = this.HorseArray;
          this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
      }
      RefreshButton(_skinGetForType) {
          this.skinGetForType = _skinGetForType;
          this.ShowUI(this.skinGetForType);
      }
      ShowButton(type) {
          if (type == 1) {
              var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
              var usingId = equipcap;
              let item = this.CapArray[0].require_type;
              this._data = this.CapArray[0];
              var _id = this._data.id;
              var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
              var require_type = item;
              if (usingId == _id) {
                  this.skinGetForType = SkinGetForType.Using;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
              if (hasequip) {
                  this.skinGetForType = SkinGetForType.Geted;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
              if (require_type == 2) {
                  this.skinGetForType = SkinGetForType.Bycoin;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
              if (require_type == 4) {
                  this.skinGetForType = SkinGetForType.GetByActivity;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
              if (require_type == 3) {
                  this.skinGetForType = SkinGetForType.GetByVideo;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
          }
          else {
              var equiphorse = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
              var usingId = equiphorse;
              let item = this.HorseArray[0].require_type;
              this._data = this.HorseArray[0];
              var _id = this._data.id;
              var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
              var require_type = item;
              if (usingId == _id) {
                  this.skinGetForType = SkinGetForType.Using;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
              if (hasequip) {
                  this.skinGetForType = SkinGetForType.Geted;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
              if (require_type == 2) {
                  this.skinGetForType = SkinGetForType.Bycoin;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
              if (require_type == 4) {
                  this.skinGetForType = SkinGetForType.GetByActivity;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
              if (require_type == 3) {
                  this.skinGetForType = SkinGetForType.GetByVideo;
                  this.RefreshButton(this.skinGetForType);
                  return;
              }
          }
      }
      ClickGet() {
          switch (this.skinGetForType) {
              case SkinGetForType.Bycoin:
                  var money = Number(AccountManager.Instance.curplayerData.GainAccount("money"));
                  if (money < Number(this._data.require_num)) {
                      WXSDK.ShowTxt("金币不足--");
                  }
                  else {
                      this.Buy();
                  }
                  console.log("金币--");
                  break;
              case SkinGetForType.GetByActivity:
                  WXSDK.ShowTxt("暂未开放!");
                  console.log("活动获取--");
                  break;
              case SkinGetForType.GetByVideo:
                  console.log("视频获取--");
                  this.VideoGet();
                  break;
              case SkinGetForType.Geted:
                  this.Use();
                  break;
          }
      }
      ShowUI(_type) {
          console.log("所需类型--", _type);
          if (_type == SkinGetForType.Using) {
              for (let index = 0; index < this.uiArr.length; index++) {
                  if (index == 0) {
                      this.uiArr[index].visible = true;
                  }
                  else {
                      this.uiArr[index].visible = false;
                  }
              }
              return;
          }
          this.Using.visible = false;
          for (let index = 1; index < this.uiArr.length; index++) {
              if (index == _type) {
                  this.uiArr[index].visible = true;
              }
              else {
                  this.uiArr[index].visible = false;
              }
          }
          switch (_type) {
              case SkinGetForType.Bycoin:
                  this.RequireCoinNum.text = this._data.require_num.toString();
                  break;
              case SkinGetForType.GetByVideo:
                  this.RequireVideoNum.text = AccountManager.Instance.curplayerData.GetProgress(this._data.id) + "/" + this._data.require_num.toString();
                  break;
          }
      }
      VideoGet() {
          GuangGao.Instance.loadVideo(isLoaded => {
              if (isLoaded) {
                  GuangGao.Instance.showVideo(isOk => {
                      if (isOk) {
                          WXSDK.AldEvent("皮肤界面看视频得金币成功");
                          var getkey = ArcherWorrior.vd;
                          let param = [{ "reward_item": "1000" }, { "reward_num": "200" }, { "t": AccountManager.Instance.ServerTime.toString() }];
                          ServerManager.Instance.SendHttp(getkey, param, Laya.Handler.create(this, this.VideoGetSuccess), Laya.Handler.create(this, this.VideoGetFail));
                      }
                  });
              }
              else {
                  WXSDK.fengxiangtupian(isOk => {
                      if (isOk) {
                          WXSDK.AldEvent("皮肤界面看视频得金币成功");
                          var getkey = ArcherWorrior.vd;
                          let param = [{ "reward_item": "1000" }, { "reward_num": "200" }, { "t": AccountManager.Instance.ServerTime.toString() }];
                          ServerManager.Instance.SendHttp(getkey, param, Laya.Handler.create(this, this.VideoGetSuccess), Laya.Handler.create(this, this.VideoGetFail));
                      }
                  });
              }
          });
      }
      VideoGetSuccess(_data) {
          this.RefreshItem();
          console.log("LookVideo->suc:" + JSON.stringify(_data));
      }
      VideoGetFail(_data) {
          console.log("LookVideo->fail:" + JSON.stringify(_data));
      }
      Use() {
          var agrs = [{ "id": this._data.id }];
          ServerManager.Instance.SendHttp(ArcherWorrior.WearEquip, agrs, Laya.Handler.create(this, this.UseSuccess), Laya.Handler.create(this, this.UseFail));
      }
      UseSuccess(data) {
          this.RefreshItem();
          this.RefreshButton(SkinGetForType.Using);
          WXSDK.ShowTxt("装备成功!");
          console.log("装备suc:" + JSON.stringify(data));
      }
      UseFail(data) {
          console.log(data);
      }
      Buy() {
          var agrs = [{ "id": this._data.id.toString() }];
          ServerManager.Instance.SendHttp(ArcherWorrior.BuyEquip, agrs, Laya.Handler.create(this, this.BuySuccess), Laya.Handler.create(this, this.BuyFail));
      }
      BuySuccess(data) {
          WXSDK.AldEvent("购买" + this._data.name + "成功");
          this.RefreshItem();
          this.RefreshButton(SkinGetForType.Using);
          console.log("购买suc:" + JSON.stringify(data));
      }
      BuyFail(data) {
          console.log("购买fail:" + JSON.stringify(data));
      }
  }
  class ShopScene {
      constructor() {
          this.first = true;
          this.motordic = new ResDic();
          ShopScene.ins = this;
      }
      static get Instance() {
          if (ShopScene.ins) {
              return ShopScene.ins;
          }
          else {
              return new ShopScene();
          }
      }
      CreateMoto(_motorindex, _image, trial = null) {
          if (!this._shopscene || this._shopscene.destroyed || this._shopscene == null) {
              this.first = true;
              this._shopscene = new Laya.Scene3D();
              this._camera = new Laya.Camera();
              if (trial) {
                  this._camera.transform.position = new Laya.Vector3(0, 0.7, 3);
                  this._camera.clearFlag = 2;
                  this._camera.fieldOfView = 40;
              }
              else {
                  this._camera.transform.position = new Laya.Vector3(0, 0.6, 3.5);
                  this._camera.clearFlag = 2;
                  this._camera.fieldOfView = 30;
              }
              this._shopscene.addChild(this._camera);
              let _light = new Laya.DirectionLight();
              _light.intensity = 0.5;
              this._shopscene.addChild(_light);
              var player = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(_motorindex), "");
              this._shopscene.addChild(player);
              _image.addChild(this._shopscene);
              player.transform.position = new Laya.Vector3(0, 0, -2);
              this._position = new Laya.Vector3(0, 0.01, 0);
          }
          if (_image) {
              this._camera.viewport = new Laya.Viewport(_image.x, _image.y, _image.width, _image.height);
          }
          if (this._motor) {
              this._motor.active = false;
              this._motor.removeSelf();
              this._motor = null;
          }
          if (!this.first)
              return;
          this.first = false;
          Laya.timer.frameLoop(1, this, this.Rotation, [player]);
      }
      Rotation(model) {
          model.transform.rotate(this._position);
      }
      CloseShop() {
          Laya.timer.clear(this, this.Rotation);
          if (this._motor) {
              this._motor.active = false;
              this._motor.removeSelf();
          }
          if (this._player) {
              this._player.active = false;
              this._player.removeSelf();
          }
          if (this._shopscene) {
              this._shopscene.destroy(true);
          }
          this._shopscene = null;
          this._motor = null;
          this._sprite = null;
          this._player = null;
          this.first = true;
      }
  }

  class TrialView extends ui.TrialViewUI {
      constructor() {
          super();
      }
      static get Instance() {
          if (TrialView.ins) {
              return TrialView.ins;
          }
          else {
              return new TrialView();
          }
      }
      Show() {
          WXSDK.AldEvent("打开皮肤试用界面");
          GuangGao.OpenBanner();
          this.Init();
          this.TrialBtn.clickHandler = Laya.Handler.create(this, this.Trial);
          this.NoTrialBtn.visible = false;
          Laya.timer.once(2000, this, () => {
              this.NoTrialBtn.visible = true;
              this.NoTrialBtn.clickHandler = Laya.Handler.create(this, this.ClickClose);
          });
          this.height = Laya.stage.height;
          Laya.stage.on(Laya.Event.RESIZE, this, () => {
              this.height = Laya.stage.height;
          });
      }
      Close() {
          WXSDK.AldEvent("关闭皮肤试用界面");
      }
      ClickClose() {
          var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
          ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
      }
      Trial() {
          GuangGao.Instance.loadVideo(isLoaded => {
              if (isLoaded) {
                  GuangGao.Instance.showVideo(isOk => {
                      if (isOk) {
                          WXSDK.AldEvent("观看视频试用皮肤成功");
                          var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
                          ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
                          GameManager.Instance.SetHorse(this.arr.id);
                      }
                      else {
                          WXSDK.AldEvent("观看视频试用皮肤失败");
                          var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
                          ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
                      }
                  });
              }
              else {
                  WXSDK.fengxiangtupian(isOk => {
                      if (isOk) {
                          WXSDK.AldEvent("分享好友试用皮肤成功");
                          var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
                          ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
                          GameManager.Instance.SetHorse(this.arr.id);
                      }
                      else {
                          WXSDK.AldEvent("分享好友试用皮肤失败");
                          var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
                          ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
                      }
                  });
              }
          });
      }
      Complete(_data) {
          ShopScene.Instance.CloseShop();
          ViewManager.Instance.ShowView(ViewType.IngameView);
          let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
          WXSDK.AldStart(stage);
          AudioManager.playMusic(MusicType.click);
          MainGameView.Instance.play_id = _data.play_id;
          EventManager.StageTrigger(StageState.Start);
          ViewManager.Instance.ShowView(ViewType.IngameView);
      }
      Init() {
          this.data = this.GetTryOutTheme();
          this.count = this.data.length;
          if (this.count == 1) {
              this.arr = this.data[0];
          }
          else {
              let index = GameTools.RandomANumber(0, this.count);
              this.arr = this.data[index];
          }
          ShopScene.Instance.CreateMoto(this.arr.id, this.SceneViewPort, 1);
      }
      GetTryOutTheme() {
          let arr = [];
          let themeCfg = AccountManager.Instance.curplayerData.GainCollocation("theme");
          let temp;
          if (themeCfg) {
              for (let index = 5; index < themeCfg.length; index++) {
                  const element = themeCfg[index];
                  let _id = element.id;
                  if (!AccountManager.Instance.curplayerData.HasEquip(_id)) {
                      arr.push(element);
                  }
                  if (index == themeCfg.length - 2) {
                      temp = element;
                  }
              }
          }
          if (arr.length == 0)
              arr.push(temp);
          return arr;
      }
  }

  class CompleteView extends ui.CompleteViewUI {
      constructor() {
          super();
          this.win = true;
      }
      static get Instance() {
          if (CompleteView.ins) {
              return CompleteView.ins;
          }
          else {
              return new CompleteView();
          }
      }
      Show(_data) {
          this.Init(_data);
          GuangGao.WudaoAnNiu(this.BtnBox);
          let gold = this.DealData(GameManager.Instance.KillNum);
          this.goldnum.text = Math.floor(gold).toString();
          this.SetData();
          this.height = Laya.stage.height;
          Laya.stage.on(Laya.Event.RESIZE, this, () => {
              this.height = Laya.stage.height;
          });
      }
      Close() {
      }
      Init(_data) {
          switch (_data) {
              case 1:
                  WXSDK.AldEvent("打开胜利界面");
                  this.loseimage.visible = false;
                  this.reviveimage.visible = false;
                  this.NoBtn.visible = false;
                  this.TryAgainBtn.visible = false;
                  this.ReviveBtn.visible = false;
                  this.NextLevelBtn.clickHandler = Laya.Handler.create(this, this.NextLevel, [true]);
                  break;
              case 2:
                  WXSDK.AldEvent("打开失败界面");
                  this.winimage.visible = false;
                  this.reviveimage.visible = false;
                  this.NoBtn.visible = false;
                  this.NextLevelBtn.visible = false;
                  this.ReviveBtn.visible = false;
                  this.TryAgainBtn.clickHandler = Laya.Handler.create(this, this.TryAgain, [false]);
                  break;
              case 3:
                  WXSDK.AldEvent("打开结算界面");
                  this.winimage.visible = false;
                  this.loseimage.visible = false;
                  this.NextLevelBtn.visible = false;
                  this.TryAgainBtn.visible = false;
                  this.NoBtn.clickHandler = Laya.Handler.create(this, this.NoRevive);
                  this.ReviveBtn.clickHandler = Laya.Handler.create(this, this.Revive);
          }
      }
      NextLevel(_win) {
          let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
          WXSDK.AldEnd(stage, true);
          AudioManager.playMusic(MusicType.click);
          this.win = _win;
          var iswin = _win ? "1" : "0";
          var coinnum = this.goldnum.text;
          var args = [{ "t": AccountManager.Instance.ServerTime.toString() }, { "play_id": MainGameView.Instance.play_id }, { "win": iswin }, { "money": coinnum }];
          ServerManager.Instance.SendHttp(ArcherWorrior.JieShu, args, Laya.Handler.create(this, this.Success), null);
      }
      Revive() {
          AudioManager.playMusic(MusicType.click);
          GuangGao.Instance.loadVideo(isLoaded => {
              if (isLoaded) {
                  GuangGao.Instance.showVideo(isOk => {
                      if (isOk) {
                          WXSDK.AldEvent("观看视频复活成功");
                          GameManager.Instance.ReviveNum -= 1;
                          GameManager.Instance.Revive();
                      }
                  });
              }
              else {
                  WXSDK.fengxiangtupian(isOk => {
                      if (isOk) {
                          WXSDK.AldEvent("分享复活成功");
                          GameManager.Instance.ReviveNum -= 1;
                          GameManager.Instance.Revive();
                      }
                      else {
                          EventManager.StageTrigger(StageState.Lose);
                      }
                  });
              }
          });
      }
      NoRevive() {
          GameManager.Instance.ReviveNum -= 1;
          ViewManager.Instance.ShowView(ViewType.CompleteView, 2);
      }
      TryAgain(_win) {
          let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
          WXSDK.AldEnd(stage, false);
          AudioManager.playMusic(MusicType.click);
          this.win = _win;
          var iswin = _win ? "1" : "0";
          var coinnum = this.goldnum.text;
          var args = [{ "t": AccountManager.Instance.ServerTime.toString() }, { "play_id": MainGameView.Instance.play_id }, { "win": iswin }, { "money": coinnum }];
          ServerManager.Instance.SendHttp(ArcherWorrior.JieShu, args, Laya.Handler.create(this, this.Success), null);
      }
      Success() {
          EventManager.StageTrigger(StageState.Restart);
          ViewManager.Instance.OpenPopView(ViewType.ExportView);
      }
      DealData(_num) {
          if (_num > StageControl.Instance.curstage.Goal) {
              _num = StageControl.Instance.curstage.Goal;
          }
          var _reward = AccountManager.Instance.curplayerData.GlobalData("mission_reward");
          var gold = _reward * StageControl.Instance.curstage.Modulus * (_num / StageControl.Instance.curstage.Goal);
          return gold;
      }
      SetData() {
          SDKZS.SetHuTuiList(this.PushList, 1, "");
          this.GunGun();
      }
      GunGun() {
          var maxBtm;
          try {
              this.PushList.scrollBar.value = 0;
              maxBtm = this.PushList.scrollBar.max;
          }
          catch (error) {
              console.error(error);
              return;
          }
          let tempBtm = 1;
          Laya.timer.frameLoop(1, this, () => {
              this.PushList.scrollBar.value += tempBtm;
              if (this.PushList.scrollBar.value >= maxBtm || this.PushList.scrollBar.value <= 0) {
                  tempBtm = -tempBtm;
              }
          });
      }
  }

  class ExportView extends ui.ExportViewUI {
      OnOpen(data) {
          WXSDK.AldEvent("打开全屏幕导出界面");
          this.CloseExportBtn.clickHandler = Laya.Handler.create(this, this.ClickClose, [data]);
          this.SetData();
          this.height = Laya.stage.height;
          Laya.stage.on(Laya.Event.RESIZE, this, () => {
              this.height = Laya.stage.height;
          });
      }
      OnHide() {
          Laya.timer.clearAll(this);
          WXSDK.AldEvent("关闭全屏导出界面");
      }
      ClickClose(data) {
          ViewManager.Instance.ClosePopView(ViewType.ExportView);
      }
      SetData() {
          SDKZS.SetHuTuiList(this.HList, 2, "");
          SDKZS.SetHuTuiList(this.VList, 1, "");
          this.GunGun();
      }
      GunGun() {
          var maxTop;
          var maxBtm;
          try {
              this.VList.scrollBar.value = 0;
              this.HList.scrollBar.value = 0;
              maxTop = this.HList.scrollBar.max;
              maxBtm = this.VList.scrollBar.max;
          }
          catch (error) {
              console.error(error);
              return;
          }
          var tempTop = 1;
          var tempBtm = 1;
          Laya.timer.frameLoop(1, this, () => {
              this.HList.scrollBar.value += tempTop;
              if (this.HList.scrollBar.value >= maxTop || this.HList.scrollBar.value <= 0) {
                  tempTop = -tempTop;
              }
              this.VList.scrollBar.value += tempBtm;
              if (this.VList.scrollBar.value >= maxBtm || this.VList.scrollBar.value <= 0) {
                  tempBtm = -tempBtm;
              }
          });
      }
  }

  var ViewType;
  (function (ViewType) {
      ViewType[ViewType["MainView"] = 0] = "MainView";
      ViewType[ViewType["IngameView"] = 1] = "IngameView";
      ViewType[ViewType["ShopView"] = 2] = "ShopView";
      ViewType[ViewType["TrialView"] = 3] = "TrialView";
      ViewType[ViewType["CompleteView"] = 4] = "CompleteView";
      ViewType[ViewType["ExportView"] = 5] = "ExportView";
  })(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();
          }
          GuangGao.Clear();
          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) {
          GuangGao.Clear();
          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;
          }
          GuangGao.Clear();
          popView.OnHide();
          popView.visible = false;
          this.showexportview = 0;
      }
      ClearPopViews() {
          GuangGao.Clear();
      }
      CreateView(_viewtype) {
          switch (_viewtype) {
              case ViewType.MainView:
                  return new MainGameView();
              case ViewType.IngameView:
                  return new InGameView();
              case ViewType.TrialView:
                  return new TrialView();
              case ViewType.CompleteView:
                  return new CompleteView();
              case ViewType.ExportView:
                  return new ExportView();
              case ViewType.ShopView:
                  return new ShopView();
          }
          return null;
      }
  }

  class SDKZS {
      static SetHuTuiList(list, scrol = 1, type = "") {
          console.log("互推数据--", SDKZS.data);
          console.log("互推数据准备状态---", SDKZS.isReady);
          let arr = SDKZS.data.promotion;
          if (!arr || arr.length == 0)
              return;
          list.selectEnable = false;
          scrol == 1 ? list.vScrollBarSkin = "" : list.hScrollBarSkin = "";
          list.renderHandler = Laya.Handler.create(this, SDKZS.updateItem, [type], false);
          list.array = arr;
          list.refresh();
      }
      static updateItem(type, cell, index) {
          var aditem = cell.getComponent(ListItem);
          aditem.Refresh(type);
      }
      static loadData() {
          zs.sdk.loadAd((res) => {
              console.log("[LOG]互推数据");
              console.log(res);
              SDKZS.data = res;
              console.log("拉取互推数据--", SDKZS.data);
              SDKZS.isReady = true;
          });
      }
      static navigate2Mini(data) {
          zs.sdk.navigate2Mini(data, AccountManager.Instance.curplayerData.openid, () => {
              WXSDK.AldEvent("成功跳转到" + data.app_title);
          }, () => {
              WXSDK.AldEvent("跳转" + data.app_title + "失败");
              if (ViewManager.Instance.showexportview == 0) {
                  ViewManager.Instance.OpenPopView(ViewType.ExportView);
              }
          }, () => {
          });
      }
      static get CanCheat() {
          var checkscence = AccountManager.Instance.curplayerData.CheckScene;
          if (checkscence == false) {
              return true;
          }
          if (Main.SceneNum == "1037" || Main.SceneNum == "1058"
              || Main.SceneNum == "1067" || Main.SceneNum == "1095") {
              return true;
          }
          return false;
      }
  }
  SDKZS.isReady = false;

  class ListItem extends Laya.Script {
      constructor() { super(); }
      onAwake() {
          this.self = this.owner;
          this.icon = this.self.getChildByName("icon");
          this.btn = this.self.getChildByName("btn");
          this.name = this.self.getChildByName("name");
          this._tip = this.self.getChildByName("tip");
          this.bottom = this.self.getChildByName("bottom");
          this.remen = this.self.getChildByName("remen");
          this.diandian = this.icon.getChildAt(0);
          this.btn.clickHandler = new Laya.Handler(this, this.clickAd);
      }
      Refresh(type) {
          this.data = this.self.dataSource;
          this.type = type;
          if (this.name) {
              this.name.text = this.data.app_title;
          }
          if (this._tip) {
              this._tip.visible = true;
              let rnd = GameTools.RandomANumber(1, 200000);
              let text = rnd.toString() + "人玩过";
              if (rnd > 9999) {
                  text = Math.floor(rnd / 10000) + "W人玩过";
              }
              this._tip.text = text;
          }
          if (this.diandian) {
              this.diandian.visible = false;
          }
          if (this.bottom) {
              let num = GameTools.RandomANumber(1, 10);
              this.bottom.skin = "Game/res/bottom/" + num + ".png";
          }
          if (this.remen) {
              this.remen.visible = Math.random() < 0.2 ? true : false;
          }
          this.icon.skin = this.data.app_icon;
      }
      clickAd() {
          SDKZS.navigate2Mini(this.data);
      }
      onDestroy() {
          this.btn.clickHandler = null;
      }
  }

  class GameConfig {
      constructor() { }
      static init() {
          var reg = Laya.ClassUtils.regClass;
          reg("Tools/ListItem.ts", ListItem);
          reg("Tools/ShopItem.ts", ShopItem);
      }
  }
  GameConfig.width = 720;
  GameConfig.height = 1280;
  GameConfig.scaleMode = "fixedwidth";
  GameConfig.screenMode = "none";
  GameConfig.alignV = "top";
  GameConfig.alignH = "left";
  GameConfig.startScene = "LoadView.scene";
  GameConfig.sceneRoot = "";
  GameConfig.debug = false;
  GameConfig.stat = false;
  GameConfig.physicsDebug = false;
  GameConfig.exportSceneToJson = true;
  GameConfig.init();

  class Main {
      constructor() {
          if (CheckMain.Creat)
              return;
          CheckMain.Creat = 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;
          if (Laya.Browser.onWeiXin) {
              Laya.Browser.window.wx.showShareMenu({
                  withShareTicket: true
              });
              Laya.Browser.window.wx.onShareAppMessage(function () {
                  return {
                      title: "有人@你，一起骑马仗箭走天涯",
                      imageUrl: "Game/res/textrue/share.jpg",
                  };
              });
              Laya.Browser.window.wx.onShow((option) => {
                  var shareTicket = option.shareTicket;
                  var userId = option.query.userId;
                  var shareTitle = option.query.shareTitle;
                  var scenevalue = Laya.LocalStorage.getItem("SceneValue");
                  if (scenevalue) {
                      Main.SceneNum = scenevalue;
                  }
                  else {
                      Laya.LocalStorage.setItem("SceneValue", option.scene);
                      Main.SceneNum = option.scene;
                  }
                  WXSDK.querychannel = option.query.channel;
                  WXSDK.shareOpenId = option.query.userId;
                  console.log("scene:", option.scene);
                  if (WXSDK.querychannel != null) {
                      console.log("onShow channel is:", WXSDK.querychannel);
                  }
                  if (option.referrerInfo) {
                      WXSDK.referrerInfoappId = option.referrerInfo.appId;
                      console.log("onShow appId is:", option.referrerInfo.appId);
                  }
              });
              if (!Laya.Browser.onWeiXin)
                  return;
              const updateManager = Laya.Browser.window.wx.getUpdateManager();
              updateManager.onCheckForUpdate(function (res) {
                  console.log("最新版本:" + res.hasUpdate);
              });
              updateManager.onUpdateReady(function () {
                  Laya.Browser.window.wx.showModal({
                      showCancel: false,
                      title: '更新提示',
                      content: '新版本已经准备好，是否重启应用？',
                      success(res) {
                          updateManager.applyUpdate();
                      },
                      fail(res) {
                          updateManager.applyUpdate();
                      }
                  });
              });
          }
          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();
      }
  }
  Main.Ver = "1.0.0";
  Main.CFG = "123";
  new Main();

  var HttpRequest = Laya.HttpRequest;
  var Event = Laya.Event;
  const ArcherWorriorApiUrl = "https://archerworriorapi.xwxgame.com/";
  class ArcherWorrior {
  }
  ArcherWorrior.DengLu = "user/login";
  ArcherWorrior.KaiShi = "game/start";
  ArcherWorrior.JieShu = "game/play";
  ArcherWorrior.QianDao = "sign/sign";
  ArcherWorrior.Chengjiu = "achievement/getRewards";
  ArcherWorrior.Config = "config/table";
  ArcherWorrior.FenXiang = "fission/share";
  ArcherWorrior.LiXian = "fission/offline";
  ArcherWorrior.vd = "fission/vd";
  ArcherWorrior.FuHuo = "game/revival";
  ArcherWorrior.gadagdag = "treasure/click";
  ArcherWorrior.Invite = "invite/getRewards";
  ArcherWorrior.Lottery = "lottery/lottery";
  ArcherWorrior.ShareGetSkin = "theme/fission";
  ArcherWorrior.WearEquip = "theme/equip";
  ArcherWorrior.BuyEquip = "theme/buy";
  ArcherWorrior.ShouQuan = "user/auth";
  ArcherWorrior.JinBi = "user/sync";
  class ServerManager {
      constructor() { }
      static get Instance() {
          if (ServerManager.ins) {
              return ServerManager.ins;
          }
          else {
              return new ServerManager();
          }
      }
      Login(progresscb, completecb, errorcb) {
          var Account = AccountManager.Instance;
          var ver = Main.Ver;
          let Data = `code=${Account.code}&nickname=${Account.nickName}&avatar=${Account.avatarUrl}&gender=${Account.gender}&country=${Account.country}&province=${Account.province}&city=${Account.city}& device=${Account.device}$&share_id=${Account.share_id}&scene=${Account.scene}&v=${ver}`;
          let httpRequest = new HttpRequest();
          httpRequest.once(Event.PROGRESS, this, this.Progress, [progresscb, httpRequest]);
          httpRequest.once(Event.COMPLETE, this, this.Complete, [completecb, httpRequest]);
          httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
          httpRequest.send(ArcherWorriorApiUrl + ArcherWorrior.DengLu, Data, "post", "text");
      }
      Progress(_progresscb, _httpreq) {
          if (_progresscb) {
              _progresscb.run();
          }
      }
      Complete(_completecb, _httpreq) {
          let data = JSON.parse(_httpreq.data);
          console.log(data);
          if (data["code"] != "0") {
              console.log("登录异常错误！错误信息sssssssss：", _httpreq.data["code"]);
              return;
          }
          console.log("-----------sss", data["t"]);
          AccountManager.Instance.SFSFSF = data["t"];
          this.RessetConfig(data, _completecb);
      }
      RessetConfig(data, completecb) {
          AccountManager.Instance.ReSetting(data, (flag) => {
              if (flag) {
                  completecb.runWith(data);
              }
              else {
                  this.RessetConfig(data, completecb);
              }
          });
      }
      Errorcb(_errorcb, _httpreq) {
          if (_errorcb != null) {
              _errorcb.runWith(_httpreq);
          }
      }
      SendHttp(protocol, param, completecb, errorcb, hasToken = true) {
          let sfaasfsfa = "";
          let daadsads = ArcherWorriorApiUrl + protocol;
          if (hasToken == true) {
              sfaasfsfa = `token=${AccountManager.Instance.curplayerData.zhengshu}&`;
          }
          if (protocol == ArcherWorrior.KaiShi || protocol == ArcherWorrior.JieShu || protocol == ArcherWorrior.vd || protocol == ArcherWorrior.Lottery) {
              let asddsa = "abcdefghijkimnopqrstuvwxyz0123456789";
              let adsassda = "{";
              let saafsafs = "";
              for (let i = 0; i < 4; i++) {
                  saafsafs += asddsa[Math.floor(Math.random() * 100) % asddsa.length];
              }
              for (let i = 0; i < param.length; i++) {
                  for (let key in param[i]) {
                      adsassda += `\"${key}\":\"${param[i][key]}\"`;
                  }
                  if (i < param.length - 1) {
                      adsassda += ",";
                  }
                  else {
                      adsassda += "}";
                  }
              }
              sfaasfsfa += "_r=" + saafsafs + this.SFGSGSG(adsassda);
          }
          else {
              if (param != null) {
                  for (let i = 0; i < param.length; i++) {
                      for (let key in param[i]) {
                          let val = param[i][key];
                          sfaasfsfa += `${key}=${val}`;
                          if (i < param.length - 1) {
                              sfaasfsfa += "&";
                          }
                      }
                  }
              }
          }
          let httpRequest = new HttpRequest();
          httpRequest.once(Event.COMPLETE, this, this.onHttpRequestComplete, [completecb, errorcb, httpRequest]);
          httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
          httpRequest.send(daadsads, sfaasfsfa, "post", "text");
      }
      onHttpRequestComplete(succeedcb, failurecb, httpRequest) {
          let data = JSON.parse(httpRequest.data);
          if (data["code"] == 0) {
              AccountManager.Instance.ReSetting(data);
              if (succeedcb != null) {
                  succeedcb.runWith(data);
              }
          }
          else {
              if (failurecb != null) {
                  failurecb.runWith(data);
              }
              console.log("Error! Http request complete error, code: " + data["code"] + " message: " + data["message"]);
          }
      }
      SFGSGSG(str) {
          var c1, c2, c3;
          var SFSFFSFSFSFS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
          var i = 0, len = str.length, SFFSSFFS = '';
          while (i < len) {
              c1 = str.charCodeAt(i++) & 0xff;
              if (i == len) {
                  SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
                  SFFSSFFS += SFSFFSFSFSFS.charAt((c1 & 0x3) << 4);
                  SFFSSFFS += "==";
                  break;
              }
              c2 = str.charCodeAt(i++);
              if (i == len) {
                  SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
                  SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
                  SFFSSFFS += SFSFFSFSFSFS.charAt((c2 & 0xF) << 2);
                  SFFSSFFS += "=";
                  break;
              }
              c3 = str.charCodeAt(i++);
              SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
              SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
              SFFSSFFS += SFSFFSFSFSFS.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
              SFFSSFFS += SFSFFSFSFSFS.charAt(c3 & 0x3F);
          }
          return SFFSSFFS;
      }
  }

  class AccountManager {
      constructor(_code, _userinfo, _nickname, _avatarurl, _gender, _province, _city, _country, _device, _shareid, _scene, _v) {
          this.createTime = Laya.timer.currTimer;
          AccountManager.ins = this;
          this.code = _code;
          this.userInfo = _userinfo;
          this.nickName = _nickname;
          this.avatarUrl = _avatarurl;
          this.gender = _gender;
          this.province = _province;
          this.city = _city;
          this.country = _country;
          this.device = _device;
          this.share_id = _shareid;
          this.scene = _scene;
          this.v = _v;
      }
      static get Instance() {
          if (AccountManager.ins == null) {
              new AccountManager("222222", "你找谁？", "1233", "123", 1, "中国", "上海", "上海", "iphone6s", "123", "123", "123");
          }
          return AccountManager.ins;
      }
      ReSetting(data, cb = null) {
          var zhengshu = data["token"];
          var netset = data["app_setting"];
          var user = data["user"];
          var jichu = data["user_base"];
          var qiandao = data["user_sign"];
          var chengjiu = data["user_achievement"];
          var invite = data["user_invite"];
          var lottery = data["user_lottery"];
          if (this.curplayerData == null) {
              this.curplayerData = new PlayerData(zhengshu, null, netset, user, jichu, invite, null, qiandao, chengjiu, lottery);
              this.JundgCfg(data.table_version, cb);
          }
          else {
              if (netset) {
                  this.curplayerData.netzheshe = netset;
              }
              if (user) {
                  this.curplayerData.account = user;
              }
              if (jichu) {
                  this.curplayerData.accountssss = jichu;
              }
              if (qiandao) {
                  this.curplayerData.qiandao = qiandao;
              }
              if (chengjiu) {
                  this.curplayerData.renwu = chengjiu;
              }
          }
      }
      JundgCfg(ver, callball) {
          var cfg = Laya.LocalStorage.getJSON(Main.CFG);
          if (cfg) {
              if (cfg.VER == ver) {
                  console.log("已经拥有,不用更新");
                  this.SetCfg(cfg);
                  if (callball)
                      callball(true);
              }
              else {
                  console.log("cfg存在但是过期了");
                  Laya.LocalStorage.removeItem(Main.CFG);
                  ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
                      data.configs.VER = ver;
                      Laya.LocalStorage.setJSON(Main.CFG, data.configs);
                      this.SetCfg(data.configs);
                      if (callball)
                          callball(true);
                  }), Laya.Handler.create(this, (data) => {
                      console.log("配置获取失败" + data);
                      if (callball)
                          callball(false);
                      return;
                  }));
              }
          }
          else {
              console.log("本地没有cfg");
              ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
                  data.configs.VER = ver;
                  Laya.LocalStorage.setJSON(Main.CFG, data.configs);
                  this.SetCfg(data.configs);
                  if (callball)
                      callball(true);
              }), Laya.Handler.create(this, (data) => {
                  console.log("配置获取失败" + data);
              }));
          }
      }
      SetCfg(data) {
          this.curplayerData.peizhis = data;
      }
      RessetConfig() {
          ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
              this.curplayerData.peizhis = data["configs"];
          }), null);
      }
      get ServerTime() {
          let time = Laya.timer.currTimer;
          let stime = this.SFSFSF + Math.ceil((time - this.createTime) / 1000);
          return stime;
      }
  }

  var Vector3$4 = Laya.Vector3;
  var NpcState;
  (function (NpcState) {
      NpcState[NpcState["Attack"] = 0] = "Attack";
      NpcState[NpcState["Idle"] = 1] = "Idle";
      NpcState[NpcState["Win"] = 2] = "Win";
      NpcState[NpcState["Pursue"] = 3] = "Pursue";
      NpcState[NpcState["Run"] = 4] = "Run";
      NpcState[NpcState["Die"] = 5] = "Die";
  })(NpcState || (NpcState = {}));
  class NpcRunner extends Laya.Script {
      constructor() {
          super();
          this.m_distance = 20;
          this.m_distanceatk = 5;
          this.DIE = false;
          this.m_npcspeed = 0;
          this.atked = false;
          this.wined = false;
          this.begin = false;
          this.frontdie = false;
          this.reardie = false;
          this.canmove = false;
          this.dir = new Vector3$4();
          this.currotV = new Vector3$4();
          this.currot = new Laya.Quaternion;
          this.CurrectRotate = new Laya.Quaternion();
          this.curspeed = 0;
          this.offest = new Vector3$4();
          this.curpos = new Vector3$4();
          this.die = false;
          NpcRunner.ins = this;
          EventManager.StageOn(StageState.Start, this, this.Begin);
          EventManager.StageOn(StageState.Lose, this, this.GameOver);
          EventManager.StageOn(StageState.Win, this, this.GameOver);
          EventManager.StageOn(StageState.Press, this, this.AddSpeed);
          EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
      }
      static get Instance() {
          if (NpcRunner.ins) {
              return NpcRunner.ins;
          }
          else {
              return new NpcRunner();
          }
      }
      onAwake() {
          this.m_npcmodel = this.owner;
          this.m_npcanimator = this.owner.getComponent(Laya.Animator);
          this.player = PlayerControl.Instance.Player;
          this.m_distance = AccountManager.Instance.curplayerData.NpcRunDistance * 1.65;
          this.m_distanceatk = AccountManager.Instance.curplayerData.NpcAtkDistance * 1.65;
          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          if (stage == 1) {
              this.m_npcspeed = 0.1;
          }
          else {
              this.m_npcspeed = StageControl.Instance.curstage.npcspeed;
          }
      }
      Begin() {
          this.ChangeState(NpcState.Idle);
          this.begin = true;
      }
      onUpdate() {
          if (!this.begin)
              return;
          if (this.npc_state == NpcState.Die)
              return;
          if (this.frontdie || this.reardie) {
              this.ChangeState(NpcState.Die);
              return;
          }
          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          var distance = Vector3$4.distance(this.player.transform.position, this.m_npcmodel.transform.position);
          if (distance < this.m_distance && distance > this.m_distanceatk && !this.atked && stage > 2) {
              Vector3$4.subtract(this.player.transform.position, this.m_npcmodel.transform.position, this.currotV);
              Vector3$4.normalize(this.currotV, this.currotV);
              this.m_npcmodel.transform.lookAt(new Vector3$4(this.m_npcmodel.transform.position.x - this.currotV.x, this.m_npcmodel.transform.position.y, this.m_npcmodel.transform.position.z - this.currotV.z), new Vector3$4(0, 1, 0));
              this.NPCMoveDir = this.currotV;
              this.canmove = true;
              this.ChangeState(NpcState.Run);
          }
          else if (distance <= this.m_distanceatk && !this.atked && stage > 2) {
              Vector3$4.subtract(this.player.transform.position, this.m_npcmodel.transform.position, this.currotV);
              Vector3$4.normalize(this.currotV, this.currotV);
              this.m_npcmodel.transform.lookAt(new Vector3$4(this.m_npcmodel.transform.position.x - this.currotV.x, this.m_npcmodel.transform.position.y, this.m_npcmodel.transform.position.z - this.currotV.z), new Vector3$4(0, 1, 0));
              this.NPCMoveDir = this.currotV;
              this.atked = true;
              this.ChangeState(NpcState.Attack);
          }
          this.Move(this.NPCMoveDir, this.m_npcspeed);
          this.RayCheck();
      }
      Move(_dir, _speed) {
          if (this.canmove) {
              var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
              this.curspeed = sp;
              Vector3$4.scale(_dir, this.curspeed, this.offest);
              Vector3$4.add(this.m_npcmodel.transform.position, this.offest, this.curpos);
              Vector3$4.lerp(this.m_npcmodel.transform.position, this.curpos, 0.15, this.curpos);
              this.curpos = new Vector3$4(this.curpos.x, this.curpos.y, this.curpos.z);
              this.m_npcmodel.transform.position = this.curpos;
          }
      }
      AddSpeed() {
          this.m_npcspeed = StageControl.Instance.curstage.npcspeed;
      }
      SlowSpeed() {
          this.m_npcspeed = StageControl.Instance.curstage.npcspeed / 2;
      }
      GameOver() {
          EventManager.StageOff(StageState.Press, this, this.AddSpeed);
          EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
          EventManager.StageOff(StageState.Start, this, this.Begin);
      }
      ChangeState(_state) {
          if (this.npc_state == _state)
              return;
          this.npc_state = _state;
          switch (this.npc_state) {
              case NpcState.Attack:
                  this.Attack();
                  break;
              case NpcState.Pursue:
                  this.Pursue();
                  break;
              case NpcState.Win:
                  this.Win();
                  break;
              case NpcState.Idle:
                  this.Idle();
                  break;
              case NpcState.Run:
                  this.Run();
                  break;
              case NpcState.Die:
                  this.Die();
                  break;
          }
      }
      Idle() {
          this.m_npcanimator.play("idle");
      }
      Attack() {
          this.m_npcanimator.play("atk");
          Laya.timer.once(500, this, () => {
              this.canmove = false;
          });
      }
      Win() {
          this.m_npcanimator.play("win");
      }
      Pursue() {
      }
      Run() {
          this.m_npcanimator.play("run");
      }
      Die() {
          if (this.die)
              return;
          this.die = true;
          AudioManager.playMusic(MusicType.die);
          this.PiaoZi();
          EventManager.StageOff(StageState.Start, this, this.Begin);
          Laya.timer.once(500, this, () => {
              GamePool.Instance.RecoveryModel(this.m_npcmodel);
          });
          if (this.frontdie) {
              this.m_npcanimator.play("diefront");
          }
          else if (this.reardie) {
              this.m_npcanimator.play("dierear");
          }
          this.canmove = false;
      }
      PiaoZi() {
          let headshoot = new Laya.Image();
          headshoot.skin = "Game/res/textrue/headshoot.png";
          headshoot.scaleX = 1;
          headshoot.scaleY = 1;
          headshoot.anchorX = 0.5;
          headshoot.anchorY = 0.5;
          Laya.stage.addChild(headshoot);
          Laya.timer.once(1000, this, () => {
              headshoot.visible = false;
          });
          GameManager.Instance.UIArray.push(headshoot);
          let UIPos = this.m_npcmodel.getChildByName("UIPos");
          let screenpos1 = new Vector3$4();
          Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, headshoot, screenpos1]);
      }
      UIFollow(UIPos, UI, POS) {
          AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
          UI.pos(POS.x, POS.y);
      }
      RayCheck() {
          if (this.wined)
              return;
          let startpos = new Vector3$4(this.m_npcmodel.transform.position.x, this.m_npcmodel.transform.position.y + 1.5, this.m_npcmodel.transform.position.z);
          let dir = Transform3DHelper.getForward(this.m_npcmodel.transform);
          let ray = new Laya.Ray(startpos, dir);
          let hitres = new Laya.HitResult();
          let isHit = AssetManager.Instance.mainscene.physicsSimulation.rayCast(ray, hitres, 1, 200);
          if (isHit) {
              let target = hitres.collider.owner.parent;
              if (target.name == "player") {
                  let runner = target.getComponent(Runner);
                  let ani = target.getComponent(Laya.Animator);
                  if (!runner.Invincible) {
                      Laya.timer.once(150, this, () => {
                          runner.isdead = true;
                          this.wined = true;
                      });
                  }
              }
              else if (target.name == "bonfire") {
                  this.ChangeState(NpcState.Die);
                  this.wined = true;
              }
              else if (target.name == "stone") ;
              else if (target.name == "") ;
          }
      }
  }

  var Vector3$5 = Laya.Vector3;
  var HostageState;
  (function (HostageState) {
      HostageState[HostageState["Run"] = 0] = "Run";
      HostageState[HostageState["Rescue"] = 1] = "Rescue";
      HostageState[HostageState["Arrest"] = 2] = "Arrest";
      HostageState[HostageState["Die"] = 3] = "Die";
  })(HostageState || (HostageState = {}));
  class Hostage extends Laya.Script {
      constructor() {
          super();
          this._hostagespeed = 0;
          this.begin = false;
          this.isbarrier = false;
          this.canmove = false;
          this.isdead = false;
          this.DownHit = new Laya.HitResult();
          this.FowardHit = new Laya.HitResult();
          this.currotV = new Vector3$5();
          this.hostagedir = new Vector3$5();
          this.offest = new Vector3$5();
          this.curpos = new Vector3$5();
          this.curspeed = 0;
          Hostage.ins = this;
          EventManager.StageOn(StageState.Start, this, this.Begin);
          EventManager.StageOn(StageState.Lose, this, this.GameOver);
          EventManager.StageOn(StageState.Win, this, this.GameOver);
          EventManager.StageOn(StageState.Press, this, this.AddSpeed);
          EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
      }
      static get Instance() {
          if (Hostage.ins) {
              return Hostage.ins;
          }
          else {
              return new Hostage();
          }
      }
      onAwake() {
          this.m_hostagemodel = this.owner;
          this.m_hostageanimator = this.m_hostagemodel.getComponent(Laya.Animator);
          this.enemy = this.owner.parent.parent.getChildByName("enemy").getChildAt(0);
          this._hostagespeed = StageControl.Instance.curstage.hostspeed;
      }
      Begin() {
          this.ChangeState(HostageState.Run);
          this.begin = true;
      }
      onUpdate() {
          if (!this.begin)
              return;
          if (this.isdead) {
              this.ChangeState(HostageState.Die);
              return;
          }
          let npc = this.enemy.getComponent(ChaseNpc);
          if (npc.isdead || this.enemy == null || this.enemy.destroyed) {
              this.canmove = false;
              this.ChangeState(HostageState.Rescue);
              return;
          }
          this.RayCheck();
          let target = this.LookforRoad();
          if (this.canmove) {
              if (target) {
                  Vector3$5.subtract(target.transform.position, this.m_hostagemodel.transform.position, this.currotV);
                  Vector3$5.normalize(this.currotV, this.currotV);
                  this.m_hostagemodel.transform.lookAt(new Vector3$5(this.m_hostagemodel.transform.position.x - this.currotV.x, this.m_hostagemodel.transform.position.y, this.m_hostagemodel.transform.position.z - this.currotV.z), new Vector3$5(0, 1, 0));
                  this.hostagedir = this.currotV;
                  if (!this.isbarrier) {
                      this.Move(this.currotV, this._hostagespeed);
                  }
              }
              else {
                  if (!this.isbarrier) {
                      this.Move(new Vector3$5(0, 0, 1), this._hostagespeed);
                  }
              }
          }
      }
      LookforRoad() {
          var doorarr = [];
          for (let i = 0; i < DataManager.DoorArray.length; i++) {
              let _door = DataManager.DoorArray[i];
              if (this.m_hostagemodel.transform.position.z < _door.transform.position.z) {
                  doorarr.push(_door);
              }
          }
          for (let i = 0; i < doorarr.length; i++) {
              for (let j = 0; j < doorarr.length - i - 1; j++) {
                  var _dis = Vector3$5.distance(doorarr[i].transform.position, this.m_hostagemodel.transform.position);
                  var _dis2 = Vector3$5.distance(doorarr[i + 1].transform.position, this.m_hostagemodel.transform.position);
                  if (_dis > _dis2) {
                      let door1 = doorarr[i];
                      doorarr[i] = doorarr[i + 1];
                      doorarr[i + 1] = door1;
                  }
              }
          }
          return doorarr[0];
      }
      Move(_dir, _speed) {
          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          if (stage == 1)
              return;
          if (this.canmove) {
              var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
              this.curspeed = sp;
              Vector3$5.scale(_dir, this.curspeed, this.offest);
              Vector3$5.add(this.m_hostagemodel.transform.position, this.offest, this.curpos);
              Vector3$5.lerp(this.m_hostagemodel.transform.position, this.curpos, 0.15, this.curpos);
              this.curpos = new Vector3$5(this.curpos.x, this.curpos.y, this.curpos.z);
              this.m_hostagemodel.transform.position = this.curpos;
          }
      }
      AddSpeed() {
          this._hostagespeed = StageControl.Instance.curstage.hostspeed;
      }
      SlowSpeed() {
          this._hostagespeed = StageControl.Instance.curstage.hostspeed / 2;
      }
      GameOver() {
          EventManager.StageOff(StageState.Press, this, this.AddSpeed);
          EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
          EventManager.StageOff(StageState.Start, this, this.Begin);
          Laya.timer.clearAll(this);
          this.canmove = false;
      }
      ChangeState(_state) {
          if (this.m_hostagestate == _state)
              return;
          this.m_hostagestate = _state;
          switch (this.m_hostagestate) {
              case HostageState.Run:
                  this.Run();
                  break;
              case HostageState.Arrest:
                  this.Arrest();
                  break;
              case HostageState.Rescue:
                  this.Rescue();
                  break;
              case HostageState.Die:
                  this.Die();
                  break;
          }
      }
      Run() {
          this.m_hostageanimator.play("run");
      }
      Rescue() {
          this.m_hostageanimator.play("thank");
          this.PiaoZi();
      }
      Arrest() {
          this.m_hostageanimator.play("dierear");
          this.canmove = false;
      }
      Die() {
          WXSDK.Shake(true);
          this.m_hostageanimator.play("dierear");
          this.canmove = false;
          EventManager.StageOff(StageState.Start, this, this.Begin);
          Laya.timer.clearAll(this);
          EventManager.StageTrigger(StageState.Lose);
      }
      RayCheck() {
          if (this.FowardRayCheck) {
              this.CrashBarrier();
              this.isbarrier = true;
          }
          else {
              this.isbarrier = false;
          }
      }
      PiaoZi() {
          let smile = new Laya.Image();
          smile.skin = "Game/res/textrue/happy.png";
          smile.scaleX = 0.05;
          smile.scaleY = 0.05;
          smile.anchorX = 0.5;
          smile.anchorY = 0.5;
          Laya.stage.addChild(smile);
          Laya.timer.once(1000, this, () => {
              smile.visible = false;
              Laya.timer.clear(this, this.UIFollow);
          });
          GameManager.Instance.UIArray.push(smile);
          let UIPos = this.m_hostagemodel.getChildByName("UIPos");
          let screenpos = new Vector3$5();
          Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, smile, screenpos]);
      }
      UIFollow(UIPos, UI, POS) {
          AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
          UI.pos(POS.x, POS.y);
      }
      CrashBarrier() {
          var target = this.FowardHit.collider.owner.parent;
          if (target.name == "stone") {
              this._hostagespeed = 0;
          }
          else if (target.name == "bonfire") ;
          else if (target.name == "big_fence") {
              this._hostagespeed = 0;
          }
          else if (target.name == "wood_Cylinder") {
              this._hostagespeed = 0;
          }
      }
      get FowardRayCheck() {
          var isFowardHit = false;
          var startPos = new Vector3$5(this.m_hostagemodel.transform.position.x, this.m_hostagemodel.transform.position.y + 1, this.m_hostagemodel.transform.position.z + 0.5);
          var direction = new Vector3$5(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 Vector3$6 = Laya.Vector3;
  var ChaseNpcState;
  (function (ChaseNpcState) {
      ChaseNpcState[ChaseNpcState["Idle"] = 0] = "Idle";
      ChaseNpcState[ChaseNpcState["Run"] = 1] = "Run";
      ChaseNpcState[ChaseNpcState["Die"] = 2] = "Die";
      ChaseNpcState[ChaseNpcState["Atk"] = 3] = "Atk";
  })(ChaseNpcState || (ChaseNpcState = {}));
  class ChaseNpc extends Laya.Script {
      constructor() {
          super();
          this.frontdie = false;
          this.reardie = false;
          this.canmove = false;
          this.isdead = false;
          this.atked = false;
          this.begin = false;
          this.m_chasenpcspeed = 0;
          this.pursuediatance = 0;
          this.atkdistance = 10;
          this.NPCRushSpeed = 0;
          this.Distance = 0;
          this.ChaseDistance = 0;
          this.NpcStartPos = new Vector3$6();
          this.dir = new Vector3$6();
          this.currotV = new Vector3$6();
          this.currot = new Laya.Quaternion;
          this.CurrectRotate = new Laya.Quaternion();
          this.curspeed = 0;
          this.offest = new Vector3$6();
          this.curpos = new Vector3$6();
          this.die = false;
          ChaseNpc.ins = this;
          EventManager.StageOn(StageState.Start, this, this.Begin);
          EventManager.StageOn(StageState.Lose, this, this.GameOver);
          EventManager.StageOn(StageState.Win, this, this.GameOver);
          EventManager.StageOn(StageState.Press, this, this.AddSpeed);
          EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
      }
      static get Instance() {
          if (ChaseNpc.ins) {
              return ChaseNpc.ins;
          }
          else {
              return new ChaseNpc();
          }
      }
      onAwake() {
          this.m_chasenpcmodel = this.owner;
      }
      onStart() {
          this.m_chasenpcanimator = this.m_chasenpcmodel.getComponent(Laya.Animator);
          this.m_hostage = this.owner.parent.parent.getChildByName("player").getChildAt(0);
          this.NpcStartPos = this.m_chasenpcmodel.transform.position.clone();
          this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed;
          this.Distance = AccountManager.Instance.curplayerData.NpcChaseDistance * 1.65;
          this.ChaseDistance = AccountManager.Instance.curplayerData.NpcRushDistance * 1.65;
          this.NPCRushSpeed = AccountManager.Instance.curplayerData.NPCRushSpeed;
      }
      Begin() {
          this.ChangeState(ChaseNpcState.Run);
          this.begin = true;
      }
      onUpdate() {
          if (!this.begin)
              return;
          if (this.isdead)
              return;
          let _host = this.m_hostage.getComponent(Hostage);
          if (_host.isdead) {
              this.ChangeState(ChaseNpcState.Idle);
              return;
          }
          if (this.frontdie || this.reardie) {
              this.ChangeState(ChaseNpcState.Die);
              return;
          }
          var distance = Vector3$6.distance(PlayerControl.Instance.Player.transform.position, this.m_chasenpcmodel.transform.position);
          if (distance < this.Distance && !this.atked) {
              Vector3$6.subtract(this.m_hostage.transform.position, this.m_chasenpcmodel.transform.position, this.currotV);
              Vector3$6.normalize(this.currotV, this.currotV);
              this.m_chasenpcmodel.transform.lookAt(new Vector3$6(this.m_chasenpcmodel.transform.position.x - this.currotV.x, this.m_chasenpcmodel.transform.position.y, this.m_chasenpcmodel.transform.position.z - this.currotV.z), new Vector3$6(0, 1, 0));
              this.NPCMoveDir = this.currotV;
              this.canmove = true;
              _host.canmove = true;
              let _dis = this.m_chasenpcmodel.transform.position.z - this.NpcStartPos.z;
              if (_dis >= this.ChaseDistance) {
                  this.atked = true;
                  this.m_chasenpcspeed = this.NPCRushSpeed;
                  this.ChangeState(ChaseNpcState.Atk);
              }
          }
          this.Move(this.NPCMoveDir, this.m_chasenpcspeed);
          this.RayCheck();
      }
      Move(_dir, _speed) {
          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          if (stage <= 2)
              return;
          if (this.canmove) {
              var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
              this.curspeed = sp;
              Vector3$6.scale(_dir, this.curspeed, this.offest);
              Vector3$6.add(this.m_chasenpcmodel.transform.position, this.offest, this.curpos);
              Vector3$6.lerp(this.m_chasenpcmodel.transform.position, this.curpos, 0.15, this.curpos);
              this.curpos = new Vector3$6(this.curpos.x, this.curpos.y, this.curpos.z);
              this.m_chasenpcmodel.transform.position = this.curpos;
          }
      }
      AddSpeed() {
          this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed;
      }
      SlowSpeed() {
          this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed / 2;
      }
      GameOver() {
          EventManager.StageOff(StageState.Press, this, this.AddSpeed);
          EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
          EventManager.StageOff(StageState.Start, this, this.Begin);
          EventManager.StageOff(StageState.Lose, this, this.GameOver);
          EventManager.StageOff(StageState.Win, this, this.GameOver);
      }
      ChangeState(_state) {
          if (this.m_chasenpcstate == _state)
              return;
          this.m_chasenpcstate = _state;
          switch (this.m_chasenpcstate) {
              case ChaseNpcState.Atk:
                  this.Attack();
                  break;
              case ChaseNpcState.Idle:
                  this.Idle();
                  break;
              case ChaseNpcState.Run:
                  this.Run();
                  break;
              case ChaseNpcState.Die:
                  this.Die();
                  break;
          }
      }
      Idle() {
          this.m_chasenpcanimator.play("idle");
      }
      Attack() {
          this.m_chasenpcanimator.play("atk");
          Laya.timer.once(500, this, () => {
              this.canmove = false;
          });
      }
      Win() {
          this.m_chasenpcanimator.play("win");
      }
      Run() {
          this.m_chasenpcanimator.play("run");
      }
      Die() {
          if (this.die)
              return;
          this.die = true;
          AudioManager.playMusic(MusicType.die);
          this.PiaoZi();
          this.isdead = true;
          EventManager.StageOff(StageState.Start, this, this.Begin);
          if (this.frontdie) {
              this.m_chasenpcanimator.play("diefront");
          }
          if (this.reardie) {
              this.m_chasenpcanimator.play("dierear");
          }
          this.m_chasenpcanimator.play("diefront");
          this.canmove = false;
      }
      PiaoZi() {
          let headshoot = new Laya.Image();
          headshoot.skin = "Game/res/textrue/headshoot.png";
          headshoot.scaleX = 1;
          headshoot.scaleY = 1;
          headshoot.anchorX = 0.5;
          headshoot.anchorY = 0.5;
          Laya.stage.addChild(headshoot);
          Laya.timer.once(1000, this, () => {
              headshoot.visible = false;
              Laya.timer.clear(this, this.UIFollow);
          });
          GameManager.Instance.UIArray.push(headshoot);
          let UIPos = this.m_chasenpcmodel.getChildByName("UIPos");
          let screenpos2 = new Vector3$6();
          Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, headshoot, screenpos2]);
      }
      UIFollow(UIPos, UI, POS) {
          AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
          UI.pos(POS.x, POS.y);
      }
      RayCheck() {
          let startpos = new Vector3$6(this.m_chasenpcmodel.transform.position.x, this.m_chasenpcmodel.transform.position.y + 0.5, this.m_chasenpcmodel.transform.position.z);
          let dir = Transform3DHelper.getForward(this.m_chasenpcmodel.transform);
          let ray = new Laya.Ray(startpos, dir);
          let hitres = new Laya.HitResult();
          let isHit = AssetManager.Instance.mainscene.physicsSimulation.rayCast(ray, hitres, 3, 200);
          if (isHit) {
              let target = hitres.collider.owner.parent;
              if (target.name == "hostage") {
                  let _hostage = target.getComponent(Hostage);
                  _hostage.isdead = true;
              }
              else if (target.name == "bonfire") {
                  this.ChangeState(ChaseNpcState.Die);
              }
              else if (target.name == "stone") {
                  this.m_chasenpcspeed = 0;
              }
              else if (target.name == "") ;
          }
      }
  }

  class Dictionary {
      constructor() {
          this.keys = new Array();
          this.values = new Array();
      }
      get count() {
          return this.keys.length;
      }
      add(key, value) {
          let index = this.keys.indexOf(key);
          if (index == -1) {
              this.keys.push(key);
              this.values.push(value);
          }
          else {
              this.values[index] = value;
          }
      }
      remove(key) {
          let index = this.keys.indexOf(key);
          if (index != -1) {
              this.keys.splice(index, 1);
              this.values.splice(index, 1);
          }
      }
      getValue(key) {
          let index = this.keys.indexOf(key);
          if (index != -1) {
              return this.values[index];
          }
          return null;
      }
      containKey(key) {
          let index = this.keys.indexOf(key);
          if (index != -1) {
              return true;
          }
          return false;
      }
      containValue(value) {
          let index = this.values.indexOf(value);
          if (index != -1) {
              return true;
          }
          return false;
      }
      clear() {
          this.keys.length = 0;
          this.values.length = 0;
      }
  }

  var Vector3$7 = Laya.Vector3;
  var BossState;
  (function (BossState) {
      BossState[BossState["Idle"] = 0] = "Idle";
      BossState[BossState["Run"] = 1] = "Run";
      BossState[BossState["Die"] = 2] = "Die";
      BossState[BossState["Walk"] = 3] = "Walk";
  })(BossState || (BossState = {}));
  class Boss extends Laya.Script {
      constructor() {
          super();
          this.canmove = false;
          this.FowardHit = new Laya.HitResult();
          this.isfence = false;
          this.arrowarray = [];
          this.m_arrowspeed = 0;
          this.AtkInterval = 0;
          this.BossSpeed = 1;
          this.CreatGround = false;
          this.randomdir = false;
          this.ArrowList = new Dictionary();
          this.currotV = new Vector3$7();
          this.currot = new Laya.Quaternion;
          this.NormalizeSpeed = new Vector3$7();
          this.curpos = new Vector3$7();
          this.offest = new Vector3$7();
          this.offestx = 0;
          this.atk = false;
          this.run = false;
          this.curspeed = 0;
          this.BossMoveDir = new Vector3$7(0, 0, 1);
          this.CurrectRotate = new Laya.Quaternion();
          this.recover = false;
          this.speed = 0;
          this.arrowoffset = new Vector3$7();
          this.arrowcurpos = new Vector3$7();
          EventManager.StageOn(StageState.Press, this, this.AddSpeed);
          EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
          EventManager.StageOn(StageState.Win, this, this.GameOver);
          EventManager.StageOn(StageState.Lose, this, this.GameOver);
      }
      static get Instance() {
          if (Boss.ins) {
              return Boss.ins;
          }
          else {
              return new Boss();
          }
      }
      onAwake() {
          this.m_bossmodel = this.owner;
          this.m_horsemodel = this.m_bossmodel.parent;
          this.m_bossanimator = this.m_bossmodel.getComponent(Laya.Animator);
          this.m_horseanimator = this.m_horsemodel.getComponent(Laya.Animator);
          this.arrowpos = this.m_bossmodel.getChildByName("arrowpos");
          this.archerpos = this.m_bossmodel.getChildByName("archerpos");
          this.raypos = this.m_bossmodel.getChildByName("raypos");
          this.CreatRay(this.raypos.transform.position.clone(), this.raypos.transform.rotationEuler.clone(), this.raypos);
          this.CreatArcher(this.archerpos.transform.position.clone(), this.archerpos.transform.rotationEuler.clone(), this.archerpos);
          this.Player = PlayerControl.Instance.Player;
          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          this.BossHp = Number(StageControl.Instance.curstagedic[stage].BossHp);
          this.NowBossHp = this.BossHp;
          this.AddHpUI();
          this.BossDistance = AccountManager.Instance.curplayerData.BossDistance * 1.65;
          this.level = AccountManager.Instance.curplayerData.GainAccount("stage");
          this.AtkInterval = AccountManager.Instance.curplayerData.BossAtkInterval - (this.level - 1) * 0.5;
          this.m_arrowspeed = AccountManager.Instance.curplayerData.ArrowSpeed;
      }
      onUpdate() {
          if (this.isdead)
              return;
          var dis = Vector3$7.distance(this.Player.transform.position, this.m_bossmodel.transform.position);
          if (dis <= this.BossDistance && !this.run) {
              this.run = true;
              WXSDK.Shake();
              this.ChangeState(BossState.Run);
          }
          if (dis >= AccountManager.Instance.curplayerData.MaxBossDistance * 1.65 && this.run) {
              this.canmove = false;
          }
          else if (dis > AccountManager.Instance.curplayerData.MinBossDistance * 1.65 && dis < AccountManager.Instance.curplayerData.MaxBossDistance * 1.65 && this.run) {
              this.ChangeState(BossState.Run);
              this.canmove = true;
              this.BossSpeed = StageControl.Instance.curstage.mainrolespeed;
          }
          if (!this.canmove)
              return;
          this.Move(this.BossMoveDir, this.BossSpeed);
          if (!this.atk) {
              this.atk = true;
              Laya.timer.once(this.AtkInterval * 1000, this, this.Atk);
          }
          if (!this.CreatGround && this.m_bossmodel.transform.position.z > StageControl.Instance.LastGround - 50) {
              StageControl.Instance.CreatGround(5);
          }
          if (!this.randomdir) {
              this.randomdir = true;
              Laya.timer.once(2000, this, this.RandomDir);
          }
          this.RayCheck();
          if (this.ArrowList != null) {
              var keys = this.ArrowList.keys;
              for (var i = 0; i < keys.length; i++) {
                  var key = keys[i];
                  if (keys[i] != null) {
                      var value = this.ArrowList.getValue(keys[i]);
                      this.ArrowMove(key, (this.ArrowList.getValue(key))[0], (this.ArrowList.getValue(key))[1]);
                  }
              }
          }
      }
      TurnDir(_dir) {
          if (_dir.x != 0) {
              Vector3$7.lerp(this.currotV, _dir, 0.35, _dir);
              this.currotV = _dir;
              Laya.Quaternion.rotationLookAt(_dir, new Vector3$7(0, 1, 0), this.currot);
              Laya.Quaternion.slerp(this.m_horsemodel.transform.rotation, this.currot, 0.025, this.currot);
              this.currot = new Laya.Quaternion(0, this.currot.y, 0);
              this.m_horsemodel.transform.rotation = this.currot;
          }
      }
      MoveX(_speed) {
          if (this.m_horsemodel.transform.position.x < 0 && _speed < 0 && this.isfence) {
              return;
          }
          else if (this.m_horsemodel.transform.position.x > 0 && _speed > 0 && this.isfence) {
              return;
          }
          else if (this.m_horsemodel.transform.position.x >= GameManager.Instance.fenceleftpos && _speed > 0) {
              return;
          }
          else if (this.m_horsemodel.transform.position.x <= GameManager.Instance.fencerightpos && _speed < 0) {
              return;
          }
          _speed *= 0.07;
          this.m_horsemodel.transform.translate(new Vector3$7(_speed, 0, 0));
      }
      RandomDir() {
          let _dir = Math.random() > 0.5 ? -0.5 : 0.5;
          this.BossMoveDir = new Vector3$7(_dir, 0, 1);
          Laya.timer.once(200, this, () => {
              this.BossMoveDir = new Vector3$7(0, 0, 1);
              this.randomdir = false;
          });
      }
      Move(_dir, _speed) {
          var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
          this.curspeed = sp;
          Vector3$7.scale(_dir, this.curspeed, this.offest);
          Vector3$7.add(this.m_horsemodel.transform.position, this.offest, this.curpos);
          Vector3$7.lerp(this.m_horsemodel.transform.position, this.curpos, 0.15, this.curpos);
          this.m_horsemodel.transform.position = this.curpos;
          this.m_horsemodel.transform.position = this.m_horsemodel.transform.position.x < GameManager.Instance.fencerightpos + 0.5 ? new Vector3$7(GameManager.Instance.fencerightpos + 0.5, this.m_horsemodel.transform.position.y, this.m_horsemodel.transform.position.z) : this.m_horsemodel.transform.position;
          this.m_horsemodel.transform.position = this.m_horsemodel.transform.position.x > GameManager.Instance.fenceleftpos - 0.5 ? new Vector3$7(GameManager.Instance.fenceleftpos - 0.5, this.m_horsemodel.transform.position.y, this.m_horsemodel.transform.position.z) : this.m_horsemodel.transform.position;
      }
      Atk() {
          Laya.timer.frameLoop(1, this, this.RotationMove);
      }
      SlowSpeed() {
          if (this.run) {
              this.ChangeState(BossState.Walk);
              this.BossSpeed = AccountManager.Instance.curplayerData.BossSpeed / 2;
          }
      }
      AddSpeed() {
          if (this.run) {
              this.ChangeState(BossState.Run);
              this.BossSpeed = AccountManager.Instance.curplayerData.BossSpeed;
          }
      }
      GameOver() {
          EventManager.StageOff(StageState.Press, this, this.AddSpeed);
          EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
      }
      RotationMove() {
          Vector3$7.subtract(this.Player.transform.position, this.m_bossmodel.transform.position, this.currotV);
          Vector3$7.normalize(this.currotV, this.currotV);
          var curdir = new Vector3$7(-this.currotV.x, -this.currotV.y, -this.currotV.z);
          Laya.Quaternion.rotationLookAt(curdir, new Vector3$7(0, 10, 0), this.CurrectRotate);
          this.CurrectRotate.invert(this.CurrectRotate);
          Laya.Quaternion.slerp(this.m_bossmodel.transform.rotation, this.CurrectRotate, 0.05, this.CurrectRotate);
          this.m_bossmodel.transform.rotation = this.CurrectRotate;
          var bossfoward = Transform3DHelper.getForward(this.m_bossmodel.transform);
          let _angle = this.JupdeAngle(bossfoward, this.currotV);
          if (_angle > 0.995) {
              Laya.timer.clear(this, this.RotationMove);
              this.Shoot();
              let rotation2 = GameTools.tweenRotate(this.m_bossmodel.transform, new Vector3$7(0, 0, 0), 700, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
                  rotation2.clear();
                  this.atk = false;
              }));
          }
      }
      JupdeAngle(dir1, dir2) {
          let Dir1 = new Vector3$7(dir1.x, 0, dir1.z);
          let Dir2 = new Vector3$7(dir2.x, 0, dir2.z);
          Vector3$7.normalize(Dir1, Dir1);
          Vector3$7.normalize(Dir2, Dir2);
          var dot = Vector3$7.dot(Dir1, Dir2);
          return dot;
      }
      Shoot() {
          this.CreatArrow();
          var currect = this.m_arrow;
          this.m_arrow = null;
          let ray = this.owner.getChildByName("raypos").getChildAt(0);
          let forw = Transform3DHelper.getForward(ray.transform);
          let raypos = this.owner.getChildByName("raypos");
          let trans = raypos.transform;
          let testRay = new Laya.Ray(new Vector3$7(trans.position.x, trans.position.y - 1, trans.position.z), forw);
          let hitRes = new Laya.HitResult();
          this.m_bossanimator.play("shoot");
          if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes)) {
              let target = hitRes.collider.owner.parent;
              this.ArrowList.add(currect, [forw, target]);
          }
          else {
              this.ArrowList.add(currect, [forw, null]);
          }
      }
      ArrowMove(arrow, _dir, target) {
          if (target) {
              if (arrow.destroyed)
                  return;
              if (arrow.transform.position.z <= target.transform.position.z) {
                  if (target.name == "player") {
                      let _runner = target.getComponent(Runner);
                      _runner.isdead = true;
                      this.BossProgress.visible = false;
                  }
                  if (this.ArrowList.containKey(arrow)) {
                      this.ArrowList.remove(arrow);
                  }
                  GamePool.Instance.RecoveryModel(arrow);
              }
              else {
                  var sp = GameTools.Instance.lerp(this.speed, this.m_arrowspeed, 0.1);
                  this.speed = sp;
                  Vector3$7.scale(_dir, this.speed, this.arrowoffset);
                  Vector3$7.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
                  Vector3$7.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
                  arrow.transform.position = this.arrowcurpos;
              }
          }
          else {
              var sp = GameTools.Instance.lerp(this.speed, this.m_arrowspeed, 0.1);
              this.speed = sp;
              Vector3$7.scale(_dir, this.speed, this.arrowoffset);
              Vector3$7.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
              Vector3$7.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
              arrow.transform.position = this.arrowcurpos;
              if (!this.recover) {
                  this.recover = true;
                  Laya.timer.once(1000, this, () => {
                      if (this.ArrowList.containKey(arrow)) {
                          this.ArrowList.remove(arrow);
                      }
                      GamePool.Instance.RecoveryModel(arrow);
                      this.recover = false;
                  });
              }
          }
      }
      ChangeState(_state) {
          if (this._bossstate == _state)
              return;
          this._bossstate = _state;
          switch (this._bossstate) {
              case BossState.Idle:
                  this.Idle();
                  break;
              case BossState.Run:
                  this.Run();
                  break;
              case BossState.Die:
                  this.Die();
                  break;
              case BossState.Walk:
                  this.Walk();
                  break;
          }
      }
      Idle() {
          this.m_bossanimator.play("idle");
          this.m_horseanimator.play("idle");
      }
      Walk() {
          this.m_horseanimator.play("walk");
          this.m_bossanimator.play("down");
      }
      Run() {
          this.canmove = true;
          this.m_bossanimator.play("down");
          this.m_horseanimator.play("run");
      }
      Die() {
          this.BossProgress.visible = false;
          this.isdead = true;
          Laya.timer.clearAll(this);
          this.m_horseanimator.play("idle");
          this.m_bossanimator.play("die");
          EventManager.StageTrigger(StageState.Win);
      }
      RayCheck() {
          if (this.FowardRayCheck) {
              this.CrashBarrier();
          }
          else {
              this.isfence = false;
          }
      }
      CrashBarrier() {
          var target = this.FowardHit.collider.owner.parent;
          if (target.name == "small_fence") {
              this.isfence = true;
          }
      }
      get FowardRayCheck() {
          var isFowardHit = false;
          var startPos = new Vector3$7(this.m_bossmodel.transform.position.x, this.m_bossmodel.transform.position.y + 0.5, this.m_bossmodel.transform.position.z + 2);
          let dir = Transform3DHelper.getForward(this.m_bossmodel.transform);
          var DownRay = new Laya.Ray(startPos, dir);
          if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
              if (this.FowardHit.collider.collisionGroup == 100) {
                  isFowardHit = true;
              }
          }
          return isFowardHit;
      }
      CreatRay(pos, euler, raypos) {
          var ray = this.CreatRayPrefab();
          raypos.addChild(ray);
          ray.transform.position = pos;
          ray.transform.rotationEuler = euler;
      }
      CreatRayPrefab() {
          var ray = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(18), "");
          return ray;
      }
      CreatArcher(_pos, _euler, archerpos) {
          var archer = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(16), "");
          archerpos.addChild(archer);
          archer.transform.position = _pos;
          archer.transform.rotationEuler = _euler;
          var scale = archer.transform.scale.clone();
          scale.x = 0.3;
          scale.y = 0.3;
          scale.z = 0.6;
          archer.transform.scale = scale;
      }
      CreatArrow() {
          var arrow = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(17), "");
          AssetManager.Instance.mainscene.addChild(arrow);
          this.arrowarray.push(arrow);
          arrow.transform.position = this.arrowpos.transform.position.clone();
          var euler = this.arrowpos.transform.rotationEuler.clone();
          arrow.transform.rotationEuler = euler;
          let scale = arrow.transform.scale.clone();
          scale.z = 0.5;
          scale.x = 0.5;
          scale.y = 0.5;
          arrow.transform.scale = scale;
          this.m_arrow = arrow;
      }
      AddHpUI() {
          this.BossProgress = new Laya.ProgressBar();
          this.BossProgress.skin = "Game/res/textrue/healthbar1.png";
          this.BossProgress.scaleX = 0.4;
          this.BossProgress.scaleY = 0.4;
          this.BossProgress.anchorX = 0.5;
          this.BossProgress.anchorY = 0.5;
          Laya.stage.addChild(this.BossProgress);
          GameManager.Instance.UIArray.push(this.BossProgress);
          let UIPos = this.m_bossmodel.getChildByName("UIPos");
          this.InitHpUI();
          Laya.timer.frameLoop(1, this, () => {
              let ScreenPos = new Vector3$7();
              AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, ScreenPos);
              this.BossProgress.pos(ScreenPos.x, ScreenPos.y);
          });
      }
      InitHpUI() {
          this.BossProgress.value = this.NowBossHp / this.BossHp;
      }
      LoseHp(_damage) {
          GameManager.Instance.KillNum++;
          InGameView.Instance.InitUI();
          if (this.NowBossHp >= _damage) {
              this.NowBossHp = this.NowBossHp -= _damage;
          }
          else if (this.NowBossHp < _damage && this.NowBossHp > 0) {
              this.NowBossHp = 0;
          }
          if (this.NowBossHp == 0) {
              this.ChangeState(BossState.Die);
              this.BossProgress.destroy();
          }
          else {
              this.InitHpUI();
          }
      }
  }

  var Vector3$8 = 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["Walk"] = 5] = "Walk";
      CharacterState[CharacterState["Revive"] = 6] = "Revive";
  })(CharacterState || (CharacterState = {}));
  class Runner extends Laya.Script3D {
      constructor() {
          super();
          this.Invincible = false;
          this.started = false;
          this.shoot = false;
          this.isbarrier = false;
          this.isfence = false;
          this.arrowarray = [];
          this.isdead = false;
          this.canmove = false;
          this._speed = 0;
          this._press = false;
          this.RayDir = new Vector3$8();
          this.DownHit = new Laya.HitResult();
          this.FowardHit = new Laya.HitResult();
          this.curspeed = 0;
          this.currotV = new Vector3$8();
          this.currot = new Laya.Quaternion;
          this.NormalizeSpeed = new Vector3$8();
          this.curpos = new Vector3$8();
          this.offest = new Vector3$8();
          this.ArrowList = new Dictionary();
          this.arrowspeed = 0;
          this.speed = 0;
          this.arrowoffset = new Vector3$8();
          this.arrowcurpos = new Vector3$8();
          this.recover = false;
          this.hitfence = false;
          EventManager.StageOn(StageState.Start, this, this.Begin);
          EventManager.StageOn(StageState.Lose, this, this.GameOver);
          EventManager.StageOn(StageState.Win, this, this.GameOver);
      }
      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_arrowpos = this.owner.getChildByName("arrowpos");
          this.m_raypos = this.owner.getChildByName("raypos");
          this.m_archerpos = this.owner.getChildByName("archerpos");
          this.m_horseanimator = this.owner.getChildAt(this.owner.numChildren - 1).getComponent(Laya.Animator);
          this._speed = StageControl.Instance.curstage.mainrolespeed;
          this.m_PlayerDamage = AccountManager.Instance.curplayerData.PlayerDamage;
          this.stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          this.ChangeState(CharacterState.Idle);
          this.DirRoatationLerp = AccountManager.Instance.curplayerData.DirRoatationLerp;
          this.DirMoveLerp = AccountManager.Instance.curplayerData.DirMoveLerp;
          this.arrowspeed = AccountManager.Instance.curplayerData.ArrowSpeed;
          this.m_range = AccountManager.Instance.curplayerData.Range;
      }
      Begin() {
          this.canmove = true;
          this.CreatArrow();
          this.ChangeState(CharacterState.Walk);
      }
      onUpdate() {
          if (this.isdead) {
              this.ChangeState(CharacterState.Die);
              return;
          }
          if (this.canmove && this.started) {
              var speed;
              if (!this.isbarrier) {
                  if (this._press) {
                      speed = StageControl.Instance.curstage.mainrolespeed;
                  }
                  else {
                      speed = StageControl.Instance.curstage.mainrolespeed / 2;
                  }
                  let foward = Transform3DHelper.getForward(this.m_player.transform);
                  this.Move(foward, speed);
              }
          }
          this.RayCheck();
          if (this.ArrowList != null) {
              var keys = this.ArrowList.keys;
              for (var i = 0; i < keys.length; i++) {
                  var key = keys[i];
                  if (keys[i] != null) {
                      var value = this.ArrowList.getValue(keys[i]);
                      this.ArrowMove(key, (this.ArrowList.getValue(key))[0], (this.ArrowList.getValue(key))[1]);
                  }
              }
          }
      }
      MoveX(_speed) {
          if (this.m_player.transform.position.x < 0 && _speed < 0 && this.isfence) {
              return;
          }
          else if (this.m_player.transform.position.x > 0 && _speed > 0 && this.isfence) {
              return;
          }
          else if (this.m_player.transform.position.x >= GameManager.Instance.fenceleftpos && _speed > 0) {
              return;
          }
          else if (this.m_player.transform.position.x <= GameManager.Instance.fencerightpos && _speed < 0) {
              return;
          }
          _speed *= this.DirMoveLerp;
          if (this.canmove && this.started) {
              this.m_player.transform.translate(new Vector3$8(_speed, 0, 0));
          }
      }
      TurnDir(_dir) {
          if (_dir.x != 0) {
              Vector3$8.lerp(this.currotV, _dir, 0.35, _dir);
              this.currotV = _dir;
              Laya.Quaternion.rotationLookAt(_dir, new Vector3$8(0, 1, 0), this.currot);
              Laya.Quaternion.slerp(this.m_player.transform.rotation, this.currot, this.DirRoatationLerp, 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$8.scale(_dir, this.curspeed, this.offest);
          Vector3$8.add(this.m_player.transform.position, this.offest, this.curpos);
          Vector3$8.lerp(this.m_player.transform.position, this.curpos, 0.15, this.curpos);
          this.curpos = new Vector3$8(this.curpos.x, this.curpos.y, this.curpos.z);
          this.m_player.transform.position = this.curpos;
          this.m_player.transform.position = this.m_player.transform.position.x < GameManager.Instance.fencerightpos + 0.5 ? new Vector3$8(GameManager.Instance.fencerightpos + 0.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 > GameManager.Instance.fenceleftpos - 0.5 ? new Vector3$8(GameManager.Instance.fenceleftpos - 0.5, this.m_player.transform.position.y, this.m_player.transform.position.z) : this.m_player.transform.position;
      }
      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.Shoot:
                  this.Shoot();
                  break;
              case CharacterState.Walk:
                  this.Walk();
                  break;
          }
      }
      Idle() {
          this.m_animator.play("idle");
          this.m_horseanimator.play("idle");
      }
      Run() {
          this.m_animator.play("down");
          this.m_horseanimator.play("run");
      }
      ReviveState() {
          this.m_horseanimator.play("walk");
          this.m_animator.play("down");
      }
      Die() {
          WXSDK.Shake(true);
          this.canmove = false;
          this.m_animator.play("die");
          this.m_horseanimator.play("idle");
          EventManager.StageTrigger(StageState.Lose);
      }
      GameOver() {
          Laya.timer.clear(this, this.AnimatorState);
          EventManager.StageOff(StageState.Start, this, this.Begin);
      }
      Walk() {
          this.m_horseanimator.play("walk");
      }
      Shoot() {
          this.m_animator.play("shoot");
      }
      RayCheck() {
          if (this.FowardRayCheck) {
              this.CrashBarrier();
          }
          else {
              this.isbarrier = false;
              this.isfence = false;
          }
      }
      CrashBarrier() {
          var target = this.FowardHit.collider.owner.parent;
          if (target.name == "stone") {
              this.isbarrier = true;
          }
          else if (target.name == "bonfire") {
              this.ChangeState(CharacterState.Die);
          }
          else if (target.name == "big_fence") {
              this.isbarrier = true;
          }
          else if (target.name == "wood_Cylinder") {
              this.isbarrier = true;
          }
          else if (target.name == "small_fence") {
              this.isfence = true;
          }
      }
      get FowardRayCheck() {
          var isFowardHit = false;
          var startPos = new Vector3$8(this.m_player.transform.position.x, this.m_player.transform.position.y + 0.5, this.m_player.transform.position.z);
          let dir = Transform3DHelper.getForward(this.m_player.transform);
          var DownRay = new Laya.Ray(startPos, dir);
          if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
              if (this.FowardHit.collider.collisionGroup == 100) {
                  isFowardHit = true;
              }
          }
          return isFowardHit;
      }
      Archery() {
          var currect = this.m_arrow;
          this.m_arrow = null;
          AudioManager.playMusic(MusicType.shoot);
          Laya.timer.clear(this, this.ArrowFollow);
          Laya.timer.clear(this, this.AnimatorState);
          let ray = this.owner.getChildByName("raypos").getChildAt(0);
          let forw = Transform3DHelper.getForward(ray.transform);
          let raypos = this.owner.getChildByName("raypos");
          let trans = raypos.transform;
          let testRay = new Laya.Ray(new Vector3$8(trans.position.x, trans.position.y - 0.5, trans.position.z), forw);
          let hitRes = new Laya.HitResult();
          this.m_animator.play("shoot");
          Laya.timer.frameLoop(1, this, this.AnimatorState);
          if (this.stage <= 2) {
              if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes, this.m_range)) {
                  let target = hitRes.collider.owner;
                  this.ArrowList.add(currect, [forw, target]);
              }
              else {
                  this.ArrowList.add(currect, [forw, null]);
              }
          }
          else {
              if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes)) {
                  let target = hitRes.collider.owner;
                  this.ArrowList.add(currect, [forw, target]);
              }
              else {
                  this.ArrowList.add(currect, [forw, null]);
              }
          }
      }
      ArrowMove(arrow, _dir, target) {
          if (target) {
              if (arrow.destroyed)
                  return;
              let parent = target.parent;
              if (arrow.transform.position.z >= parent.transform.position.z) {
                  if (parent.name == "npc") {
                      AudioManager.playMusic(MusicType.hit);
                      if (this.stage == 1) {
                          if (InGameView.Instance.Guide2.visible) {
                              if (GameManager.Instance.GuideKill < 2) {
                                  GameManager.Instance.GuideKill += 1;
                              }
                              if (GameManager.Instance.GuideKill == 1) {
                                  this.started = true;
                                  InGameView.Instance.Guide2.visible = false;
                                  Laya.timer.once(2500, this, () => {
                                      this.started = false;
                                      InGameView.Instance.Guide3.visible = true;
                                      this.m_range = 100;
                                  });
                              }
                          }
                      }
                      else if (this.stage == 2) {
                          if (InGameView.Instance.Guide2.visible) {
                              GameManager.Instance.GuideKill += 1;
                              if (GameManager.Instance.GuideKill >= 1) {
                                  this.started = true;
                                  InGameView.Instance.Guide2.visible = false;
                                  Laya.timer.once(2000, this, () => {
                                      this.started = false;
                                      InGameView.Instance.Guide4.visible = true;
                                      this.m_range = 100;
                                  });
                              }
                          }
                      }
                      let _npcrunner = parent.getComponent(NpcRunner);
                      let _chaseNpc = parent.getComponent(ChaseNpc);
                      if (_npcrunner) {
                          let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
                          if (stage == 1) {
                              if (GameManager.Instance.GuideKill == 1) {
                                  if (target.name == "npcfrontcollider") {
                                      _npcrunner.frontdie = true;
                                  }
                                  else if (target.name == "npcrearcollider") {
                                      _npcrunner.reardie = true;
                                  }
                                  GameManager.Instance.KillNum++;
                                  InGameView.Instance.InitUI();
                              }
                          }
                          else if (stage == 2) {
                              if (InGameView.Instance.Guide2.visible || GameManager.Instance.GuideKill == 1) {
                                  if (target.name == "npcfrontcollider") {
                                      _npcrunner.frontdie = true;
                                  }
                                  else if (target.name == "npcrearcollider") {
                                      _npcrunner.reardie = true;
                                  }
                              }
                              GameManager.Instance.KillNum++;
                              InGameView.Instance.InitUI();
                          }
                          else if (stage > 2) {
                              if (target.name == "npcfrontcollider") {
                                  _npcrunner.frontdie = true;
                              }
                              else if (target.name == "npcrearcollider") {
                                  _npcrunner.reardie = true;
                              }
                              GameManager.Instance.KillNum++;
                              InGameView.Instance.InitUI();
                          }
                          WXSDK.Shake(true);
                          WXSDK.stageShake();
                      }
                      else if (_chaseNpc) {
                          if (this.stage == 2) {
                              if (InGameView.Instance.Guide4.visible && GameManager.Instance.GuideKill >= 1) {
                                  InGameView.Instance.Guide4.visible = false;
                                  WXSDK.AldEvent("完成第四阶段引导");
                                  this.started = true;
                                  Laya.timer.once(3000, this, () => {
                                      EventManager.StageTrigger(StageState.Win);
                                  });
                                  if (target.name == "npcfrontcollider") {
                                      _chaseNpc.frontdie = true;
                                  }
                                  else if (target.name == "npcrearcollider") {
                                      _chaseNpc.reardie = true;
                                  }
                                  GameManager.Instance.KillNum++;
                                  InGameView.Instance.InitUI();
                              }
                          }
                          else {
                              if (target.name == "npcfrontcollider") {
                                  _chaseNpc.frontdie = true;
                              }
                              else if (target.name == "npcrearcollider") {
                                  _chaseNpc.reardie = true;
                              }
                              GameManager.Instance.KillNum++;
                              InGameView.Instance.InitUI();
                          }
                          WXSDK.Shake(true);
                          WXSDK.stageShake();
                      }
                  }
                  else if (parent.name == "big_fence") {
                      AudioManager.playMusic(MusicType.hit);
                      WXSDK.Shake(true);
                      if (this.stage == 1) {
                          if (GameManager.Instance.GuideKill >= 1) {
                              InGameView.Instance.Guide3.visible = false;
                              if (!this.hitfence) {
                                  Laya.timer.once(5000, this, () => {
                                      EventManager.StageTrigger(StageState.Win);
                                  });
                                  WXSDK.AldEvent("完成第三阶段引导");
                                  this.started = true;
                                  this.hitfence = true;
                              }
                              let tweenpos = GameTools.tweenMove(parent.transform, new Vector3$8(parent.transform.position.x, parent.transform.position.y, parent.transform.position.z + 5), 200, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
                                  tweenpos.clear();
                              }));
                              let tweenrot = GameTools.tweenRotate(parent.transform, new Vector3$8(90, 0, 0), 500, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
                                  tweenrot.clear();
                              }));
                              Laya.timer.once(500, this, () => {
                                  GamePool.Instance.RecoveryModel(parent);
                              });
                          }
                      }
                      else {
                          let tweenpos = GameTools.tweenMove(parent.transform, new Vector3$8(parent.transform.position.x, parent.transform.position.y, parent.transform.position.z + 5), 200, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
                              tweenpos.clear();
                          }));
                          let tweenrot = GameTools.tweenRotate(parent.transform, new Vector3$8(90, 0, 0), 500, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
                              tweenrot.clear();
                          }));
                          Laya.timer.once(1000, this, () => {
                              GamePool.Instance.RecoveryModel(parent);
                          });
                      }
                  }
                  else if (parent.name == "hostage") {
                      if (this.stage > 1) {
                          AudioManager.playMusic(MusicType.hit);
                          let _host = parent.getComponent(Hostage);
                          _host.isdead = true;
                      }
                  }
                  else if (parent.name == "boss") {
                      AudioManager.playMusic(MusicType.hit);
                      let _boss = parent.getComponent(Boss);
                      _boss.LoseHp(this.m_PlayerDamage);
                  }
                  if (this.ArrowList.containKey(arrow)) {
                      this.ArrowList.remove(arrow);
                  }
                  GamePool.Instance.RecoveryModel(arrow);
              }
              else {
                  var sp = GameTools.Instance.lerp(this.speed, this.arrowspeed, 0.1);
                  this.speed = sp;
                  Vector3$8.scale(_dir, this.speed, this.arrowoffset);
                  Vector3$8.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
                  Vector3$8.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
                  arrow.transform.position = this.arrowcurpos;
              }
          }
          else {
              var sp = GameTools.Instance.lerp(this.speed, this.arrowspeed, 0.1);
              this.speed = sp;
              Vector3$8.scale(_dir, this.speed, this.arrowoffset);
              Vector3$8.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
              Vector3$8.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
              arrow.transform.position = this.arrowcurpos;
              if (!this.recover) {
                  this.recover = true;
                  Laya.timer.once(500, this, () => {
                      if (this.ArrowList.containKey(arrow)) {
                          this.ArrowList.remove(arrow);
                      }
                      GamePool.Instance.RecoveryModel(arrow);
                      this.recover = false;
                  });
              }
          }
      }
      AnimatorState() {
          if (this.m_animator.getCurrentAnimatorPlayState(0).normalizedTime >= 1) {
              Laya.timer.clear(this, this.AnimatorState);
              if (!this.m_arrowpos.destroyed) {
                  this.CreatArrow();
                  this.shoot = false;
              }
          }
      }
      CreatArrow() {
          var arrow = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(17), "");
          AssetManager.Instance.mainscene.addChild(arrow);
          this.arrowarray.push(arrow);
          arrow.transform.position = this.m_arrowpos.transform.position.clone();
          var euler = this.m_arrowpos.transform.rotationEuler.clone();
          arrow.transform.rotationEuler = euler;
          let scale = arrow.transform.scale.clone();
          scale.z = 0.5;
          scale.x = 0.8;
          scale.y = 0.5;
          arrow.transform.scale = scale;
          this.m_arrow = arrow;
          Laya.timer.frameLoop(1, this, this.ArrowFollow, [arrow, this.m_arrowpos]);
      }
      ArrowFollow(arrow, arrowpos) {
          if (!arrowpos.destroyed) {
              arrow.transform.position = arrowpos.transform.position.clone();
              arrow.transform.rotationEuler = arrowpos.transform.rotationEuler.clone();
          }
          else {
              Laya.timer.clear(this, this.ArrowFollow);
          }
      }
      Revive() {
          this.Invincible = true;
          Laya.timer.once(AccountManager.Instance.curplayerData.Invincible, this, () => {
              this.Invincible = false;
          });
          this.ReviveState();
          this.m_player.transform.position = new Vector3$8(this.m_player.transform.position.x, this.m_player.transform.position.y, this.m_player.transform.position.z - 15);
          this.canmove = true;
          this.ChangeState(CharacterState.Walk);
      }
  }

  var Vector3$9 = Laya.Vector3;
  class PlayerControl {
      constructor() {
          this.DownHit = new Laya.HitResult();
          this.speed = 1;
          this.press = false;
          this.win = false;
          this.offset = new Vector3$9(0, 0, 0);
          this.offestx = 0;
          this.first = false;
          this.poschazhi = new Vector3$9();
          this.gengsuipos = new Vector3$9();
          this.lllpos = new Vector3$9();
          this.hights = 0;
          this.wights = 0;
          PlayerControl.ins = this;
          EventManager.StageOn(StageState.Lose, this, this.GameOver);
          EventManager.StageOn(StageState.Win, this, this.GameOver);
      }
      static get Instance() {
          if (PlayerControl.ins) {
              return PlayerControl.ins;
          }
          else {
              return new PlayerControl();
          }
      }
      Init(_player) {
          this.win = false;
          this.Player = _player;
          this.arrowpos = _player.getChildByName("arrowpos");
          let runner = this.Player.getComponent(Runner);
          if (runner) {
              runner.destroy();
          }
          this._runner = this.Player.addComponent(Runner);
          this.Camera = AssetManager.Instance.maincamera;
          this.Camera.transform.position = new Laya.Vector3(0, 10, -19);
          this.Camera.transform.rotationEuler = new Laya.Vector3(-35.7, 180, 0);
          Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
          this.CameraFollow();
          Laya.timer.frameLoop(1, this, this.CheckWin);
          this.stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
          this.curtouchsmoothness = AccountManager.Instance.curplayerData.CurTouchsmoothness;
          this.curtouchsize = AccountManager.Instance.curplayerData.CurTouchsize;
      }
      CheckWin() {
          if (this.stage == 1) {
              if (this.Player.transform.position.z >= StageControl.Instance.curstage.endposition.z * 1.65 && !this.win) {
                  this.win = true;
                  EventManager.StageTrigger(StageState.Win);
                  Laya.timer.clear(this, this.CheckWin);
              }
          }
          else if (this.stage > 2 && StageControl.Instance.curstage.isboss == 0) {
              if (this.Player.transform.position.z >= StageControl.Instance.curstage.endposition.z * 1.2 && !this.win) {
                  this.win = true;
                  EventManager.StageTrigger(StageState.Win);
                  Laya.timer.clear(this, this.CheckWin);
              }
          }
      }
      onMouseDown(e) {
          if (!this._runner.canmove)
              return;
          if (this.stage > 2) {
              this._runner.started = true;
          }
          else if (this.stage == 2 && !this.first) {
              this._runner.started = true;
          }
          if (this.stage == 2 && !this.first) {
              this.first = true;
              Laya.timer.once(1500, this, () => {
                  this._runner.started = false;
                  InGameView.Instance.Guide2.visible = true;
              });
          }
          if (InGameView.Instance.Guide1.visible) {
              InGameView.Instance.Guide1.visible = false;
              WXSDK.AldEvent("完成第一阶段引导");
              InGameView.Instance.ani1.stop();
              this._runner.started = true;
              Laya.timer.once(2000, this, () => {
                  this._runner.started = false;
                  InGameView.Instance.Guide2.visible = true;
              });
          }
          this._runner._press = true;
          this.curMousePos = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
          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);
          this._runner.ChangeState(CharacterState.Run);
          EventManager.StageTrigger(StageState.Press);
      }
      onMouseMove() {
          if (this.stage != 1) {
              if (!this._runner.canmove) {
                  Laya.timer.clear(this, this.onMouseMove);
                  return;
              }
          }
          var MousePos = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
          var offestX = MousePos.x - this.curMousePos.x;
          offestX = offestX > 50 ? 50 : offestX;
          offestX = offestX < -50 ? -50 : offestX;
          this.offestx = GameTools.Instance.lerp(this.offestx, offestX, this.curtouchsmoothness);
          var dir = new Vector3$9(-offestX * this.curtouchsize, 0, 0);
          this._runner.TurnDir(dir);
          this.curMousePos = MousePos;
      }
      onMouseUp() {
          if (!this._runner.canmove)
              return;
          this.offestx = 0;
          Laya.timer.clear(this, this.onMouseMove);
          this._runner._press = false;
          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);
          if (!this._runner.shoot) {
              this._runner.shoot = true;
              this._runner.Archery();
          }
          this._runner.ChangeState(CharacterState.Walk);
          EventManager.StageTrigger(StageState.UnPress);
      }
      GameOver() {
          this._runner.canmove = false;
          this._runner._press = false;
          this.CameraCancelFollow();
          Laya.timer.clear(this, this.CheckWin);
          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);
          Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
      }
      Revive() {
          this.Camera.transform.position = new Vector3$9(this.Camera.transform.position.x, this.Camera.transform.position.y, this.Camera.transform.position.z - 15);
          this._runner.Revive();
          this.CameraFollow();
          Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
      }
      CameraFollow() {
          this.hights = 0;
          this.wights = 0;
          Vector3$9.subtract(this.Player.transform.position, this.Camera.transform.position, this.poschazhi);
          Laya.timer.frameLoop(1, this, this.GenSui);
      }
      GenSui() {
          Vector3$9.subtract(this.Player.transform.position, this.poschazhi, this.gengsuipos);
          this.hights = GameTools.Instance.lerp(this.hights, 1, 0.03);
          this.wights = GameTools.Instance.lerp(this.wights, 0.8, 0.02);
          this.gengsuipos = new Vector3$9(this.gengsuipos.x, this.gengsuipos.y, this.gengsuipos.z - this.wights);
          Vector3$9.lerp(this.Camera.transform.position, this.gengsuipos, 0.25, this.lllpos);
          this.lllpos = new Vector3$9(this.gengsuipos.x, this.lllpos.y, this.lllpos.z);
          this.Camera.transform.position = this.lllpos;
          var qqqwe = new Laya.Quaternion();
          var eyePos = new Vector3$9(this.gengsuipos.x, this.gengsuipos.y - 0.8, this.gengsuipos.z);
          Laya.Quaternion.lookAt(eyePos, this.Player.transform.position, new Vector3$9(0, 1, 0), qqqwe);
          qqqwe.invert(qqqwe);
          Laya.Quaternion.slerp(this.Camera.transform.rotation, qqqwe, 0.1, qqqwe);
          this.Camera.transform.rotation = qqqwe;
      }
      CameraCancelFollow() {
          Laya.timer.clear(this, this.GenSui);
      }
  }

  class NpcControl {
      constructor() {
          NpcControl.ins = this;
      }
      static get Instance() {
          if (NpcControl.ins) {
              return NpcControl.ins;
          }
          else {
              return new NpcControl();
          }
      }
      Init(_npc) {
          this.m_npcmodel = _npc;
          let npcrunner = this.m_npcmodel.getComponent(NpcRunner);
          if (npcrunner) {
              npcrunner.destroy();
          }
          this.m_npcrunner = this.m_npcmodel.addComponent(NpcRunner);
      }
  }

  class GameManager {
      constructor() {
          this.started = false;
          this.GuideKill = 0;
          this.KillNum = 0;
          this.ReviveNum = 1;
          this.CharacterArray = [];
          this.UIArray = [];
          this.fenceleftpos = 0;
          this.fencerightpos = 0;
          this.treeleftpos = 0;
          this.treerightpos = 0;
          GameManager.ins = this;
          EventManager.EventOn(EventState.StageInit, this, this.CreatStage);
          EventManager.EventOn(EventState.StageCreateComplete, 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);
      }
      CreatStage() {
          StageControl.Instance.RessetStage();
      }
      CreatCharacter() {
          this.CreatPlayer();
      }
      CreatPlayer() {
          var equiphorseid = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
          var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
          var playermodel = GamePool.Instance.GetModel(AssetManager.Instance.Player.get(1), "");
          var horsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(equiphorseid), "");
          playermodel.addChild(horsemodel);
          playermodel.transform.position = new Laya.Vector3(0, 0, -9);
          horsemodel.transform.localScale = new Laya.Vector3(1, 1, 1);
          horsemodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
          this.raypos = playermodel.getChildByName("raypos");
          this.archerpos = playermodel.getChildByName("archerpos");
          this.arrowpos = playermodel.getChildByName("arrowpos");
          this.cappos = playermodel.getChildByName("cappos");
          if (equipcap) {
              var capmodel = GamePool.Instance.GetModel(AssetManager.Instance.Cap.get(equipcap), "");
              this.cappos.addChild(capmodel);
              capmodel.transform.localScale = new Laya.Vector3(0.5, 0.5, 0.5);
              capmodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
              capmodel.transform.localRotationEuler = new Laya.Vector3(-90, 0, 0);
          }
          let ray = this.raypos.getChildAt(0);
          if (!ray) {
              this.CreatRay(this.raypos.transform.position.clone(), this.raypos.transform.rotationEuler.clone(), this.raypos);
          }
          let archer = this.archerpos.getChildAt(0);
          if (!archer) {
              this.CreatArcher(this.archerpos.transform.position.clone(), this.archerpos.transform.rotationEuler.clone(), this.archerpos);
          }
          PlayerControl.Instance.Init(playermodel);
          AssetManager.Instance.mainscene.addChild(playermodel);
          this.CharacterArray.push(playermodel);
          GameTools.Instance.PlayerSetCollider(playermodel, 200);
      }
      CreatEnemy(enemy) {
          enemy.transform.rotationEuler = new Laya.Vector3(0, 180, 0);
          NpcControl.Instance.Init(enemy);
          GameTools.Instance.EnemySetCollider(enemy, 100);
          this.CharacterArray.push(enemy);
      }
      CreatChaseCharacter(_node) {
          let enemy = _node.getChildByName("enemy").getChildAt(0);
          let hostage = _node.getChildByName("player").getChildAt(0);
          hostage.transform.localPosition = new Laya.Vector3(0, 0, 0);
          hostage.transform.localRotationEuler = new Laya.Vector3(0, 0, 0);
          enemy.transform.localPosition = new Laya.Vector3(0, 0, -2);
          enemy.transform.localRotationEuler = new Laya.Vector3(0, 0, 0);
          GameTools.Instance.EnemySetCollider(enemy, 100);
          GameTools.Instance.HostageSetCollider(hostage, 200);
          let chase = enemy.getComponent(ChaseNpc);
          if (chase) {
              chase.destroy();
          }
          else {
              let _ChaseNpc = enemy.addComponent(ChaseNpc);
          }
          let host = hostage.getComponent(Hostage);
          if (host) {
              host.destroy();
          }
          else {
              let _Hostage = hostage.addComponent(Hostage);
          }
          this.CharacterArray.push(_node);
      }
      CreatBoss(_pos) {
          var bossmodel = GamePool.Instance.GetModel(AssetManager.Instance.Boss.get(1), "");
          var horsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(50), "");
          let bos = bossmodel.getComponent(Boss);
          if (bos) ;
          else {
              let _boss = bossmodel.addComponent(Boss);
          }
          horsemodel.addChild(bossmodel);
          bossmodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
          bossmodel.transform.localScale = new Laya.Vector3(1, 1, 1);
          horsemodel.transform.position = _pos.clone();
          AssetManager.Instance.mainscene.addChild(horsemodel);
          this.CharacterArray.push(horsemodel);
      }
      RecoveryCharacter() {
          for (let i = 0; i < this.CharacterArray.length; i++) {
              let model = this.CharacterArray[i];
              switch (model.name) {
                  case "npc":
                      let npcrunner = model.getComponent(NpcRunner);
                      if (npcrunner)
                          npcrunner.destroy();
                      break;
                  case "pursue":
                      let hostage = model.getChildByName("player").getChildAt(0).getComponent(Hostage);
                      let chasenpc = model.getChildByName("enemy").getChildAt(0).getComponent(ChaseNpc);
                      if (hostage)
                          hostage.destroy();
                      if (chasenpc)
                          chasenpc.destroy();
                      break;
                  case "horse1":
                      let boss = model.getChildByName("boss");
                      boss.active = false;
                      boss.removeSelf();
                      GamePool.Instance.RecoveryModel(boss);
                      let _bs = boss.getComponent(Boss);
                      if (_bs) {
                          for (let i = 0; i < _bs.arrowarray.length; i++) {
                              let arrow = _bs.arrowarray[i];
                              GamePool.Instance.RecoveryModel(arrow);
                              _bs.arrowarray[i] = null;
                          }
                          _bs.arrowarray.splice(0, _bs.arrowarray.length);
                          _bs.destroy();
                      }
                      break;
                  case "player":
                      let runner = model.getComponent(Runner);
                      let horse = model.getChildAt(model.numChildren - 1);
                      let cap = model.getChildByName("cappos").getChildAt(0);
                      if (cap) {
                          cap.removeSelf();
                          GamePool.Instance.RecoveryModel(cap);
                      }
                      horse.active = false;
                      horse.removeSelf();
                      GamePool.Instance.RecoveryModel(horse);
                      if (runner) {
                          for (let i = 0; i < runner.arrowarray.length; i++) {
                              let arrow = runner.arrowarray[i];
                              GamePool.Instance.RecoveryModel(arrow);
                              runner.arrowarray[i] = null;
                          }
                          runner.arrowarray.splice(0, runner.arrowarray.length);
                          runner.destroy();
                      }
                      break;
              }
              GamePool.Instance.RecoveryModel(model);
              this.CharacterArray[i] = null;
          }
          this.CharacterArray.splice(0, this.CharacterArray.length);
          for (let i = 0; i < this.UIArray.length; i++) {
              let UI = this.UIArray[i];
              UI.removeSelf();
              UI.destroy();
          }
          this.UIArray.splice(0, this.UIArray.length);
      }
      CreatRay(pos, euler, raypos) {
          var ray = this.CreatRayPrefab();
          raypos.addChild(ray);
          ray.transform.position = pos;
          ray.transform.rotationEuler = euler;
      }
      CreatRayPrefab() {
          var ray = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(18), "");
          return ray;
      }
      CreatArcher(_pos, _euler, archerpos) {
          var archer = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(16), "");
          archerpos.addChild(archer);
          archer.transform.position = _pos;
          archer.transform.rotationEuler = _euler;
          var scale = archer.transform.scale.clone();
          scale.x = 0.3;
          scale.y = 0.3;
          scale.z = 0.6;
          archer.transform.scale = scale;
      }
      Revive() {
          PlayerControl.Instance.Revive();
          ViewManager.Instance.ShowView(ViewType.IngameView);
      }
      SetHorse(_id) {
          let horsemodel = PlayerControl.Instance.Player.getChildAt(PlayerControl.Instance.Player.numChildren - 1);
          horsemodel.removeSelf();
          GamePool.Instance.RecoveryModel(horsemodel);
          var newhorsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(_id), "");
          PlayerControl.Instance.Player.addChild(newhorsemodel);
          newhorsemodel.transform.localScale = new Laya.Vector3(1, 1, 1);
          newhorsemodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
          PlayerControl.Instance._runner.m_horseanimator = newhorsemodel.getComponent(Laya.Animator);
      }
      SetCap(_id) {
          let cappos = PlayerControl.Instance._runner.m_player.getChildByName("cappos");
          let cap = cappos.getChildAt(0);
          if (cap) {
              cap.removeSelf();
              GamePool.Instance.RecoveryModel(cap);
          }
          let newcap = GamePool.Instance.GetModel(AssetManager.Instance.Cap.get(_id), "");
          cappos.addChild(newcap);
          newcap.transform.localPosition = new Laya.Vector3(0, 0, 0);
          newcap.transform.localScale = new Laya.Vector3(0.5, 0.5, 0.5);
          newcap.transform.localRotationEuler = new Laya.Vector3(-90, 0, 0);
      }
  }

  class MainGame {
      constructor() {
          MainGame.ins = this;
          EventManager.StageOn(StageState.Lose, this, this.GameFailure);
          EventManager.StageOn(StageState.Win, this, this.GameWin);
      }
      static get Instance() {
          if (MainGame.ins) {
              return MainGame.ins;
          }
          else {
              return new MainGame();
          }
      }
      GameFailure() {
          if (GameManager.Instance.ReviveNum > 0) {
              ViewManager.Instance.ShowView(ViewType.CompleteView, 3);
          }
          else {
              AudioManager.StopMusic();
              AudioManager.playMusic(MusicType.Lose);
              ViewManager.Instance.ShowView(ViewType.CompleteView, 2);
          }
      }
      GameWin() {
          AudioManager.StopMusic();
          AudioManager.playMusic(MusicType.Win);
          ViewManager.Instance.ShowView(ViewType.CompleteView, 1);
      }
      Revive() {
          ViewManager.Instance.ShowView(ViewType.CompleteView, 3);
      }
  }

  class LoadView extends ui.LoadViewUI {
      constructor() {
          super();
          this.progressnum = 0;
          this.fast = 0.07;
          this.slow = 0.001;
          this.End = false;
          this.EndProgress = false;
          Laya.stage.addChild(this);
          LoadView.ins = this;
          this.height = Laya.stage.height;
          Laya.stage.on(Laya.Event.RESIZE, this, () => {
              this.height = Laya.stage.height;
          });
          this.Init();
      }
      static get Instance() {
          if (LoadView.ins) {
              return LoadView.ins;
          }
          else {
              return new LoadView();
          }
      }
      Init() {
          console.log("load界面构造函数");
          new GameManager();
          new StageControl();
          new MainGame();
          this.Login();
          Laya.timer.frameLoop(1, this, this.UpdateProgress);
      }
      UpdateProgress() {
          if (this.progressnum <= 0.7) {
              this.progressnum += this.fast;
          }
          else if (this.progressnum > 0.7 && this.progressnum < 0.99) {
              this.progressnum += this.slow;
          }
          else {
              if (this.End) {
                  this.progressnum += this.slow;
              }
          }
          if (!this.EndProgress && this.progressnum >= 1) {
              this.EndProgress = true;
              this.progressnum = 1;
              Laya.timer.clear(this, this.UpdateProgress);
              this.LoadComplete();
          }
          this.LoadProgress.value = this.progressnum;
      }
      complete() {
          this.End = true;
          this.slow = this.fast;
      }
      Login() {
          WXSDK.AldEvent("开始加载");
          if (Laya.Browser.onWeiXin) {
              this.WXLogin();
          }
          else {
              this.LocalLogin();
          }
      }
      WXLogin() {
          if (Laya.Browser.onWeiXin) {
              WXSDK.DengLu((res) => {
                  if (res != "error") {
                      WXSDK.AldEvent("微信登陆成功");
                      console.log("1微信登录成功:" + res);
                      this.LocalLogin();
                  }
                  else {
                      this.WXLogin();
                  }
              });
          }
          else {
              this.LocalLogin();
          }
      }
      LocalLogin() {
          ServerManager.Instance.Login(null, Laya.Handler.create(this, this.LoginComplete), Laya.Handler.create(this, this.LoginFail));
      }
      LoginComplete() {
          WXSDK.canshakestage = AccountManager.Instance.curplayerData.CanStageShake;
          SDKZS.loadData();
          WXSDK.AldEvent("本地服务器登陆成功");
          console.log("本地服务器登陆成功");
          this.LoadSubPackage();
      }
      LoginFail() {
          console.log("本地服务器登陆失败");
      }
      LoadComplete() {
          this.destroy();
          EventManager.EventTrigger(EventState.LoadComplete);
          WXSDK.AldEvent("资源加载完毕，开始进入主界面");
          console.log("加载完毕--");
      }
      LoadSubPackage() {
          WXSDK.LoadSubPackage("Game", callback => {
              if (callback) {
                  WXSDK.AldEvent("分包加载成功");
                  this.LoadScene();
              }
          });
      }
      LoadScene() {
          Laya.Scene3D.load(ResourcesPath.MainScene, Laya.Handler.create(this, (scene) => {
              this.mainscene = scene;
              AssetManager.Instance.mainscene = this.mainscene;
              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 + 50, model);
                  Laya.loader.clearRes(ResourcesPath.Horse[i]);
              }
              console.log("马模型资源加载完毕---");
              this.LoadBoss();
          }));
      }
      LoadBoss() {
          var path = [];
          for (let i = 0; i < ResourcesPath.Boss.length; i++) {
              path.push(ResourcesPath.Boss[i]);
          }
          Laya.loader.create(path, Laya.Handler.create(this, () => {
              for (let i = 0; i < ResourcesPath.Boss.length; i++) {
                  var model = Laya.loader.getRes(ResourcesPath.Boss[i]);
                  AssetManager.Instance.Boss.set(i + 1, model);
                  Laya.loader.clearRes(ResourcesPath.Boss[i]);
              }
              console.log("boss模型资源加载完毕---");
              this.LoadCap();
          }));
      }
      LoadCap() {
          var path = [];
          for (let i = 0; i < ResourcesPath.Cap.length; i++) {
              path.push(ResourcesPath.Cap[i]);
          }
          Laya.loader.create(path, Laya.Handler.create(this, () => {
              for (let i = 0; i < ResourcesPath.Cap.length; i++) {
                  var model = Laya.loader.getRes(ResourcesPath.Cap[i]);
                  AssetManager.Instance.Cap.set(i + 1, model);
                  Laya.loader.clearRes(ResourcesPath.Cap[i]);
              }
              console.log("帽子模型资源加载完毕---");
              this.LoadProp();
          }));
      }
      LoadProp() {
          Laya.loader.create(ResourcesPath.Prop, Laya.Handler.create(this, this.LoadResources));
      }
      LoadResources(_prop) {
          var Prop = _prop.getChildByName("Prop");
          for (let i = 0; i < Prop.numChildren; i++) {
              var model = Prop.getChildAt(i);
              model.active = false;
              AssetManager.Instance.Prop.set(i + 1, model);
          }
          var Plane = _prop.getChildByName("plane");
          AssetManager.Instance.Plane.set(1, Plane);
          var smallfence = _prop.getChildByName("small_fence");
          AssetManager.Instance.Small_Fence.set(1, smallfence);
          var Tree = _prop.getChildByName("Tree");
          for (let i = 0; i < Tree.numChildren; i++) {
              var tree = Tree.getChildAt(i);
              tree.active = false;
              AssetManager.Instance.Tree.set(i + 1, tree);
          }
          Laya.loader.clearRes(ResourcesPath.Prop);
          console.log("道具资源加载完毕---");
          this.complete();
      }
  }

  class Main$1 {
      constructor() {
          if (CheckMain.Creat)
              return;
          CheckMain.Creat = 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;
          if (Laya.Browser.onWeiXin) {
              Laya.Browser.window.wx.showShareMenu({
                  withShareTicket: true
              });
              Laya.Browser.window.wx.onShareAppMessage(function () {
                  return {
                      title: "有人@你，一起骑马仗箭走天涯",
                      imageUrl: "Game/res/textrue/share.jpg",
                  };
              });
              Laya.Browser.window.wx.onShow((option) => {
                  var shareTicket = option.shareTicket;
                  var userId = option.query.userId;
                  var shareTitle = option.query.shareTitle;
                  var scenevalue = Laya.LocalStorage.getItem("SceneValue");
                  if (scenevalue) {
                      Main$1.SceneNum = scenevalue;
                  }
                  else {
                      Laya.LocalStorage.setItem("SceneValue", option.scene);
                      Main$1.SceneNum = option.scene;
                  }
                  WXSDK.querychannel = option.query.channel;
                  WXSDK.shareOpenId = option.query.userId;
                  console.log("scene:", option.scene);
                  if (WXSDK.querychannel != null) {
                      console.log("onShow channel is:", WXSDK.querychannel);
                  }
                  if (option.referrerInfo) {
                      WXSDK.referrerInfoappId = option.referrerInfo.appId;
                      console.log("onShow appId is:", option.referrerInfo.appId);
                  }
              });
              if (!Laya.Browser.onWeiXin)
                  return;
              const updateManager = Laya.Browser.window.wx.getUpdateManager();
              updateManager.onCheckForUpdate(function (res) {
                  console.log("最新版本:" + res.hasUpdate);
              });
              updateManager.onUpdateReady(function () {
                  Laya.Browser.window.wx.showModal({
                      showCancel: false,
                      title: '更新提示',
                      content: '新版本已经准备好，是否重启应用？',
                      success(res) {
                          updateManager.applyUpdate();
                      },
                      fail(res) {
                          updateManager.applyUpdate();
                      }
                  });
              });
          }
          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();
      }
  }
  Main$1.Ver = "1.0.0";
  Main$1.CFG = "123";
  new Main$1();

  exports.Main = Main$1;

  return exports;

}({}));
//# sourceMappingURL=bundle.js.map
