bundle.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. (function () {
  2. 'use strict';
  3. class GameConfig {
  4. constructor() { }
  5. static init() {
  6. var reg = Laya.ClassUtils.regClass;
  7. }
  8. }
  9. GameConfig.width = 640;
  10. GameConfig.height = 1136;
  11. GameConfig.scaleMode = "fixedwidth";
  12. GameConfig.screenMode = "none";
  13. GameConfig.alignV = "top";
  14. GameConfig.alignH = "left";
  15. GameConfig.startScene = "";
  16. GameConfig.sceneRoot = "";
  17. GameConfig.debug = false;
  18. GameConfig.stat = false;
  19. GameConfig.physicsDebug = false;
  20. GameConfig.exportSceneToJson = true;
  21. GameConfig.init();
  22. class ResDic {
  23. constructor() {
  24. this._container = {};
  25. this._length = 0;
  26. }
  27. get container() {
  28. return this._container;
  29. }
  30. get size() {
  31. return this._length;
  32. }
  33. set(key, value) {
  34. if (!this._container.hasOwnProperty(key)) {
  35. this._length++;
  36. }
  37. this._container[key] = value;
  38. }
  39. has(key) {
  40. return this._container.hasOwnProperty(key) ? true : false;
  41. }
  42. get(key) {
  43. if (this._container.hasOwnProperty(key)) {
  44. return this._container[key];
  45. }
  46. else {
  47. return undefined;
  48. }
  49. }
  50. delete(key) {
  51. if (this._container.hasOwnProperty(key)) {
  52. delete this._container[key];
  53. this._length--;
  54. }
  55. }
  56. clear() {
  57. this._container = {};
  58. this._length = 0;
  59. }
  60. }
  61. var EventState;
  62. (function (EventState) {
  63. EventState[EventState["LoadComplete"] = 0] = "LoadComplete";
  64. EventState[EventState["SceneInit"] = 1] = "SceneInit";
  65. EventState[EventState["StageInit"] = 2] = "StageInit";
  66. EventState[EventState["StageCreateComplete"] = 3] = "StageCreateComplete";
  67. EventState[EventState["AnimatorEnd"] = 4] = "AnimatorEnd";
  68. })(EventState || (EventState = {}));
  69. var StageState;
  70. (function (StageState) {
  71. StageState[StageState["Win"] = 0] = "Win";
  72. StageState[StageState["Lose"] = 1] = "Lose";
  73. StageState[StageState["Start"] = 2] = "Start";
  74. StageState[StageState["StageCreateComPlete"] = 3] = "StageCreateComPlete";
  75. StageState[StageState["Over"] = 4] = "Over";
  76. })(StageState || (StageState = {}));
  77. class EventManager {
  78. static EventOn(_mode, caller, fun, args = []) {
  79. EventManager.instance.on(EventState[_mode], caller, fun, args);
  80. }
  81. static EventOff(_mode, caller, fun, args = []) {
  82. EventManager.instance.off(EventState[_mode], caller, fun);
  83. }
  84. static EventTrigger(_mode, args = []) {
  85. EventManager.instance.event(EventState[_mode], args);
  86. }
  87. static StageOn(_mode, caller, fun, args = []) {
  88. EventManager.instance.on(StageState[_mode], caller, fun, args);
  89. }
  90. static StageOff(_mode, caller, fun, args = []) {
  91. EventManager.instance.off(StageState[_mode], caller, fun);
  92. }
  93. static StageTrigger(_mode, args = []) {
  94. EventManager.instance.event(StageState[_mode], args);
  95. }
  96. }
  97. EventManager.instance = new Laya.EventDispatcher();
  98. class GameTools {
  99. constructor() {
  100. GameTools.ins = this;
  101. }
  102. static get Instance() {
  103. if (GameTools.ins) {
  104. return GameTools.ins;
  105. }
  106. else {
  107. return new GameTools();
  108. }
  109. }
  110. lerp(form, to, t) {
  111. if (t <= 0) {
  112. return form;
  113. }
  114. else if (t >= 1) {
  115. return to;
  116. }
  117. var a = t * to + (1 - t) * form;
  118. return a;
  119. }
  120. SetCollider(setNode, CollisionGroup) {
  121. var numchild = setNode.numChildren;
  122. for (var i = 0; i < setNode.numChildren; i++) {
  123. var numchild2 = setNode.getChildAt(i).numChildren;
  124. if (numchild2 > 1) {
  125. this.SetCollider(setNode.getChildAt(i), CollisionGroup);
  126. }
  127. var physicsCollider = setNode.getChildAt(i).getComponent(Laya.PhysicsCollider);
  128. if (physicsCollider) {
  129. physicsCollider.collisionGroup = CollisionGroup;
  130. }
  131. }
  132. }
  133. static RandomNumber(from, to) {
  134. if (from >= to) {
  135. return 0;
  136. }
  137. var size = to - from;
  138. var curNumber = Math.random() * size + from;
  139. return curNumber;
  140. }
  141. static RandomANumber(from, to) {
  142. if (from >= to) {
  143. return 0;
  144. }
  145. var size = to - from;
  146. var curNumber = Math.random() * size + from;
  147. return Math.floor(curNumber);
  148. }
  149. static GetMoney(_num, _pos = null, _completeHandle = null) {
  150. if (_num == 0)
  151. return;
  152. var fafaafsfa = new Laya.Box;
  153. fafaafsfa.width = 400;
  154. fafaafsfa.height = 100;
  155. fafaafsfa.pivotX = fafaafsfa.width / 2;
  156. fafaafsfa.pivotY = fafaafsfa.height / 2;
  157. if (_pos == null) {
  158. _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2);
  159. }
  160. fafaafsfa.pos(_pos.x, _pos.y);
  161. var aafafaffa = new Laya.Image;
  162. aafafaffa.skin = "game/qiandao_1_7.png";
  163. aafafaffa.width = 60;
  164. aafafaffa.height = 60;
  165. aafafaffa.left = 50;
  166. aafafaffa.y = 10;
  167. fafaafsfa.addChild(aafafaffa);
  168. var faasfafsafs = new Laya.Text;
  169. faasfafsafs.width = 300;
  170. faasfafsafs.height = 50;
  171. faasfafsafs.align = "center";
  172. faasfafsafs.valign = "middle";
  173. faasfafsafs.font = "Microsoft YaHei";
  174. faasfafsafs.fontSize = 40;
  175. faasfafsafs.color = "#FFFFFF";
  176. faasfafsafs.bold = true;
  177. faasfafsafs.font = "Microsoft YaHei";
  178. faasfafsafs.text = "金币 +" + _num;
  179. faasfafsafs.x = 60;
  180. faasfafsafs.y = 10;
  181. fafaafsfa.addChild(faasfafsafs);
  182. Laya.stage.addChild(fafaafsfa);
  183. var faasfsaf = Laya.Tween.to(fafaafsfa, { y: fafaafsfa.y - 200 }, 1500, Laya.Ease.expoInOut, Laya.Handler.create(this, () => {
  184. faasfsaf.clear();
  185. fafaafsfa.destroy();
  186. if (_completeHandle) {
  187. _completeHandle.run();
  188. }
  189. }), 100);
  190. }
  191. static TweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
  192. var afasafsafsfa = new Laya.Text();
  193. afasafsafsfa.width = faafssfafsa.size.x;
  194. afasafsafsfa.height = faafssfafsa.size.y;
  195. afasafsafsfa.align = "center";
  196. afasafsafsfa.valign = "middle";
  197. afasafsafsfa.font = "Microsoft YaHei";
  198. afasafsafsfa.fontSize = faafssfafsa.fontSize;
  199. afasafsafsfa.pivotX = afasafsafsfa.width / 2;
  200. afasafsafsfa.pivotY = afasafsafsfa.height / 2;
  201. afasafsafsfa.color = "#5ad122";
  202. afasafsafsfa.bold = true;
  203. afasafsafsfa.stroke = 5;
  204. afasafsafsfa.strokeColor = "#ffffff";
  205. if (faafssfafsa.color) {
  206. faafssfafsa.color = faafssfafsa.color;
  207. }
  208. afasafsafsfa.text = faafssfafsa.message;
  209. afasafsafsfa.zOrder = 1;
  210. Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
  211. afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
  212. var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
  213. }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
  214. tween.clear();
  215. if (hide) {
  216. afasafsafsfa.destroy();
  217. }
  218. if (_completeHandle) {
  219. _completeHandle.run();
  220. }
  221. }));
  222. if (hide) {
  223. Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 500);
  224. }
  225. return afasafsafsfa;
  226. }
  227. static StationTweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
  228. var afasafsafsfa = new Laya.Text();
  229. afasafsafsfa.width = faafssfafsa.size.x;
  230. afasafsafsfa.height = faafssfafsa.size.y;
  231. afasafsafsfa.align = "center";
  232. afasafsafsfa.valign = "middle";
  233. afasafsafsfa.font = "Microsoft YaHei";
  234. afasafsafsfa.fontSize = 50;
  235. afasafsafsfa.pivotX = afasafsafsfa.width / 2;
  236. afasafsafsfa.pivotY = afasafsafsfa.height / 2;
  237. afasafsafsfa.color = "#5ad122";
  238. afasafsafsfa.bold = true;
  239. afasafsafsfa.stroke = 5;
  240. afasafsafsfa.strokeColor = "#ffffff";
  241. if (faafssfafsa.color) {
  242. faafssfafsa.color = faafssfafsa.color;
  243. }
  244. afasafsafsfa.text = faafssfafsa.message;
  245. afasafsafsfa.zOrder = 1;
  246. Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
  247. afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
  248. var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
  249. }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
  250. tween.clear();
  251. if (hide) {
  252. afasafsafsfa.destroy();
  253. }
  254. if (_completeHandle) {
  255. _completeHandle.run();
  256. }
  257. }));
  258. if (hide) {
  259. Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 10000);
  260. }
  261. return afasafsafsfa;
  262. }
  263. static tweenMove(transform, targPos, delay, ease, complete) {
  264. let curPos = transform.position.clone();
  265. return Laya.Tween.to(curPos, {
  266. x: targPos.x,
  267. y: targPos.y,
  268. z: targPos.z,
  269. update: new Laya.Handler(this, () => {
  270. transform.position = curPos.clone();
  271. })
  272. }, delay, ease, complete);
  273. }
  274. static tweenRotate(transform, targEuler, delay, ease, complete) {
  275. let curEuler = transform.rotationEuler.clone();
  276. return Laya.Tween.to(curEuler, {
  277. x: targEuler.x,
  278. y: targEuler.y,
  279. z: targEuler.z,
  280. update: new Laya.Handler(this, () => {
  281. transform.rotationEuler = curEuler.clone();
  282. })
  283. }, delay, ease, complete);
  284. }
  285. }
  286. class AssetManager {
  287. constructor() {
  288. this.Player = new ResDic();
  289. this.Enemy = new ResDic();
  290. this.Horse = new ResDic();
  291. this.Prop = new ResDic();
  292. AssetManager.ins = this;
  293. EventManager.EventOn(EventState.LoadComplete, this, this.Init);
  294. }
  295. static get Instance() {
  296. if (AssetManager.ins) {
  297. return AssetManager.ins;
  298. }
  299. else {
  300. return new AssetManager();
  301. }
  302. }
  303. Init() {
  304. this.maincamera = this.mainscene.getChildByName("Main Camera");
  305. this.Plane = this.mainscene.getChildByName("Plane");
  306. GameTools.Instance.SetCollider(this.Plane, 100);
  307. EventManager.EventTrigger(EventState.SceneInit);
  308. }
  309. }
  310. class ResourcesPath {
  311. }
  312. ResourcesPath.MainScene = "Game/res/MainScene/LayaScene_Mainscene/Conventional/Mainscene.ls";
  313. ResourcesPath.Horse = [
  314. "Game/res/Role/LayaScene_Role/Conventional/Horse.lh"
  315. ];
  316. ResourcesPath.Player = [
  317. "Game/res/Role/LayaScene_Role/Conventional/player.lh"
  318. ];
  319. ResourcesPath.Enemy = [
  320. "Game/res/Role/LayaScene_Role/Conventional/enemy.lh"
  321. ];
  322. var Sprite3D = Laya.Sprite3D;
  323. var Vector3 = Laya.Vector3;
  324. class modelConfig {
  325. constructor(model) {
  326. this.modelcur = model;
  327. this.modelPos = model.transform.position.clone();
  328. this.modelRot = model.transform.rotation.clone();
  329. this.modelSca = model.transform.scale.clone();
  330. }
  331. }
  332. class GamePool {
  333. constructor() {
  334. this.modelpool = {};
  335. this.maxAcount = 30;
  336. GamePool.Ins = this;
  337. }
  338. static get Instance() {
  339. if (GamePool.Ins) {
  340. return GamePool.Ins;
  341. }
  342. else {
  343. return new GamePool();
  344. }
  345. }
  346. GetModel(_model, title) {
  347. var poolname = title + _model.name;
  348. if (this.modelpool[poolname] != null && this.modelpool[poolname] != undefined) {
  349. if (this.modelpool[poolname].length > 0) {
  350. var model1 = this.modelpool[poolname][0];
  351. this.modelpool[poolname].splice(0, 1);
  352. if (model1.modelcur.destroyed) {
  353. model1.modelcur = Sprite3D.instantiate(_model);
  354. if (!model1.modelcur.active) {
  355. model1.modelcur.active = true;
  356. }
  357. }
  358. model1.modelcur.active = true;
  359. model1.modelcur.transform.position = _model.transform.position.clone();
  360. model1.modelcur.transform.rotation = _model.transform.rotation.clone();
  361. model1.modelcur.transform.scale = _model.transform.scale.clone();
  362. return model1.modelcur;
  363. }
  364. else {
  365. var model = Sprite3D.instantiate(_model);
  366. model.active = true;
  367. return model;
  368. }
  369. }
  370. else {
  371. var model = Sprite3D.instantiate(_model);
  372. model.active = true;
  373. return model;
  374. }
  375. }
  376. RecoveryModel(model, title = "", modelstate = false) {
  377. if (model.destroyed) {
  378. return;
  379. }
  380. if (!modelstate && model.active == false) {
  381. return;
  382. }
  383. var poolname = title + model.name;
  384. if (this.modelpool[poolname] != null && this.modelpool[poolname] != undefined) {
  385. var modelnum = this.modelpool[poolname];
  386. if (modelnum.length > this.maxAcount) {
  387. model.destroy();
  388. return;
  389. }
  390. else {
  391. modelnum.push(new modelConfig(model));
  392. }
  393. }
  394. else {
  395. modelnum = [];
  396. modelnum.push(new modelConfig(model));
  397. this.modelpool[poolname] = modelnum;
  398. }
  399. model.transform.position = new Vector3(0, 0, -10000);
  400. model.removeSelf();
  401. model.active = false;
  402. }
  403. ResetsModelPool() {
  404. for (var Key in this.modelpool) {
  405. var model = this.modelpool[Key];
  406. for (var i = 0; i < model.length; i++) {
  407. model[i].modelcur.destroy();
  408. }
  409. }
  410. this.modelpool = {};
  411. }
  412. }
  413. var Vector3$1 = Laya.Vector3;
  414. class Runner extends Laya.Script3D {
  415. constructor() {
  416. super();
  417. this.currotV = new Vector3$1();
  418. this.currot = new Laya.Quaternion;
  419. this.NormalizeSpeed = new Vector3$1();
  420. this.turndir = new Vector3$1(1, 0, 0);
  421. }
  422. static get Instance() {
  423. if (Runner.ins) {
  424. return Runner.ins;
  425. }
  426. else {
  427. return new Runner();
  428. }
  429. }
  430. onAwake() {
  431. this.m_player = this.owner;
  432. }
  433. onUpdate() {
  434. }
  435. MoveX(_speed) {
  436. _speed *= 0.07;
  437. this.m_player.transform.translate(new Vector3$1(_speed, 0, 0));
  438. this.m_player.transform.position = this.m_player.transform.position.x < -4.5 ? new Vector3$1(-4.5, this.m_player.transform.position.y, this.m_player.transform.position.z) : this.m_player.transform.position;
  439. this.m_player.transform.position = this.m_player.transform.position.x > 4.5 ? new Vector3$1(4.5, this.m_player.transform.position.y, this.m_player.transform.position.z) : this.m_player.transform.position;
  440. }
  441. TurnDir(_dir) {
  442. if (_dir.x != 0) {
  443. Vector3$1.lerp(this.currotV, _dir, 0.35, _dir);
  444. this.currotV = _dir;
  445. Laya.Quaternion.rotationLookAt(_dir, new Vector3$1(0, 1, 0), this.currot);
  446. Laya.Quaternion.slerp(this.m_player.transform.rotation, this.currot, 0.025, this.currot);
  447. this.currot = new Laya.Quaternion(0, this.currot.y, 0);
  448. this.m_player.transform.rotation = this.currot;
  449. }
  450. else {
  451. Laya.Quaternion.slerp(this.m_player.transform.rotation, new Laya.Quaternion(0, 0, 0, 0), 0.1, this.currot);
  452. this.currot = new Laya.Quaternion(0, this.currot.y, 0);
  453. this.m_player.transform.rotation = this.currot;
  454. }
  455. }
  456. }
  457. var Vector2 = Laya.Vector2;
  458. var Vector3$2 = Laya.Vector3;
  459. class PlayerControl {
  460. constructor() {
  461. this.DownHit = new Laya.HitResult();
  462. this.canmove = true;
  463. this.speed = 1;
  464. this.press = false;
  465. this.offset = new Vector3$2(0, 0, 0);
  466. this.offestx = 0;
  467. this.poschazhi = new Vector3$2();
  468. this.gengsuipos = new Vector3$2();
  469. this.lllpos = new Vector3$2();
  470. this.hights = 0;
  471. this.wights = 0;
  472. this.rolepos = new Vector3$2;
  473. this.rundir = new Vector3$2;
  474. this.curspeed = 0;
  475. PlayerControl.ins = this;
  476. }
  477. static get Instance() {
  478. if (PlayerControl.ins) {
  479. return PlayerControl.ins;
  480. }
  481. else {
  482. return new PlayerControl();
  483. }
  484. }
  485. Init(_player) {
  486. this.Player = _player;
  487. this._runner = this.Player.addComponent(Runner);
  488. this.Player.transform.position = new Vector3$2();
  489. this.Camera = AssetManager.Instance.maincamera;
  490. this.Camera.transform.position = new Vector3$2(0, 10, -10);
  491. this.Camera.transform.localRotationEuler = new Vector3$2(-5, 0, 0);
  492. Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
  493. Laya.timer.frameLoop(1, this, this.LateUpdate);
  494. this.CameraFollow();
  495. }
  496. MouseListen() {
  497. }
  498. onMouseDown(e) {
  499. this.startMousePos = new Vector3$2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
  500. var startpoint = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
  501. this.curMousePos1 = startpoint.clone();
  502. Laya.timer.frameLoop(1, this, this.onMouseMove);
  503. Laya.stage.on(Laya.Event.MOUSE_UP, this, this.onMouseUp);
  504. Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
  505. }
  506. onMouseMove() {
  507. var MousePos = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
  508. var offestX = MousePos.x - this.curMousePos1.x;
  509. offestX = offestX > 100 ? 100 : offestX;
  510. offestX = offestX < -100 ? -100 : offestX;
  511. this.offestx = GameTools.Instance.lerp(this.offestx, offestX, 0.015);
  512. this._runner.MoveX(-this.offestx);
  513. var dir = new Vector3$2(-offestX * 0.005, 0, 0);
  514. this._runner.TurnDir(dir);
  515. this.curMousePos1 = new Vector2(MousePos.x, MousePos.y);
  516. }
  517. onMouseUp() {
  518. this.offestx = 0;
  519. Laya.timer.clear(this, this.onMouseMove);
  520. }
  521. CameraFollow() {
  522. this.hights = 0;
  523. this.wights = 0;
  524. Vector3$2.subtract(this.Player.transform.position, this.Camera.transform.position, this.poschazhi);
  525. Laya.timer.frameLoop(1, this, this.GenSui);
  526. }
  527. GenSui() {
  528. Vector3$2.subtract(this.Player.transform.position, this.poschazhi, this.gengsuipos);
  529. this.hights = GameTools.Instance.lerp(this.hights, 1.0, 0.03);
  530. this.wights = GameTools.Instance.lerp(this.wights, 0.8, 0.02);
  531. this.gengsuipos = new Vector3$2(this.gengsuipos.x, this.gengsuipos.y, this.gengsuipos.z - this.wights);
  532. Vector3$2.lerp(this.Camera.transform.position, this.gengsuipos, 0.25, this.lllpos);
  533. this.lllpos = new Vector3$2(this.gengsuipos.x, this.gengsuipos.y, this.lllpos.z);
  534. this.lllpos = new Vector3$2(this.gengsuipos.x, this.lllpos.y, this.lllpos.z);
  535. this.Camera.transform.position = this.lllpos;
  536. var qqqwe = new Laya.Quaternion();
  537. var eyePos = new Vector3$2(this.gengsuipos.x, this.gengsuipos.y - 0.8, this.gengsuipos.z);
  538. Laya.Quaternion.lookAt(eyePos, this.Player.transform.position, new Vector3$2(0, 1, 0), qqqwe);
  539. qqqwe.invert(qqqwe);
  540. Laya.Quaternion.slerp(this.Camera.transform.rotation, qqqwe, 0.1, qqqwe);
  541. this.Camera.transform.rotation = qqqwe;
  542. }
  543. get DownRayCheck() {
  544. var isDownHit = false;
  545. var startPos = new Vector3$2(this.Player.transform.position.x, this.Player.transform.position.y + 1.5, this.Player.transform.position.z + 0.5);
  546. var direction = new Vector3$2(0, -1, 0);
  547. var DownRay = new Laya.Ray(startPos, direction);
  548. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.DownHit, 100)) {
  549. if (this.DownHit.collider.collisionGroup == 100) {
  550. isDownHit = true;
  551. }
  552. }
  553. return isDownHit;
  554. }
  555. Move() {
  556. if (this.canmove) {
  557. this.speed = this.press ? 1 : 0.5;
  558. this.curspeed = GameTools.Instance.lerp(this.curspeed, this.speed, 0.04);
  559. Vector3$2.scale(new Vector3$2(0, 0, 1), this.curspeed, this.rundir);
  560. Vector3$2.add(this.Player.transform.position, this.rundir, this.rolepos);
  561. Vector3$2.lerp(this.Player.transform.position, this.rolepos, 0.15, this.rolepos);
  562. this.Player.transform.position = this.rolepos;
  563. }
  564. }
  565. RayCheck() {
  566. if (this.DownRayCheck) {
  567. this.Player.transform.position = new Laya.Vector3(this.Player.transform.position.x, this.DownHit.point.y, this.Player.transform.position.z);
  568. }
  569. }
  570. LateUpdate() {
  571. }
  572. }
  573. class GameManager {
  574. constructor() {
  575. this.EnemyArray = [];
  576. GameManager.ins = this;
  577. EventManager.EventOn(EventState.SceneInit, this, this.Init);
  578. }
  579. static get Instance() {
  580. if (GameManager.ins) {
  581. return GameManager.ins;
  582. }
  583. else {
  584. return new GameManager();
  585. }
  586. }
  587. Init() {
  588. this.CreatCharacter();
  589. this.mainscene = AssetManager.Instance.mainscene;
  590. Laya.stage.addChildAt(this.mainscene, 0);
  591. }
  592. CreatCharacter() {
  593. this.CreatPlayer();
  594. this.CreatEnemy();
  595. }
  596. CreatPlayer() {
  597. var playermodel = GamePool.Instance.GetModel(AssetManager.Instance.Player.get(1), "");
  598. var horsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(1), "");
  599. playermodel.addChild(horsemodel);
  600. playermodel.transform.position = new Laya.Vector3(0, 0, 0);
  601. horsemodel.transform.localScale = new Laya.Vector3(1, 1, 1);
  602. horsemodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
  603. PlayerControl.Instance.Init(playermodel);
  604. AssetManager.Instance.mainscene.addChild(playermodel);
  605. }
  606. CreatEnemy() {
  607. }
  608. }
  609. class LoadView {
  610. constructor() {
  611. LoadView.ins = this;
  612. this.Init();
  613. }
  614. static get Instance() {
  615. if (LoadView.ins) {
  616. return LoadView.ins;
  617. }
  618. else {
  619. return new LoadView();
  620. }
  621. }
  622. Init() {
  623. new GameManager();
  624. this.LoadScene();
  625. }
  626. LoadComplete() {
  627. console.log("加载完毕--");
  628. EventManager.EventTrigger(EventState.LoadComplete);
  629. }
  630. LoadScene() {
  631. let abc = 0.15 * 18;
  632. console.log("abc---", abc);
  633. Laya.Scene3D.load(ResourcesPath.MainScene, Laya.Handler.create(this, (scene) => {
  634. this.scene = scene;
  635. AssetManager.Instance.mainscene = this.scene;
  636. console.log("场景加载完毕");
  637. this.LoadEnemy();
  638. }));
  639. }
  640. LoadEnemy() {
  641. var path = [];
  642. for (let i = 0; i < ResourcesPath.Enemy.length; i++) {
  643. path.push(ResourcesPath.Enemy[i]);
  644. }
  645. Laya.loader.create(path, Laya.Handler.create(this, () => {
  646. for (let i = 0; i < ResourcesPath.Enemy.length; i++) {
  647. var model = Laya.loader.getRes(ResourcesPath.Enemy[i]);
  648. AssetManager.Instance.Enemy.set(i + 1, model);
  649. Laya.loader.clearRes(ResourcesPath.Enemy[i]);
  650. }
  651. console.log("敌人模型资源加载完毕---");
  652. this.LoadPlayer();
  653. }));
  654. }
  655. LoadPlayer() {
  656. var path = [];
  657. for (let i = 0; i < ResourcesPath.Player.length; i++) {
  658. path.push(ResourcesPath.Player[i]);
  659. }
  660. Laya.loader.create(path, Laya.Handler.create(this, () => {
  661. for (let i = 0; i < ResourcesPath.Player.length; i++) {
  662. var model = Laya.loader.getRes(ResourcesPath.Player[i]);
  663. AssetManager.Instance.Player.set(i + 1, model);
  664. Laya.loader.clearRes(ResourcesPath.Player[i]);
  665. }
  666. console.log("玩家模型资源加载完毕---");
  667. this.LoadHorse();
  668. }));
  669. }
  670. LoadHorse() {
  671. var path = [];
  672. for (let i = 0; i < ResourcesPath.Horse.length; i++) {
  673. path.push(ResourcesPath.Horse[i]);
  674. }
  675. Laya.loader.create(path, Laya.Handler.create(this, () => {
  676. for (let i = 0; i < ResourcesPath.Horse.length; i++) {
  677. var model = Laya.loader.getRes(ResourcesPath.Horse[i]);
  678. AssetManager.Instance.Horse.set(i + 1, model);
  679. Laya.loader.clearRes(ResourcesPath.Horse[i]);
  680. }
  681. console.log("马模型资源加载完毕---");
  682. this.LoadComplete();
  683. }));
  684. }
  685. }
  686. class Main {
  687. constructor() {
  688. if (window["Laya3D"])
  689. Laya3D.init(GameConfig.width, GameConfig.height);
  690. else
  691. Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
  692. Laya["Physics"] && Laya["Physics"].enable();
  693. Laya["DebugPanel"] && Laya["DebugPanel"].enable();
  694. Laya.stage.scaleMode = GameConfig.scaleMode;
  695. Laya.stage.screenMode = GameConfig.screenMode;
  696. Laya.stage.alignV = GameConfig.alignV;
  697. Laya.stage.alignH = GameConfig.alignH;
  698. Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
  699. if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
  700. Laya.enableDebugPanel();
  701. if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
  702. Laya["PhysicsDebugDraw"].enable();
  703. if (GameConfig.stat)
  704. Laya.Stat.show();
  705. Laya.alertGlobalError = true;
  706. Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
  707. }
  708. onVersionLoaded() {
  709. Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
  710. }
  711. onConfigLoaded() {
  712. new LoadView();
  713. }
  714. }
  715. new Main();
  716. }());
  717. //# sourceMappingURL=bundle.js.map