bundle.js 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962
  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 AccountUser;
  23. (function (AccountUser) {
  24. AccountUser[AccountUser["buyed_kun"] = 0] = "buyed_kun";
  25. AccountUser[AccountUser["diamond"] = 1] = "diamond";
  26. AccountUser[AccountUser["equip_themes"] = 2] = "equip_themes";
  27. AccountUser[AccountUser["favorite_times"] = 3] = "favorite_times";
  28. AccountUser[AccountUser["game_times"] = 4] = "game_times";
  29. AccountUser[AccountUser["get_themes"] = 5] = "get_themes";
  30. AccountUser[AccountUser["list_kun"] = 6] = "list_kun";
  31. AccountUser[AccountUser["moeny"] = 7] = "moeny";
  32. AccountUser[AccountUser["progress_themes"] = 8] = "progress_themes";
  33. AccountUser[AccountUser["revival"] = 9] = "revival";
  34. AccountUser[AccountUser["stage"] = 10] = "stage";
  35. })(AccountUser || (AccountUser = {}));
  36. class PlayerData {
  37. constructor(_token, _config, _appSetting, _user, _userbase, _useInvite, _user_stage = null, _user_sign, _user_achievement, lottery) {
  38. this.openid = "";
  39. this.userId = "";
  40. this.zhengshu = _token;
  41. this.netzheshe = _appSetting;
  42. this.account = _user;
  43. this.accountssss = _userbase;
  44. this.qiandao = _user_sign;
  45. this.renwu = _user_achievement;
  46. this.userId = this.account["user_id"];
  47. this.openid = this.accountssss["openid"];
  48. this.m_invite = _useInvite;
  49. this.lottery = lottery;
  50. console.log("user_id:" + this.userId);
  51. }
  52. GainCollocation(_type) {
  53. return this.peizhis[_type];
  54. }
  55. GainAccount(_type) {
  56. return this.account[_type];
  57. }
  58. get fenxiang() {
  59. return this.netzheshe["share"] == "1";
  60. }
  61. get CheckScene() {
  62. return this.netzheshe["checkscene"] == "1";
  63. }
  64. get Cheat() {
  65. return this.netzheshe["cheat"] == "1";
  66. }
  67. get Banner() {
  68. return this.netzheshe["Banner"] == "1";
  69. }
  70. get wudaoshijian() {
  71. return Number(this.netzheshe["wudaoshijian"]);
  72. }
  73. GetUser(_type) {
  74. var type = AccountUser[_type];
  75. return this.account[type];
  76. }
  77. HasGun(_id) {
  78. var data = this.GainAccount("get_themes");
  79. for (var i = 0; i < data.length; i++) {
  80. var hd = data[i];
  81. if (_id == hd) {
  82. return true;
  83. }
  84. }
  85. return false;
  86. }
  87. GetProgress(_id) {
  88. var config = this.account["progress_themes"];
  89. var progress = config[_id] ? config[_id] : 0;
  90. return progress;
  91. }
  92. get ShareTxt() {
  93. return this.netzheshe["sharecontent"];
  94. }
  95. }
  96. class Global {
  97. }
  98. Global.VERSION = "1.0.0";
  99. Global.CFG = "123";
  100. var HttpRequest = Laya.HttpRequest;
  101. var Event = Laya.Event;
  102. const JtSniperApiUrl = "https://jtsniperapi.xwxgame.com/";
  103. class JtSniper {
  104. }
  105. JtSniper.DengLu = "user/login";
  106. JtSniper.KaiShi = "game/start";
  107. JtSniper.JieShu = "game/play";
  108. JtSniper.QianDao = "sign/sign";
  109. JtSniper.Chengjiu = "achievement/getRewards";
  110. JtSniper.Config = "config/table";
  111. JtSniper.FenXiang = "fission/share";
  112. JtSniper.LiXian = "fission/offline";
  113. JtSniper.vd = "fission/vd";
  114. JtSniper.FuHuo = "game/revival";
  115. JtSniper.gadagdag = "treasure/click";
  116. JtSniper.Invite = "invite/getRewards";
  117. JtSniper.Lottery = "lottery/lottery";
  118. JtSniper.ShareGetSkin = "theme/fission";
  119. JtSniper.WearEquip = "theme/equip";
  120. JtSniper.BuyEquip = "theme/buy";
  121. JtSniper.ShouQuan = "user/auth";
  122. JtSniper.JinBi = "user/sync";
  123. class ServerManager {
  124. constructor() { }
  125. static get Instance() {
  126. if (ServerManager.ins) {
  127. return ServerManager.ins;
  128. }
  129. else {
  130. return new ServerManager();
  131. }
  132. }
  133. Login(progresscb, completecb, errorcb) {
  134. var Account = AccountManager.Instance;
  135. var ver = Global.VERSION;
  136. 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}`;
  137. let httpRequest = new HttpRequest();
  138. httpRequest.once(Event.PROGRESS, this, this.Progress, [progresscb, httpRequest]);
  139. httpRequest.once(Event.COMPLETE, this, this.Complete, [completecb, httpRequest]);
  140. httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
  141. httpRequest.send(JtSniperApiUrl + JtSniper.DengLu, Data, "post", "text");
  142. }
  143. Progress(_progresscb, _httpreq) {
  144. if (_progresscb) {
  145. _progresscb.run();
  146. }
  147. }
  148. Complete(_completecb, _httpreq) {
  149. let data = JSON.parse(_httpreq.data);
  150. console.log(data);
  151. if (data["code"] != "0") {
  152. console.log("登录异常错误!错误信息sssssssss:", _httpreq.data["code"]);
  153. return;
  154. }
  155. console.log("-----------sss", data["t"]);
  156. AccountManager.Instance.SFSFSF = data["t"];
  157. this.RessetConfig(data, _completecb);
  158. }
  159. RessetConfig(data, completecb) {
  160. AccountManager.Instance.ReSetting(data, (flag) => {
  161. if (flag) {
  162. completecb.runWith(data);
  163. }
  164. else {
  165. this.RessetConfig(data, completecb);
  166. }
  167. });
  168. }
  169. Errorcb(_errorcb, _httpreq) {
  170. if (_errorcb != null) {
  171. _errorcb.runWith(_httpreq);
  172. }
  173. }
  174. SendHttp(protocol, param, completecb, errorcb, hasToken = true) {
  175. let sfaasfsfa = "";
  176. let daadsads = JtSniperApiUrl + protocol;
  177. if (hasToken == true) {
  178. sfaasfsfa = `token=${AccountManager.Instance.curplayerData.zhengshu}&`;
  179. }
  180. if (protocol == JtSniper.KaiShi || protocol == JtSniper.JieShu || protocol == JtSniper.vd || protocol == JtSniper.Lottery || protocol == JtSniper.ShareGetSkin) {
  181. let asddsa = "abcdefghijkimnopqrstuvwxyz0123456789";
  182. let adsassda = "{";
  183. let saafsafs = "";
  184. for (let i = 0; i < 4; i++) {
  185. saafsafs += asddsa[Math.floor(Math.random() * 100) % asddsa.length];
  186. }
  187. for (let i = 0; i < param.length; i++) {
  188. for (let key in param[i]) {
  189. adsassda += `\"${key}\":\"${param[i][key]}\"`;
  190. }
  191. if (i < param.length - 1) {
  192. adsassda += ",";
  193. }
  194. else {
  195. adsassda += "}";
  196. }
  197. }
  198. sfaasfsfa += "_r=" + saafsafs + this.SFGSGSG(adsassda);
  199. }
  200. else {
  201. if (param != null) {
  202. for (let i = 0; i < param.length; i++) {
  203. for (let key in param[i]) {
  204. let val = param[i][key];
  205. sfaasfsfa += `${key}=${val}`;
  206. if (i < param.length - 1) {
  207. sfaasfsfa += "&";
  208. }
  209. }
  210. }
  211. }
  212. }
  213. let httpRequest = new HttpRequest();
  214. httpRequest.once(Event.COMPLETE, this, this.onHttpRequestComplete, [completecb, errorcb, httpRequest]);
  215. httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
  216. httpRequest.send(daadsads, sfaasfsfa, "post", "text");
  217. }
  218. onHttpRequestComplete(succeedcb, failurecb, httpRequest) {
  219. let data = JSON.parse(httpRequest.data);
  220. if (data["code"] == 0) {
  221. AccountManager.Instance.ReSetting(data);
  222. if (succeedcb != null) {
  223. succeedcb.runWith(data);
  224. }
  225. }
  226. else {
  227. if (failurecb != null) {
  228. failurecb.runWith(data);
  229. }
  230. console.log("Error! Http request complete error, code: " + data["code"] + " message: " + data["message"]);
  231. }
  232. }
  233. SFGSGSG(str) {
  234. var c1, c2, c3;
  235. var SFSFFSFSFSFS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  236. var i = 0, len = str.length, SFFSSFFS = '';
  237. while (i < len) {
  238. c1 = str.charCodeAt(i++) & 0xff;
  239. if (i == len) {
  240. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  241. SFFSSFFS += SFSFFSFSFSFS.charAt((c1 & 0x3) << 4);
  242. SFFSSFFS += "==";
  243. break;
  244. }
  245. c2 = str.charCodeAt(i++);
  246. if (i == len) {
  247. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  248. SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  249. SFFSSFFS += SFSFFSFSFSFS.charAt((c2 & 0xF) << 2);
  250. SFFSSFFS += "=";
  251. break;
  252. }
  253. c3 = str.charCodeAt(i++);
  254. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  255. SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  256. SFFSSFFS += SFSFFSFSFSFS.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
  257. SFFSSFFS += SFSFFSFSFSFS.charAt(c3 & 0x3F);
  258. }
  259. return SFFSSFFS;
  260. }
  261. }
  262. class AccountManager {
  263. constructor(_code, _userinfo, _nickname, _avatarurl, _gender, _province, _city, _country, _device, _shareid, _scene, _v) {
  264. this.createTime = Laya.timer.currTimer;
  265. AccountManager.ins = this;
  266. this.code = _code;
  267. this.userInfo = _userinfo;
  268. this.nickName = _nickname;
  269. this.avatarUrl = _avatarurl;
  270. this.gender = _gender;
  271. this.province = _province;
  272. this.city = _city;
  273. this.country = _country;
  274. this.device = _device;
  275. this.share_id = _shareid;
  276. this.scene = _scene;
  277. this.v = _v;
  278. }
  279. static get Instance() {
  280. if (AccountManager.ins == null) {
  281. new AccountManager("222222", "你找谁?", "1233", "123", 1, "中国", "上海", "上海", "iphone6s", "123", "123", "123");
  282. }
  283. return AccountManager.ins;
  284. }
  285. ReSetting(data, cb = null) {
  286. var zhengshu = data["token"];
  287. var netset = data["app_setting"];
  288. var user = data["user"];
  289. var jichu = data["user_base"];
  290. var qiandao = data["user_sign"];
  291. var chengjiu = data["user_achievement"];
  292. var invite = data["user_invite"];
  293. var lottery = data["user_lottery"];
  294. if (this.curplayerData == null) {
  295. this.curplayerData = new PlayerData(zhengshu, null, netset, user, jichu, invite, null, qiandao, chengjiu, lottery);
  296. this.JundgCfg(data.table_version, cb);
  297. }
  298. else {
  299. if (netset) {
  300. this.curplayerData.netzheshe = netset;
  301. }
  302. if (user) {
  303. this.curplayerData.account = user;
  304. }
  305. if (jichu) {
  306. this.curplayerData.accountssss = jichu;
  307. }
  308. if (qiandao) {
  309. this.curplayerData.qiandao = qiandao;
  310. }
  311. if (chengjiu) {
  312. this.curplayerData.renwu = chengjiu;
  313. }
  314. }
  315. }
  316. JundgCfg(ver, callball) {
  317. var cfg = Laya.LocalStorage.getJSON(Global.CFG);
  318. if (cfg) {
  319. if (cfg.VER == ver) {
  320. console.log("已经拥有,不用更新");
  321. this.SetCfg(cfg);
  322. if (callball)
  323. callball(true);
  324. }
  325. else {
  326. console.log("cfg存在但是过期了");
  327. Laya.LocalStorage.removeItem(Global.CFG);
  328. ServerManager.Instance.SendHttp(JtSniper.Config, null, Laya.Handler.create(this, (data) => {
  329. data.configs.VER = ver;
  330. Laya.LocalStorage.setJSON(Global.CFG, data.configs);
  331. this.SetCfg(data.configs);
  332. if (callball)
  333. callball(true);
  334. }), Laya.Handler.create(this, (data) => {
  335. console.log("配置获取失败" + data);
  336. if (callball)
  337. callball(false);
  338. return;
  339. }));
  340. }
  341. }
  342. else {
  343. console.log("本地没有cfg");
  344. ServerManager.Instance.SendHttp(JtSniper.Config, null, Laya.Handler.create(this, (data) => {
  345. data.configs.VER = ver;
  346. Laya.LocalStorage.setJSON(Global.CFG, data.configs);
  347. this.SetCfg(data.configs);
  348. if (callball)
  349. callball(true);
  350. }), Laya.Handler.create(this, (data) => {
  351. console.log("配置获取失败" + data);
  352. }));
  353. }
  354. }
  355. SetCfg(data) {
  356. this.curplayerData.peizhis = data;
  357. }
  358. RessetConfig() {
  359. ServerManager.Instance.SendHttp(JtSniper.Config, null, Laya.Handler.create(this, (data) => {
  360. this.curplayerData.peizhis = data["configs"];
  361. }), null);
  362. }
  363. get ServerTime() {
  364. let time = Laya.timer.currTimer;
  365. let stime = this.SFSFSF + Math.ceil((time - this.createTime) / 1000);
  366. return stime;
  367. }
  368. }
  369. var Vector3 = Laya.Vector3;
  370. class GameTools {
  371. constructor() {
  372. GameTools.ins = this;
  373. }
  374. static get Instance() {
  375. if (GameTools.ins) {
  376. return GameTools.ins;
  377. }
  378. else {
  379. return new GameTools();
  380. }
  381. }
  382. lerp(form, to, t) {
  383. if (t <= 0) {
  384. return form;
  385. }
  386. else if (t >= 1) {
  387. return to;
  388. }
  389. var a = t * to + (1 - t) * form;
  390. return a;
  391. }
  392. SetCollider(setNode, CollisionGroup) {
  393. var numchild = setNode.numChildren;
  394. for (var i = 0; i < setNode.numChildren; i++) {
  395. var numchild2 = setNode.getChildAt(i).numChildren;
  396. if (numchild2 > 1) {
  397. this.SetCollider(setNode.getChildAt(i), CollisionGroup);
  398. }
  399. var physicsCollider = setNode.getChildAt(i).getComponent(Laya.PhysicsCollider);
  400. if (physicsCollider) {
  401. physicsCollider.collisionGroup = CollisionGroup;
  402. }
  403. }
  404. }
  405. EnemySetCollider(setNode, collisionGroup) {
  406. var collider = setNode.getChildByName("npcfrontcollider");
  407. var collider2 = setNode.getChildByName("npcrearcollider");
  408. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  409. var physicsCollider2 = collider2.getComponent(Laya.PhysicsCollider);
  410. if (physicsCollider) {
  411. physicsCollider.collisionGroup = collisionGroup;
  412. }
  413. if (physicsCollider2) {
  414. physicsCollider2.collisionGroup = collisionGroup;
  415. }
  416. }
  417. PlayerSetCollider(setNode, collisionGroup) {
  418. var collider = setNode.getChildByName("playercollider");
  419. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  420. if (physicsCollider) {
  421. physicsCollider.collisionGroup = collisionGroup;
  422. }
  423. }
  424. HostageSetCollider(setNode, collisionGroup) {
  425. var collider = setNode.getChildByName("hostagecollider");
  426. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  427. if (physicsCollider) {
  428. physicsCollider.collisionGroup = collisionGroup;
  429. }
  430. }
  431. static RandomNumber(from, to) {
  432. if (from >= to) {
  433. return 0;
  434. }
  435. var size = to - from;
  436. var curNumber = Math.random() * size + from;
  437. return curNumber;
  438. }
  439. static RandomANumber(from, to) {
  440. if (from >= to) {
  441. return 0;
  442. }
  443. var size = to - from;
  444. var curNumber = Math.random() * size + from;
  445. return Math.floor(curNumber);
  446. }
  447. static GetMoney(_num, _pos = null, _completeHandle = null) {
  448. if (_num == 0)
  449. return;
  450. var fafaafsfa = new Laya.Box;
  451. fafaafsfa.width = 400;
  452. fafaafsfa.height = 100;
  453. fafaafsfa.pivotX = fafaafsfa.width / 2;
  454. fafaafsfa.pivotY = fafaafsfa.height / 2;
  455. if (_pos == null) {
  456. _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2);
  457. }
  458. fafaafsfa.pos(_pos.x, _pos.y);
  459. var aafafaffa = new Laya.Image;
  460. aafafaffa.skin = "game/qiandao_1_7.png";
  461. aafafaffa.width = 60;
  462. aafafaffa.height = 60;
  463. aafafaffa.left = 50;
  464. aafafaffa.y = 10;
  465. fafaafsfa.addChild(aafafaffa);
  466. var faasfafsafs = new Laya.Text;
  467. faasfafsafs.width = 300;
  468. faasfafsafs.height = 50;
  469. faasfafsafs.align = "center";
  470. faasfafsafs.valign = "middle";
  471. faasfafsafs.font = "Microsoft YaHei";
  472. faasfafsafs.fontSize = 40;
  473. faasfafsafs.color = "#FFFFFF";
  474. faasfafsafs.bold = true;
  475. faasfafsafs.font = "Microsoft YaHei";
  476. faasfafsafs.text = "金币 +" + _num;
  477. faasfafsafs.x = 60;
  478. faasfafsafs.y = 10;
  479. fafaafsfa.addChild(faasfafsafs);
  480. Laya.stage.addChild(fafaafsfa);
  481. var faasfsaf = Laya.Tween.to(fafaafsfa, { y: fafaafsfa.y - 200 }, 1500, Laya.Ease.expoInOut, Laya.Handler.create(this, () => {
  482. faasfsaf.clear();
  483. fafaafsfa.destroy();
  484. if (_completeHandle) {
  485. _completeHandle.run();
  486. }
  487. }), 100);
  488. }
  489. static TweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
  490. var afasafsafsfa = new Laya.Text();
  491. afasafsafsfa.width = faafssfafsa.size.x;
  492. afasafsafsfa.height = faafssfafsa.size.y;
  493. afasafsafsfa.align = "center";
  494. afasafsafsfa.valign = "middle";
  495. afasafsafsfa.font = "Microsoft YaHei";
  496. afasafsafsfa.fontSize = faafssfafsa.fontSize;
  497. afasafsafsfa.pivotX = afasafsafsfa.width / 2;
  498. afasafsafsfa.pivotY = afasafsafsfa.height / 2;
  499. afasafsafsfa.color = "#5ad122";
  500. afasafsafsfa.bold = true;
  501. afasafsafsfa.stroke = 5;
  502. afasafsafsfa.strokeColor = "#ffffff";
  503. if (faafssfafsa.color) {
  504. faafssfafsa.color = faafssfafsa.color;
  505. }
  506. afasafsafsfa.text = faafssfafsa.message;
  507. afasafsafsfa.zOrder = 1;
  508. Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
  509. afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
  510. var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
  511. }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
  512. tween.clear();
  513. if (hide) {
  514. afasafsafsfa.destroy();
  515. }
  516. if (_completeHandle) {
  517. _completeHandle.run();
  518. }
  519. }));
  520. if (hide) {
  521. Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 500);
  522. }
  523. return afasafsafsfa;
  524. }
  525. static StationTweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
  526. var afasafsafsfa = new Laya.Text();
  527. afasafsafsfa.width = faafssfafsa.size.x;
  528. afasafsafsfa.height = faafssfafsa.size.y;
  529. afasafsafsfa.align = "center";
  530. afasafsafsfa.valign = "middle";
  531. afasafsafsfa.font = "Microsoft YaHei";
  532. afasafsafsfa.fontSize = 50;
  533. afasafsafsfa.pivotX = afasafsafsfa.width / 2;
  534. afasafsafsfa.pivotY = afasafsafsfa.height / 2;
  535. afasafsafsfa.color = "#5ad122";
  536. afasafsafsfa.bold = true;
  537. afasafsafsfa.stroke = 5;
  538. afasafsafsfa.strokeColor = "#ffffff";
  539. if (faafssfafsa.color) {
  540. faafssfafsa.color = faafssfafsa.color;
  541. }
  542. afasafsafsfa.text = faafssfafsa.message;
  543. afasafsafsfa.zOrder = 1;
  544. Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
  545. afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
  546. var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
  547. }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
  548. tween.clear();
  549. if (hide) {
  550. afasafsafsfa.destroy();
  551. }
  552. if (_completeHandle) {
  553. _completeHandle.run();
  554. }
  555. }));
  556. if (hide) {
  557. Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 10000);
  558. }
  559. return afasafsafsfa;
  560. }
  561. static tweenMove(transform, targPos, delay, ease, complete) {
  562. let curPos = transform.position.clone();
  563. return Laya.Tween.to(curPos, {
  564. x: targPos.x,
  565. y: targPos.y,
  566. z: targPos.z,
  567. update: new Laya.Handler(this, () => {
  568. transform.position = curPos.clone();
  569. })
  570. }, delay, ease, complete);
  571. }
  572. static tweenRotate(transform, targEuler, delay, ease, complete) {
  573. let curEuler = transform.rotationEuler.clone();
  574. return Laya.Tween.to(curEuler, {
  575. x: targEuler.x,
  576. y: targEuler.y,
  577. z: targEuler.z,
  578. update: new Laya.Handler(this, () => {
  579. transform.rotationEuler = curEuler.clone();
  580. })
  581. }, delay, ease, complete);
  582. }
  583. }
  584. class ShareUtil {
  585. beginShare(callBack) {
  586. ShareUtil.beginShareTime = new Date().getTime();
  587. console.log("分享点击时间=" + ShareUtil.beginShareTime);
  588. ShareUtil.isSharing = true;
  589. ShareUtil.callback = callBack;
  590. }
  591. onRegister() {
  592. if (Laya.Browser.window.wx == null) {
  593. return;
  594. }
  595. Laya.Browser.window.wx.onShow(function (option) {
  596. console.log("onshow share start");
  597. if (ShareUtil.isSharing) {
  598. ShareUtil.isSharing = false;
  599. let time = new Date().getTime();
  600. console.log("分享回到游戏时间" + time);
  601. let wait = (time - ShareUtil.beginShareTime) / 1000;
  602. console.log("分享停留时间为:" + wait);
  603. if (wait < 3) {
  604. Laya.Browser.window.wx.showToast({ title: "请重试一次" });
  605. ShareUtil.callback(false);
  606. }
  607. else {
  608. var random = Math.random();
  609. if (random <= 0.3) {
  610. var message = ["你已分享过该群", "请重新换个群分享!", "请分享到30人大群中!"];
  611. var curmes = message[GameTools.RandomANumber(0, 2)];
  612. Laya.Browser.window.wx.showToast({ title: curmes });
  613. ShareUtil.callback(false);
  614. }
  615. else {
  616. Laya.Browser.window.wx.showToast({ title: "分享成功!" });
  617. ShareUtil.callback(true);
  618. }
  619. }
  620. }
  621. });
  622. }
  623. static ShareMessage() {
  624. if (!Laya.Browser.onWeiXin)
  625. return;
  626. var t = AccountManager.Instance.ServerTime;
  627. var _title = AccountManager.Instance.curplayerData.ShareTxt;
  628. _title = (_title == "" || !_title) ? "有人@你,快来比一比枪法" : _title;
  629. var _image = "subpackage/res/share/1.jpg";
  630. Laya.Browser.window.wx.onShareAppMessage(() => ({
  631. title: _title,
  632. imageUrl: _image,
  633. query: "shareid=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
  634. }));
  635. }
  636. static shareImage(channel, callback = null, shareType) {
  637. if (Laya.Browser.window.wx == null) {
  638. return;
  639. }
  640. var t = AccountManager.Instance.ServerTime;
  641. var _title = AccountManager.Instance.curplayerData.ShareTxt;
  642. _title = (_title == "" || !_title) ? "有人@你,快来比一比枪法" : _title;
  643. var _image = "subpackage/res/share/1.jpg";
  644. Laya.Browser.window.wx.aldShareAppMessage({
  645. title: _title,
  646. imageUrl: _image,
  647. query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + shareType + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
  648. });
  649. if (callback) {
  650. ShareUtil.Instance.beginShare(callback);
  651. }
  652. }
  653. }
  654. ShareUtil.Instance = new ShareUtil();
  655. ShareUtil.shareSuccessTime = 0;
  656. ShareUtil.isSharing = false;
  657. class WXSDK {
  658. constructor() {
  659. WXSDK.ins = this;
  660. }
  661. static get Instance() {
  662. if (WXSDK.ins) {
  663. return WXSDK.ins;
  664. }
  665. else {
  666. return new WXSDK();
  667. }
  668. }
  669. static Init() {
  670. }
  671. static DengLu(_complete) {
  672. var that = this;
  673. Laya.Browser.window.wx.login({
  674. success: function (res) {
  675. if (res.code) {
  676. ShareUtil.Instance.onRegister();
  677. console.log("微信登陆成功----");
  678. that.codeValue = res.code;
  679. console.log("shareid:" + WXSDK.shareOpenId);
  680. new AccountManager(res.code, "", "", "", 0, "", "", "", "", WXSDK.shareOpenId, WXSDK.shareOpenId, Global.VERSION);
  681. _complete(res);
  682. }
  683. else {
  684. WXSDK.DengLu(WXSDK.DengLu);
  685. console.log('wx no code' + res.errMsg);
  686. }
  687. },
  688. fail: function (res) { console.log("wx.login: failed, res=" + res); }
  689. });
  690. }
  691. static ShowTxt(text) {
  692. if (Laya.Browser.onWeiXin) {
  693. Laya.Browser.window.wx.showToast({ title: text });
  694. }
  695. else {
  696. console.log(text);
  697. }
  698. }
  699. static OnShow(cb) {
  700. if (!Laya.Browser.onWeiXin)
  701. return;
  702. Laya.Browser.window.wx.onShow(cb);
  703. }
  704. static OffShow(cb) {
  705. if (!Laya.Browser.onWeiXin)
  706. return;
  707. Laya.Browser.window.wx.offShow(cb);
  708. }
  709. static OnHide(cb) {
  710. if (!Laya.Browser.onWeiXin)
  711. return;
  712. Laya.Browser.window.wx.onHide(cb);
  713. }
  714. static OffHide(cb) {
  715. if (!Laya.Browser.onWeiXin)
  716. return;
  717. Laya.Browser.window.wx.offHide(cb);
  718. }
  719. static ShortShake() {
  720. Laya.Browser.window.wx.vibrateShort({});
  721. }
  722. static LongShake() {
  723. Laya.Browser.window.wx.vibrateLong({});
  724. }
  725. static Shake(_short = true) {
  726. if (Laya.Browser.onWeiXin && WXSDK.shake) {
  727. if (_short) {
  728. this.ShortShake();
  729. }
  730. else {
  731. this.LongShake();
  732. }
  733. }
  734. }
  735. static LoadSubPackage(name, _complete) {
  736. if (Laya.Browser.onWeiXin) {
  737. const loadTask = Laya.Browser.window.wx.loadSubpackage({
  738. name: 'subpackage',
  739. success: function (res) {
  740. _complete && _complete(true);
  741. console.log("分包加载成功");
  742. },
  743. fail: function (res) {
  744. _complete && _complete(false);
  745. console.log("分包加载失败");
  746. }
  747. });
  748. }
  749. else {
  750. console.log("未进行分包加载");
  751. _complete && _complete(true);
  752. }
  753. }
  754. static stageShake(callBack = null, speed = 32) {
  755. if (this.isShake || !this.canshakestage)
  756. return;
  757. this.isShake = true;
  758. var point = new Laya.Vector2(Laya.stage.x, Laya.stage.y);
  759. Laya.stage.timerLoop(speed, this, this.shakeObject, [point, callBack]);
  760. }
  761. static shakeObject(_point, _callBack) {
  762. var count = (this.num++) % 4;
  763. this.offsetArr[this.num % 2] = count < 2 ? 0 : this.offset;
  764. Laya.stage.x = this.offsetArr[0] + _point.x;
  765. Laya.stage.y = this.offsetArr[1] + _point.y;
  766. if (this.num > (this.times * 4 + 1)) {
  767. Laya.stage.clearTimer(this, this.shakeObject);
  768. Laya.stage.pos(0, 0);
  769. this.num = 0;
  770. this.isShake = false;
  771. if (_callBack != null) {
  772. _callBack();
  773. }
  774. }
  775. }
  776. static UpdateGuide(ShowGuide = 0) {
  777. var kvDataList = new Array();
  778. let date = new Date().getTime();
  779. var myValue = JSON.stringify({
  780. "guide": {
  781. "ShowGuide": ShowGuide,
  782. "update_time": date.toString()
  783. }
  784. });
  785. kvDataList.push({ key: "ShowGuide", value: myValue });
  786. if (Laya.Browser.window.wx) {
  787. Laya.Browser.window.wx.setUserCloudStorage({
  788. KVDataList: kvDataList,
  789. success: r => {
  790. console.log("KVDATALIST---", kvDataList);
  791. console.log("上传新手指引成功:" + ShowGuide);
  792. }
  793. });
  794. }
  795. }
  796. static UpdateScore(max_score) {
  797. var kvDataList = new Array();
  798. let date = new Date().getTime();
  799. var myValue = JSON.stringify({
  800. "wxgame": {
  801. "max_score": max_score,
  802. "update_time": date.toString(),
  803. }
  804. });
  805. kvDataList.push({ key: "max_score", value: myValue });
  806. if (Laya.Browser.window.wx) {
  807. Laya.Browser.window.wx.setUserCloudStorage({
  808. KVDataList: kvDataList,
  809. success: r => {
  810. console.log("KVDATALIST---", kvDataList);
  811. console.log("上传分数成功:" + max_score);
  812. }
  813. });
  814. }
  815. }
  816. static fengxiangtupian(callback) {
  817. if (Laya.Browser.window.wx == null) {
  818. return;
  819. }
  820. var _title = "有人@你,一起骑马仗箭走天涯";
  821. var t = AccountManager.Instance.ServerTime;
  822. Laya.Browser.window.wx.aldShareAppMessage({
  823. title: _title,
  824. imageUrl: "Game/res/textrue/share.jpg",
  825. query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
  826. });
  827. }
  828. static AldEvent(eventName, key = "用户id", value = "") {
  829. if (!Laya.Browser.onWeiXin)
  830. return;
  831. Laya.Browser.window.wx.aldSendEvent(eventName, { key: value });
  832. }
  833. static AldStart(stageId) {
  834. if (!Laya.Browser.onWeiXin)
  835. return;
  836. Laya.Browser.window.wx.aldStage.onStart({
  837. stageId: stageId,
  838. stageName: "第" + stageId + "关",
  839. });
  840. }
  841. static AldEnd(stageId, isComplete) {
  842. if (!Laya.Browser.onWeiXin)
  843. return;
  844. let event = isComplete ? "complete" : "fail";
  845. let desc = isComplete ? "关卡完成" : "关卡失败";
  846. Laya.Browser.window.wx.aldStage.onEnd({
  847. stageId: stageId,
  848. stageName: "第" + stageId + "关",
  849. event: event,
  850. params: {
  851. desc: desc
  852. }
  853. });
  854. }
  855. }
  856. WXSDK.codeValue = "";
  857. WXSDK.shareOpenId = "";
  858. WXSDK.openId = 0;
  859. WXSDK.shareScene = "";
  860. WXSDK.uid = "123";
  861. WXSDK.querychannel = "";
  862. WXSDK.referrerInfoappId = "";
  863. WXSDK.shake = true;
  864. WXSDK.times = 1.3;
  865. WXSDK.num = 0;
  866. WXSDK.offsetArr = [0, 0];
  867. WXSDK.offset = 14;
  868. WXSDK.canshakestage = false;
  869. var REG = Laya.ClassUtils.regClass;
  870. var ui;
  871. (function (ui) {
  872. class HomeViewUI extends Laya.Scene {
  873. constructor() { super(); }
  874. createChildren() {
  875. super.createChildren();
  876. this.createView(HomeViewUI.uiView);
  877. }
  878. }
  879. HomeViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Button", "props": { "y": 815, "x": 180, "var": "StartBtn", "stateNum": 1, "skin": "Main/zhujiemian-1-4.png" }, "compId": 7 }], "loadList": ["Main/zhujiemian-1-4.png"], "loadList3D": [] };
  880. ui.HomeViewUI = HomeViewUI;
  881. REG("ui.HomeViewUI", HomeViewUI);
  882. class InGameViewUI extends Laya.Scene {
  883. constructor() { super(); }
  884. createChildren() {
  885. super.createChildren();
  886. this.createView(InGameViewUI.uiView);
  887. }
  888. }
  889. InGameViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "y": 979, "x": 447, "var": "hand", "skin": "Main/IconHand.png", "anchorY": 0.5, "anchorX": 0.5 }, "compId": 6 }], "animations": [{ "nodes": [{ "target": 6, "keyframes": { "scaleY": [{ "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleY", "index": 0 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleY", "index": 5 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleY", "index": 10 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleY", "index": 15 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleY", "index": 20 }], "scaleX": [{ "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleX", "index": 0 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleX", "index": 5 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleX", "index": 10 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleX", "index": 15 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "scaleX", "index": 20 }] } }], "name": "click", "id": 1, "frameRate": 24, "action": 0 }], "loadList": ["Main/IconHand.png"], "loadList3D": [] };
  890. ui.InGameViewUI = InGameViewUI;
  891. REG("ui.InGameViewUI", InGameViewUI);
  892. class LoadViewUI extends Laya.Scene {
  893. constructor() { super(); }
  894. createChildren() {
  895. super.createChildren();
  896. this.createView(LoadViewUI.uiView);
  897. }
  898. }
  899. LoadViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Load/jiazai-1-5.png", "sizeGrid": "10,14,12,10", "right": 0, "left": 0, "bottom": 0 }, "compId": 4 }, { "type": "ProgressBar", "props": { "y": 868, "x": 167, "var": "jindupro", "skin": "Load/jiazai-1-4.png" }, "compId": 3 }], "loadList": ["Load/jiazai-1-5.png", "Load/jiazai-1-4.png"], "loadList3D": [] };
  900. ui.LoadViewUI = LoadViewUI;
  901. REG("ui.LoadViewUI", LoadViewUI);
  902. })(ui || (ui = {}));
  903. class GuangGao {
  904. constructor() {
  905. GuangGao.ins = this;
  906. }
  907. static get Instance() {
  908. if (GuangGao.ins) {
  909. return GuangGao.ins;
  910. }
  911. else {
  912. return new GuangGao();
  913. }
  914. }
  915. static InitVideo() {
  916. if (!Laya.Browser.onWeiXin)
  917. return;
  918. console.log(this.bannerAdUnitId);
  919. this.fsaasfafssfa = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: this.videlAdUnitId });
  920. this.fsaasfafssfa.onLoad(() => {
  921. console.log('激励视频 广告加载成功');
  922. this.asfasfsaffsa = true;
  923. });
  924. this.fsaasfafssfa.onError(err => {
  925. console.log("激励视屏加载失败:" + err);
  926. this.asfasfsaffsa = false;
  927. });
  928. this.afsfsaafsfsa = true;
  929. }
  930. static ShowVideo(callback) {
  931. if (this.asfasfsaffsa) {
  932. console.log("showVideoAd:" + this.asfasfsaffsa);
  933. this.SetVideoCallBack(callback);
  934. this.fsaasfafssfa.show().catch(err => {
  935. this.fsaasfafssfa.load().then(() => {
  936. this.SetVideoCallBack(callback);
  937. this.fsaasfafssfa.show();
  938. });
  939. });
  940. }
  941. }
  942. static SetVideoCallBack(callback) {
  943. this.fsaasfafssfa.offClose();
  944. this.fsaasfafssfa.onClose(res => {
  945. console.log("激励视频关闭:" + res.isEnded);
  946. if (res && res.isEnded || res === undefined) {
  947. callback && callback(true);
  948. }
  949. else {
  950. callback && callback(false);
  951. }
  952. this.fsaasfafssfa.offClose();
  953. });
  954. }
  955. static OpenBanner(gap = 0, callVack = null, iswait = false) {
  956. if (!Laya.Browser.onWeiXin) {
  957. if (callVack) {
  958. callVack(null);
  959. }
  960. return;
  961. }
  962. this.canshowbanner = true;
  963. var idd = this.bannerAdUnitId;
  964. console.log("adUnitId:" + idd);
  965. let newBanner = Laya.Browser.window.wx.createBannerAd({
  966. adUnitId: idd,
  967. style: {
  968. left: 0,
  969. top: 0,
  970. width: 460
  971. }
  972. });
  973. newBanner.onError(err => {
  974. console.log("广告错误onerror--");
  975. console.log(err);
  976. callVack(null);
  977. });
  978. newBanner.onLoad(() => {
  979. if (this.curbanner)
  980. this.curbanner.destroy();
  981. this.curbanner = newBanner;
  982. var hight = this.GetRealHight(gap);
  983. if (callVack != null) {
  984. callVack(hight);
  985. }
  986. if (this.canshowbanner && !iswait) {
  987. this.curbanner.show();
  988. }
  989. else {
  990. this.curbanner.hide();
  991. }
  992. });
  993. }
  994. static GetRealHight(gap) {
  995. if (this.curbanner) {
  996. let info = Laya.Browser.window.wx.getSystemInfoSync();
  997. this.curbanner.style.width = info.windowWidth;
  998. this.curbanner.style.top = info.windowHeight - this.curbanner.style.realHeight - gap;
  999. return Laya.stage.height / info.windowHeight * this.curbanner.style.realHeight;
  1000. }
  1001. }
  1002. static Clear() {
  1003. Laya.timer.clearAll(this);
  1004. Laya.Tween.clearAll(this);
  1005. this.canshowbanner = false;
  1006. if (this.curbanner)
  1007. this.curbanner.hide();
  1008. }
  1009. static hidebanner() {
  1010. if (!Laya.Browser.onWeiXin)
  1011. return;
  1012. if (this.curbanner)
  1013. this.curbanner.hide();
  1014. }
  1015. static showbanner() {
  1016. if (!Laya.Browser.onWeiXin)
  1017. return;
  1018. if (this.curbanner)
  1019. this.curbanner.show();
  1020. }
  1021. static get cancheat() {
  1022. return false;
  1023. }
  1024. static SetPosBanner(btn, complete) {
  1025. if (Laya.Browser.onPC) {
  1026. complete(false);
  1027. return;
  1028. }
  1029. let info = Laya.Browser.window.wx.getSystemInfoSync();
  1030. var reshight = btn.y * info.windowHeight / Laya.stage.height;
  1031. var idd = this.bannerAdUnitId;
  1032. console.log("adUnitId:" + idd);
  1033. if (this.curbanner)
  1034. this.curbanner.destroy();
  1035. let newBanner = Laya.Browser.window.wx.createBannerAd({
  1036. adUnitId: idd,
  1037. style: {
  1038. left: 0,
  1039. top: 0,
  1040. width: 720
  1041. }
  1042. });
  1043. newBanner.onError(err => {
  1044. console.log(err);
  1045. complete(false);
  1046. });
  1047. newBanner.onLoad(() => {
  1048. this.curbanner = newBanner;
  1049. this.curbanner.style.top = reshight;
  1050. if (this.curbanner) {
  1051. console.log("banner show");
  1052. this.curbanner.show();
  1053. Laya.timer.once(2300, this, () => {
  1054. this.curbanner.style.top = info.windowHeight - GuangGao.bannerhigt;
  1055. complete(true);
  1056. });
  1057. }
  1058. });
  1059. newBanner.onResize((res) => {
  1060. GuangGao.bannerhigt = res.height;
  1061. this.curbanner.style.width = info.windowWidth;
  1062. this.curbanner.style.top = reshight;
  1063. });
  1064. }
  1065. static CheatBanner(btn, complete = null, gap = 0) {
  1066. if (!AccountManager.Instance.curplayerData.Cheat) {
  1067. console.log("ignorecheat");
  1068. GuangGao.OpenBanner(0, (height) => {
  1069. if (height == null) {
  1070. console.log("banner高度为null---");
  1071. }
  1072. });
  1073. }
  1074. else {
  1075. btn.y = Laya.stage.height - btn.height - 100;
  1076. GuangGao.OpenBanner(gap, (height) => {
  1077. if (height == null) ;
  1078. else {
  1079. console.log("cheatstart", "bottom:100");
  1080. btn.mouseEnabled = false;
  1081. var end = Laya.stage.height - height - btn.height - 20;
  1082. console.log("y:" + end);
  1083. Laya.timer.once(1000, this, () => {
  1084. btn.mouseEnabled = true;
  1085. this.showbanner();
  1086. Laya.Tween.to(btn, { y: end }, 500, null, Laya.Handler.create(this, () => {
  1087. if (complete != null) {
  1088. complete();
  1089. }
  1090. }));
  1091. });
  1092. }
  1093. }, true);
  1094. }
  1095. }
  1096. showBanner(success = null, fail = null) {
  1097. if (!Laya.Browser.onWeiXin)
  1098. return;
  1099. var ran = GameTools.RandomANumber(0, 3);
  1100. let ad = GuangGao.bannerAdUnitId;
  1101. let bannerAd = Laya.Browser.window.wx.createBannerAd({
  1102. adUnitId: ad,
  1103. style: {
  1104. left: 0,
  1105. top: 0,
  1106. width: 460
  1107. }
  1108. });
  1109. bannerAd.onLoad(() => {
  1110. console.log("[LOG] Banner广告加载成功");
  1111. this.hideBanner();
  1112. this._bannerAd = bannerAd;
  1113. let info = Laya.Browser.window.wx.getSystemInfoSync();
  1114. this._bannerAd.style.width = info.windowWidth;
  1115. this._bannerAd.style.top = info.windowHeight - this._bannerAd.style.realHeight - 20;
  1116. this._bannerAd.show();
  1117. success && success(this._bannerAd);
  1118. });
  1119. bannerAd.onError(err => {
  1120. console.log("[LOG] Banner广告加载失败");
  1121. console.log(err);
  1122. fail && fail();
  1123. });
  1124. }
  1125. hideBanner() {
  1126. if (!Laya.Browser.onWeiXin)
  1127. return;
  1128. if (this._bannerAd) {
  1129. this._bannerAd.hide();
  1130. this._bannerAd.destroy();
  1131. this._bannerAd = null;
  1132. }
  1133. }
  1134. }
  1135. GuangGao.videlAdUnitId = "adunit-8feb4e40536601ff";
  1136. GuangGao.bannerAdUnitId = "adunit-426c9d6299d18f7e";
  1137. GuangGao.afsfsaafsfsa = false;
  1138. GuangGao.asfasfsaffsa = false;
  1139. GuangGao.canshowbanner = true;
  1140. GuangGao.bannerhigt = 0;
  1141. class ResourcesPath {
  1142. }
  1143. ResourcesPath.mainscene = "subpackage/mainscene/LayaScene_mainscene/Conventional/mainscene.ls";
  1144. ResourcesPath.Character = [
  1145. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character1.lh",
  1146. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character2.lh",
  1147. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character3.lh",
  1148. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character4.lh",
  1149. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character5.lh",
  1150. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character6.lh",
  1151. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character7.lh",
  1152. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character8.lh",
  1153. "subpackage/gameresources/LayaScene_gameresources/Conventional/Character9.lh"
  1154. ];
  1155. ResourcesPath.Prop = [
  1156. "subpackage/gameresources/LayaScene_gameresources/Conventional/CheckPoint1.lh",
  1157. "subpackage/gameresources/LayaScene_gameresources/Conventional/CheckPoint2.lh",
  1158. "subpackage/gameresources/LayaScene_gameresources/Conventional/FinishCircle.lh",
  1159. "subpackage/gameresources/LayaScene_gameresources/Conventional/FinishCircle2.lh",
  1160. "subpackage/gameresources/LayaScene_gameresources/Conventional/magnet.lh",
  1161. "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail1.lh",
  1162. "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail2.lh",
  1163. "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail3.lh",
  1164. "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail4.lh",
  1165. "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail5.lh",
  1166. "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail6.lh",
  1167. "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail7.lh"
  1168. ];
  1169. class Dictionary {
  1170. constructor() {
  1171. this._items = {};
  1172. this.length = 0;
  1173. }
  1174. get container() {
  1175. return this._items;
  1176. }
  1177. has(key) {
  1178. return this._items.hasOwnProperty(key);
  1179. }
  1180. set(key, val) {
  1181. if (!this.has(key)) {
  1182. this.length++;
  1183. }
  1184. this._items[key] = val;
  1185. }
  1186. delete(key) {
  1187. let val = null;
  1188. if (this.has(key)) {
  1189. val = this._items[key];
  1190. delete this._items[key];
  1191. this.length--;
  1192. }
  1193. return val;
  1194. }
  1195. get(key) {
  1196. return this.has(key) ? this._items[key] : null;
  1197. }
  1198. values() {
  1199. let values = [];
  1200. for (let k in this._items) {
  1201. if (this.has(k)) {
  1202. values.push(this._items[k]);
  1203. }
  1204. }
  1205. return values;
  1206. }
  1207. keys() {
  1208. let keys = [];
  1209. for (let k in this._items) {
  1210. if (this.has(k)) {
  1211. keys.push(k);
  1212. }
  1213. }
  1214. return keys;
  1215. }
  1216. clear() {
  1217. this._items = {};
  1218. this.length = 0;
  1219. }
  1220. }
  1221. class NodeUtil {
  1222. static GetChild(node, cond) {
  1223. let queue = [];
  1224. for (let i = 0; i < node.numChildren; i++) {
  1225. queue.push(node.getChildAt(i));
  1226. }
  1227. while (queue.length > 0) {
  1228. let first = queue.shift();
  1229. if (cond(first)) {
  1230. return first;
  1231. }
  1232. else {
  1233. for (let i = 0; i < first.numChildren; i++) {
  1234. queue.push(first.getChildAt(i));
  1235. }
  1236. }
  1237. }
  1238. return null;
  1239. }
  1240. static GetChildByName(node, name) {
  1241. return NodeUtil.GetChild(node, s => s.name == name);
  1242. }
  1243. static getChildren(node, cond) {
  1244. let finded = [];
  1245. let queue = [];
  1246. for (let i = 0; i < node.numChildren; i++) {
  1247. queue.push(node.getChildAt(i));
  1248. }
  1249. while (queue.length > 0) {
  1250. let first = queue.shift();
  1251. if (cond(first)) {
  1252. finded.push(first);
  1253. }
  1254. for (let i = 0; i < first.numChildren; i++) {
  1255. queue.push(first.getChildAt(i));
  1256. }
  1257. }
  1258. return finded;
  1259. }
  1260. static SetColliderInactive(sp) {
  1261. let colliders = NodeUtil.getChildren(sp, s => s.getComponent(Laya.PhysicsCollider));
  1262. colliders.forEach(s => {
  1263. let collider = s.getComponent(Laya.PhysicsCollider);
  1264. if (collider) {
  1265. collider.enabled = false;
  1266. }
  1267. }, this);
  1268. }
  1269. static SetColliderGroup(sp, _group) {
  1270. let colliders = NodeUtil.getChildren(sp, s => s.getComponent(Laya.PhysicsCollider));
  1271. colliders.forEach(s => {
  1272. let collisionGroup = _group;
  1273. let collider = s.getComponent(Laya.PhysicsCollider);
  1274. collider.collisionGroup = collisionGroup;
  1275. }, this);
  1276. }
  1277. }
  1278. NodeUtil.All = Laya.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER;
  1279. NodeUtil.Body = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER1;
  1280. NodeUtil.Head = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER2;
  1281. NodeUtil.Citizen = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER3;
  1282. class Transform3DHelper {
  1283. static getForward(transform) {
  1284. let forward = new Laya.Vector3();
  1285. transform.getForward(forward);
  1286. Laya.Vector3.scale(forward, -1, forward);
  1287. Laya.Vector3.normalize(forward, forward);
  1288. return forward;
  1289. }
  1290. }
  1291. var EventState;
  1292. (function (EventState) {
  1293. EventState[EventState["LoadComplete"] = 0] = "LoadComplete";
  1294. EventState[EventState["SceneInit"] = 1] = "SceneInit";
  1295. EventState[EventState["StageInit"] = 2] = "StageInit";
  1296. EventState[EventState["ShowModel"] = 3] = "ShowModel";
  1297. })(EventState || (EventState = {}));
  1298. var StageState;
  1299. (function (StageState) {
  1300. StageState[StageState["Win"] = 0] = "Win";
  1301. StageState[StageState["Lose"] = 1] = "Lose";
  1302. StageState[StageState["Start"] = 2] = "Start";
  1303. StageState[StageState["BackMain"] = 3] = "BackMain";
  1304. StageState[StageState["StageCreateComPlete"] = 4] = "StageCreateComPlete";
  1305. StageState[StageState["Over"] = 5] = "Over";
  1306. StageState[StageState["Pause"] = 6] = "Pause";
  1307. StageState[StageState["Resume"] = 7] = "Resume";
  1308. })(StageState || (StageState = {}));
  1309. class DispatcherManager {
  1310. static EventOn(_mode, caller, fun, args = []) {
  1311. DispatcherManager.instance.on(EventState[_mode], caller, fun, args);
  1312. }
  1313. static EventOff(_mode, caller, fun, args = []) {
  1314. DispatcherManager.instance.off(EventState[_mode], caller, fun);
  1315. }
  1316. static EventTrigger(_mode, args = []) {
  1317. DispatcherManager.instance.event(EventState[_mode], args);
  1318. }
  1319. static StageOn(_mode, caller, fun, args = []) {
  1320. DispatcherManager.instance.on(StageState[_mode], caller, fun, args);
  1321. }
  1322. static StageOff(_mode, caller, fun, args = []) {
  1323. DispatcherManager.instance.off(StageState[_mode], caller, fun);
  1324. }
  1325. static StageTrigger(_mode, args = []) {
  1326. DispatcherManager.instance.event(StageState[_mode], args);
  1327. }
  1328. }
  1329. DispatcherManager.instance = new Laya.EventDispatcher();
  1330. var Vector3$1 = Laya.Vector3;
  1331. class RoleMoveBehav extends Laya.Script3D {
  1332. constructor() {
  1333. super();
  1334. this.start = false;
  1335. this.Downhit = new Laya.HitResult();
  1336. this.FowardHit = new Laya.HitResult();
  1337. this.isdead = false;
  1338. this.curpos = new Vector3$1();
  1339. this.offest = new Vector3$1();
  1340. this.curspeed = 0;
  1341. }
  1342. onAwake() {
  1343. this.m_player = this.owner;
  1344. DispatcherManager.StageOn(StageState.Start, this, this.Start);
  1345. }
  1346. Start() {
  1347. this.start = true;
  1348. }
  1349. onUpdate() {
  1350. if (!this.start)
  1351. return;
  1352. if (this.isdead) {
  1353. this.ChangeDeadState();
  1354. return;
  1355. }
  1356. if (this.DownRayCheck) ;
  1357. else {
  1358. this.isdead = true;
  1359. }
  1360. if (this.FowardRayCheck) ;
  1361. let foward = Transform3DHelper.getForward(this.m_player.transform);
  1362. this.Move(foward, 0.2);
  1363. }
  1364. Move(_dir, _speed) {
  1365. var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
  1366. this.curspeed = sp;
  1367. Vector3$1.scale(_dir, this.curspeed, this.offest);
  1368. Vector3$1.add(this.m_player.transform.position, this.offest, this.curpos);
  1369. Vector3$1.lerp(this.m_player.transform.position, this.curpos, 0.15, this.curpos);
  1370. this.curpos = new Vector3$1(this.curpos.x, this.curpos.y, this.curpos.z);
  1371. this.m_player.transform.position = this.curpos;
  1372. }
  1373. MoveRayJupde() {
  1374. var isDownHit = false;
  1375. var hitResult = new Laya.HitResult();
  1376. var boxCollider = new Laya.BoxColliderShape(0.2, 0.2, 0.2);
  1377. var from = new Vector3$1(this.m_player.transform.position.x, this.m_player.transform.position.y + 0.5, this.m_player.transform.position.z);
  1378. var dir = new Vector3$1(0, -100, 0);
  1379. var to = new Vector3$1(0, 0, 0);
  1380. Vector3$1.add(from, dir, to);
  1381. if (AssetManager.Instance.mainscene.physicsSimulation.shapeCast(boxCollider, from, to, hitResult)) {
  1382. if (hitResult != null) {
  1383. if (this.Downhit.collider.collisionGroup == 1) {
  1384. isDownHit = true;
  1385. }
  1386. }
  1387. }
  1388. return isDownHit;
  1389. }
  1390. get DownRayCheck() {
  1391. var isDownHit = false;
  1392. var boxCollider = new Laya.BoxColliderShape(0.2, 0.2, 0.2);
  1393. var from = new Vector3$1(this.m_player.transform.position.x, this.m_player.transform.position.y + 0.5, this.m_player.transform.position.z);
  1394. var dir = new Vector3$1(0, -100, 0);
  1395. var to = new Vector3$1(0, 0, 0);
  1396. Vector3$1.add(from, dir, to);
  1397. if (AssetManager.Instance.mainscene.physicsSimulation.shapeCast(boxCollider, from, to, this.Downhit)) {
  1398. if (this.Downhit != null) {
  1399. console.log("111111111111", this.Downhit.collider.owner.name);
  1400. if (this.Downhit.collider.collisionGroup == 1 || this.Downhit.collider.collisionGroup == 100) {
  1401. isDownHit = true;
  1402. }
  1403. }
  1404. }
  1405. return isDownHit;
  1406. }
  1407. get FowardRayCheck() {
  1408. var isFowardHit = false;
  1409. var startPos = new Vector3$1(this.m_player.transform.position.x, this.m_player.transform.position.y + 0.5, this.m_player.transform.position.z + 0.2);
  1410. let foward = Transform3DHelper.getForward(this.m_player.transform);
  1411. var FowardRay = new Laya.Ray(startPos, foward);
  1412. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this.FowardHit, 1)) {
  1413. if (this.FowardHit) {
  1414. console.log(this.FowardHit.collider.owner.name);
  1415. console.log("前方有物体");
  1416. }
  1417. if (this.FowardHit.collider.collisionGroup == 100) {
  1418. console.log("射线打到npc了");
  1419. this.ForwardTarget = this.FowardHit.collider;
  1420. isFowardHit = true;
  1421. }
  1422. }
  1423. return isFowardHit;
  1424. }
  1425. ChangeDeadState() {
  1426. this.destroy();
  1427. }
  1428. }
  1429. class PlayerManager {
  1430. constructor() {
  1431. this.trun = true;
  1432. this.first = true;
  1433. PlayerManager.ins = this;
  1434. }
  1435. static get Instance() {
  1436. if (PlayerManager.ins == null) {
  1437. return new PlayerManager();
  1438. }
  1439. return PlayerManager.ins;
  1440. }
  1441. Init() {
  1442. if (this.PlayerNode == null) {
  1443. this.PlayerNode = new Laya.Sprite3D();
  1444. LevelManager.Instance.spritepool.addChild(this.PlayerNode);
  1445. if (this.player == null) {
  1446. let playerpref = AssetManager.Instance.Character.get(2);
  1447. this.player = Laya.Sprite3D.instantiate(playerpref);
  1448. this.PlayerNode.addChild(this.player);
  1449. }
  1450. }
  1451. this.PlayerNode.transform.position = AssetManager.Instance.playerpos.transform.position.clone();
  1452. this.PlayerNode.transform.rotation = AssetManager.Instance.playerpos.transform.rotation.clone();
  1453. this.player.transform.localPosition = new Laya.Vector3(0, 0, 0);
  1454. }
  1455. EnablePlayer() {
  1456. this.PlayerNode.addComponent(RoleMoveBehav);
  1457. Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.OnMouseDown);
  1458. }
  1459. DisablePlayer() {
  1460. let _move = this.PlayerNode.getComponent(RoleMoveBehav);
  1461. if (_move) {
  1462. _move.destroy();
  1463. }
  1464. Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.OnMouseDown);
  1465. }
  1466. OnMouseDown() {
  1467. if (this.first) {
  1468. this.first = false;
  1469. return;
  1470. }
  1471. if (this.trun) {
  1472. this.PlayerNode.transform.rotationEuler = new Laya.Vector3(0, -90, 0);
  1473. this.trun = !this.trun;
  1474. }
  1475. else {
  1476. this.PlayerNode.transform.rotationEuler = new Laya.Vector3(0, 0, 0);
  1477. this.trun = !this.trun;
  1478. }
  1479. }
  1480. }
  1481. class LevelManager {
  1482. constructor() {
  1483. LevelManager.ins = this;
  1484. }
  1485. static get Instance() {
  1486. if (LevelManager.ins == null) {
  1487. return new LevelManager();
  1488. }
  1489. return LevelManager.ins;
  1490. }
  1491. RegEvent() {
  1492. DispatcherManager.StageOn(StageState.Lose, this, this.GameLose);
  1493. DispatcherManager.StageOn(StageState.Win, this, this.GameWin);
  1494. DispatcherManager.StageOn(StageState.Pause, this, this.GamePause);
  1495. DispatcherManager.StageOn(StageState.Resume, this, this.GameResume);
  1496. }
  1497. GameStart() {
  1498. PlayerManager.Instance.Init();
  1499. PlayerManager.Instance.EnablePlayer();
  1500. }
  1501. GameLose() {
  1502. }
  1503. GameWin() {
  1504. }
  1505. GamePause() {
  1506. }
  1507. GameResume() {
  1508. }
  1509. }
  1510. class CameraManager {
  1511. constructor() {
  1512. this.poschazhi = new Laya.Vector3();
  1513. this.gengsuipos = new Laya.Vector3();
  1514. this.lllpos = new Laya.Vector3();
  1515. this.hights = 0;
  1516. this.wights = 0;
  1517. CameraManager.ins = this;
  1518. DispatcherManager.StageOn(StageState.Start, this, this.CameraFollow);
  1519. DispatcherManager.StageOn(StageState.Win, this, this.CameraCancelFollow);
  1520. DispatcherManager.StageOn(StageState.Lose, this, this.CameraCancelFollow);
  1521. }
  1522. static get Instance() {
  1523. if (CameraManager.ins == null) {
  1524. return new CameraManager();
  1525. }
  1526. return CameraManager.ins;
  1527. }
  1528. Init() {
  1529. }
  1530. CameraFollow() {
  1531. this.hights = 0;
  1532. this.wights = 0;
  1533. Laya.Vector3.subtract(PlayerManager.Instance.PlayerNode.transform.position, this.camera.transform.position, this.poschazhi);
  1534. Laya.timer.frameLoop(1, this, this.GenSui);
  1535. }
  1536. GenSui() {
  1537. Laya.Vector3.subtract(PlayerManager.Instance.PlayerNode.transform.position, this.poschazhi, this.gengsuipos);
  1538. this.hights = GameTools.Instance.lerp(this.hights, 1, 0.03);
  1539. this.wights = GameTools.Instance.lerp(this.wights, 0.8, 0.02);
  1540. this.gengsuipos = new Laya.Vector3(this.gengsuipos.x, this.gengsuipos.y, this.gengsuipos.z);
  1541. Laya.Vector3.lerp(this.camera.transform.position, this.gengsuipos, 0.25, this.lllpos);
  1542. this.lllpos = new Laya.Vector3(this.gengsuipos.x, this.lllpos.y, this.lllpos.z);
  1543. this.camera.transform.position = this.lllpos;
  1544. var qqqwe = new Laya.Quaternion();
  1545. var eyePos = new Laya.Vector3(this.gengsuipos.x, this.gengsuipos.y - 0.8, this.gengsuipos.z);
  1546. Laya.Quaternion.lookAt(eyePos, PlayerManager.Instance.PlayerNode.transform.position, new Laya.Vector3(0, 1, 0), qqqwe);
  1547. qqqwe.invert(qqqwe);
  1548. Laya.Quaternion.slerp(this.camera.transform.rotation, qqqwe, 0.1, qqqwe);
  1549. this.camera.transform.rotation = qqqwe;
  1550. }
  1551. CameraCancelFollow() {
  1552. Laya.timer.clear(this, this.GenSui);
  1553. }
  1554. }
  1555. class InGameView extends ui.InGameViewUI {
  1556. constructor() {
  1557. super();
  1558. InGameView.ins = this;
  1559. }
  1560. static get Instance() {
  1561. if (InGameView.ins == null) {
  1562. return new InGameView();
  1563. }
  1564. return InGameView.ins;
  1565. }
  1566. OnShow() {
  1567. console.log("游戏界面");
  1568. this.click.play(null, true);
  1569. this.on(Laya.Event.MOUSE_DOWN, this, this.ClickStart);
  1570. }
  1571. ClickStart() {
  1572. this.click.stop();
  1573. this.hand.visible = false;
  1574. this.off(Laya.Event.MOUSE_DOWN, this, this.ClickStart);
  1575. }
  1576. OnHide() {
  1577. }
  1578. }
  1579. class HomeView extends ui.HomeViewUI {
  1580. constructor() {
  1581. super();
  1582. HomeView.ins = this;
  1583. }
  1584. static get Instance() {
  1585. if (HomeView.ins == null) {
  1586. return new HomeView();
  1587. }
  1588. return HomeView.ins;
  1589. }
  1590. OnShow() {
  1591. console.log("主界面");
  1592. this.RegButton();
  1593. }
  1594. RegButton() {
  1595. this.StartBtn.clickHandler = new Laya.Handler(this, this.Start);
  1596. }
  1597. Start() {
  1598. ViewManager.Instance.ShowView(ViewType.InGameView);
  1599. DispatcherManager.StageTrigger(StageState.Start);
  1600. }
  1601. OnHide() {
  1602. }
  1603. }
  1604. var ViewType;
  1605. (function (ViewType) {
  1606. ViewType[ViewType["InGameView"] = 0] = "InGameView";
  1607. ViewType[ViewType["HomeView"] = 1] = "HomeView";
  1608. ViewType[ViewType["GameResultView"] = 2] = "GameResultView";
  1609. ViewType[ViewType["PauseView"] = 3] = "PauseView";
  1610. ViewType[ViewType["UpGradeView"] = 4] = "UpGradeView";
  1611. ViewType[ViewType["SkinView"] = 5] = "SkinView";
  1612. ViewType[ViewType["TrialView"] = 6] = "TrialView";
  1613. ViewType[ViewType["BannerView"] = 7] = "BannerView";
  1614. })(ViewType || (ViewType = {}));
  1615. class ViewManager {
  1616. constructor() {
  1617. this.showexportview = 0;
  1618. this.popViewDic = [];
  1619. this.ViewSprite = new Laya.Sprite();
  1620. this.OtherViewSprite = new Laya.Sprite();
  1621. ViewManager.ins = this;
  1622. Laya.stage.addChild(this.ViewSprite);
  1623. Laya.stage.addChild(this.OtherViewSprite);
  1624. }
  1625. static get Instance() {
  1626. if (ViewManager.ins) {
  1627. return ViewManager.ins;
  1628. }
  1629. else {
  1630. return new ViewManager();
  1631. }
  1632. }
  1633. ShowView(_viewtype, data = null) {
  1634. if (this.curView != null) {
  1635. this.curView.OnHide();
  1636. this.curView.destroy();
  1637. this.curView.removeSelf();
  1638. }
  1639. this.curView = this.CreateView(_viewtype);
  1640. this.curView.name = ViewType[_viewtype];
  1641. this.ViewSprite.addChild(this.curView);
  1642. this.curView.OnShow(data);
  1643. }
  1644. CloseView() {
  1645. if (this.curView != null) {
  1646. this.curView.OnHide();
  1647. this.curView.destroy();
  1648. this.curView.removeSelf();
  1649. }
  1650. }
  1651. OpenPopView(viewType, data = null) {
  1652. var popView;
  1653. if (this.popViewDic[viewType]) {
  1654. popView = this.popViewDic[viewType];
  1655. this.OtherViewSprite.setChildIndex(popView, this.OtherViewSprite.numChildren - 1);
  1656. popView.visible = true;
  1657. }
  1658. else {
  1659. popView = this.CreateView(viewType);
  1660. this.OtherViewSprite.addChild(popView);
  1661. this.popViewDic[viewType] = popView;
  1662. }
  1663. popView.OnOpen(data);
  1664. }
  1665. ClosePopView(viewType) {
  1666. var popView = this.popViewDic[viewType];
  1667. if (popView == null) {
  1668. return;
  1669. }
  1670. popView.OnHide();
  1671. popView.visible = false;
  1672. }
  1673. ClearPopViews() {
  1674. }
  1675. CreateView(_viewtype) {
  1676. switch (_viewtype) {
  1677. case ViewType.InGameView:
  1678. return new InGameView();
  1679. case ViewType.HomeView:
  1680. return new HomeView();
  1681. }
  1682. return null;
  1683. }
  1684. }
  1685. class AssetManager {
  1686. constructor() {
  1687. this.Prop = new Dictionary();
  1688. this.Character = new Dictionary();
  1689. AssetManager.ins = this;
  1690. DispatcherManager.EventOn(EventState.LoadComplete, this, this.Init);
  1691. }
  1692. static get Instance() {
  1693. if (AssetManager.ins == null) {
  1694. return new AssetManager();
  1695. }
  1696. return AssetManager.ins;
  1697. }
  1698. Init() {
  1699. Laya.stage.addChild(this.mainscene);
  1700. this.maincamera = this.mainscene.getChildByName("Main Camera");
  1701. this.maincamera.enableHDR = false;
  1702. CameraManager.Instance.camera = this.maincamera;
  1703. let _sprite = new Laya.Sprite3D();
  1704. this.mainscene.addChild(_sprite);
  1705. LevelManager.Instance.spritepool = _sprite;
  1706. this.SetCharacterPos();
  1707. LevelManager.Instance.RegEvent();
  1708. LevelManager.Instance.GameStart();
  1709. ViewManager.Instance.ShowView(ViewType.HomeView);
  1710. }
  1711. getPref(name) {
  1712. return this.Prop.get(name);
  1713. }
  1714. getRolePref(index) {
  1715. return this.Character.get(index);
  1716. }
  1717. SetCharacterPos() {
  1718. let _level = this.mainscene.getChildByName("level1");
  1719. for (let i = 0; i < _level.numChildren; i++) {
  1720. let item = _level.getChildAt(i);
  1721. if (item.name == "player") {
  1722. this.playerpos = item;
  1723. }
  1724. else if (item.name == "role") {
  1725. let _pref = this.getRolePref(1);
  1726. let _player = Laya.Sprite3D.instantiate(_pref);
  1727. LevelManager.Instance.spritepool.addChild(_player);
  1728. _player.transform.position = item.transform.position.clone();
  1729. _player.transform.rotation = item.transform.rotation.clone();
  1730. NodeUtil.SetColliderGroup(_player, 100);
  1731. }
  1732. }
  1733. }
  1734. }
  1735. class LoadView extends ui.LoadViewUI {
  1736. constructor() {
  1737. super();
  1738. this.progressnum = 0;
  1739. this.fast = 0.07;
  1740. this.slow = 0.005;
  1741. this.End = false;
  1742. this.EndProgress = false;
  1743. LoadView.ins = this;
  1744. Laya.stage.addChild(this);
  1745. this.Init();
  1746. }
  1747. static get Instance() {
  1748. if (LoadView.ins == null) {
  1749. return new LoadView();
  1750. }
  1751. return LoadView.ins;
  1752. }
  1753. Init() {
  1754. this.LoadScene();
  1755. Laya.timer.loop(1, this, this.UpdateProgress);
  1756. this.height = Laya.stage.height;
  1757. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  1758. this.height = Laya.stage.height;
  1759. });
  1760. }
  1761. UpdateProgress() {
  1762. if (this.progressnum <= 0.7) {
  1763. this.progressnum += this.fast;
  1764. }
  1765. else if (this.progressnum > 0.7 && this.progressnum < 0.99) {
  1766. this.progressnum += this.slow;
  1767. }
  1768. else {
  1769. if (this.End) {
  1770. this.progressnum += this.slow;
  1771. }
  1772. }
  1773. if (!this.EndProgress && this.progressnum >= 1) {
  1774. this.EndProgress = true;
  1775. this.progressnum = 1;
  1776. Laya.timer.clear(this, this.UpdateProgress);
  1777. this.LoadComplete();
  1778. }
  1779. this.jindupro.value = this.progressnum;
  1780. }
  1781. Login() {
  1782. WXSDK.AldEvent("开始登陆");
  1783. window['zzsdkui'].aliEvent('loading', { 'start': true });
  1784. if (Laya.Browser.onWeiXin) {
  1785. this.LoginWx();
  1786. }
  1787. else {
  1788. this.LoginLocal();
  1789. }
  1790. }
  1791. LoginWx() {
  1792. if (Laya.Browser.onWeiXin) {
  1793. WXSDK.DengLu((res) => {
  1794. if (res != "error") {
  1795. WXSDK.AldEvent("微信登陆成功");
  1796. console.log("1微信登录成功:" + res);
  1797. this.LoginLocal();
  1798. }
  1799. else {
  1800. this.LoginWx();
  1801. }
  1802. });
  1803. }
  1804. else {
  1805. this.LoginLocal();
  1806. }
  1807. }
  1808. LoginLocal() {
  1809. ServerManager.Instance.Login(null, Laya.Handler.create(this, this.LoginComplete), Laya.Handler.create(this, this.LoginFail));
  1810. }
  1811. LoginComplete() {
  1812. WXSDK.AldEvent("本地服务器登陆成功");
  1813. console.log("本地服务器登陆成功");
  1814. GuangGao.InitVideo();
  1815. if (Laya.Browser.onWeiXin) {
  1816. this.LoadSubPackage();
  1817. }
  1818. else {
  1819. this.LoadScene();
  1820. }
  1821. }
  1822. LoginFail() {
  1823. console.log("本地服务器登陆失败");
  1824. }
  1825. LoadSubPackage() {
  1826. Laya.Browser.window.wx.loadSubpackage({
  1827. name: 'subpackage',
  1828. success: (res) => {
  1829. WXSDK.AldEvent("分包1加载成功");
  1830. this.LoadSubPackage2();
  1831. },
  1832. fail: (res) => {
  1833. this.LoadSubPackage();
  1834. }
  1835. });
  1836. }
  1837. LoadSubPackage2() {
  1838. Laya.Browser.window.wx.loadSubpackage({
  1839. name: 'subpackage2',
  1840. success: (res) => {
  1841. WXSDK.AldEvent("分包2加载成功");
  1842. this.LoadScene();
  1843. },
  1844. fail: (res) => {
  1845. this.LoadSubPackage2();
  1846. }
  1847. });
  1848. }
  1849. LoadScene() {
  1850. Laya.Scene3D.load(ResourcesPath.mainscene, Laya.Handler.create(this, (sprite) => {
  1851. this.mainscene = sprite;
  1852. AssetManager.Instance.mainscene = this.mainscene;
  1853. WXSDK.AldEvent("场景资源加载完毕");
  1854. this.LoadRole();
  1855. }));
  1856. console.log("场景资源加载成功");
  1857. }
  1858. LoadRole() {
  1859. var arr = [];
  1860. for (let i = 0; i < ResourcesPath.Character.length; i++) {
  1861. let item = ResourcesPath.Character[i];
  1862. arr.push(item);
  1863. }
  1864. Laya.loader.create(arr, Laya.Handler.create(this, () => {
  1865. for (let i = 0; i < ResourcesPath.Character.length; i++) {
  1866. let model = Laya.loader.getRes(ResourcesPath.Character[i]);
  1867. AssetManager.Instance.Character.set(i + 1, model);
  1868. Laya.loader.clearRes(ResourcesPath.Character[i]);
  1869. }
  1870. console.log("玩家模型加载成功");
  1871. WXSDK.AldEvent("玩家模型加载完毕");
  1872. this.LoadResources();
  1873. }));
  1874. }
  1875. LoadResources() {
  1876. var arr = [];
  1877. for (let i = 0; i < ResourcesPath.Prop.length; i++) {
  1878. let item = ResourcesPath.Prop[i];
  1879. arr.push(item);
  1880. }
  1881. Laya.loader.create(arr, Laya.Handler.create(this, () => {
  1882. arr.forEach(s => {
  1883. if (s.progress == 1) {
  1884. let sp = Laya.loader.getRes(s.url);
  1885. AssetManager.Instance.Prop.set(sp.name, sp);
  1886. }
  1887. else {
  1888. console.log(`[LOG]${s.url}加载失败`);
  1889. }
  1890. }, this);
  1891. console.log("道具模型加载成功");
  1892. WXSDK.AldEvent("道具模型加载完毕");
  1893. this.complete();
  1894. }));
  1895. }
  1896. complete() {
  1897. this.End = true;
  1898. this.slow = this.fast;
  1899. DispatcherManager.EventTrigger(EventState.LoadComplete);
  1900. }
  1901. LoadComplete() {
  1902. this.destroy();
  1903. }
  1904. }
  1905. class Main {
  1906. constructor() {
  1907. if (window["Laya3D"])
  1908. Laya3D.init(GameConfig.width, GameConfig.height);
  1909. else
  1910. Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
  1911. Laya["Physics"] && Laya["Physics"].enable();
  1912. Laya["DebugPanel"] && Laya["DebugPanel"].enable();
  1913. Laya.stage.scaleMode = GameConfig.scaleMode;
  1914. Laya.stage.screenMode = GameConfig.screenMode;
  1915. Laya.stage.alignV = GameConfig.alignV;
  1916. Laya.stage.alignH = GameConfig.alignH;
  1917. Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
  1918. if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
  1919. Laya.enableDebugPanel();
  1920. if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
  1921. Laya["PhysicsDebugDraw"].enable();
  1922. if (GameConfig.stat)
  1923. Laya.Stat.show();
  1924. Laya.alertGlobalError = true;
  1925. Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
  1926. }
  1927. onVersionLoaded() {
  1928. Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
  1929. }
  1930. onConfigLoaded() {
  1931. new LoadView();
  1932. }
  1933. }
  1934. new Main();
  1935. }());
  1936. //# sourceMappingURL=bundle.js.map