bundle.js 135 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881
  1. (function () {
  2. 'use strict';
  3. class GameConfig {
  4. constructor() { }
  5. static init() {
  6. var reg = Laya.ClassUtils.regClass;
  7. }
  8. }
  9. GameConfig.width = 720;
  10. GameConfig.height = 1280;
  11. GameConfig.scaleMode = "fixedwidth";
  12. GameConfig.screenMode = "none";
  13. GameConfig.alignV = "top";
  14. GameConfig.alignH = "left";
  15. GameConfig.startScene = "LoadView.scene";
  16. GameConfig.sceneRoot = "";
  17. GameConfig.debug = false;
  18. GameConfig.stat = false;
  19. GameConfig.physicsDebug = false;
  20. GameConfig.exportSceneToJson = false;
  21. GameConfig.init();
  22. var Vector3 = Laya.Vector3;
  23. class GameTools {
  24. constructor() {
  25. GameTools.ins = this;
  26. }
  27. static get Instance() {
  28. if (GameTools.ins) {
  29. return GameTools.ins;
  30. }
  31. else {
  32. return new GameTools();
  33. }
  34. }
  35. lerp(form, to, t) {
  36. if (t <= 0) {
  37. return form;
  38. }
  39. else if (t >= 1) {
  40. return to;
  41. }
  42. var a = t * to + (1 - t) * form;
  43. return a;
  44. }
  45. SetCollider(setNode, CollisionGroup) {
  46. var numchild = setNode.numChildren;
  47. for (var i = 0; i < setNode.numChildren; i++) {
  48. var numchild2 = setNode.getChildAt(i).numChildren;
  49. if (numchild2 > 1) {
  50. this.SetCollider(setNode.getChildAt(i), CollisionGroup);
  51. }
  52. var physicsCollider = setNode.getChildAt(i).getComponent(Laya.PhysicsCollider);
  53. if (physicsCollider) {
  54. physicsCollider.collisionGroup = CollisionGroup;
  55. }
  56. }
  57. }
  58. EnemySetCollider(setNode, collisionGroup) {
  59. var collider = setNode.getChildByName("npcfrontcollider");
  60. var collider2 = setNode.getChildByName("npcrearcollider");
  61. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  62. var physicsCollider2 = collider2.getComponent(Laya.PhysicsCollider);
  63. if (physicsCollider) {
  64. physicsCollider.collisionGroup = collisionGroup;
  65. }
  66. if (physicsCollider2) {
  67. physicsCollider2.collisionGroup = collisionGroup;
  68. }
  69. }
  70. PlayerSetCollider(setNode, collisionGroup) {
  71. var collider = setNode.getChildByName("playercollider");
  72. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  73. if (physicsCollider) {
  74. physicsCollider.collisionGroup = collisionGroup;
  75. }
  76. }
  77. HostageSetCollider(setNode, collisionGroup) {
  78. var collider = setNode.getChildByName("hostagecollider");
  79. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  80. if (physicsCollider) {
  81. physicsCollider.collisionGroup = collisionGroup;
  82. }
  83. }
  84. static RandomNumber(from, to) {
  85. if (from >= to) {
  86. return 0;
  87. }
  88. var size = to - from;
  89. var curNumber = Math.random() * size + from;
  90. return curNumber;
  91. }
  92. static RandomANumber(from, to) {
  93. if (from >= to) {
  94. return 0;
  95. }
  96. var size = to - from;
  97. var curNumber = Math.random() * size + from;
  98. return Math.floor(curNumber);
  99. }
  100. static GetMoney(_num, _pos = null, _completeHandle = null) {
  101. if (_num == 0)
  102. return;
  103. var fafaafsfa = new Laya.Box;
  104. fafaafsfa.width = 400;
  105. fafaafsfa.height = 100;
  106. fafaafsfa.pivotX = fafaafsfa.width / 2;
  107. fafaafsfa.pivotY = fafaafsfa.height / 2;
  108. if (_pos == null) {
  109. _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2);
  110. }
  111. fafaafsfa.pos(_pos.x, _pos.y);
  112. var aafafaffa = new Laya.Image;
  113. aafafaffa.skin = "game/qiandao_1_7.png";
  114. aafafaffa.width = 60;
  115. aafafaffa.height = 60;
  116. aafafaffa.left = 50;
  117. aafafaffa.y = 10;
  118. fafaafsfa.addChild(aafafaffa);
  119. var faasfafsafs = new Laya.Text;
  120. faasfafsafs.width = 300;
  121. faasfafsafs.height = 50;
  122. faasfafsafs.align = "center";
  123. faasfafsafs.valign = "middle";
  124. faasfafsafs.font = "Microsoft YaHei";
  125. faasfafsafs.fontSize = 40;
  126. faasfafsafs.color = "#FFFFFF";
  127. faasfafsafs.bold = true;
  128. faasfafsafs.font = "Microsoft YaHei";
  129. faasfafsafs.text = "金币 +" + _num;
  130. faasfafsafs.x = 60;
  131. faasfafsafs.y = 10;
  132. fafaafsfa.addChild(faasfafsafs);
  133. Laya.stage.addChild(fafaafsfa);
  134. var faasfsaf = Laya.Tween.to(fafaafsfa, { y: fafaafsfa.y - 200 }, 1500, Laya.Ease.expoInOut, Laya.Handler.create(this, () => {
  135. faasfsaf.clear();
  136. fafaafsfa.destroy();
  137. if (_completeHandle) {
  138. _completeHandle.run();
  139. }
  140. }), 100);
  141. }
  142. static TweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
  143. var afasafsafsfa = new Laya.Text();
  144. afasafsafsfa.width = faafssfafsa.size.x;
  145. afasafsafsfa.height = faafssfafsa.size.y;
  146. afasafsafsfa.align = "center";
  147. afasafsafsfa.valign = "middle";
  148. afasafsafsfa.font = "Microsoft YaHei";
  149. afasafsafsfa.fontSize = faafssfafsa.fontSize;
  150. afasafsafsfa.pivotX = afasafsafsfa.width / 2;
  151. afasafsafsfa.pivotY = afasafsafsfa.height / 2;
  152. afasafsafsfa.color = "#5ad122";
  153. afasafsafsfa.bold = true;
  154. afasafsafsfa.stroke = 5;
  155. afasafsafsfa.strokeColor = "#ffffff";
  156. if (faafssfafsa.color) {
  157. faafssfafsa.color = faafssfafsa.color;
  158. }
  159. afasafsafsfa.text = faafssfafsa.message;
  160. afasafsafsfa.zOrder = 1;
  161. Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
  162. afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
  163. var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
  164. }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
  165. tween.clear();
  166. if (hide) {
  167. afasafsafsfa.destroy();
  168. }
  169. if (_completeHandle) {
  170. _completeHandle.run();
  171. }
  172. }));
  173. if (hide) {
  174. Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 500);
  175. }
  176. return afasafsafsfa;
  177. }
  178. static StationTweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
  179. var afasafsafsfa = new Laya.Text();
  180. afasafsafsfa.width = faafssfafsa.size.x;
  181. afasafsafsfa.height = faafssfafsa.size.y;
  182. afasafsafsfa.align = "center";
  183. afasafsafsfa.valign = "middle";
  184. afasafsafsfa.font = "Microsoft YaHei";
  185. afasafsafsfa.fontSize = 50;
  186. afasafsafsfa.pivotX = afasafsafsfa.width / 2;
  187. afasafsafsfa.pivotY = afasafsafsfa.height / 2;
  188. afasafsafsfa.color = "#5ad122";
  189. afasafsafsfa.bold = true;
  190. afasafsafsfa.stroke = 5;
  191. afasafsafsfa.strokeColor = "#ffffff";
  192. if (faafssfafsa.color) {
  193. faafssfafsa.color = faafssfafsa.color;
  194. }
  195. afasafsafsfa.text = faafssfafsa.message;
  196. afasafsafsfa.zOrder = 1;
  197. Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
  198. afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
  199. var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
  200. }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
  201. tween.clear();
  202. if (hide) {
  203. afasafsafsfa.destroy();
  204. }
  205. if (_completeHandle) {
  206. _completeHandle.run();
  207. }
  208. }));
  209. if (hide) {
  210. Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 10000);
  211. }
  212. return afasafsafsfa;
  213. }
  214. static tweenMove(transform, targPos, delay, ease, complete) {
  215. let curPos = transform.position.clone();
  216. return Laya.Tween.to(curPos, {
  217. x: targPos.x,
  218. y: targPos.y,
  219. z: targPos.z,
  220. update: new Laya.Handler(this, () => {
  221. transform.position = curPos.clone();
  222. })
  223. }, delay, ease, complete);
  224. }
  225. static tweenRotate(transform, targEuler, delay, ease, complete) {
  226. let curEuler = transform.rotationEuler.clone();
  227. return Laya.Tween.to(curEuler, {
  228. x: targEuler.x,
  229. y: targEuler.y,
  230. z: targEuler.z,
  231. update: new Laya.Handler(this, () => {
  232. transform.rotationEuler = curEuler.clone();
  233. })
  234. }, delay, ease, complete);
  235. }
  236. }
  237. var EventState;
  238. (function (EventState) {
  239. EventState[EventState["LoadComplete"] = 0] = "LoadComplete";
  240. EventState[EventState["SceneInit"] = 1] = "SceneInit";
  241. EventState[EventState["StageInit"] = 2] = "StageInit";
  242. EventState[EventState["ShowModel"] = 3] = "ShowModel";
  243. })(EventState || (EventState = {}));
  244. var StageState;
  245. (function (StageState) {
  246. StageState[StageState["Win"] = 0] = "Win";
  247. StageState[StageState["Lose"] = 1] = "Lose";
  248. StageState[StageState["Start"] = 2] = "Start";
  249. StageState[StageState["BackMain"] = 3] = "BackMain";
  250. StageState[StageState["StageCreateComPlete"] = 4] = "StageCreateComPlete";
  251. StageState[StageState["Over"] = 5] = "Over";
  252. StageState[StageState["Pause"] = 6] = "Pause";
  253. StageState[StageState["Resume"] = 7] = "Resume";
  254. StageState[StageState["RefreshPro"] = 8] = "RefreshPro";
  255. })(StageState || (StageState = {}));
  256. var RoleState;
  257. (function (RoleState) {
  258. RoleState[RoleState["Die"] = 0] = "Die";
  259. RoleState[RoleState["Sky"] = 1] = "Sky";
  260. RoleState[RoleState["OnLand"] = 2] = "OnLand";
  261. RoleState[RoleState["Land"] = 3] = "Land";
  262. RoleState[RoleState["Arriver"] = 4] = "Arriver";
  263. })(RoleState || (RoleState = {}));
  264. class DispatcherManager {
  265. static EventOn(_mode, caller, fun, args = []) {
  266. DispatcherManager.instance.on(EventState[_mode], caller, fun, args);
  267. }
  268. static EventOff(_mode, caller, fun, args = []) {
  269. DispatcherManager.instance.off(EventState[_mode], caller, fun);
  270. }
  271. static EventTrigger(_mode, args = []) {
  272. DispatcherManager.instance.event(EventState[_mode], args);
  273. }
  274. static StageOn(_mode, caller, fun, args = []) {
  275. DispatcherManager.instance.on(StageState[_mode], caller, fun, args);
  276. }
  277. static StageOff(_mode, caller, fun, args = []) {
  278. DispatcherManager.instance.off(StageState[_mode], caller, fun);
  279. }
  280. static StageTrigger(_mode, args = []) {
  281. DispatcherManager.instance.event(StageState[_mode], args);
  282. }
  283. }
  284. DispatcherManager.instance = new Laya.EventDispatcher();
  285. class Dictionary {
  286. constructor() {
  287. this._items = {};
  288. this.length = 0;
  289. }
  290. get container() {
  291. return this._items;
  292. }
  293. has(key) {
  294. return this._items.hasOwnProperty(key);
  295. }
  296. set(key, val) {
  297. if (!this.has(key)) {
  298. this.length++;
  299. }
  300. this._items[key] = val;
  301. }
  302. delete(key) {
  303. let val = null;
  304. if (this.has(key)) {
  305. val = this._items[key];
  306. delete this._items[key];
  307. this.length--;
  308. }
  309. return val;
  310. }
  311. get(key) {
  312. return this.has(key) ? this._items[key] : null;
  313. }
  314. values() {
  315. let values = [];
  316. for (let k in this._items) {
  317. if (this.has(k)) {
  318. values.push(this._items[k]);
  319. }
  320. }
  321. return values;
  322. }
  323. keys() {
  324. let keys = [];
  325. for (let k in this._items) {
  326. if (this.has(k)) {
  327. keys.push(k);
  328. }
  329. }
  330. return keys;
  331. }
  332. clear() {
  333. this._items = {};
  334. this.length = 0;
  335. }
  336. }
  337. class NodeUtil {
  338. static GetChild(node, cond) {
  339. let queue = [];
  340. for (let i = 0; i < node.numChildren; i++) {
  341. queue.push(node.getChildAt(i));
  342. }
  343. while (queue.length > 0) {
  344. let first = queue.shift();
  345. if (cond(first)) {
  346. return first;
  347. }
  348. else {
  349. for (let i = 0; i < first.numChildren; i++) {
  350. queue.push(first.getChildAt(i));
  351. }
  352. }
  353. }
  354. return null;
  355. }
  356. static GetChildByName(node, name) {
  357. return NodeUtil.GetChild(node, s => s.name == name);
  358. }
  359. static getChildren(node, cond) {
  360. let finded = [];
  361. let queue = [];
  362. for (let i = 0; i < node.numChildren; i++) {
  363. queue.push(node.getChildAt(i));
  364. }
  365. while (queue.length > 0) {
  366. let first = queue.shift();
  367. if (cond(first)) {
  368. finded.push(first);
  369. }
  370. for (let i = 0; i < first.numChildren; i++) {
  371. queue.push(first.getChildAt(i));
  372. }
  373. }
  374. return finded;
  375. }
  376. static SetColliderInactive(sp) {
  377. let colliders = NodeUtil.getChildren(sp, s => s.getComponent(Laya.PhysicsCollider));
  378. colliders.forEach(s => {
  379. let collider = s.getComponent(Laya.PhysicsCollider);
  380. if (collider) {
  381. collider.enabled = false;
  382. }
  383. }, this);
  384. }
  385. static SetColliderGroup(sp, _group) {
  386. let colliders = NodeUtil.getChildren(sp, s => s.getComponent(Laya.PhysicsCollider));
  387. colliders.forEach(s => {
  388. let collisionGroup = _group;
  389. let collider = s.getComponent(Laya.PhysicsCollider);
  390. collider.collisionGroup = collisionGroup;
  391. }, this);
  392. }
  393. }
  394. NodeUtil.All = Laya.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER;
  395. NodeUtil.Body = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER1;
  396. NodeUtil.Head = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER2;
  397. NodeUtil.Citizen = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER3;
  398. class Transform3DHelper {
  399. static getForward(transform) {
  400. let forward = new Laya.Vector3();
  401. transform.getForward(forward);
  402. Laya.Vector3.scale(forward, -1, forward);
  403. Laya.Vector3.normalize(forward, forward);
  404. return forward;
  405. }
  406. }
  407. class ResourcesPath {
  408. }
  409. ResourcesPath.Yan = "yan";
  410. ResourcesPath.YanHua = "yanhua";
  411. ResourcesPath.Nail1 = "Nail1";
  412. ResourcesPath.Nail2 = "Nail2";
  413. ResourcesPath.Nail3 = "Nail3";
  414. ResourcesPath.Nail4 = "Nail4";
  415. ResourcesPath.Nail5 = "Nail5";
  416. ResourcesPath.Nail6 = "Nail6";
  417. ResourcesPath.Nail7 = "Nail7";
  418. ResourcesPath.Coin = "Coin";
  419. ResourcesPath.FinishCircle = "FinishCircle";
  420. ResourcesPath.Speed = "speed";
  421. ResourcesPath.Ramp = "Ramp";
  422. ResourcesPath.mainscene = "subpackage/res/mainscene/LayaScene_mainscene/Conventional/mainscene.ls";
  423. ResourcesPath.Character = [
  424. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Character1.lh",
  425. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Character2.lh",
  426. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Character3.lh",
  427. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Character4.lh"
  428. ];
  429. ResourcesPath.Prop = [
  430. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/FinishCircle.lh",
  431. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/FinishCircle2.lh",
  432. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail1.lh",
  433. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail2.lh",
  434. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail3.lh",
  435. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail4.lh",
  436. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail5.lh",
  437. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail6.lh",
  438. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail7.lh",
  439. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/yan.lh",
  440. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/yanhua.lh",
  441. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/flag.lh",
  442. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Coin.lh",
  443. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Ramp.lh",
  444. "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/speed.lh",
  445. ];
  446. ResourcesPath.fogcolor = [
  447. new Laya.Vector3(0.5803922, 0.8431373, 1),
  448. new Laya.Vector3(216 / 255, 142 / 255, 247 / 255),
  449. new Laya.Vector3(180 / 255, 1, 217 / 255)
  450. ];
  451. var Vector3$1 = Laya.Vector3;
  452. class WallBehav extends Laya.Script3D {
  453. constructor() {
  454. super();
  455. this._hitres = new Laya.HitResult();
  456. this.crash = false;
  457. this._hitres2 = new Laya.HitResult();
  458. }
  459. onAwake() {
  460. this._gameobject = this.owner;
  461. }
  462. onStart() {
  463. var startPos = new Vector3$1(this._gameobject.transform.position.x, this._gameobject.transform.position.y, this._gameobject.transform.position.z);
  464. let _up = new Laya.Vector3(0, 1, 0);
  465. var FowardRay = new Laya.Ray(startPos, _up);
  466. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this._hitres, 1)) {
  467. if (this._hitres.collider.collisionGroup == 2) {
  468. let _wall = this._hitres.collider.owner.parent;
  469. if (this.crash) {
  470. NodeUtil.SetColliderInactive(this._gameobject);
  471. let _pre = AssetManager.Instance.getPref(ResourcesPath.Yan);
  472. let yan = Laya.Sprite3D.instantiate(_pre);
  473. LevelManager.Instance.spritepool.addChild(yan);
  474. yan.transform.position = this._gameobject.transform.position.clone();
  475. yan.transform.scale = new Laya.Vector3(0.5, 0.5, 0.5);
  476. this.destroy();
  477. this._gameobject.destroy();
  478. }
  479. else {
  480. this.FallDown();
  481. }
  482. let _behav = _wall.addComponent(WallBehav);
  483. }
  484. }
  485. else {
  486. if (this.crash) {
  487. NodeUtil.SetColliderInactive(this._gameobject);
  488. let _pre = AssetManager.Instance.getPref(ResourcesPath.Yan);
  489. let yan = Laya.Sprite3D.instantiate(_pre);
  490. LevelManager.Instance.spritepool.addChild(yan);
  491. yan.transform.position = this._gameobject.transform.position.clone();
  492. yan.transform.scale = new Laya.Vector3(0.5, 0.5, 0.5);
  493. this.destroy();
  494. this._gameobject.destroy();
  495. }
  496. }
  497. }
  498. onUpdate() {
  499. if (this.crash) {
  500. NodeUtil.SetColliderInactive(this._gameobject);
  501. let _pre = AssetManager.Instance.getPref(ResourcesPath.Yan);
  502. let yan = Laya.Sprite3D.instantiate(_pre);
  503. LevelManager.Instance.spritepool.addChild(yan);
  504. yan.transform.position = this._gameobject.transform.position.clone();
  505. yan.transform.scale = new Laya.Vector3(0.5, 0.5, 0.5);
  506. this.destroy();
  507. this._gameobject.destroy();
  508. return;
  509. }
  510. this.Down();
  511. }
  512. Crash() {
  513. NodeUtil.SetColliderInactive(this._gameobject);
  514. let _pre = AssetManager.Instance.getPref(ResourcesPath.Yan);
  515. let yan = Laya.Sprite3D.instantiate(_pre);
  516. LevelManager.Instance.spritepool.addChild(yan);
  517. yan.transform.position = this._gameobject.transform.position.clone();
  518. yan.transform.scale = new Laya.Vector3(0.5, 0.5, 0.5);
  519. this.destroy();
  520. this._gameobject.destroy();
  521. }
  522. FallDown() {
  523. Laya.timer.loop(1, this, this.Down);
  524. }
  525. Down() {
  526. var startPos = new Vector3$1(this._gameobject.transform.position.x, this._gameobject.transform.position.y + 0.1, this._gameobject.transform.position.z);
  527. let _down = new Laya.Vector3(0, -0.1, 0);
  528. var FowardRay = new Laya.Ray(startPos, _down);
  529. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this._hitres2, 0.2)) {
  530. if (this._hitres2 != null && (this._hitres2.collider.collisionGroup == 1 || this._hitres2.collider.collisionGroup == 2)) {
  531. Laya.timer.clear(this, this.Down);
  532. }
  533. else {
  534. let _posy = this._gameobject.transform.position.y -= 0.03;
  535. this._gameobject.transform.position = new Laya.Vector3(this._gameobject.transform.position.x, _posy, this._gameobject.transform.position.z);
  536. }
  537. }
  538. else {
  539. let _posy = this._gameobject.transform.position.y -= 0.03;
  540. this._gameobject.transform.position = new Laya.Vector3(this._gameobject.transform.position.x, _posy, this._gameobject.transform.position.z);
  541. }
  542. }
  543. }
  544. var VoiceType;
  545. (function (VoiceType) {
  546. VoiceType[VoiceType["crashrole"] = 0] = "crashrole";
  547. VoiceType[VoiceType["crashwall"] = 1] = "crashwall";
  548. VoiceType[VoiceType["win"] = 2] = "win";
  549. VoiceType[VoiceType["lose"] = 3] = "lose";
  550. VoiceType[VoiceType["fly"] = 4] = "fly";
  551. VoiceType[VoiceType["speedup"] = 5] = "speedup";
  552. VoiceType[VoiceType["coin"] = 6] = "coin";
  553. })(VoiceType || (VoiceType = {}));
  554. var BGMType;
  555. (function (BGMType) {
  556. BGMType[BGMType["bgm"] = 0] = "bgm";
  557. })(BGMType || (BGMType = {}));
  558. class AudioManager {
  559. static voiceres(_type) {
  560. return "subpackage2/res/music/" + VoiceType[_type] + ".mp3";
  561. }
  562. static bgmres(_type) {
  563. return "subpackage2/res/music/" + BGMType[_type] + ".mp3";
  564. }
  565. static ClearAudio() {
  566. Laya.SoundManager.stopAllSound();
  567. }
  568. static StopMusic() {
  569. Laya.SoundManager.stopMusic();
  570. }
  571. static PlayBGM(_type) {
  572. if (!this.play)
  573. return;
  574. Laya.SoundManager.playMusic(this.bgmres(_type), 0);
  575. Laya.SoundManager.musicVolume = 0.5;
  576. }
  577. static PlayVoice(_type, _loop = false) {
  578. if (!this.play)
  579. return;
  580. var loop = _loop ? 0 : 1;
  581. Laya.SoundManager.playSound(this.voiceres(_type), loop);
  582. }
  583. }
  584. AudioManager.play = true;
  585. class CoinBehav extends Laya.Script3D {
  586. constructor() {
  587. super();
  588. }
  589. onAwake() {
  590. this._gameobject = this.owner;
  591. Laya.timer.loop(1, this, this.Rotate);
  592. }
  593. OnTouch() {
  594. AudioManager.PlayVoice(VoiceType.coin);
  595. Laya.timer.clear(this, this.Rotate);
  596. this.destroy();
  597. }
  598. Rotate() {
  599. this._gameobject.transform.rotate(new Laya.Vector3(0, 0.05, 0));
  600. }
  601. }
  602. var Vector3$2 = Laya.Vector3;
  603. var Quaternion = Laya.Quaternion;
  604. class MateMove extends Laya.Script3D {
  605. constructor() {
  606. super();
  607. this._speed = 0.2;
  608. this.testspeed = 0.3;
  609. this.Tag_Head = false;
  610. this.start = false;
  611. this.isdead = false;
  612. this.geted = false;
  613. this._arriver = false;
  614. this._destination = false;
  615. this.GravityTime = 0;
  616. this.ChargeSpeed = 0;
  617. this.ChargeTime = 0;
  618. this.Downhit = new Laya.HitResult();
  619. this.FowardHit = new Laya.HitResult();
  620. this._forward = new Vector3$2(0, 0, 0);
  621. this._up = new Vector3$2(0, 1, 0);
  622. this.CanJump = false;
  623. this.JumpTime = 0;
  624. this.JumpSpeed = 0.3;
  625. this.JumpSpeedUp = 1;
  626. this.targetPos = new Vector3$2(0, 0, 0);
  627. this.forW = new Vector3$2(0, 0, 0);
  628. this.RoleList = [];
  629. this.MovePointList = [];
  630. this.MoveRotateList = [];
  631. this._foward = new Laya.Vector3(0, 0, 0);
  632. this._MovetarPos = new Laya.Vector3(0, 0, 0);
  633. this.curpos2 = new Vector3$2();
  634. this.offest2 = new Vector3$2();
  635. this.curspeed2 = 0;
  636. this.curpos = new Vector3$2();
  637. this.offest = new Vector3$2();
  638. this.curspeed = 0;
  639. DispatcherManager.StageOn(StageState.Start, this, this.GameStart);
  640. }
  641. onAwake() {
  642. this._gameobject = this.owner;
  643. this._transform = this._gameobject.transform;
  644. this._quaternion = new Quaternion();
  645. this._animator = this._gameobject.getComponent(Laya.Animator);
  646. }
  647. onUpdate() {
  648. if (!this.start)
  649. return;
  650. if (this.isdead) {
  651. this.RoleDie();
  652. this.ChangeState(RoleState.Die);
  653. return;
  654. }
  655. if (this._destination)
  656. return;
  657. if (this.Tag_Head) {
  658. this.RefreshUI();
  659. if (this.DownRayCheck) {
  660. if (this.curstate == RoleState.OnLand) {
  661. this._gameobject.transform.position = new Vector3$2(this._gameobject.transform.position.x, this.Downhit.point.y, this._gameobject.transform.position.z);
  662. if (this.Downhit.collider.owner.parent.name == "speed") {
  663. AudioManager.PlayVoice(VoiceType.speedup);
  664. this.SpeedUp(0.6, 0.1);
  665. }
  666. else if (this.Downhit.collider.owner.parent.name == "Ramp") {
  667. AudioManager.PlayVoice(VoiceType.fly);
  668. this.SpeedUp(0.3, 0.2);
  669. this.Jump();
  670. }
  671. }
  672. else if (this.curstate == RoleState.Sky) {
  673. var distance = this._gameobject.transform.position.y - this.Downhit.point.y;
  674. if (distance < 0.5) {
  675. var leropos = new Vector3$2(this._gameobject.transform.position.x, this.Downhit.point.y, this._gameobject.transform.position.z);
  676. Vector3$2.lerp(this._gameobject.transform.position, leropos, 0.3, leropos);
  677. this._gameobject.transform.position = leropos;
  678. this.ChangeState(RoleState.OnLand);
  679. }
  680. }
  681. }
  682. else {
  683. this.ChangeState(RoleState.Sky);
  684. }
  685. if (this.FowardRayCheck) ;
  686. let foward = Transform3DHelper.getForward(this._gameobject.transform);
  687. this.Move(foward);
  688. this.Gravity();
  689. }
  690. else {
  691. if (!this.geted)
  692. return;
  693. if (this._arriver) {
  694. if (this.DownRayCheck) {
  695. if (this.curstate == RoleState.OnLand) {
  696. this._gameobject.transform.position = new Vector3$2(this._gameobject.transform.position.x, this.Downhit.point.y, this._gameobject.transform.position.z);
  697. }
  698. else if (this.curstate == RoleState.Sky) {
  699. var distance = this._gameobject.transform.position.y - this.Downhit.point.y;
  700. if (distance < 0.5) {
  701. var leropos = new Vector3$2(this._gameobject.transform.position.x, this.Downhit.point.y, this._gameobject.transform.position.z);
  702. Vector3$2.lerp(this._gameobject.transform.position, leropos, 0.3, leropos);
  703. this._gameobject.transform.position = leropos;
  704. this.ChangeState(RoleState.OnLand);
  705. }
  706. }
  707. }
  708. else {
  709. this.ChangeState(RoleState.Sky);
  710. }
  711. this.RoleMoveFun();
  712. this.Gravity();
  713. }
  714. else {
  715. this.MoveToGroup();
  716. }
  717. }
  718. if (this._gameobject.transform.position.y < -15) {
  719. this.FallDown();
  720. }
  721. }
  722. RefreshUI() {
  723. let pre = PlayerManager.Instance.RefreshPro();
  724. let count = this.RoleList.length;
  725. let data = {};
  726. data["pre"] = pre;
  727. data["count"] = count;
  728. DispatcherManager.StageTrigger(StageState.RefreshPro, [data]);
  729. }
  730. GameStart() {
  731. this.start = true;
  732. if (this.Tag_Head)
  733. this.ChangeState(RoleState.OnLand);
  734. Laya.timer.loop(2, this, this.SetNewMovePoint, [this._transform]);
  735. }
  736. Start(model) {
  737. if (this.geted)
  738. return;
  739. this.targetmodel = model.getChildByName("followpos");
  740. this.geted = true;
  741. this.ChangeState(RoleState.OnLand);
  742. }
  743. ChangeState(state) {
  744. if (this.curstate == state)
  745. return;
  746. this.curstate = state;
  747. switch (this.curstate) {
  748. case RoleState.Die:
  749. this.DIE();
  750. break;
  751. case RoleState.Sky:
  752. this.SKY();
  753. break;
  754. case RoleState.OnLand:
  755. this.ONLAND();
  756. break;
  757. case RoleState.Arriver:
  758. this.ARRIVER();
  759. break;
  760. }
  761. }
  762. ONLAND() {
  763. if (this.Tag_Head) {
  764. this._animator.play("run");
  765. this._animator.speed = 2;
  766. }
  767. else {
  768. if (this.geted) {
  769. this._animator.play("run");
  770. this._animator.speed = 2;
  771. }
  772. else {
  773. this._animator.play("idle");
  774. }
  775. }
  776. }
  777. SKY() {
  778. this._animator.play("sky");
  779. }
  780. ARRIVER() {
  781. this._destination = true;
  782. Laya.timer.clear(this, this.SetNewMovePoint);
  783. this._animator.play("win");
  784. if (this.Tag_Head) {
  785. GameManager.Instance.GameWin();
  786. for (let i = 0; i < this.RoleList.length; i++) {
  787. let item = this.RoleList[i].getComponent(MateMove);
  788. if (item) {
  789. item.ARRIVER();
  790. }
  791. }
  792. }
  793. }
  794. DIE() {
  795. Laya.timer.clear(this, this.SetNewMovePoint);
  796. this._gameobject.active = false;
  797. if (this.Tag_Head && this.RoleList.length == 0) {
  798. GameManager.Instance.GameLose();
  799. }
  800. this.destroy();
  801. }
  802. FallDown() {
  803. Laya.timer.clear(this, this.SetNewMovePoint);
  804. GameManager.Instance.GameLose();
  805. AudioManager.PlayVoice(VoiceType.lose);
  806. WXSDK.Shake(true);
  807. this.destroy();
  808. }
  809. SetMoveTarger(_point, _rotate) {
  810. if (_point) {
  811. this._MovetarPos = _point;
  812. this._gameobject.transform.position = this._MovetarPos.clone();
  813. this._gameobject.transform.rotationEuler = _rotate.clone();
  814. this.MovePointList.push(_point);
  815. if (this.MovePointList.length > 100) {
  816. this.MovePointList.shift();
  817. }
  818. this.MoveRotateList.push(_rotate);
  819. if (this.MoveRotateList.length > 100) {
  820. this.MoveRotateList.shift();
  821. }
  822. }
  823. }
  824. RoleMoveFun() {
  825. Quaternion.lookAt(this._MovetarPos, this._transform.position, this._up, this._quaternion);
  826. this._quaternion.invert(this._quaternion);
  827. Quaternion.slerp(this._transform.rotation, this._quaternion, 0.1, this._quaternion);
  828. this._transform.rotation = this._quaternion.clone();
  829. let _rotationEuler = this._transform.rotationEuler.clone();
  830. _rotationEuler.x = 0;
  831. _rotationEuler.z = 0;
  832. this._transform.rotationEuler = _rotationEuler;
  833. }
  834. SetNewMovePoint(_transform) {
  835. if (this.Tag_Head) {
  836. var _movePos = _transform.position.clone();
  837. var _point = new Laya.Vector3(_movePos.x, _movePos.y, _movePos.z);
  838. var _rotate = _transform.rotationEuler.clone();
  839. this.MovePointList.push(_point);
  840. if (this.MovePointList.length > 200) {
  841. this.MovePointList.shift();
  842. }
  843. this.MoveRotateList.push(_rotate);
  844. if (this.MoveRotateList.length > 200) {
  845. this.MoveRotateList.shift();
  846. }
  847. for (let i = 0; i < this.RoleList.length; i++) {
  848. var _script = this.RoleList[i].getComponent(MateMove);
  849. if (_script) {
  850. var _id = this.MovePointList.length - 1 - (i + 1) * 10;
  851. _script.SetMoveTarger(this.MovePointList[_id], this.MoveRotateList[_id]);
  852. }
  853. }
  854. }
  855. }
  856. RoleDie() {
  857. if (this.RoleList.length == 0) {
  858. return;
  859. }
  860. var _newHand = this.RoleList[0];
  861. var _script = _newHand.getComponent(MateMove);
  862. if (_script) {
  863. _script._gameobject.transform.rotationEuler = this._gameobject.transform.rotationEuler.clone();
  864. _script.Tag_Head = true;
  865. PlayerManager.Instance.player = _script._gameobject;
  866. _script.RoleList = [];
  867. for (let i = 1; i < this.RoleList.length; i++) {
  868. _script.RoleList.push(this.RoleList[i]);
  869. }
  870. }
  871. }
  872. MoveToGroup() {
  873. this.targetPos = this.targetmodel.transform.position;
  874. let tarPos = this.targetPos;
  875. let speed = 0.05;
  876. Vector3$2.subtract(tarPos, this._transform.position, this._forward);
  877. Vector3$2.normalize(this._forward, this._forward);
  878. this._forward = new Vector3$2(this._forward.x * speed, this._forward.y * speed, this._forward.z * speed);
  879. this._transform.translate(this._forward, false);
  880. if (Vector3$2.distance(this._transform.position, tarPos) < 0.1) {
  881. this.ArriverTargetPos();
  882. return;
  883. }
  884. Quaternion.lookAt(tarPos, this._transform.position, this._up, this._quaternion);
  885. this._quaternion.invert(this._quaternion);
  886. Quaternion.slerp(this._transform.rotation, this._quaternion, 0.1, this._quaternion);
  887. this._transform.rotation = this._quaternion.clone();
  888. }
  889. Move(_dir) {
  890. let speed = this.testspeed;
  891. if (this.ChargeTime > 0) {
  892. this.ChargeTime -= 0.01;
  893. speed = speed + this.ChargeSpeed;
  894. }
  895. else {
  896. this.ChargeSpeed = GameTools.Instance.lerp(this.ChargeSpeed, 0, 0.1);
  897. speed = speed + this.ChargeSpeed;
  898. this.ChargeTime = 0;
  899. }
  900. this.curspeed = GameTools.Instance.lerp(this.curspeed, speed, 0.1);
  901. Vector3$2.scale(_dir, this.curspeed, this.offest);
  902. Vector3$2.add(this._gameobject.transform.position, this.offest, this.curpos);
  903. Vector3$2.lerp(this._gameobject.transform.position, this.curpos, 0.15, this.curpos);
  904. if (this.CanJump) {
  905. this.JumpTime += 0.8;
  906. var Height = this.JumpSpeed * this.JumpTime * 1.9 - (this.JumpTime * this.JumpTime * this.JumpSpeedUp);
  907. if (Height > 0) {
  908. this.curpos = new Vector3$2(this.curpos.x, this.curpos.y + Height, this.curpos.z);
  909. }
  910. else {
  911. this.CanJump = false;
  912. }
  913. this.curpos = new Vector3$2(this.curpos.x, this.curpos.y + 0.8, this.curpos.z);
  914. this._gameobject.transform.position = this.curpos;
  915. }
  916. else {
  917. this.curpos = new Vector3$2(this.curpos.x, this.curpos.y, this.curpos.z);
  918. this._gameobject.transform.position = this.curpos;
  919. }
  920. }
  921. ArriverTargetPos() {
  922. this._gameobject.transform.position = this.targetmodel.transform.position.clone();
  923. this._gameobject.transform.rotationEuler = this.targetmodel.transform.rotationEuler.clone();
  924. this._arriver = true;
  925. }
  926. get DownRayCheck() {
  927. var startPos = new Vector3$2(this._gameobject.transform.position.x, this._gameobject.transform.position.y + 0.1, this._gameobject.transform.position.z);
  928. let foward = new Laya.Vector3(0, -1, 0);
  929. var FowardRay = new Laya.Ray(startPos, foward);
  930. var isDownHit = false;
  931. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this.Downhit, 1)) {
  932. if (this.Downhit != null) {
  933. if (this.Downhit.collider.collisionGroup == 1) {
  934. isDownHit = true;
  935. }
  936. }
  937. }
  938. return isDownHit;
  939. }
  940. get FowardRayCheck() {
  941. var isFowardHit = false;
  942. var startPos = new Vector3$2(this._gameobject.transform.position.x, this._gameobject.transform.position.y + 0.1, this._gameobject.transform.position.z);
  943. let foward = Transform3DHelper.getForward(this._gameobject.transform);
  944. var FowardRay = new Laya.Ray(startPos, foward);
  945. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this.FowardHit, 0.1)) {
  946. if (this.FowardHit) {
  947. console.log(this.FowardHit.collider.owner.parent.name);
  948. console.log("前方有物体");
  949. }
  950. if (this.FowardHit.collider.collisionGroup == 100) {
  951. console.log("射线打到npc了");
  952. this.ForwardTarget = this.FowardHit.collider;
  953. isFowardHit = true;
  954. let _mate = this.FowardHit.collider.owner.parent.getComponent(MateMove);
  955. if (_mate) {
  956. let _model;
  957. if (this.RoleList.length > 0) {
  958. _model = this.RoleList[this.RoleList.length - 1];
  959. }
  960. else {
  961. _model = this._gameobject;
  962. }
  963. _mate.Start(_model);
  964. let target = this.FowardHit.collider.owner.parent;
  965. if (!this.JudgeEqual(target)) {
  966. this.RoleList.push(target);
  967. }
  968. }
  969. AudioManager.PlayVoice(VoiceType.crashrole);
  970. WXSDK.Shake();
  971. }
  972. else if (this.FowardHit.collider.collisionGroup == 2) {
  973. this.isdead = true;
  974. let _wall = this.FowardHit.collider.owner.parent;
  975. let _behav = _wall.getComponent(WallBehav);
  976. if (_behav) {
  977. _behav.Crash();
  978. }
  979. else {
  980. _behav = _wall.addComponent(WallBehav);
  981. _behav.crash = true;
  982. }
  983. AudioManager.PlayVoice(VoiceType.crashwall);
  984. WXSDK.Shake();
  985. }
  986. else if (this.FowardHit.collider.collisionGroup == 3) {
  987. this.Crash();
  988. }
  989. else if (this.FowardHit.collider.collisionGroup == 200) {
  990. this.ChangeState(RoleState.Arriver);
  991. AudioManager.PlayVoice(VoiceType.win);
  992. WXSDK.Shake(true);
  993. }
  994. }
  995. return isFowardHit;
  996. }
  997. Crash() {
  998. let target = this.FowardHit.collider.owner.parent;
  999. switch (target.name) {
  1000. case "Ramp":
  1001. AudioManager.PlayVoice(VoiceType.fly);
  1002. this.SpeedUp(0.8, 0.3);
  1003. this.Jump();
  1004. break;
  1005. case "Coin":
  1006. let _behav = target.getComponent(CoinBehav);
  1007. if (_behav) {
  1008. _behav.OnTouch();
  1009. }
  1010. target.destroy();
  1011. break;
  1012. }
  1013. }
  1014. Gravity() {
  1015. if (this.curstate == RoleState.Sky) {
  1016. if (this.ChargeSpeed > 0.001) {
  1017. this.GravityTime += 0.008;
  1018. }
  1019. else {
  1020. this.GravityTime += 0.010;
  1021. }
  1022. var hight = this.GravityTime * this.GravityTime;
  1023. this._gameobject.transform.position = new Vector3$2(this._gameobject.transform.position.x, this._gameobject.transform.position.y - hight, this._gameobject.transform.position.z + hight / 2);
  1024. }
  1025. }
  1026. Jump() {
  1027. this.CanJump = true;
  1028. this.JumpTime = 0;
  1029. }
  1030. SpeedUp(_speed, _time) {
  1031. if (this.ChargeTime < _time) {
  1032. this.ChargeTime += 0.1;
  1033. }
  1034. if (this.ChargeSpeed < _speed) {
  1035. this.ChargeSpeed += 0.2;
  1036. }
  1037. }
  1038. JudgeEqual(_model) {
  1039. for (let i = 0; i < this.RoleList.length; i++) {
  1040. let item = this.RoleList[i];
  1041. if (item == _model) {
  1042. return true;
  1043. }
  1044. }
  1045. return false;
  1046. }
  1047. }
  1048. class PlayerManager {
  1049. constructor() {
  1050. this.canmove = false;
  1051. this.trun = true;
  1052. PlayerManager.ins = this;
  1053. }
  1054. static get Instance() {
  1055. if (PlayerManager.ins == null) {
  1056. return new PlayerManager();
  1057. }
  1058. return PlayerManager.ins;
  1059. }
  1060. Init() {
  1061. this.Direction = AccountManager.Instance.curplayerData.LevelDirection;
  1062. let playerpref = AssetManager.Instance.Character.get(1);
  1063. this.player = Laya.Sprite3D.instantiate(playerpref);
  1064. LevelManager.Instance.spritepool.addChild(this.player);
  1065. this.player.transform.position = AssetManager.Instance.playerpos.transform.position.clone();
  1066. this.player.transform.rotation = AssetManager.Instance.playerpos.transform.rotation.clone();
  1067. this.trun = true;
  1068. }
  1069. RefreshPro() {
  1070. let startpoint = AssetManager.Instance.playerpos.transform.position.clone();
  1071. let Z = startpoint.z;
  1072. let finishpoint = AssetManager.Instance.finishpoint.z;
  1073. let distance = finishpoint - Z;
  1074. let pro = this.player.transform.position.z / distance;
  1075. return pro;
  1076. }
  1077. EnablePlayer() {
  1078. let _move = this.player.addComponent(MateMove);
  1079. _move.Tag_Head = true;
  1080. this.ListenOn();
  1081. }
  1082. ListenOn() {
  1083. Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.OnMouseDown);
  1084. }
  1085. ListenOff() {
  1086. Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.OnMouseDown);
  1087. }
  1088. DisablePlayer() {
  1089. let _move = this.player.getComponent(MateMove);
  1090. if (_move) {
  1091. _move.destroy();
  1092. }
  1093. }
  1094. OnMouseDown() {
  1095. if (this.Direction == 1) {
  1096. if (this.trun) {
  1097. this.player.transform.rotationEuler = new Laya.Vector3(0, -90, 0);
  1098. this.trun = !this.trun;
  1099. }
  1100. else {
  1101. this.player.transform.rotationEuler = new Laya.Vector3(0, 0, 0);
  1102. this.trun = !this.trun;
  1103. }
  1104. }
  1105. else if (this.Direction == 2) {
  1106. if (this.trun) {
  1107. this.player.transform.rotationEuler = new Laya.Vector3(0, 90, 0);
  1108. this.trun = !this.trun;
  1109. }
  1110. else {
  1111. this.player.transform.rotationEuler = new Laya.Vector3(0, 0, 0);
  1112. this.trun = !this.trun;
  1113. }
  1114. }
  1115. }
  1116. }
  1117. var REG = Laya.ClassUtils.regClass;
  1118. var ui;
  1119. (function (ui) {
  1120. class GameResultViewUI extends Laya.Scene {
  1121. constructor() { super(); }
  1122. createChildren() {
  1123. super.createChildren();
  1124. this.createView(GameResultViewUI.uiView);
  1125. }
  1126. }
  1127. GameResultViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,13,14,10", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 29 }, { "type": "Image", "props": { "y": 210, "x": 90.5, "var": "WinBox", "skin": "Main/lanshandi.png", "alpha": 1 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": -140, "x": 24, "skin": "Main/shenglilo.png" }, "compId": 5 }, { "type": "Image", "props": { "y": 151, "x": 52.5, "skin": "Main/shangkuan.png" }, "compId": 6, "child": [{ "type": "Image", "props": { "y": 150, "x": 90.5, "skin": "Main/jinbidi.png" }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 27, "x": 86, "skin": "Main/jinbihud.png" }, "compId": 8 }, { "type": "Image", "props": { "y": 20, "x": 30, "skin": "Main/jinbi.png" }, "compId": 9 }, { "type": "Text", "props": { "y": -101, "x": 6, "width": 241, "var": "Win_GoldNum", "valign": "middle", "text": "888", "height": 69, "fontSize": 92, "font": "Microsoft YaHei", "color": "#92501d", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 10 }] }] }, { "type": "Button", "props": { "y": 470, "x": 82, "var": "Win_VideoBtn", "stateNum": 1, "skin": "Main/dihong.png" }, "compId": 12, "child": [{ "type": "Image", "props": { "y": 39, "x": 45, "skin": "Main/shipin.png" }, "compId": 13 }, { "type": "Image", "props": { "y": 40.5, "x": 158, "skin": "Main/sanbeilingqu.png" }, "compId": 14 }] }, { "type": "Button", "props": { "y": 631, "x": 185, "var": "Win_BackBtn", "stateNum": 1, "skin": "Main/buyongxieix.png" }, "compId": 15 }] }, { "type": "Image", "props": { "y": 210, "x": 90.5, "var": "FailBox", "skin": "Main/beijing.png", "alpha": 1 }, "compId": 17, "child": [{ "type": "Image", "props": { "y": -140, "x": 24, "skin": "Main/tongguanshi-lo.png" }, "compId": 18 }, { "type": "Image", "props": { "y": 151, "x": 52.5, "skin": "Main/shangshudi.png" }, "compId": 19, "child": [{ "type": "Image", "props": { "y": 150, "x": 90.5, "skin": "Main/qinandi.png" }, "compId": 20, "child": [{ "type": "Image", "props": { "y": 27, "x": 86, "skin": "Main/jinbihud.png" }, "compId": 21 }, { "type": "Image", "props": { "y": 20, "x": 30, "skin": "Main/jinbi.png" }, "compId": 22 }, { "type": "Text", "props": { "y": -101, "x": 6, "width": 241, "var": "Fail_GoldNum", "valign": "middle", "text": "888", "height": 69, "fontSize": 92, "font": "Microsoft YaHei", "color": "#3660ab", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 23 }] }] }, { "type": "Button", "props": { "y": 470, "x": 82, "var": "Fail_VideoBtn", "stateNum": 1, "skin": "Main/ludi.png" }, "compId": 24, "child": [{ "type": "Image", "props": { "y": 39, "x": 45, "skin": "Main/shipin.png" }, "compId": 25 }, { "type": "Image", "props": { "y": 39, "x": 157, "skin": "Main/sanbeilingqu.png" }, "compId": 26 }] }, { "type": "Button", "props": { "y": 631, "x": 185, "var": "Fail_BackBtn", "stateNum": 1, "skin": "Main/buyongxeixie.png" }, "compId": 27 }] }], "loadList": ["Main/chunhei.png", "Main/lanshandi.png", "Main/shenglilo.png", "Main/shangkuan.png", "Main/jinbidi.png", "Main/jinbihud.png", "Main/jinbi.png", "Main/dihong.png", "Main/shipin.png", "Main/sanbeilingqu.png", "Main/buyongxieix.png", "Main/beijing.png", "Main/tongguanshi-lo.png", "Main/shangshudi.png", "Main/qinandi.png", "Main/ludi.png", "Main/buyongxeixie.png"], "loadList3D": [] };
  1128. ui.GameResultViewUI = GameResultViewUI;
  1129. REG("ui.GameResultViewUI", GameResultViewUI);
  1130. class HomeViewUI extends Laya.Scene {
  1131. constructor() { super(); }
  1132. createChildren() {
  1133. super.createChildren();
  1134. this.createView(HomeViewUI.uiView);
  1135. }
  1136. }
  1137. HomeViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Button", "props": { "y": 963, "x": 204, "var": "StartBtn", "stateNum": 1, "skin": "Main/dianjikaishi.png" }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 72, "x": 209, "width": 86, "var": "shou", "skin": "Main/shou.png", "scaleY": 1, "scaleX": 1, "pivotY": 46, "pivotX": 43, "height": 92 }, "compId": 19 }] }, { "type": "Button", "props": { "y": 754, "x": 0, "stateNum": 1, "skin": "Main/gengduo.png", "name": "MoreFunBtn" }, "compId": 9 }, { "type": "Button", "props": { "y": 754, "x": 605, "var": "SkinBtn", "stateNum": 1, "skin": "Main/shangdain.png" }, "compId": 10 }, { "type": "Button", "props": { "y": 630, "x": 605, "var": "SignBtn", "stateNum": 1, "skin": "Main/qiandao.png" }, "compId": 11 }, { "type": "Image", "props": { "y": 95, "x": 557, "width": 164, "skin": "Main/qiandi.png", "height": 55 }, "compId": 13, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "skin": "Main/qian.png" }, "compId": 15 }, { "type": "Text", "props": { "y": 0, "x": 54, "width": 110, "var": "GoldNum", "valign": "middle", "text": "99999", "height": 55, "fontSize": 40, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 18 }] }, { "type": "Box", "props": { "y": 160.5, "x": 127.5, "width": 487, "var": "ProBox", "height": 81 }, "compId": 21, "child": [{ "type": "ProgressBar", "props": { "y": 30, "x": 68, "width": 352, "value": 0, "skin": "Main/guandi-3.png", "height": 22 }, "compId": 20 }, { "type": "Image", "props": { "y": 11.5, "x": 20, "skin": "Main/guandi.png" }, "compId": 22, "child": [{ "type": "Text", "props": { "y": 9, "x": 1, "width": 56, "var": "NowLevelNum", "valign": "middle", "text": "10", "height": 40, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 23 }] }, { "type": "Image", "props": { "y": 12, "x": 414, "skin": "Main/zhongdian.png" }, "compId": 24 }] }, { "type": "Button", "props": { "y": 36, "x": 32, "var": "SetBtn", "stateNum": 1, "skin": "Main/shezhi.png" }, "compId": 26 }, { "type": "Image", "props": { "visible": false, "var": "SetPanel", "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "13,15,15,15", "right": 0, "left": 0, "bottom": 0 }, "compId": 48, "child": [{ "type": "Image", "props": { "y": 466, "x": 118.5, "skin": "Main/Background Pop up ads.png" }, "compId": 29, "child": [{ "type": "Image", "props": { "y": 40, "x": 73, "skin": "Main/Bouton policy privacy.png", "name": "shake" }, "compId": 30, "child": [{ "type": "Image", "props": { "y": 15, "x": 43, "skin": "Main/zhenfu.png" }, "compId": 33 }, { "type": "Image", "props": { "y": 25, "x": 121, "skin": "Main/kaigdi.png" }, "compId": 35, "child": [{ "type": "Image", "props": { "y": 9, "x": 94, "skin": "Main/OFF.png" }, "compId": 38 }, { "type": "Image", "props": { "y": 9, "x": 23, "skin": "Main/ON.png" }, "compId": 39 }] }, { "type": "Image", "props": { "y": 25, "x": 206, "skin": "Main/bodong.png", "name": "on" }, "compId": 41 }, { "type": "Image", "props": { "y": 25, "x": 121, "skin": "Main/boodong-2.png", "name": "off" }, "compId": 40 }, { "type": "Button", "props": { "y": 26, "x": 121, "width": 171, "var": "shakebtn", "height": 41 }, "compId": 49 }] }, { "type": "Image", "props": { "y": 151.5, "x": 73, "skin": "Main/Bouton policy privacy.png", "name": "sound" }, "compId": 31, "child": [{ "type": "Image", "props": { "y": 20, "x": 47, "skin": "Main/yinfu.png" }, "compId": 34 }, { "type": "Image", "props": { "y": 25, "x": 121, "skin": "Main/kaigdi.png" }, "compId": 42, "child": [{ "type": "Image", "props": { "y": 9, "x": 94, "skin": "Main/OFF.png" }, "compId": 43 }, { "type": "Image", "props": { "y": 9, "x": 23, "skin": "Main/ON.png" }, "compId": 44 }] }, { "type": "Image", "props": { "y": 25, "x": 206, "skin": "Main/bodong.png", "name": "on" }, "compId": 45 }, { "type": "Image", "props": { "y": 25, "x": 121, "skin": "Main/boodong-2.png", "name": "off" }, "compId": 46 }, { "type": "Button", "props": { "y": 26, "x": 121, "width": 171, "var": "soundbtn", "height": 41 }, "compId": 50 }] }, { "type": "Button", "props": { "y": -46, "x": -35, "var": "CloseSetBtn", "stateNum": 1, "skin": "Main/guanbi.png" }, "compId": 47 }] }] }], "animations": [{ "nodes": [{ "target": 19, "keyframes": { "scaleY": [{ "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 0 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 5 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 10 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 15 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 20 }], "scaleX": [{ "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 0 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 5 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 10 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 15 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 20 }] } }], "name": "handclick", "id": 1, "frameRate": 24, "action": 0 }], "loadList": ["Main/dianjikaishi.png", "Main/shou.png", "Main/gengduo.png", "Main/shangdain.png", "Main/qiandao.png", "Main/qiandi.png", "Main/qian.png", "Main/guandi-3.png", "Main/guandi.png", "Main/zhongdian.png", "Main/shezhi.png", "Main/chunhei.png", "Main/Background Pop up ads.png", "Main/Bouton policy privacy.png", "Main/zhenfu.png", "Main/kaigdi.png", "Main/OFF.png", "Main/ON.png", "Main/bodong.png", "Main/boodong-2.png", "Main/yinfu.png", "Main/guanbi.png"], "loadList3D": [] };
  1138. ui.HomeViewUI = HomeViewUI;
  1139. REG("ui.HomeViewUI", HomeViewUI);
  1140. class InGameViewUI extends Laya.Scene {
  1141. constructor() { super(); }
  1142. createChildren() {
  1143. super.createChildren();
  1144. this.createView(InGameViewUI.uiView);
  1145. }
  1146. }
  1147. InGameViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Box", "props": { "y": 123, "x": 116.5, "width": 487, "visible": true, "var": "ProBox", "height": 81 }, "compId": 8, "child": [{ "type": "ProgressBar", "props": { "y": 30, "x": 68, "width": 352, "var": "jindupro", "value": 0, "skin": "Main/guandi-3.png", "height": 22 }, "compId": 9 }, { "type": "Image", "props": { "y": 11.5, "x": 20, "skin": "Main/guandi.png" }, "compId": 10, "child": [{ "type": "Text", "props": { "y": 9, "x": 1, "width": 56, "var": "NowLevelNum", "valign": "middle", "text": "10", "height": 40, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 11 }] }, { "type": "Image", "props": { "y": 12, "x": 414, "skin": "Main/zhongdian.png" }, "compId": 12 }] }, { "type": "Image", "props": { "y": 181.5, "x": 251.5, "visible": true, "skin": "Main/shuliandi.png" }, "compId": 13, "child": [{ "type": "Text", "props": { "y": 0, "x": 28, "width": 161, "var": "CountTxt", "valign": "middle", "text": "小人数量:22", "height": 45, "fontSize": 24, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 14 }] }], "loadList": ["Main/guandi-3.png", "Main/guandi.png", "Main/zhongdian.png", "Main/shuliandi.png"], "loadList3D": [] };
  1148. ui.InGameViewUI = InGameViewUI;
  1149. REG("ui.InGameViewUI", InGameViewUI);
  1150. class LoadViewUI extends Laya.Scene {
  1151. constructor() { super(); }
  1152. createChildren() {
  1153. super.createChildren();
  1154. this.createView(LoadViewUI.uiView);
  1155. }
  1156. }
  1157. LoadViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Load/beijing.png", "sizeGrid": "10,14,12,10", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 4 }, { "type": "ProgressBar", "props": { "y": 1018, "x": 165, "var": "jindupro", "skin": "Load/ss.png" }, "compId": 3 }, { "type": "Image", "props": { "y": 160, "x": 105, "skin": "Load/title.png" }, "compId": 5 }, { "type": "Image", "props": { "y": 1062, "x": 292.5, "skin": "Load/jiazaizhon.png" }, "compId": 7 }], "loadList": ["Load/beijing.png", "Load/ss.png", "Load/title.png", "Load/jiazaizhon.png"], "loadList3D": [] };
  1158. ui.LoadViewUI = LoadViewUI;
  1159. REG("ui.LoadViewUI", LoadViewUI);
  1160. class ReviveViewUI extends Laya.Scene {
  1161. constructor() { super(); }
  1162. createChildren() {
  1163. super.createChildren();
  1164. this.createView(ReviveViewUI.uiView);
  1165. }
  1166. }
  1167. ReviveViewUI.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": "12,13,14,10", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 15 }, { "type": "Button", "props": { "y": 711, "x": 172.5, "var": "ReviveBtn", "stateNum": 1, "skin": "Main/dihong.png" }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 39, "x": 41, "skin": "Main/shipin.png" }, "compId": 5 }, { "type": "Image", "props": { "y": 39, "x": 162, "skin": "Main/fuhuowenzi.png" }, "compId": 6 }] }, { "type": "Button", "props": { "y": 888, "x": 294, "var": "BackBtn", "stateNum": 1, "skin": "Main/fanhuiwenzi.png" }, "compId": 7 }, { "type": "Box", "props": { "y": 315, "x": 116.5, "width": 487, "var": "ProBox", "height": 81 }, "compId": 8, "child": [{ "type": "ProgressBar", "props": { "y": 30, "x": 68, "width": 352, "skin": "Main/guandi-3.png", "height": 22 }, "compId": 9 }, { "type": "Image", "props": { "y": 11.5, "x": 20, "skin": "Main/guandi.png" }, "compId": 10, "child": [{ "type": "Text", "props": { "y": 9, "x": 1, "width": 56, "var": "NowLevelNum", "valign": "middle", "text": "10", "height": 40, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 11 }] }, { "type": "Image", "props": { "y": 12, "x": 414, "skin": "Main/zhongdian.png" }, "compId": 12 }] }, { "type": "Image", "props": { "y": 192, "x": 80.5, "skin": "Main/wenzi.png" }, "compId": 13 }], "loadList": ["Main/chunhei.png", "Main/dihong.png", "Main/shipin.png", "Main/fuhuowenzi.png", "Main/fanhuiwenzi.png", "Main/guandi-3.png", "Main/guandi.png", "Main/zhongdian.png", "Main/wenzi.png"], "loadList3D": [] };
  1168. ui.ReviveViewUI = ReviveViewUI;
  1169. REG("ui.ReviveViewUI", ReviveViewUI);
  1170. class SignViewUI extends Laya.Scene {
  1171. constructor() { super(); }
  1172. createChildren() {
  1173. super.createChildren();
  1174. this.createView(SignViewUI.uiView);
  1175. }
  1176. }
  1177. SignViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "top": 0, "skin": "Main/chunhei.png", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 72 }, { "type": "Image", "props": { "y": 143, "x": 60.5, "skin": "Main/qinad-d.png" }, "compId": 5, "child": [{ "type": "Image", "props": { "y": 12, "x": 188, "skin": "Main/qiriqiandao.png" }, "compId": 6 }, { "type": "Box", "props": { "y": 102, "x": 18, "width": 180, "height": 200 }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 8, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第1天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 9 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 12, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 14 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 11, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 10 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 15 }] }, { "type": "Box", "props": { "y": 102, "x": 209.5, "width": 180, "height": 200 }, "compId": 17, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 18, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第2天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 19 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 20, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 21 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 22, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 23 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 24 }] }, { "type": "Box", "props": { "y": 102, "x": 402, "width": 180, "height": 200 }, "compId": 25, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 26, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第3天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 27 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 28, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 29 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 30, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 31 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 32 }] }, { "type": "Box", "props": { "y": 318, "x": 18, "width": 180, "height": 200 }, "compId": 33, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 36, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第4天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 37 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 38, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 39 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 40, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 41 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 42 }] }, { "type": "Box", "props": { "y": 318, "x": 209, "width": 180, "height": 200 }, "compId": 34, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 43, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第5天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 44 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 45, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 46 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 47, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 48 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 49 }] }, { "type": "Box", "props": { "y": 318, "x": 402, "width": 180, "height": 200 }, "compId": 35, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 50, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第6天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 51 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 52, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 53 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 54, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 55 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 56 }] }, { "type": "Box", "props": { "y": 536, "x": 23, "width": 553, "height": 196 }, "compId": 57, "child": [{ "type": "Image", "props": { "y": -2, "x": 77, "skin": "Main/qitiankuang.png" }, "compId": 58, "child": [{ "type": "Text", "props": { "y": 42, "x": 42, "width": 78, "valign": "middle", "text": "第7天", "rotation": -45, "pivotY": 17, "pivotX": 39, "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 59 }] }, { "type": "Image", "props": { "y": 66.5, "x": 276.5, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 60, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 61 }] }, { "type": "Image", "props": { "y": -2, "x": 76, "width": 433, "skin": "Main/heizha.png", "sizeGrid": "63,54,82,55", "name": "complete", "height": 198 }, "compId": 62, "child": [{ "type": "Image", "props": { "y": 42.5, "x": 160, "skin": "Main/yihuode.png" }, "compId": 63 }] }, { "type": "Button", "props": { "y": 0, "x": 77, "width": 431, "name": "btn", "height": 196 }, "compId": 64 }] }] }, { "type": "Image", "props": { "y": 70, "x": 556, "width": 164, "skin": "Main/qiandi.png", "height": 55 }, "compId": 65, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "skin": "Main/qian.png" }, "compId": 66 }, { "type": "Text", "props": { "y": 0, "x": 54, "width": 110, "var": "GoldNum", "valign": "middle", "text": "99999", "height": 55, "fontSize": 40, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 67 }] }, { "type": "Button", "props": { "y": 921, "x": 172.5, "var": "VideoSign", "stateNum": 1, "skin": "Main/bd-d.png" }, "compId": 68, "child": [{ "type": "Image", "props": { "y": 39, "x": 42, "skin": "Main/ship.png" }, "compId": 69 }, { "type": "Image", "props": { "y": 39, "x": 156, "skin": "Main/minf.png" }, "compId": 70 }] }, { "type": "Button", "props": { "y": 1074, "x": 274, "stateNum": 1, "skin": "Main/buyong.png", "name": "NoBtn" }, "compId": 71 }], "loadList": ["Main/chunhei.png", "Main/qinad-d.png", "Main/qiriqiandao.png", "Main/pitongkuan.png", "Main/jinbi.png", "Main/heizha.png", "Main/yihuode.png", "Main/qitiankuang.png", "Main/qiandi.png", "Main/qian.png", "Main/bd-d.png", "Main/ship.png", "Main/minf.png", "Main/buyong.png"], "loadList3D": [] };
  1178. ui.SignViewUI = SignViewUI;
  1179. REG("ui.SignViewUI", SignViewUI);
  1180. })(ui || (ui = {}));
  1181. class InGameView extends ui.InGameViewUI {
  1182. constructor() {
  1183. super();
  1184. InGameView.ins = this;
  1185. }
  1186. static get Instance() {
  1187. if (InGameView.ins == null) {
  1188. return new InGameView();
  1189. }
  1190. return InGameView.ins;
  1191. }
  1192. OnShow() {
  1193. console.log("游戏界面");
  1194. this.on(Laya.Event.MOUSE_DOWN, this, this.ClickStart);
  1195. this.RefreshUI();
  1196. this.height = Laya.stage.height;
  1197. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  1198. this.height = Laya.stage.height;
  1199. });
  1200. DispatcherManager.StageOn(StageState.RefreshPro, this, this.SetProValue);
  1201. }
  1202. ClickStart() {
  1203. this.off(Laya.Event.MOUSE_DOWN, this, this.ClickStart);
  1204. }
  1205. RefreshUI() {
  1206. let stage = AccountManager.Instance.curplayerData.STAGE;
  1207. this.NowLevelNum.text = stage + "";
  1208. }
  1209. SetProValue(data) {
  1210. this.jindupro.value = data["pre"];
  1211. this.CountTxt.text = "小人数量:" + (Number(data["count"]) + 1);
  1212. }
  1213. OnHide() {
  1214. DispatcherManager.StageOff(StageState.RefreshPro, this, this.SetProValue);
  1215. }
  1216. }
  1217. class Global {
  1218. }
  1219. Global.VERSION = "1.0.0";
  1220. Global.CFG = "123";
  1221. var HttpRequest = Laya.HttpRequest;
  1222. var Event = Laya.Event;
  1223. const JtSniperApiUrl = "https://waveapi.xwxgame.com/";
  1224. class TeamWave {
  1225. }
  1226. TeamWave.DengLu = "user/login";
  1227. TeamWave.KaiShi = "game/start";
  1228. TeamWave.JieShu = "game/play";
  1229. TeamWave.QianDao = "sign/sign";
  1230. TeamWave.Chengjiu = "achievement/getRewards";
  1231. TeamWave.Config = "config/table";
  1232. TeamWave.FenXiang = "fission/share";
  1233. TeamWave.LiXian = "fission/offline";
  1234. TeamWave.vd = "fission/vd";
  1235. TeamWave.FuHuo = "game/revival";
  1236. TeamWave.gadagdag = "treasure/click";
  1237. TeamWave.Invite = "invite/getRewards";
  1238. TeamWave.Lottery = "lottery/lottery";
  1239. TeamWave.ShareGetSkin = "theme/fission";
  1240. TeamWave.WearEquip = "theme/equip";
  1241. TeamWave.BuyEquip = "theme/buy";
  1242. TeamWave.ShouQuan = "user/auth";
  1243. TeamWave.JinBi = "user/sync";
  1244. class ServerManager {
  1245. constructor() { }
  1246. static get Instance() {
  1247. if (ServerManager.ins) {
  1248. return ServerManager.ins;
  1249. }
  1250. else {
  1251. return new ServerManager();
  1252. }
  1253. }
  1254. Login(progresscb, completecb, errorcb) {
  1255. var Account = AccountManager.Instance;
  1256. var ver = Global.VERSION;
  1257. 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}`;
  1258. let httpRequest = new HttpRequest();
  1259. httpRequest.once(Event.PROGRESS, this, this.Progress, [progresscb, httpRequest]);
  1260. httpRequest.once(Event.COMPLETE, this, this.Complete, [completecb, httpRequest]);
  1261. httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
  1262. httpRequest.send(JtSniperApiUrl + TeamWave.DengLu, Data, "post", "text");
  1263. }
  1264. Progress(_progresscb, _httpreq) {
  1265. if (_progresscb) {
  1266. _progresscb.run();
  1267. }
  1268. }
  1269. Complete(_completecb, _httpreq) {
  1270. let data = JSON.parse(_httpreq.data);
  1271. console.log(data);
  1272. if (data["code"] != "0") {
  1273. console.log("登录异常错误!错误信息sssssssss:", _httpreq.data["code"]);
  1274. return;
  1275. }
  1276. console.log("-----------sss", data["t"]);
  1277. AccountManager.Instance.SFSFSF = data["t"];
  1278. this.RessetConfig(data, _completecb);
  1279. }
  1280. RessetConfig(data, completecb) {
  1281. AccountManager.Instance.ReSetting(data, (flag) => {
  1282. if (flag) {
  1283. completecb.runWith(data);
  1284. }
  1285. else {
  1286. this.RessetConfig(data, completecb);
  1287. }
  1288. });
  1289. }
  1290. Errorcb(_errorcb, _httpreq) {
  1291. if (_errorcb != null) {
  1292. _errorcb.runWith(_httpreq);
  1293. }
  1294. }
  1295. SendHttp(protocol, param, completecb, errorcb, hasToken = true) {
  1296. let sfaasfsfa = "";
  1297. let daadsads = JtSniperApiUrl + protocol;
  1298. if (hasToken == true) {
  1299. sfaasfsfa = `token=${AccountManager.Instance.curplayerData.zhengshu}&`;
  1300. }
  1301. if (protocol == TeamWave.KaiShi || protocol == TeamWave.JieShu || protocol == TeamWave.vd || protocol == TeamWave.Lottery || protocol == TeamWave.ShareGetSkin) {
  1302. let asddsa = "abcdefghijkimnopqrstuvwxyz0123456789";
  1303. let adsassda = "{";
  1304. let saafsafs = "";
  1305. for (let i = 0; i < 4; i++) {
  1306. saafsafs += asddsa[Math.floor(Math.random() * 100) % asddsa.length];
  1307. }
  1308. for (let i = 0; i < param.length; i++) {
  1309. for (let key in param[i]) {
  1310. adsassda += `\"${key}\":\"${param[i][key]}\"`;
  1311. }
  1312. if (i < param.length - 1) {
  1313. adsassda += ",";
  1314. }
  1315. else {
  1316. adsassda += "}";
  1317. }
  1318. }
  1319. sfaasfsfa += "_r=" + saafsafs + this.SFGSGSG(adsassda);
  1320. }
  1321. else {
  1322. if (param != null) {
  1323. for (let i = 0; i < param.length; i++) {
  1324. for (let key in param[i]) {
  1325. let val = param[i][key];
  1326. sfaasfsfa += `${key}=${val}`;
  1327. if (i < param.length - 1) {
  1328. sfaasfsfa += "&";
  1329. }
  1330. }
  1331. }
  1332. }
  1333. }
  1334. let httpRequest = new HttpRequest();
  1335. httpRequest.once(Event.COMPLETE, this, this.onHttpRequestComplete, [completecb, errorcb, httpRequest]);
  1336. httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
  1337. httpRequest.send(daadsads, sfaasfsfa, "post", "text");
  1338. }
  1339. onHttpRequestComplete(succeedcb, failurecb, httpRequest) {
  1340. let data = JSON.parse(httpRequest.data);
  1341. if (data["code"] == 0) {
  1342. AccountManager.Instance.ReSetting(data);
  1343. if (succeedcb != null) {
  1344. succeedcb.runWith(data);
  1345. }
  1346. }
  1347. else {
  1348. if (failurecb != null) {
  1349. failurecb.runWith(data);
  1350. }
  1351. console.log("Error! Http request complete error, code: " + data["code"] + " message: " + data["message"]);
  1352. }
  1353. }
  1354. SFGSGSG(str) {
  1355. var c1, c2, c3;
  1356. var SFSFFSFSFSFS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  1357. var i = 0, len = str.length, SFFSSFFS = '';
  1358. while (i < len) {
  1359. c1 = str.charCodeAt(i++) & 0xff;
  1360. if (i == len) {
  1361. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  1362. SFFSSFFS += SFSFFSFSFSFS.charAt((c1 & 0x3) << 4);
  1363. SFFSSFFS += "==";
  1364. break;
  1365. }
  1366. c2 = str.charCodeAt(i++);
  1367. if (i == len) {
  1368. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  1369. SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  1370. SFFSSFFS += SFSFFSFSFSFS.charAt((c2 & 0xF) << 2);
  1371. SFFSSFFS += "=";
  1372. break;
  1373. }
  1374. c3 = str.charCodeAt(i++);
  1375. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  1376. SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  1377. SFFSSFFS += SFSFFSFSFSFS.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
  1378. SFFSSFFS += SFSFFSFSFSFS.charAt(c3 & 0x3F);
  1379. }
  1380. return SFFSSFFS;
  1381. }
  1382. }
  1383. class HomeView extends ui.HomeViewUI {
  1384. constructor() {
  1385. super();
  1386. HomeView.ins = this;
  1387. }
  1388. static get Instance() {
  1389. if (HomeView.ins == null) {
  1390. return new HomeView();
  1391. }
  1392. return HomeView.ins;
  1393. }
  1394. OnShow() {
  1395. console.log("主界面");
  1396. this.RefreshUI();
  1397. this.RegButton();
  1398. this.handclick.play(null, true);
  1399. }
  1400. RegButton() {
  1401. this.StartBtn.clickHandler = new Laya.Handler(this, this.Start);
  1402. this.SetBtn.clickHandler = new Laya.Handler(this, this.ShowSetPanel);
  1403. this.CloseSetBtn.clickHandler = new Laya.Handler(this, this.HideSetPanel);
  1404. this.shakebtn.clickHandler = new Laya.Handler(this, this.ClickShake);
  1405. this.soundbtn.clickHandler = new Laya.Handler(this, this.ClickSound);
  1406. this.height = Laya.stage.height;
  1407. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  1408. this.height = Laya.stage.height;
  1409. });
  1410. }
  1411. RefreshUI() {
  1412. let stage = AccountManager.Instance.curplayerData.STAGE;
  1413. this.NowLevelNum.text = stage + "";
  1414. this.GoldNum.text = AccountManager.Instance.curplayerData.GainAccount("money");
  1415. }
  1416. Start() {
  1417. var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
  1418. ServerManager.Instance.SendHttp(TeamWave.KaiShi, agrs, Laya.Handler.create(this, (data) => {
  1419. GameManager.play_id = data.play_id;
  1420. PlayerManager.Instance.EnablePlayer();
  1421. this.handclick.stop();
  1422. this.shou.visible = false;
  1423. ViewManager.Instance.ShowView(ViewType.InGameView);
  1424. DispatcherManager.StageTrigger(StageState.Start);
  1425. }), null);
  1426. }
  1427. GameStart() {
  1428. }
  1429. ShowSetPanel() {
  1430. this.SetPanel.visible = true;
  1431. let shakeon = this.SetPanel.getChildAt(0).getChildByName("shake").getChildByName("on");
  1432. let shakeoff = this.SetPanel.getChildAt(0).getChildByName("shake").getChildByName("off");
  1433. let soundon = this.SetPanel.getChildAt(0).getChildByName("sound").getChildByName("on");
  1434. let soundoff = this.SetPanel.getChildAt(0).getChildByName("sound").getChildByName("off");
  1435. soundon.visible = AudioManager.play;
  1436. soundoff.visible = !soundon.visible;
  1437. shakeon.visible = WXSDK.shake;
  1438. shakeoff.visible = !shakeon.visible;
  1439. }
  1440. HideSetPanel() {
  1441. this.SetPanel.visible = false;
  1442. }
  1443. ClickSound() {
  1444. let soundon = this.SetPanel.getChildAt(0).getChildByName("sound").getChildByName("on");
  1445. let soundoff = this.SetPanel.getChildAt(0).getChildByName("sound").getChildByName("off");
  1446. AudioManager.play = !AudioManager.play;
  1447. soundon.visible = AudioManager.play;
  1448. soundoff.visible = !soundon.visible;
  1449. if (AudioManager.play) {
  1450. AudioManager.PlayBGM(BGMType.bgm);
  1451. }
  1452. else {
  1453. AudioManager.StopMusic();
  1454. }
  1455. }
  1456. ClickShake() {
  1457. let shakeon = this.SetPanel.getChildAt(0).getChildByName("shake").getChildByName("on");
  1458. let shakeoff = this.SetPanel.getChildAt(0).getChildByName("shake").getChildByName("off");
  1459. WXSDK.shake = !WXSDK.shake;
  1460. shakeon.visible = WXSDK.shake;
  1461. shakeoff.visible = !shakeon.visible;
  1462. }
  1463. OnHide() {
  1464. }
  1465. }
  1466. class ReviveView extends ui.ReviveViewUI {
  1467. constructor() {
  1468. super();
  1469. ReviveView.ins = this;
  1470. }
  1471. static get Instance() {
  1472. if (ReviveView.ins == null) {
  1473. return new ReviveView();
  1474. }
  1475. return ReviveView.ins;
  1476. }
  1477. OnShow() {
  1478. this.height = Laya.stage.height;
  1479. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  1480. this.height = Laya.stage.height;
  1481. });
  1482. }
  1483. OnHide() {
  1484. }
  1485. }
  1486. class GameResultView extends ui.GameResultViewUI {
  1487. constructor() {
  1488. super();
  1489. GameResultView.ins = this;
  1490. }
  1491. static get Instance() {
  1492. if (GameResultView.ins == null) {
  1493. return new GameResultView();
  1494. }
  1495. return GameResultView.ins;
  1496. }
  1497. OnShow(data) {
  1498. this._result = data;
  1499. if (data) {
  1500. this.WinBox.visible = true;
  1501. this.FailBox.visible = false;
  1502. }
  1503. else {
  1504. this.WinBox.visible = false;
  1505. this.FailBox.visible = true;
  1506. }
  1507. LevelManager.Instance.BackMain();
  1508. this.RefreshUI();
  1509. this.RegButton();
  1510. this.height = Laya.stage.height;
  1511. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  1512. this.height = Laya.stage.height;
  1513. });
  1514. }
  1515. RegButton() {
  1516. this.Win_BackBtn.clickHandler = new Laya.Handler(this, this.BackHome);
  1517. this.Win_VideoBtn.clickHandler = new Laya.Handler(this, this.WinVideoGet);
  1518. this.Fail_BackBtn.clickHandler = new Laya.Handler(this, this.BackHome);
  1519. this.Fail_VideoBtn.clickHandler = new Laya.Handler(this, this.LoseVideoGet);
  1520. }
  1521. RefreshUI() {
  1522. this.Win_GoldNum.text = AccountManager.Instance.curplayerData.LevelReward(this._result) + "";
  1523. this.Fail_GoldNum.text = AccountManager.Instance.curplayerData.LevelReward(this._result) + "";
  1524. }
  1525. WinVideoGet() {
  1526. }
  1527. LoseVideoGet() {
  1528. }
  1529. BackHome() {
  1530. let stage = AccountManager.Instance.curplayerData.STAGE;
  1531. var iswin = this._result ? "1" : "0";
  1532. var coinnum = AccountManager.Instance.curplayerData.LevelReward(this._result) + "";
  1533. var args = [{ "t": AccountManager.Instance.ServerTime.toString() }, { "play_id": GameManager.play_id }, { "win": iswin }, { "money": coinnum }];
  1534. ServerManager.Instance.SendHttp(TeamWave.JieShu, args, Laya.Handler.create(this, this.Success), null);
  1535. }
  1536. Success() {
  1537. GameManager.Instance.GameOver();
  1538. }
  1539. OnHide() {
  1540. }
  1541. }
  1542. var ViewType;
  1543. (function (ViewType) {
  1544. ViewType[ViewType["InGameView"] = 0] = "InGameView";
  1545. ViewType[ViewType["HomeView"] = 1] = "HomeView";
  1546. ViewType[ViewType["GameResultView"] = 2] = "GameResultView";
  1547. ViewType[ViewType["SkinView"] = 3] = "SkinView";
  1548. ViewType[ViewType["TrialView"] = 4] = "TrialView";
  1549. ViewType[ViewType["ReviveView"] = 5] = "ReviveView";
  1550. })(ViewType || (ViewType = {}));
  1551. class ViewManager {
  1552. constructor() {
  1553. this.showexportview = 0;
  1554. this.popViewDic = [];
  1555. this.ViewSprite = new Laya.Sprite();
  1556. this.OtherViewSprite = new Laya.Sprite();
  1557. ViewManager.ins = this;
  1558. Laya.stage.addChild(this.ViewSprite);
  1559. Laya.stage.addChild(this.OtherViewSprite);
  1560. }
  1561. static get Instance() {
  1562. if (ViewManager.ins) {
  1563. return ViewManager.ins;
  1564. }
  1565. else {
  1566. return new ViewManager();
  1567. }
  1568. }
  1569. ShowView(_viewtype, data = null) {
  1570. if (this.curView != null) {
  1571. this.curView.OnHide();
  1572. this.curView.destroy();
  1573. this.curView.removeSelf();
  1574. }
  1575. this.curView = this.CreateView(_viewtype);
  1576. this.curView.name = ViewType[_viewtype];
  1577. this.ViewSprite.addChild(this.curView);
  1578. this.curView.OnShow(data);
  1579. }
  1580. CloseView() {
  1581. if (this.curView != null) {
  1582. this.curView.OnHide();
  1583. this.curView.destroy();
  1584. this.curView.removeSelf();
  1585. }
  1586. }
  1587. OpenPopView(viewType, data = null) {
  1588. var popView;
  1589. if (this.popViewDic[viewType]) {
  1590. popView = this.popViewDic[viewType];
  1591. this.OtherViewSprite.setChildIndex(popView, this.OtherViewSprite.numChildren - 1);
  1592. popView.visible = true;
  1593. }
  1594. else {
  1595. popView = this.CreateView(viewType);
  1596. this.OtherViewSprite.addChild(popView);
  1597. this.popViewDic[viewType] = popView;
  1598. }
  1599. popView.OnOpen(data);
  1600. }
  1601. ClosePopView(viewType) {
  1602. var popView = this.popViewDic[viewType];
  1603. if (popView == null) {
  1604. return;
  1605. }
  1606. popView.OnHide();
  1607. popView.visible = false;
  1608. }
  1609. ClearPopViews() {
  1610. }
  1611. CreateView(_viewtype) {
  1612. switch (_viewtype) {
  1613. case ViewType.InGameView:
  1614. return new InGameView();
  1615. case ViewType.HomeView:
  1616. return new HomeView();
  1617. case ViewType.ReviveView:
  1618. return new ReviveView();
  1619. case ViewType.GameResultView:
  1620. return new GameResultView();
  1621. }
  1622. return null;
  1623. }
  1624. }
  1625. class CameraManager {
  1626. constructor() {
  1627. this.LeftPosition = new Laya.Vector3(3.65, 5.72, -4.52);
  1628. this.LeftRotate = new Laya.Vector3(-24, 145, 0);
  1629. this.RightPosition = new Laya.Vector3(-3.78, 4.87, -4.46);
  1630. this.RightRotate = new Laya.Vector3(-24, -145, 0);
  1631. this.poschazhi = new Laya.Vector3();
  1632. this.gengsuipos = new Laya.Vector3();
  1633. this.lllpos = new Laya.Vector3();
  1634. this.hights = 0;
  1635. this.wights = 0;
  1636. CameraManager.ins = this;
  1637. DispatcherManager.StageOn(StageState.Start, this, this.CameraFollow);
  1638. DispatcherManager.StageOn(StageState.Win, this, this.CameraCancelFollow);
  1639. DispatcherManager.StageOn(StageState.Lose, this, this.CameraCancelFollow);
  1640. }
  1641. static get Instance() {
  1642. if (CameraManager.ins == null) {
  1643. return new CameraManager();
  1644. }
  1645. return CameraManager.ins;
  1646. }
  1647. Init() {
  1648. let Direction = AccountManager.Instance.curplayerData.LevelDirection;
  1649. if (Direction == 1) {
  1650. this.camera.transform.position = this.LeftPosition;
  1651. this.camera.transform.rotationEuler = this.LeftRotate;
  1652. }
  1653. else {
  1654. this.camera.transform.position = this.RightPosition;
  1655. this.camera.transform.rotationEuler = this.RightRotate;
  1656. }
  1657. this.CameraFollow();
  1658. }
  1659. CameraFollow() {
  1660. this.hights = 0;
  1661. this.wights = 0;
  1662. Laya.Vector3.subtract(PlayerManager.Instance.player.transform.position, this.camera.transform.position, this.poschazhi);
  1663. Laya.timer.frameLoop(1, this, this.GenSui);
  1664. }
  1665. GenSui() {
  1666. Laya.Vector3.subtract(PlayerManager.Instance.player.transform.position, this.poschazhi, this.gengsuipos);
  1667. this.hights = GameTools.Instance.lerp(this.hights, 1, 0.03);
  1668. this.wights = GameTools.Instance.lerp(this.wights, 1, 0.05);
  1669. this.gengsuipos = new Laya.Vector3(this.gengsuipos.x, this.gengsuipos.y, this.gengsuipos.z);
  1670. Laya.Vector3.lerp(this.camera.transform.position, this.gengsuipos, 0.25, this.lllpos);
  1671. this.lllpos = new Laya.Vector3(this.gengsuipos.x, this.lllpos.y, this.lllpos.z);
  1672. this.camera.transform.position = this.lllpos;
  1673. }
  1674. CameraCancelFollow() {
  1675. Laya.timer.clear(this, this.GenSui);
  1676. }
  1677. }
  1678. class LevelManager {
  1679. constructor() {
  1680. LevelManager.ins = this;
  1681. }
  1682. static get Instance() {
  1683. if (LevelManager.ins == null) {
  1684. return new LevelManager();
  1685. }
  1686. return LevelManager.ins;
  1687. }
  1688. RegEvent() {
  1689. DispatcherManager.StageOn(StageState.Lose, this, this.GameLose);
  1690. DispatcherManager.StageOn(StageState.Win, this, this.GameWin);
  1691. DispatcherManager.StageOn(StageState.Pause, this, this.GamePause);
  1692. DispatcherManager.StageOn(StageState.Resume, this, this.GameResume);
  1693. DispatcherManager.StageOn(StageState.Over, this, this.GameStart);
  1694. }
  1695. GameStart() {
  1696. PlayerManager.Instance.Init();
  1697. CameraManager.Instance.Init();
  1698. ViewManager.Instance.ShowView(ViewType.HomeView);
  1699. AudioManager.PlayBGM(BGMType.bgm);
  1700. }
  1701. GameLose() {
  1702. PlayerManager.Instance.ListenOff();
  1703. Laya.timer.once(500, this, () => {
  1704. ViewManager.Instance.ShowView(ViewType.GameResultView, false);
  1705. });
  1706. AudioManager.StopMusic();
  1707. }
  1708. GameWin() {
  1709. PlayerManager.Instance.ListenOff();
  1710. Laya.timer.once(500, this, () => {
  1711. ViewManager.Instance.ShowView(ViewType.GameResultView, true);
  1712. });
  1713. AudioManager.StopMusic();
  1714. }
  1715. GamePause() {
  1716. }
  1717. GameResume() {
  1718. }
  1719. BackMain() {
  1720. for (let i = this.spritepool.numChildren - 1; i >= 0; i--) {
  1721. let child = this.spritepool.getChildAt(i);
  1722. let _well = child.getComponent(WallBehav);
  1723. if (_well) {
  1724. _well.destroy();
  1725. }
  1726. let _matemove = child.getComponent(MateMove);
  1727. if (_matemove) {
  1728. _matemove.destroy();
  1729. }
  1730. child.removeSelf();
  1731. child.destroy();
  1732. child = null;
  1733. }
  1734. }
  1735. }
  1736. class AssetManager {
  1737. constructor() {
  1738. this.Prop = new Dictionary();
  1739. this.Character = new Dictionary();
  1740. AssetManager.ins = this;
  1741. DispatcherManager.EventOn(EventState.LoadComplete, this, this.Init);
  1742. }
  1743. static get Instance() {
  1744. if (AssetManager.ins == null) {
  1745. return new AssetManager();
  1746. }
  1747. return AssetManager.ins;
  1748. }
  1749. Init() {
  1750. this.mainscene.enableFog = true;
  1751. this.mainscene.fogStart = 25;
  1752. this.mainscene.fogRange = 40;
  1753. this.mainscene.fogColor = new Laya.Vector3(138 / 255, 78 / 255, 188 / 255);
  1754. Laya.stage.addChild(this.mainscene);
  1755. this.maincamera = this.mainscene.getChildByName("Main Camera");
  1756. this.maincamera.clearColor = new Laya.Vector4(138 / 255, 78 / 255, 188 / 255, 1);
  1757. this.maincamera.enableHDR = false;
  1758. CameraManager.Instance.camera = this.maincamera;
  1759. this.camerapos = this.maincamera.transform.position.clone();
  1760. this.camerarotate = this.maincamera.transform.rotationEuler.clone();
  1761. let _sprite = new Laya.Sprite3D();
  1762. this.mainscene.addChild(_sprite);
  1763. LevelManager.Instance.spritepool = _sprite;
  1764. this.SetCharacterPos();
  1765. LevelManager.Instance.RegEvent();
  1766. LevelManager.Instance.GameStart();
  1767. }
  1768. getPref(name) {
  1769. return this.Prop.get(name);
  1770. }
  1771. getRolePref(index) {
  1772. return this.Character.get(index);
  1773. }
  1774. SetCharacterPos() {
  1775. GameManager.STAGE = -1;
  1776. let _level = this.mainscene.getChildByName("levelgg");
  1777. let stage = AccountManager.Instance.curplayerData.STAGE;
  1778. let levelname = "level" + stage;
  1779. for (let i = 0; i < _level.numChildren; i++) {
  1780. let item = _level.getChildAt(i);
  1781. if (item.name != levelname) {
  1782. item.active = false;
  1783. }
  1784. else {
  1785. item.active = true;
  1786. this.curstage = item;
  1787. }
  1788. }
  1789. for (let i = 0; i < this.curstage.numChildren; i++) {
  1790. let item = this.curstage.getChildAt(i);
  1791. if (item.name == "player") {
  1792. this.playerpos = Laya.Sprite3D.instantiate(item);
  1793. }
  1794. else if (item.name == "barrier") {
  1795. let _pref = this.getPref(ResourcesPath.Nail2);
  1796. let _cube = Laya.Sprite3D.instantiate(_pref);
  1797. LevelManager.Instance.spritepool.addChild(_cube);
  1798. _cube.transform.position = item.transform.position.clone();
  1799. _cube.transform.rotation = item.transform.rotation.clone();
  1800. _cube.transform.scale = item.transform.scale.clone();
  1801. _cube.name = ResourcesPath.Nail2;
  1802. NodeUtil.SetColliderGroup(_cube, 2);
  1803. }
  1804. else if (item.name == "role") {
  1805. let _pref = this.getRolePref(1);
  1806. let _player = Laya.Sprite3D.instantiate(_pref);
  1807. LevelManager.Instance.spritepool.addChild(_player);
  1808. _player.transform.position = item.transform.position.clone();
  1809. _player.transform.rotation = item.transform.rotation.clone();
  1810. let _mate = _player.addComponent(MateMove);
  1811. NodeUtil.SetColliderGroup(_player, 100);
  1812. }
  1813. else if (item.name == "speed") {
  1814. let _pref = this.getPref(ResourcesPath.Speed);
  1815. let _cube = Laya.Sprite3D.instantiate(_pref);
  1816. LevelManager.Instance.spritepool.addChild(_cube);
  1817. _cube.transform.position = item.transform.position.clone();
  1818. _cube.transform.rotation = item.transform.rotation.clone();
  1819. _cube.transform.scale = item.transform.scale.clone();
  1820. _cube.name = ResourcesPath.Speed;
  1821. NodeUtil.SetColliderGroup(item, 1);
  1822. }
  1823. else if (item.name == "Ramp") {
  1824. let _pref = this.getPref(ResourcesPath.Ramp);
  1825. let _cube = Laya.Sprite3D.instantiate(_pref);
  1826. LevelManager.Instance.spritepool.addChild(_cube);
  1827. _cube.transform.position = item.transform.position.clone();
  1828. _cube.transform.rotation = item.transform.rotation.clone();
  1829. _cube.transform.scale = item.transform.scale.clone();
  1830. _cube.name = ResourcesPath.Ramp;
  1831. NodeUtil.SetColliderGroup(item, 1);
  1832. }
  1833. else if (item.name == "bridge") {
  1834. NodeUtil.SetColliderGroup(item, 1);
  1835. }
  1836. else if (item.name == "Coin") {
  1837. let _pref = this.getPref(ResourcesPath.Coin);
  1838. let _cube = Laya.Sprite3D.instantiate(_pref);
  1839. LevelManager.Instance.spritepool.addChild(_cube);
  1840. _cube.transform.position = item.transform.position.clone();
  1841. _cube.transform.rotation = item.transform.rotation.clone();
  1842. _cube.transform.scale = item.transform.scale.clone();
  1843. _cube.name = ResourcesPath.Coin;
  1844. let coinbehav = _cube.addComponent(CoinBehav);
  1845. NodeUtil.SetColliderGroup(_cube, 3);
  1846. }
  1847. else if (item.name == "FinishCircle") {
  1848. let _pref = this.getPref(ResourcesPath.FinishCircle);
  1849. let _cube = Laya.Sprite3D.instantiate(_pref);
  1850. LevelManager.Instance.spritepool.addChild(_cube);
  1851. _cube.transform.position = item.transform.position.clone();
  1852. _cube.transform.rotation = item.transform.rotation.clone();
  1853. _cube.transform.scale = item.transform.scale.clone();
  1854. _cube.name = ResourcesPath.FinishCircle;
  1855. this.finishpoint = item.transform.position.clone();
  1856. NodeUtil.SetColliderGroup(_cube, 200);
  1857. }
  1858. }
  1859. }
  1860. }
  1861. class GameManager {
  1862. constructor() {
  1863. GameManager.ins = this;
  1864. }
  1865. static get Instance() {
  1866. if (GameManager.ins == null) {
  1867. return new GameManager();
  1868. }
  1869. return GameManager.ins;
  1870. }
  1871. GameLose() {
  1872. DispatcherManager.StageTrigger(StageState.Lose);
  1873. }
  1874. GameWin() {
  1875. DispatcherManager.StageTrigger(StageState.Win);
  1876. }
  1877. GameOver() {
  1878. AssetManager.Instance.SetCharacterPos();
  1879. DispatcherManager.StageTrigger(StageState.Over);
  1880. }
  1881. }
  1882. GameManager.STAGE = -1;
  1883. var AccountUser;
  1884. (function (AccountUser) {
  1885. AccountUser[AccountUser["buyed_kun"] = 0] = "buyed_kun";
  1886. AccountUser[AccountUser["diamond"] = 1] = "diamond";
  1887. AccountUser[AccountUser["equip_themes"] = 2] = "equip_themes";
  1888. AccountUser[AccountUser["favorite_times"] = 3] = "favorite_times";
  1889. AccountUser[AccountUser["game_times"] = 4] = "game_times";
  1890. AccountUser[AccountUser["get_themes"] = 5] = "get_themes";
  1891. AccountUser[AccountUser["list_kun"] = 6] = "list_kun";
  1892. AccountUser[AccountUser["moeny"] = 7] = "moeny";
  1893. AccountUser[AccountUser["progress_themes"] = 8] = "progress_themes";
  1894. AccountUser[AccountUser["revival"] = 9] = "revival";
  1895. AccountUser[AccountUser["stage"] = 10] = "stage";
  1896. })(AccountUser || (AccountUser = {}));
  1897. class PlayerData {
  1898. constructor(_token, _config, _appSetting, _user, _userbase, _useInvite, _user_stage = null, _user_sign, _user_achievement, lottery) {
  1899. this.openid = "";
  1900. this.userId = "";
  1901. this.zhengshu = _token;
  1902. this.netzheshe = _appSetting;
  1903. this.account = _user;
  1904. this.accountssss = _userbase;
  1905. this.qiandao = _user_sign;
  1906. this.renwu = _user_achievement;
  1907. this.userId = this.account["user_id"];
  1908. this.openid = this.accountssss["openid"];
  1909. this.m_invite = _useInvite;
  1910. this.lottery = lottery;
  1911. console.log("user_id:" + this.userId);
  1912. }
  1913. GainCollocation(_type) {
  1914. return this.peizhis[_type];
  1915. }
  1916. GainAccount(_type) {
  1917. return this.account[_type];
  1918. }
  1919. get fenxiang() {
  1920. return this.netzheshe["share"] == "1";
  1921. }
  1922. get CheckScene() {
  1923. return this.netzheshe["checkscene"] == "1";
  1924. }
  1925. get Cheat() {
  1926. return this.netzheshe["cheat"] == "1";
  1927. }
  1928. get Banner() {
  1929. return this.netzheshe["Banner"] == "1";
  1930. }
  1931. get wudaoshijian() {
  1932. return Number(this.netzheshe["wudaoshijian"]);
  1933. }
  1934. LevelReward(win) {
  1935. let stage = Number(this.GainAccount("stage")) + 1;
  1936. let levelinfo = this.GainCollocation("mission");
  1937. for (var key in levelinfo) {
  1938. let item = levelinfo[key];
  1939. if (item.ID == stage) {
  1940. if (win) {
  1941. return Number(item.win);
  1942. }
  1943. else {
  1944. return Number(item.lose);
  1945. }
  1946. }
  1947. }
  1948. return null;
  1949. }
  1950. get LevelDirection() {
  1951. let stage = this.STAGE;
  1952. let levelinfo = this.GainCollocation("mission");
  1953. for (var key in levelinfo) {
  1954. let item = levelinfo[key];
  1955. if (item.ID == stage) {
  1956. return Number(item.direction);
  1957. }
  1958. }
  1959. return null;
  1960. }
  1961. get STAGE() {
  1962. if (GameManager.STAGE == -1) {
  1963. GameManager.STAGE = Number(this.GainAccount("stage")) + 1;
  1964. if (GameManager.STAGE > 30) {
  1965. GameManager.STAGE = GameTools.RandomANumber(1, 30);
  1966. }
  1967. }
  1968. return GameManager.STAGE;
  1969. }
  1970. GetUser(_type) {
  1971. var type = AccountUser[_type];
  1972. return this.account[type];
  1973. }
  1974. HasGun(_id) {
  1975. var data = this.GainAccount("get_themes");
  1976. for (var i = 0; i < data.length; i++) {
  1977. var hd = data[i];
  1978. if (_id == hd) {
  1979. return true;
  1980. }
  1981. }
  1982. return false;
  1983. }
  1984. GetProgress(_id) {
  1985. var config = this.account["progress_themes"];
  1986. var progress = config[_id] ? config[_id] : 0;
  1987. return progress;
  1988. }
  1989. get ShareTxt() {
  1990. return this.netzheshe["sharecontent"];
  1991. }
  1992. }
  1993. class AccountManager {
  1994. constructor(_code, _userinfo, _nickname, _avatarurl, _gender, _province, _city, _country, _device, _shareid, _scene, _v) {
  1995. this.createTime = Laya.timer.currTimer;
  1996. AccountManager.ins = this;
  1997. this.code = _code;
  1998. this.userInfo = _userinfo;
  1999. this.nickName = _nickname;
  2000. this.avatarUrl = _avatarurl;
  2001. this.gender = _gender;
  2002. this.province = _province;
  2003. this.city = _city;
  2004. this.country = _country;
  2005. this.device = _device;
  2006. this.share_id = _shareid;
  2007. this.scene = _scene;
  2008. this.v = _v;
  2009. }
  2010. static get Instance() {
  2011. if (AccountManager.ins == null) {
  2012. new AccountManager("222222", "你找谁?", "1233", "123", 1, "中国", "上海", "上海", "iphone6s", "123", "123", "123");
  2013. }
  2014. return AccountManager.ins;
  2015. }
  2016. ReSetting(data, cb = null) {
  2017. var zhengshu = data["token"];
  2018. var netset = data["app_setting"];
  2019. var user = data["user"];
  2020. var jichu = data["user_base"];
  2021. var qiandao = data["user_sign"];
  2022. var chengjiu = data["user_achievement"];
  2023. var invite = data["user_invite"];
  2024. var lottery = data["user_lottery"];
  2025. if (this.curplayerData == null) {
  2026. this.curplayerData = new PlayerData(zhengshu, null, netset, user, jichu, invite, null, qiandao, chengjiu, lottery);
  2027. this.JundgCfg(data.table_version, cb);
  2028. }
  2029. else {
  2030. if (netset) {
  2031. this.curplayerData.netzheshe = netset;
  2032. }
  2033. if (user) {
  2034. this.curplayerData.account = user;
  2035. }
  2036. if (jichu) {
  2037. this.curplayerData.accountssss = jichu;
  2038. }
  2039. if (qiandao) {
  2040. this.curplayerData.qiandao = qiandao;
  2041. }
  2042. if (chengjiu) {
  2043. this.curplayerData.renwu = chengjiu;
  2044. }
  2045. }
  2046. }
  2047. JundgCfg(ver, callball) {
  2048. var cfg = Laya.LocalStorage.getJSON(Global.CFG);
  2049. if (cfg) {
  2050. if (cfg.VER == ver) {
  2051. console.log("已经拥有,不用更新");
  2052. this.SetCfg(cfg);
  2053. if (callball)
  2054. callball(true);
  2055. }
  2056. else {
  2057. console.log("cfg存在但是过期了");
  2058. Laya.LocalStorage.removeItem(Global.CFG);
  2059. ServerManager.Instance.SendHttp(TeamWave.Config, null, Laya.Handler.create(this, (data) => {
  2060. data.configs.VER = ver;
  2061. Laya.LocalStorage.setJSON(Global.CFG, data.configs);
  2062. this.SetCfg(data.configs);
  2063. if (callball)
  2064. callball(true);
  2065. }), Laya.Handler.create(this, (data) => {
  2066. console.log("配置获取失败" + data);
  2067. if (callball)
  2068. callball(false);
  2069. return;
  2070. }));
  2071. }
  2072. }
  2073. else {
  2074. console.log("本地没有cfg");
  2075. ServerManager.Instance.SendHttp(TeamWave.Config, null, Laya.Handler.create(this, (data) => {
  2076. data.configs.VER = ver;
  2077. Laya.LocalStorage.setJSON(Global.CFG, data.configs);
  2078. this.SetCfg(data.configs);
  2079. if (callball)
  2080. callball(true);
  2081. }), Laya.Handler.create(this, (data) => {
  2082. console.log("配置获取失败" + data);
  2083. }));
  2084. }
  2085. }
  2086. SetCfg(data) {
  2087. this.curplayerData.peizhis = data;
  2088. }
  2089. RessetConfig() {
  2090. ServerManager.Instance.SendHttp(TeamWave.Config, null, Laya.Handler.create(this, (data) => {
  2091. this.curplayerData.peizhis = data["configs"];
  2092. }), null);
  2093. }
  2094. get ServerTime() {
  2095. let time = Laya.timer.currTimer;
  2096. let stime = this.SFSFSF + Math.ceil((time - this.createTime) / 1000);
  2097. return stime;
  2098. }
  2099. }
  2100. class ShareUtil {
  2101. beginShare(callBack) {
  2102. ShareUtil.beginShareTime = new Date().getTime();
  2103. console.log("分享点击时间=" + ShareUtil.beginShareTime);
  2104. ShareUtil.isSharing = true;
  2105. ShareUtil.callback = callBack;
  2106. }
  2107. onRegister() {
  2108. if (Laya.Browser.window.wx == null) {
  2109. return;
  2110. }
  2111. Laya.Browser.window.wx.onShow(function (option) {
  2112. console.log("onshow share start");
  2113. if (ShareUtil.isSharing) {
  2114. ShareUtil.isSharing = false;
  2115. let time = new Date().getTime();
  2116. console.log("分享回到游戏时间" + time);
  2117. let wait = (time - ShareUtil.beginShareTime) / 1000;
  2118. console.log("分享停留时间为:" + wait);
  2119. if (wait < 3) {
  2120. Laya.Browser.window.wx.showToast({ title: "请重试一次" });
  2121. ShareUtil.callback(false);
  2122. }
  2123. else {
  2124. var random = Math.random();
  2125. if (random <= 0.3) {
  2126. var message = ["你已分享过该群", "请重新换个群分享!", "请分享到30人大群中!"];
  2127. var curmes = message[GameTools.RandomANumber(0, 2)];
  2128. Laya.Browser.window.wx.showToast({ title: curmes });
  2129. ShareUtil.callback(false);
  2130. }
  2131. else {
  2132. Laya.Browser.window.wx.showToast({ title: "分享成功!" });
  2133. ShareUtil.callback(true);
  2134. }
  2135. }
  2136. }
  2137. });
  2138. }
  2139. static ShareMessage() {
  2140. if (!Laya.Browser.onWeiXin)
  2141. return;
  2142. var t = AccountManager.Instance.ServerTime;
  2143. var _title = AccountManager.Instance.curplayerData.ShareTxt;
  2144. _title = (_title == "" || !_title) ? "组团一起浪" : _title;
  2145. var _image = "subpackage2/res/share/shareimage.png";
  2146. Laya.Browser.window.wx.onShareAppMessage(() => ({
  2147. title: _title,
  2148. imageUrl: _image,
  2149. query: "shareid=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
  2150. }));
  2151. }
  2152. static shareImage(channel, callback = null, shareType) {
  2153. if (Laya.Browser.window.wx == null) {
  2154. return;
  2155. }
  2156. var t = AccountManager.Instance.ServerTime;
  2157. var _title = AccountManager.Instance.curplayerData.ShareTxt;
  2158. _title = (_title == "" || !_title) ? "组团一起浪" : _title;
  2159. var _image = "subpackage2/res/share/shareimage.png";
  2160. Laya.Browser.window.wx.aldShareAppMessage({
  2161. title: _title,
  2162. imageUrl: _image,
  2163. query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + shareType + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
  2164. });
  2165. if (callback) {
  2166. ShareUtil.Instance.beginShare(callback);
  2167. }
  2168. }
  2169. }
  2170. ShareUtil.Instance = new ShareUtil();
  2171. ShareUtil.shareSuccessTime = 0;
  2172. ShareUtil.isSharing = false;
  2173. class WXSDK {
  2174. constructor() {
  2175. WXSDK.ins = this;
  2176. }
  2177. static get Instance() {
  2178. if (WXSDK.ins) {
  2179. return WXSDK.ins;
  2180. }
  2181. else {
  2182. return new WXSDK();
  2183. }
  2184. }
  2185. static Init() {
  2186. }
  2187. static DengLu(_complete) {
  2188. var that = this;
  2189. Laya.Browser.window.wx.login({
  2190. success: function (res) {
  2191. if (res.code) {
  2192. ShareUtil.Instance.onRegister();
  2193. console.log("微信登陆成功----");
  2194. that.codeValue = res.code;
  2195. console.log("shareid:" + WXSDK.shareOpenId);
  2196. new AccountManager(res.code, "", "", "", 0, "", "", "", "", WXSDK.shareOpenId, WXSDK.shareOpenId, Global.VERSION);
  2197. _complete(res);
  2198. }
  2199. else {
  2200. WXSDK.DengLu(WXSDK.DengLu);
  2201. console.log('wx no code' + res.errMsg);
  2202. }
  2203. },
  2204. fail: function (res) { console.log("wx.login: failed, res=" + res); }
  2205. });
  2206. }
  2207. static ShowTxt(text) {
  2208. if (Laya.Browser.onWeiXin) {
  2209. Laya.Browser.window.wx.showToast({ title: text });
  2210. }
  2211. else {
  2212. console.log(text);
  2213. }
  2214. }
  2215. static OnShow(cb) {
  2216. if (!Laya.Browser.onWeiXin)
  2217. return;
  2218. Laya.Browser.window.wx.onShow(cb);
  2219. }
  2220. static OffShow(cb) {
  2221. if (!Laya.Browser.onWeiXin)
  2222. return;
  2223. Laya.Browser.window.wx.offShow(cb);
  2224. }
  2225. static OnHide(cb) {
  2226. if (!Laya.Browser.onWeiXin)
  2227. return;
  2228. Laya.Browser.window.wx.onHide(cb);
  2229. }
  2230. static OffHide(cb) {
  2231. if (!Laya.Browser.onWeiXin)
  2232. return;
  2233. Laya.Browser.window.wx.offHide(cb);
  2234. }
  2235. static ShortShake() {
  2236. Laya.Browser.window.wx.vibrateShort({});
  2237. }
  2238. static LongShake() {
  2239. Laya.Browser.window.wx.vibrateLong({});
  2240. }
  2241. static Shake(_short = true) {
  2242. if (Laya.Browser.onWeiXin && WXSDK.shake) {
  2243. if (_short) {
  2244. this.ShortShake();
  2245. }
  2246. else {
  2247. this.LongShake();
  2248. }
  2249. }
  2250. }
  2251. static LoadSubPackage(name, _complete) {
  2252. if (Laya.Browser.onWeiXin) {
  2253. const loadTask = Laya.Browser.window.wx.loadSubpackage({
  2254. name: 'subpackage',
  2255. success: function (res) {
  2256. _complete && _complete(true);
  2257. console.log("分包加载成功");
  2258. },
  2259. fail: function (res) {
  2260. _complete && _complete(false);
  2261. console.log("分包加载失败");
  2262. }
  2263. });
  2264. }
  2265. else {
  2266. console.log("未进行分包加载");
  2267. _complete && _complete(true);
  2268. }
  2269. }
  2270. static stageShake(callBack = null, speed = 32) {
  2271. if (this.isShake || !this.canshakestage)
  2272. return;
  2273. this.isShake = true;
  2274. var point = new Laya.Vector2(Laya.stage.x, Laya.stage.y);
  2275. Laya.stage.timerLoop(speed, this, this.shakeObject, [point, callBack]);
  2276. }
  2277. static shakeObject(_point, _callBack) {
  2278. var count = (this.num++) % 4;
  2279. this.offsetArr[this.num % 2] = count < 2 ? 0 : this.offset;
  2280. Laya.stage.x = this.offsetArr[0] + _point.x;
  2281. Laya.stage.y = this.offsetArr[1] + _point.y;
  2282. if (this.num > (this.times * 4 + 1)) {
  2283. Laya.stage.clearTimer(this, this.shakeObject);
  2284. Laya.stage.pos(0, 0);
  2285. this.num = 0;
  2286. this.isShake = false;
  2287. if (_callBack != null) {
  2288. _callBack();
  2289. }
  2290. }
  2291. }
  2292. static UpdateGuide(ShowGuide = 0) {
  2293. var kvDataList = new Array();
  2294. let date = new Date().getTime();
  2295. var myValue = JSON.stringify({
  2296. "guide": {
  2297. "ShowGuide": ShowGuide,
  2298. "update_time": date.toString()
  2299. }
  2300. });
  2301. kvDataList.push({ key: "ShowGuide", value: myValue });
  2302. if (Laya.Browser.window.wx) {
  2303. Laya.Browser.window.wx.setUserCloudStorage({
  2304. KVDataList: kvDataList,
  2305. success: r => {
  2306. console.log("KVDATALIST---", kvDataList);
  2307. console.log("上传新手指引成功:" + ShowGuide);
  2308. }
  2309. });
  2310. }
  2311. }
  2312. static UpdateScore(max_score) {
  2313. var kvDataList = new Array();
  2314. let date = new Date().getTime();
  2315. var myValue = JSON.stringify({
  2316. "wxgame": {
  2317. "max_score": max_score,
  2318. "update_time": date.toString(),
  2319. }
  2320. });
  2321. kvDataList.push({ key: "max_score", value: myValue });
  2322. if (Laya.Browser.window.wx) {
  2323. Laya.Browser.window.wx.setUserCloudStorage({
  2324. KVDataList: kvDataList,
  2325. success: r => {
  2326. console.log("KVDATALIST---", kvDataList);
  2327. console.log("上传分数成功:" + max_score);
  2328. }
  2329. });
  2330. }
  2331. }
  2332. static fengxiangtupian(callback) {
  2333. if (Laya.Browser.window.wx == null) {
  2334. return;
  2335. }
  2336. var _title = "组团一起浪";
  2337. var t = AccountManager.Instance.ServerTime;
  2338. Laya.Browser.window.wx.aldShareAppMessage({
  2339. title: _title,
  2340. imageUrl: "subpackage2/res/share/shareimage.png",
  2341. query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
  2342. });
  2343. }
  2344. static AldEvent(eventName, key = "用户id", value = "") {
  2345. }
  2346. static AldStart(stageId) {
  2347. }
  2348. static AldEnd(stageId, isComplete) {
  2349. }
  2350. }
  2351. WXSDK.codeValue = "";
  2352. WXSDK.shareOpenId = "";
  2353. WXSDK.openId = 0;
  2354. WXSDK.shareScene = "";
  2355. WXSDK.uid = "123";
  2356. WXSDK.querychannel = "";
  2357. WXSDK.referrerInfoappId = "";
  2358. WXSDK.shake = true;
  2359. WXSDK.times = 1.3;
  2360. WXSDK.num = 0;
  2361. WXSDK.offsetArr = [0, 0];
  2362. WXSDK.offset = 14;
  2363. WXSDK.canshakestage = false;
  2364. class GuangGao {
  2365. constructor() {
  2366. GuangGao.ins = this;
  2367. }
  2368. static get Instance() {
  2369. if (GuangGao.ins) {
  2370. return GuangGao.ins;
  2371. }
  2372. else {
  2373. return new GuangGao();
  2374. }
  2375. }
  2376. static InitVideo() {
  2377. if (!Laya.Browser.onWeiXin)
  2378. return;
  2379. console.log(this.bannerAdUnitId);
  2380. this.fsaasfafssfa = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: this.videlAdUnitId });
  2381. this.fsaasfafssfa.onLoad(() => {
  2382. console.log('激励视频 广告加载成功');
  2383. this.asfasfsaffsa = true;
  2384. });
  2385. this.fsaasfafssfa.onError(err => {
  2386. console.log("激励视屏加载失败:" + err);
  2387. this.asfasfsaffsa = false;
  2388. });
  2389. this.afsfsaafsfsa = true;
  2390. }
  2391. static ShowVideo(callback) {
  2392. if (this.asfasfsaffsa) {
  2393. console.log("showVideoAd:" + this.asfasfsaffsa);
  2394. this.SetVideoCallBack(callback);
  2395. this.fsaasfafssfa.show().catch(err => {
  2396. this.fsaasfafssfa.load().then(() => {
  2397. this.SetVideoCallBack(callback);
  2398. this.fsaasfafssfa.show();
  2399. });
  2400. });
  2401. }
  2402. }
  2403. static SetVideoCallBack(callback) {
  2404. this.fsaasfafssfa.offClose();
  2405. this.fsaasfafssfa.onClose(res => {
  2406. console.log("激励视频关闭:" + res.isEnded);
  2407. if (res && res.isEnded || res === undefined) {
  2408. callback && callback(true);
  2409. }
  2410. else {
  2411. callback && callback(false);
  2412. }
  2413. this.fsaasfafssfa.offClose();
  2414. });
  2415. }
  2416. static OpenBanner(gap = 0, callVack = null, iswait = false) {
  2417. if (!Laya.Browser.onWeiXin) {
  2418. if (callVack) {
  2419. callVack(null);
  2420. }
  2421. return;
  2422. }
  2423. this.canshowbanner = true;
  2424. var idd = this.bannerAdUnitId;
  2425. console.log("adUnitId:" + idd);
  2426. let newBanner = Laya.Browser.window.wx.createBannerAd({
  2427. adUnitId: idd,
  2428. style: {
  2429. left: 0,
  2430. top: 0,
  2431. width: 460
  2432. }
  2433. });
  2434. newBanner.onError(err => {
  2435. console.log("广告错误onerror--");
  2436. console.log(err);
  2437. callVack(null);
  2438. });
  2439. newBanner.onLoad(() => {
  2440. if (this.curbanner)
  2441. this.curbanner.destroy();
  2442. this.curbanner = newBanner;
  2443. var hight = this.GetRealHight(gap);
  2444. if (callVack != null) {
  2445. callVack(hight);
  2446. }
  2447. if (this.canshowbanner && !iswait) {
  2448. this.curbanner.show();
  2449. }
  2450. else {
  2451. this.curbanner.hide();
  2452. }
  2453. });
  2454. }
  2455. static GetRealHight(gap) {
  2456. if (this.curbanner) {
  2457. let info = Laya.Browser.window.wx.getSystemInfoSync();
  2458. this.curbanner.style.width = info.windowWidth;
  2459. this.curbanner.style.top = info.windowHeight - this.curbanner.style.realHeight - gap;
  2460. return Laya.stage.height / info.windowHeight * this.curbanner.style.realHeight;
  2461. }
  2462. }
  2463. static Clear() {
  2464. Laya.timer.clearAll(this);
  2465. Laya.Tween.clearAll(this);
  2466. this.canshowbanner = false;
  2467. if (this.curbanner)
  2468. this.curbanner.hide();
  2469. }
  2470. static hidebanner() {
  2471. if (!Laya.Browser.onWeiXin)
  2472. return;
  2473. if (this.curbanner)
  2474. this.curbanner.hide();
  2475. }
  2476. static showbanner() {
  2477. if (!Laya.Browser.onWeiXin)
  2478. return;
  2479. if (this.curbanner)
  2480. this.curbanner.show();
  2481. }
  2482. static get cancheat() {
  2483. return false;
  2484. }
  2485. static SetPosBanner(btn, complete) {
  2486. if (Laya.Browser.onPC) {
  2487. complete(false);
  2488. return;
  2489. }
  2490. let info = Laya.Browser.window.wx.getSystemInfoSync();
  2491. var reshight = btn.y * info.windowHeight / Laya.stage.height;
  2492. var idd = this.bannerAdUnitId;
  2493. console.log("adUnitId:" + idd);
  2494. if (this.curbanner)
  2495. this.curbanner.destroy();
  2496. let newBanner = Laya.Browser.window.wx.createBannerAd({
  2497. adUnitId: idd,
  2498. style: {
  2499. left: 0,
  2500. top: 0,
  2501. width: 720
  2502. }
  2503. });
  2504. newBanner.onError(err => {
  2505. console.log(err);
  2506. complete(false);
  2507. });
  2508. newBanner.onLoad(() => {
  2509. this.curbanner = newBanner;
  2510. this.curbanner.style.top = reshight;
  2511. if (this.curbanner) {
  2512. console.log("banner show");
  2513. this.curbanner.show();
  2514. Laya.timer.once(2300, this, () => {
  2515. this.curbanner.style.top = info.windowHeight - GuangGao.bannerhigt;
  2516. complete(true);
  2517. });
  2518. }
  2519. });
  2520. newBanner.onResize((res) => {
  2521. GuangGao.bannerhigt = res.height;
  2522. this.curbanner.style.width = info.windowWidth;
  2523. this.curbanner.style.top = reshight;
  2524. });
  2525. }
  2526. static CheatBanner(btn, complete = null, gap = 0) {
  2527. if (!AccountManager.Instance.curplayerData.Cheat) {
  2528. console.log("ignorecheat");
  2529. GuangGao.OpenBanner(0, (height) => {
  2530. if (height == null) {
  2531. console.log("banner高度为null---");
  2532. }
  2533. });
  2534. }
  2535. else {
  2536. btn.y = Laya.stage.height - btn.height - 100;
  2537. GuangGao.OpenBanner(gap, (height) => {
  2538. if (height == null) ;
  2539. else {
  2540. console.log("cheatstart", "bottom:100");
  2541. btn.mouseEnabled = false;
  2542. var end = Laya.stage.height - height - btn.height - 20;
  2543. console.log("y:" + end);
  2544. Laya.timer.once(1000, this, () => {
  2545. btn.mouseEnabled = true;
  2546. this.showbanner();
  2547. Laya.Tween.to(btn, { y: end }, 500, null, Laya.Handler.create(this, () => {
  2548. if (complete != null) {
  2549. complete();
  2550. }
  2551. }));
  2552. });
  2553. }
  2554. }, true);
  2555. }
  2556. }
  2557. showBanner(success = null, fail = null) {
  2558. if (!Laya.Browser.onWeiXin)
  2559. return;
  2560. var ran = GameTools.RandomANumber(0, 3);
  2561. let ad = GuangGao.bannerAdUnitId;
  2562. let bannerAd = Laya.Browser.window.wx.createBannerAd({
  2563. adUnitId: ad,
  2564. style: {
  2565. left: 0,
  2566. top: 0,
  2567. width: 460
  2568. }
  2569. });
  2570. bannerAd.onLoad(() => {
  2571. console.log("[LOG] Banner广告加载成功");
  2572. this.hideBanner();
  2573. this._bannerAd = bannerAd;
  2574. let info = Laya.Browser.window.wx.getSystemInfoSync();
  2575. this._bannerAd.style.width = info.windowWidth;
  2576. this._bannerAd.style.top = info.windowHeight - this._bannerAd.style.realHeight - 20;
  2577. this._bannerAd.show();
  2578. success && success(this._bannerAd);
  2579. });
  2580. bannerAd.onError(err => {
  2581. console.log("[LOG] Banner广告加载失败");
  2582. console.log(err);
  2583. fail && fail();
  2584. });
  2585. }
  2586. hideBanner() {
  2587. if (!Laya.Browser.onWeiXin)
  2588. return;
  2589. if (this._bannerAd) {
  2590. this._bannerAd.hide();
  2591. this._bannerAd.destroy();
  2592. this._bannerAd = null;
  2593. }
  2594. }
  2595. }
  2596. GuangGao.videlAdUnitId = "adunit-8feb4e40536601ff";
  2597. GuangGao.bannerAdUnitId = "adunit-426c9d6299d18f7e";
  2598. GuangGao.afsfsaafsfsa = false;
  2599. GuangGao.asfasfsaffsa = false;
  2600. GuangGao.canshowbanner = true;
  2601. GuangGao.bannerhigt = 0;
  2602. class LoadView extends ui.LoadViewUI {
  2603. constructor() {
  2604. super();
  2605. this.progressnum = 0;
  2606. this.fast = 0.07;
  2607. this.slow = 0.005;
  2608. this.End = false;
  2609. this.EndProgress = false;
  2610. LoadView.ins = this;
  2611. Laya.stage.addChild(this);
  2612. this.Init();
  2613. }
  2614. static get Instance() {
  2615. if (LoadView.ins == null) {
  2616. return new LoadView();
  2617. }
  2618. return LoadView.ins;
  2619. }
  2620. Init() {
  2621. this.Login();
  2622. Laya.timer.loop(1, this, this.UpdateProgress);
  2623. this.height = Laya.stage.height;
  2624. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  2625. this.height = Laya.stage.height;
  2626. });
  2627. }
  2628. UpdateProgress() {
  2629. if (this.progressnum <= 0.7) {
  2630. this.progressnum += this.fast;
  2631. }
  2632. else if (this.progressnum > 0.7 && this.progressnum < 0.99) {
  2633. this.progressnum += this.slow;
  2634. }
  2635. else {
  2636. if (this.End) {
  2637. this.progressnum += this.slow;
  2638. }
  2639. }
  2640. if (!this.EndProgress && this.progressnum >= 1) {
  2641. this.EndProgress = true;
  2642. this.progressnum = 1;
  2643. Laya.timer.clear(this, this.UpdateProgress);
  2644. this.LoadComplete();
  2645. }
  2646. this.jindupro.value = this.progressnum;
  2647. }
  2648. Login() {
  2649. WXSDK.AldEvent("开始登陆");
  2650. if (Laya.Browser.onWeiXin) {
  2651. this.LoginWx();
  2652. }
  2653. else {
  2654. this.LoginLocal();
  2655. }
  2656. }
  2657. LoginWx() {
  2658. if (Laya.Browser.onWeiXin) {
  2659. WXSDK.DengLu((res) => {
  2660. if (res != "error") {
  2661. WXSDK.AldEvent("微信登陆成功");
  2662. console.log("1微信登录成功:" + res);
  2663. this.LoginLocal();
  2664. }
  2665. else {
  2666. this.LoginWx();
  2667. }
  2668. });
  2669. }
  2670. else {
  2671. this.LoginLocal();
  2672. }
  2673. }
  2674. LoginLocal() {
  2675. ServerManager.Instance.Login(null, Laya.Handler.create(this, this.LoginComplete), Laya.Handler.create(this, this.LoginFail));
  2676. }
  2677. LoginComplete() {
  2678. WXSDK.AldEvent("本地服务器登陆成功");
  2679. console.log("本地服务器登陆成功");
  2680. GuangGao.InitVideo();
  2681. if (Laya.Browser.onWeiXin) {
  2682. this.LoadSubPackage();
  2683. }
  2684. else {
  2685. this.LoadScene();
  2686. }
  2687. }
  2688. LoginFail() {
  2689. console.log("本地服务器登陆失败");
  2690. }
  2691. LoadSubPackage() {
  2692. Laya.Browser.window.wx.loadSubpackage({
  2693. name: 'subpackage',
  2694. success: (res) => {
  2695. WXSDK.AldEvent("分包1加载成功");
  2696. this.LoadSubPackage2();
  2697. },
  2698. fail: (res) => {
  2699. this.LoadSubPackage();
  2700. }
  2701. });
  2702. }
  2703. LoadSubPackage2() {
  2704. Laya.Browser.window.wx.loadSubpackage({
  2705. name: 'subpackage2',
  2706. success: (res) => {
  2707. WXSDK.AldEvent("分包2加载成功");
  2708. this.LoadScene();
  2709. },
  2710. fail: (res) => {
  2711. this.LoadSubPackage2();
  2712. }
  2713. });
  2714. }
  2715. LoadScene() {
  2716. Laya.Scene3D.load(ResourcesPath.mainscene, Laya.Handler.create(this, (sprite) => {
  2717. this.mainscene = sprite;
  2718. AssetManager.Instance.mainscene = this.mainscene;
  2719. WXSDK.AldEvent("场景资源加载完毕");
  2720. this.LoadRole();
  2721. }));
  2722. console.log("场景资源加载成功");
  2723. }
  2724. LoadRole() {
  2725. var arr = [];
  2726. for (let i = 0; i < ResourcesPath.Character.length; i++) {
  2727. let item = ResourcesPath.Character[i];
  2728. arr.push(item);
  2729. }
  2730. Laya.loader.create(arr, Laya.Handler.create(this, () => {
  2731. for (let i = 0; i < ResourcesPath.Character.length; i++) {
  2732. let model = Laya.loader.getRes(ResourcesPath.Character[i]);
  2733. AssetManager.Instance.Character.set(i + 1, model);
  2734. Laya.loader.clearRes(ResourcesPath.Character[i]);
  2735. }
  2736. console.log("玩家模型加载成功");
  2737. WXSDK.AldEvent("玩家模型加载完毕");
  2738. this.LoadResources();
  2739. }));
  2740. }
  2741. LoadResources() {
  2742. var arr = [];
  2743. for (let i = 0; i < ResourcesPath.Prop.length; i++) {
  2744. let item = ResourcesPath.Prop[i];
  2745. arr.push(item);
  2746. }
  2747. Laya.loader.create(arr, Laya.Handler.create(this, () => {
  2748. arr.forEach(s => {
  2749. if (s.progress == 1) {
  2750. let sp = Laya.loader.getRes(s.url);
  2751. AssetManager.Instance.Prop.set(sp.name, sp);
  2752. }
  2753. else {
  2754. console.log(`[LOG]${s.url}加载失败`);
  2755. }
  2756. }, this);
  2757. console.log("道具模型加载成功");
  2758. WXSDK.AldEvent("道具模型加载完毕");
  2759. this.complete();
  2760. }));
  2761. }
  2762. complete() {
  2763. this.End = true;
  2764. this.slow = this.fast;
  2765. DispatcherManager.EventTrigger(EventState.LoadComplete);
  2766. }
  2767. LoadComplete() {
  2768. this.destroy();
  2769. }
  2770. }
  2771. class Main {
  2772. constructor() {
  2773. if (window["Laya3D"])
  2774. Laya3D.init(GameConfig.width, GameConfig.height);
  2775. else
  2776. Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
  2777. Laya["Physics"] && Laya["Physics"].enable();
  2778. Laya["DebugPanel"] && Laya["DebugPanel"].enable();
  2779. Laya.stage.scaleMode = GameConfig.scaleMode;
  2780. Laya.stage.screenMode = GameConfig.screenMode;
  2781. Laya.stage.alignV = GameConfig.alignV;
  2782. Laya.stage.alignH = GameConfig.alignH;
  2783. Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
  2784. if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
  2785. Laya.enableDebugPanel();
  2786. if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
  2787. Laya["PhysicsDebugDraw"].enable();
  2788. if (GameConfig.stat)
  2789. Laya.Stat.show();
  2790. Laya.alertGlobalError = true;
  2791. if (Laya.Browser.onWeiXin) {
  2792. Laya.Browser.window.wx.showShareMenu({
  2793. withShareTicket: true
  2794. });
  2795. Laya.Browser.window.wx.onShareAppMessage(function () {
  2796. return {
  2797. title: "组团一起浪",
  2798. imageUrl: "subpackage2/res/share/shareimage.png",
  2799. };
  2800. });
  2801. Laya.Browser.window.wx.onShow((option) => {
  2802. var shareTicket = option.shareTicket;
  2803. var userId = option.query.userId;
  2804. var shareTitle = option.query.shareTitle;
  2805. Main.SceneNum = option.scene;
  2806. WXSDK.querychannel = option.query.channel;
  2807. WXSDK.shareOpenId = option.query.userId;
  2808. console.log("scene:", option.scene);
  2809. if (WXSDK.querychannel != null) {
  2810. console.log("onShow channel is:", WXSDK.querychannel);
  2811. }
  2812. if (option.referrerInfo) {
  2813. WXSDK.referrerInfoappId = option.referrerInfo.appId;
  2814. console.log("onShow appId is:", option.referrerInfo.appId);
  2815. }
  2816. });
  2817. if (!Laya.Browser.onWeiXin)
  2818. return;
  2819. const updateManager = Laya.Browser.window.wx.getUpdateManager();
  2820. updateManager.onCheckForUpdate(function (res) {
  2821. console.log("最新版本:" + res.hasUpdate);
  2822. });
  2823. updateManager.onUpdateReady(function () {
  2824. Laya.Browser.window.wx.showModal({
  2825. showCancel: false,
  2826. title: '更新提示',
  2827. content: '新版本已经准备好,是否重启应用?',
  2828. success(res) {
  2829. updateManager.applyUpdate();
  2830. },
  2831. fail(res) {
  2832. updateManager.applyUpdate();
  2833. }
  2834. });
  2835. });
  2836. }
  2837. Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
  2838. }
  2839. onVersionLoaded() {
  2840. Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
  2841. }
  2842. onConfigLoaded() {
  2843. new LoadView();
  2844. }
  2845. }
  2846. Main.SceneNum = "123";
  2847. new Main();
  2848. }());
  2849. //# sourceMappingURL=bundle.js.map