bundle.js 145 KB

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