(function () { 'use strict'; class GameConfig { constructor() { } static init() { var reg = Laya.ClassUtils.regClass; } } GameConfig.width = 720; GameConfig.height = 1280; GameConfig.scaleMode = "fixedwidth"; GameConfig.screenMode = "none"; GameConfig.alignV = "top"; GameConfig.alignH = "left"; GameConfig.startScene = "LoadView.scene"; GameConfig.sceneRoot = ""; GameConfig.debug = false; GameConfig.stat = false; GameConfig.physicsDebug = false; GameConfig.exportSceneToJson = false; GameConfig.init(); var AccountUser; (function (AccountUser) { AccountUser[AccountUser["buyed_kun"] = 0] = "buyed_kun"; AccountUser[AccountUser["diamond"] = 1] = "diamond"; AccountUser[AccountUser["equip_themes"] = 2] = "equip_themes"; AccountUser[AccountUser["favorite_times"] = 3] = "favorite_times"; AccountUser[AccountUser["game_times"] = 4] = "game_times"; AccountUser[AccountUser["get_themes"] = 5] = "get_themes"; AccountUser[AccountUser["list_kun"] = 6] = "list_kun"; AccountUser[AccountUser["moeny"] = 7] = "moeny"; AccountUser[AccountUser["progress_themes"] = 8] = "progress_themes"; AccountUser[AccountUser["revival"] = 9] = "revival"; AccountUser[AccountUser["stage"] = 10] = "stage"; })(AccountUser || (AccountUser = {})); class PlayerData { constructor(_token, _config, _appSetting, _user, _userbase, _useInvite, _user_stage = null, _user_sign, _user_achievement, lottery) { this.openid = ""; this.userId = ""; this.zhengshu = _token; this.netzheshe = _appSetting; this.account = _user; this.accountssss = _userbase; this.qiandao = _user_sign; this.renwu = _user_achievement; this.userId = this.account["user_id"]; this.openid = this.accountssss["openid"]; this.m_invite = _useInvite; this.lottery = lottery; console.log("user_id:" + this.userId); } GainCollocation(_type) { return this.peizhis[_type]; } GainAccount(_type) { return this.account[_type]; } get fenxiang() { return this.netzheshe["share"] == "1"; } get CheckScene() { return this.netzheshe["checkscene"] == "1"; } get Cheat() { return this.netzheshe["cheat"] == "1"; } get Banner() { return this.netzheshe["Banner"] == "1"; } get wudaoshijian() { return Number(this.netzheshe["wudaoshijian"]); } GetUser(_type) { var type = AccountUser[_type]; return this.account[type]; } HasGun(_id) { var data = this.GainAccount("get_themes"); for (var i = 0; i < data.length; i++) { var hd = data[i]; if (_id == hd) { return true; } } return false; } GetProgress(_id) { var config = this.account["progress_themes"]; var progress = config[_id] ? config[_id] : 0; return progress; } get ShareTxt() { return this.netzheshe["sharecontent"]; } } class Global { } Global.VERSION = "1.0.0"; Global.CFG = "123"; var HttpRequest = Laya.HttpRequest; var Event = Laya.Event; const JtSniperApiUrl = "https://jtsniperapi.xwxgame.com/"; class JtSniper { } JtSniper.DengLu = "user/login"; JtSniper.KaiShi = "game/start"; JtSniper.JieShu = "game/play"; JtSniper.QianDao = "sign/sign"; JtSniper.Chengjiu = "achievement/getRewards"; JtSniper.Config = "config/table"; JtSniper.FenXiang = "fission/share"; JtSniper.LiXian = "fission/offline"; JtSniper.vd = "fission/vd"; JtSniper.FuHuo = "game/revival"; JtSniper.gadagdag = "treasure/click"; JtSniper.Invite = "invite/getRewards"; JtSniper.Lottery = "lottery/lottery"; JtSniper.ShareGetSkin = "theme/fission"; JtSniper.WearEquip = "theme/equip"; JtSniper.BuyEquip = "theme/buy"; JtSniper.ShouQuan = "user/auth"; JtSniper.JinBi = "user/sync"; class ServerManager { constructor() { } static get Instance() { if (ServerManager.ins) { return ServerManager.ins; } else { return new ServerManager(); } } Login(progresscb, completecb, errorcb) { var Account = AccountManager.Instance; var ver = Global.VERSION; let Data = `code=${Account.code}&nickname=${Account.nickName}&avatar=${Account.avatarUrl}&gender=${Account.gender}&country=${Account.country}&province=${Account.province}&city=${Account.city}& device=${Account.device}$&share_id=${Account.share_id}&scene=${Account.scene}&v=${ver}`; let httpRequest = new HttpRequest(); httpRequest.once(Event.PROGRESS, this, this.Progress, [progresscb, httpRequest]); httpRequest.once(Event.COMPLETE, this, this.Complete, [completecb, httpRequest]); httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]); httpRequest.send(JtSniperApiUrl + JtSniper.DengLu, Data, "post", "text"); } Progress(_progresscb, _httpreq) { if (_progresscb) { _progresscb.run(); } } Complete(_completecb, _httpreq) { let data = JSON.parse(_httpreq.data); console.log(data); if (data["code"] != "0") { console.log("登录异常错误!错误信息sssssssss:", _httpreq.data["code"]); return; } console.log("-----------sss", data["t"]); AccountManager.Instance.SFSFSF = data["t"]; this.RessetConfig(data, _completecb); } RessetConfig(data, completecb) { AccountManager.Instance.ReSetting(data, (flag) => { if (flag) { completecb.runWith(data); } else { this.RessetConfig(data, completecb); } }); } Errorcb(_errorcb, _httpreq) { if (_errorcb != null) { _errorcb.runWith(_httpreq); } } SendHttp(protocol, param, completecb, errorcb, hasToken = true) { let sfaasfsfa = ""; let daadsads = JtSniperApiUrl + protocol; if (hasToken == true) { sfaasfsfa = `token=${AccountManager.Instance.curplayerData.zhengshu}&`; } if (protocol == JtSniper.KaiShi || protocol == JtSniper.JieShu || protocol == JtSniper.vd || protocol == JtSniper.Lottery || protocol == JtSniper.ShareGetSkin) { let asddsa = "abcdefghijkimnopqrstuvwxyz0123456789"; let adsassda = "{"; let saafsafs = ""; for (let i = 0; i < 4; i++) { saafsafs += asddsa[Math.floor(Math.random() * 100) % asddsa.length]; } for (let i = 0; i < param.length; i++) { for (let key in param[i]) { adsassda += `\"${key}\":\"${param[i][key]}\"`; } if (i < param.length - 1) { adsassda += ","; } else { adsassda += "}"; } } sfaasfsfa += "_r=" + saafsafs + this.SFGSGSG(adsassda); } else { if (param != null) { for (let i = 0; i < param.length; i++) { for (let key in param[i]) { let val = param[i][key]; sfaasfsfa += `${key}=${val}`; if (i < param.length - 1) { sfaasfsfa += "&"; } } } } } let httpRequest = new HttpRequest(); httpRequest.once(Event.COMPLETE, this, this.onHttpRequestComplete, [completecb, errorcb, httpRequest]); httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]); httpRequest.send(daadsads, sfaasfsfa, "post", "text"); } onHttpRequestComplete(succeedcb, failurecb, httpRequest) { let data = JSON.parse(httpRequest.data); if (data["code"] == 0) { AccountManager.Instance.ReSetting(data); if (succeedcb != null) { succeedcb.runWith(data); } } else { if (failurecb != null) { failurecb.runWith(data); } console.log("Error! Http request complete error, code: " + data["code"] + " message: " + data["message"]); } } SFGSGSG(str) { var c1, c2, c3; var SFSFFSFSFSFS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var i = 0, len = str.length, SFFSSFFS = ''; while (i < len) { c1 = str.charCodeAt(i++) & 0xff; if (i == len) { SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2); SFFSSFFS += SFSFFSFSFSFS.charAt((c1 & 0x3) << 4); SFFSSFFS += "=="; break; } c2 = str.charCodeAt(i++); if (i == len) { SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2); SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); SFFSSFFS += SFSFFSFSFSFS.charAt((c2 & 0xF) << 2); SFFSSFFS += "="; break; } c3 = str.charCodeAt(i++); SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2); SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); SFFSSFFS += SFSFFSFSFSFS.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)); SFFSSFFS += SFSFFSFSFSFS.charAt(c3 & 0x3F); } return SFFSSFFS; } } class AccountManager { constructor(_code, _userinfo, _nickname, _avatarurl, _gender, _province, _city, _country, _device, _shareid, _scene, _v) { this.createTime = Laya.timer.currTimer; AccountManager.ins = this; this.code = _code; this.userInfo = _userinfo; this.nickName = _nickname; this.avatarUrl = _avatarurl; this.gender = _gender; this.province = _province; this.city = _city; this.country = _country; this.device = _device; this.share_id = _shareid; this.scene = _scene; this.v = _v; } static get Instance() { if (AccountManager.ins == null) { new AccountManager("222222", "你找谁?", "1233", "123", 1, "中国", "上海", "上海", "iphone6s", "123", "123", "123"); } return AccountManager.ins; } ReSetting(data, cb = null) { var zhengshu = data["token"]; var netset = data["app_setting"]; var user = data["user"]; var jichu = data["user_base"]; var qiandao = data["user_sign"]; var chengjiu = data["user_achievement"]; var invite = data["user_invite"]; var lottery = data["user_lottery"]; if (this.curplayerData == null) { this.curplayerData = new PlayerData(zhengshu, null, netset, user, jichu, invite, null, qiandao, chengjiu, lottery); this.JundgCfg(data.table_version, cb); } else { if (netset) { this.curplayerData.netzheshe = netset; } if (user) { this.curplayerData.account = user; } if (jichu) { this.curplayerData.accountssss = jichu; } if (qiandao) { this.curplayerData.qiandao = qiandao; } if (chengjiu) { this.curplayerData.renwu = chengjiu; } } } JundgCfg(ver, callball) { var cfg = Laya.LocalStorage.getJSON(Global.CFG); if (cfg) { if (cfg.VER == ver) { console.log("已经拥有,不用更新"); this.SetCfg(cfg); if (callball) callball(true); } else { console.log("cfg存在但是过期了"); Laya.LocalStorage.removeItem(Global.CFG); ServerManager.Instance.SendHttp(JtSniper.Config, null, Laya.Handler.create(this, (data) => { data.configs.VER = ver; Laya.LocalStorage.setJSON(Global.CFG, data.configs); this.SetCfg(data.configs); if (callball) callball(true); }), Laya.Handler.create(this, (data) => { console.log("配置获取失败" + data); if (callball) callball(false); return; })); } } else { console.log("本地没有cfg"); ServerManager.Instance.SendHttp(JtSniper.Config, null, Laya.Handler.create(this, (data) => { data.configs.VER = ver; Laya.LocalStorage.setJSON(Global.CFG, data.configs); this.SetCfg(data.configs); if (callball) callball(true); }), Laya.Handler.create(this, (data) => { console.log("配置获取失败" + data); })); } } SetCfg(data) { this.curplayerData.peizhis = data; } RessetConfig() { ServerManager.Instance.SendHttp(JtSniper.Config, null, Laya.Handler.create(this, (data) => { this.curplayerData.peizhis = data["configs"]; }), null); } get ServerTime() { let time = Laya.timer.currTimer; let stime = this.SFSFSF + Math.ceil((time - this.createTime) / 1000); return stime; } } var Vector3 = Laya.Vector3; class GameTools { constructor() { GameTools.ins = this; } static get Instance() { if (GameTools.ins) { return GameTools.ins; } else { return new GameTools(); } } lerp(form, to, t) { if (t <= 0) { return form; } else if (t >= 1) { return to; } var a = t * to + (1 - t) * form; return a; } SetCollider(setNode, CollisionGroup) { var numchild = setNode.numChildren; for (var i = 0; i < setNode.numChildren; i++) { var numchild2 = setNode.getChildAt(i).numChildren; if (numchild2 > 1) { this.SetCollider(setNode.getChildAt(i), CollisionGroup); } var physicsCollider = setNode.getChildAt(i).getComponent(Laya.PhysicsCollider); if (physicsCollider) { physicsCollider.collisionGroup = CollisionGroup; } } } EnemySetCollider(setNode, collisionGroup) { var collider = setNode.getChildByName("npcfrontcollider"); var collider2 = setNode.getChildByName("npcrearcollider"); var physicsCollider = collider.getComponent(Laya.PhysicsCollider); var physicsCollider2 = collider2.getComponent(Laya.PhysicsCollider); if (physicsCollider) { physicsCollider.collisionGroup = collisionGroup; } if (physicsCollider2) { physicsCollider2.collisionGroup = collisionGroup; } } PlayerSetCollider(setNode, collisionGroup) { var collider = setNode.getChildByName("playercollider"); var physicsCollider = collider.getComponent(Laya.PhysicsCollider); if (physicsCollider) { physicsCollider.collisionGroup = collisionGroup; } } HostageSetCollider(setNode, collisionGroup) { var collider = setNode.getChildByName("hostagecollider"); var physicsCollider = collider.getComponent(Laya.PhysicsCollider); if (physicsCollider) { physicsCollider.collisionGroup = collisionGroup; } } static RandomNumber(from, to) { if (from >= to) { return 0; } var size = to - from; var curNumber = Math.random() * size + from; return curNumber; } static RandomANumber(from, to) { if (from >= to) { return 0; } var size = to - from; var curNumber = Math.random() * size + from; return Math.floor(curNumber); } static GetMoney(_num, _pos = null, _completeHandle = null) { if (_num == 0) return; var fafaafsfa = new Laya.Box; fafaafsfa.width = 400; fafaafsfa.height = 100; fafaafsfa.pivotX = fafaafsfa.width / 2; fafaafsfa.pivotY = fafaafsfa.height / 2; if (_pos == null) { _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2); } fafaafsfa.pos(_pos.x, _pos.y); var aafafaffa = new Laya.Image; aafafaffa.skin = "game/qiandao_1_7.png"; aafafaffa.width = 60; aafafaffa.height = 60; aafafaffa.left = 50; aafafaffa.y = 10; fafaafsfa.addChild(aafafaffa); var faasfafsafs = new Laya.Text; faasfafsafs.width = 300; faasfafsafs.height = 50; faasfafsafs.align = "center"; faasfafsafs.valign = "middle"; faasfafsafs.font = "Microsoft YaHei"; faasfafsafs.fontSize = 40; faasfafsafs.color = "#FFFFFF"; faasfafsafs.bold = true; faasfafsafs.font = "Microsoft YaHei"; faasfafsafs.text = "金币 +" + _num; faasfafsafs.x = 60; faasfafsafs.y = 10; fafaafsfa.addChild(faasfafsafs); Laya.stage.addChild(fafaafsfa); var faasfsaf = Laya.Tween.to(fafaafsfa, { y: fafaafsfa.y - 200 }, 1500, Laya.Ease.expoInOut, Laya.Handler.create(this, () => { faasfsaf.clear(); fafaafsfa.destroy(); if (_completeHandle) { _completeHandle.run(); } }), 100); } static TweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) { var afasafsafsfa = new Laya.Text(); afasafsafsfa.width = faafssfafsa.size.x; afasafsafsfa.height = faafssfafsa.size.y; afasafsafsfa.align = "center"; afasafsafsfa.valign = "middle"; afasafsafsfa.font = "Microsoft YaHei"; afasafsafsfa.fontSize = faafssfafsa.fontSize; afasafsafsfa.pivotX = afasafsafsfa.width / 2; afasafsafsfa.pivotY = afasafsafsfa.height / 2; afasafsafsfa.color = "#5ad122"; afasafsafsfa.bold = true; afasafsafsfa.stroke = 5; afasafsafsfa.strokeColor = "#ffffff"; if (faafssfafsa.color) { faafssfafsa.color = faafssfafsa.color; } afasafsafsfa.text = faafssfafsa.message; afasafsafsfa.zOrder = 1; Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1); afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y); var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () { }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () { tween.clear(); if (hide) { afasafsafsfa.destroy(); } if (_completeHandle) { _completeHandle.run(); } })); if (hide) { Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 500); } return afasafsafsfa; } static StationTweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) { var afasafsafsfa = new Laya.Text(); afasafsafsfa.width = faafssfafsa.size.x; afasafsafsfa.height = faafssfafsa.size.y; afasafsafsfa.align = "center"; afasafsafsfa.valign = "middle"; afasafsafsfa.font = "Microsoft YaHei"; afasafsafsfa.fontSize = 50; afasafsafsfa.pivotX = afasafsafsfa.width / 2; afasafsafsfa.pivotY = afasafsafsfa.height / 2; afasafsafsfa.color = "#5ad122"; afasafsafsfa.bold = true; afasafsafsfa.stroke = 5; afasafsafsfa.strokeColor = "#ffffff"; if (faafssfafsa.color) { faafssfafsa.color = faafssfafsa.color; } afasafsafsfa.text = faafssfafsa.message; afasafsafsfa.zOrder = 1; Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1); afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y); var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () { }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () { tween.clear(); if (hide) { afasafsafsfa.destroy(); } if (_completeHandle) { _completeHandle.run(); } })); if (hide) { Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 10000); } return afasafsafsfa; } static tweenMove(transform, targPos, delay, ease, complete) { let curPos = transform.position.clone(); return Laya.Tween.to(curPos, { x: targPos.x, y: targPos.y, z: targPos.z, update: new Laya.Handler(this, () => { transform.position = curPos.clone(); }) }, delay, ease, complete); } static tweenRotate(transform, targEuler, delay, ease, complete) { let curEuler = transform.rotationEuler.clone(); return Laya.Tween.to(curEuler, { x: targEuler.x, y: targEuler.y, z: targEuler.z, update: new Laya.Handler(this, () => { transform.rotationEuler = curEuler.clone(); }) }, delay, ease, complete); } } class ShareUtil { beginShare(callBack) { ShareUtil.beginShareTime = new Date().getTime(); console.log("分享点击时间=" + ShareUtil.beginShareTime); ShareUtil.isSharing = true; ShareUtil.callback = callBack; } onRegister() { if (Laya.Browser.window.wx == null) { return; } Laya.Browser.window.wx.onShow(function (option) { console.log("onshow share start"); if (ShareUtil.isSharing) { ShareUtil.isSharing = false; let time = new Date().getTime(); console.log("分享回到游戏时间" + time); let wait = (time - ShareUtil.beginShareTime) / 1000; console.log("分享停留时间为:" + wait); if (wait < 3) { Laya.Browser.window.wx.showToast({ title: "请重试一次" }); ShareUtil.callback(false); } else { var random = Math.random(); if (random <= 0.3) { var message = ["你已分享过该群", "请重新换个群分享!", "请分享到30人大群中!"]; var curmes = message[GameTools.RandomANumber(0, 2)]; Laya.Browser.window.wx.showToast({ title: curmes }); ShareUtil.callback(false); } else { Laya.Browser.window.wx.showToast({ title: "分享成功!" }); ShareUtil.callback(true); } } } }); } static ShareMessage() { if (!Laya.Browser.onWeiXin) return; var t = AccountManager.Instance.ServerTime; var _title = AccountManager.Instance.curplayerData.ShareTxt; _title = (_title == "" || !_title) ? "有人@你,快来比一比枪法" : _title; var _image = "subpackage/res/share/1.jpg"; Laya.Browser.window.wx.onShareAppMessage(() => ({ title: _title, imageUrl: _image, query: "shareid=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString() })); } static shareImage(channel, callback = null, shareType) { if (Laya.Browser.window.wx == null) { return; } var t = AccountManager.Instance.ServerTime; var _title = AccountManager.Instance.curplayerData.ShareTxt; _title = (_title == "" || !_title) ? "有人@你,快来比一比枪法" : _title; var _image = "subpackage/res/share/1.jpg"; Laya.Browser.window.wx.aldShareAppMessage({ title: _title, imageUrl: _image, query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + shareType + "_" + t + "_" + Math.floor(9999 * Math.random()).toString() }); if (callback) { ShareUtil.Instance.beginShare(callback); } } } ShareUtil.Instance = new ShareUtil(); ShareUtil.shareSuccessTime = 0; ShareUtil.isSharing = false; class WXSDK { constructor() { WXSDK.ins = this; } static get Instance() { if (WXSDK.ins) { return WXSDK.ins; } else { return new WXSDK(); } } static Init() { } static DengLu(_complete) { var that = this; Laya.Browser.window.wx.login({ success: function (res) { if (res.code) { ShareUtil.Instance.onRegister(); console.log("微信登陆成功----"); that.codeValue = res.code; console.log("shareid:" + WXSDK.shareOpenId); new AccountManager(res.code, "", "", "", 0, "", "", "", "", WXSDK.shareOpenId, WXSDK.shareOpenId, Global.VERSION); _complete(res); } else { WXSDK.DengLu(WXSDK.DengLu); console.log('wx no code' + res.errMsg); } }, fail: function (res) { console.log("wx.login: failed, res=" + res); } }); } static ShowTxt(text) { if (Laya.Browser.onWeiXin) { Laya.Browser.window.wx.showToast({ title: text }); } else { console.log(text); } } static OnShow(cb) { if (!Laya.Browser.onWeiXin) return; Laya.Browser.window.wx.onShow(cb); } static OffShow(cb) { if (!Laya.Browser.onWeiXin) return; Laya.Browser.window.wx.offShow(cb); } static OnHide(cb) { if (!Laya.Browser.onWeiXin) return; Laya.Browser.window.wx.onHide(cb); } static OffHide(cb) { if (!Laya.Browser.onWeiXin) return; Laya.Browser.window.wx.offHide(cb); } static ShortShake() { Laya.Browser.window.wx.vibrateShort({}); } static LongShake() { Laya.Browser.window.wx.vibrateLong({}); } static Shake(_short = true) { if (Laya.Browser.onWeiXin && WXSDK.shake) { if (_short) { this.ShortShake(); } else { this.LongShake(); } } } static LoadSubPackage(name, _complete) { if (Laya.Browser.onWeiXin) { const loadTask = Laya.Browser.window.wx.loadSubpackage({ name: 'subpackage', success: function (res) { _complete && _complete(true); console.log("分包加载成功"); }, fail: function (res) { _complete && _complete(false); console.log("分包加载失败"); } }); } else { console.log("未进行分包加载"); _complete && _complete(true); } } static stageShake(callBack = null, speed = 32) { if (this.isShake || !this.canshakestage) return; this.isShake = true; var point = new Laya.Vector2(Laya.stage.x, Laya.stage.y); Laya.stage.timerLoop(speed, this, this.shakeObject, [point, callBack]); } static shakeObject(_point, _callBack) { var count = (this.num++) % 4; this.offsetArr[this.num % 2] = count < 2 ? 0 : this.offset; Laya.stage.x = this.offsetArr[0] + _point.x; Laya.stage.y = this.offsetArr[1] + _point.y; if (this.num > (this.times * 4 + 1)) { Laya.stage.clearTimer(this, this.shakeObject); Laya.stage.pos(0, 0); this.num = 0; this.isShake = false; if (_callBack != null) { _callBack(); } } } static UpdateGuide(ShowGuide = 0) { var kvDataList = new Array(); let date = new Date().getTime(); var myValue = JSON.stringify({ "guide": { "ShowGuide": ShowGuide, "update_time": date.toString() } }); kvDataList.push({ key: "ShowGuide", value: myValue }); if (Laya.Browser.window.wx) { Laya.Browser.window.wx.setUserCloudStorage({ KVDataList: kvDataList, success: r => { console.log("KVDATALIST---", kvDataList); console.log("上传新手指引成功:" + ShowGuide); } }); } } static UpdateScore(max_score) { var kvDataList = new Array(); let date = new Date().getTime(); var myValue = JSON.stringify({ "wxgame": { "max_score": max_score, "update_time": date.toString(), } }); kvDataList.push({ key: "max_score", value: myValue }); if (Laya.Browser.window.wx) { Laya.Browser.window.wx.setUserCloudStorage({ KVDataList: kvDataList, success: r => { console.log("KVDATALIST---", kvDataList); console.log("上传分数成功:" + max_score); } }); } } static fengxiangtupian(callback) { if (Laya.Browser.window.wx == null) { return; } var _title = "有人@你,一起骑马仗箭走天涯"; var t = AccountManager.Instance.ServerTime; Laya.Browser.window.wx.aldShareAppMessage({ title: _title, imageUrl: "Game/res/textrue/share.jpg", query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString() }); } static AldEvent(eventName, key = "用户id", value = "") { if (!Laya.Browser.onWeiXin) return; Laya.Browser.window.wx.aldSendEvent(eventName, { key: value }); } static AldStart(stageId) { if (!Laya.Browser.onWeiXin) return; Laya.Browser.window.wx.aldStage.onStart({ stageId: stageId, stageName: "第" + stageId + "关", }); } static AldEnd(stageId, isComplete) { if (!Laya.Browser.onWeiXin) return; let event = isComplete ? "complete" : "fail"; let desc = isComplete ? "关卡完成" : "关卡失败"; Laya.Browser.window.wx.aldStage.onEnd({ stageId: stageId, stageName: "第" + stageId + "关", event: event, params: { desc: desc } }); } } WXSDK.codeValue = ""; WXSDK.shareOpenId = ""; WXSDK.openId = 0; WXSDK.shareScene = ""; WXSDK.uid = "123"; WXSDK.querychannel = ""; WXSDK.referrerInfoappId = ""; WXSDK.shake = true; WXSDK.times = 1.3; WXSDK.num = 0; WXSDK.offsetArr = [0, 0]; WXSDK.offset = 14; WXSDK.canshakestage = false; var REG = Laya.ClassUtils.regClass; var ui; (function (ui) { class HomeViewUI extends Laya.Scene { constructor() { super(); } createChildren() { super.createChildren(); this.createView(HomeViewUI.uiView); } } 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": [] }; ui.HomeViewUI = HomeViewUI; REG("ui.HomeViewUI", HomeViewUI); class InGameViewUI extends Laya.Scene { constructor() { super(); } createChildren() { super.createChildren(); this.createView(InGameViewUI.uiView); } } InGameViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "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": [] }; ui.InGameViewUI = InGameViewUI; REG("ui.InGameViewUI", InGameViewUI); class LoadViewUI extends Laya.Scene { constructor() { super(); } createChildren() { super.createChildren(); this.createView(LoadViewUI.uiView); } } LoadViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Load/jiazai-1-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": [] }; ui.LoadViewUI = LoadViewUI; REG("ui.LoadViewUI", LoadViewUI); })(ui || (ui = {})); class GuangGao { constructor() { GuangGao.ins = this; } static get Instance() { if (GuangGao.ins) { return GuangGao.ins; } else { return new GuangGao(); } } static InitVideo() { if (!Laya.Browser.onWeiXin) return; console.log(this.bannerAdUnitId); this.fsaasfafssfa = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: this.videlAdUnitId }); this.fsaasfafssfa.onLoad(() => { console.log('激励视频 广告加载成功'); this.asfasfsaffsa = true; }); this.fsaasfafssfa.onError(err => { console.log("激励视屏加载失败:" + err); this.asfasfsaffsa = false; }); this.afsfsaafsfsa = true; } static ShowVideo(callback) { if (this.asfasfsaffsa) { console.log("showVideoAd:" + this.asfasfsaffsa); this.SetVideoCallBack(callback); this.fsaasfafssfa.show().catch(err => { this.fsaasfafssfa.load().then(() => { this.SetVideoCallBack(callback); this.fsaasfafssfa.show(); }); }); } } static SetVideoCallBack(callback) { this.fsaasfafssfa.offClose(); this.fsaasfafssfa.onClose(res => { console.log("激励视频关闭:" + res.isEnded); if (res && res.isEnded || res === undefined) { callback && callback(true); } else { callback && callback(false); } this.fsaasfafssfa.offClose(); }); } static OpenBanner(gap = 0, callVack = null, iswait = false) { if (!Laya.Browser.onWeiXin) { if (callVack) { callVack(null); } return; } this.canshowbanner = true; var idd = this.bannerAdUnitId; console.log("adUnitId:" + idd); let newBanner = Laya.Browser.window.wx.createBannerAd({ adUnitId: idd, style: { left: 0, top: 0, width: 460 } }); newBanner.onError(err => { console.log("广告错误onerror--"); console.log(err); callVack(null); }); newBanner.onLoad(() => { if (this.curbanner) this.curbanner.destroy(); this.curbanner = newBanner; var hight = this.GetRealHight(gap); if (callVack != null) { callVack(hight); } if (this.canshowbanner && !iswait) { this.curbanner.show(); } else { this.curbanner.hide(); } }); } static GetRealHight(gap) { if (this.curbanner) { let info = Laya.Browser.window.wx.getSystemInfoSync(); this.curbanner.style.width = info.windowWidth; this.curbanner.style.top = info.windowHeight - this.curbanner.style.realHeight - gap; return Laya.stage.height / info.windowHeight * this.curbanner.style.realHeight; } } static Clear() { Laya.timer.clearAll(this); Laya.Tween.clearAll(this); this.canshowbanner = false; if (this.curbanner) this.curbanner.hide(); } static hidebanner() { if (!Laya.Browser.onWeiXin) return; if (this.curbanner) this.curbanner.hide(); } static showbanner() { if (!Laya.Browser.onWeiXin) return; if (this.curbanner) this.curbanner.show(); } static get cancheat() { return false; } static SetPosBanner(btn, complete) { if (Laya.Browser.onPC) { complete(false); return; } let info = Laya.Browser.window.wx.getSystemInfoSync(); var reshight = btn.y * info.windowHeight / Laya.stage.height; var idd = this.bannerAdUnitId; console.log("adUnitId:" + idd); if (this.curbanner) this.curbanner.destroy(); let newBanner = Laya.Browser.window.wx.createBannerAd({ adUnitId: idd, style: { left: 0, top: 0, width: 720 } }); newBanner.onError(err => { console.log(err); complete(false); }); newBanner.onLoad(() => { this.curbanner = newBanner; this.curbanner.style.top = reshight; if (this.curbanner) { console.log("banner show"); this.curbanner.show(); Laya.timer.once(2300, this, () => { this.curbanner.style.top = info.windowHeight - GuangGao.bannerhigt; complete(true); }); } }); newBanner.onResize((res) => { GuangGao.bannerhigt = res.height; this.curbanner.style.width = info.windowWidth; this.curbanner.style.top = reshight; }); } static CheatBanner(btn, complete = null, gap = 0) { if (!AccountManager.Instance.curplayerData.Cheat) { console.log("ignorecheat"); GuangGao.OpenBanner(0, (height) => { if (height == null) { console.log("banner高度为null---"); } }); } else { btn.y = Laya.stage.height - btn.height - 100; GuangGao.OpenBanner(gap, (height) => { if (height == null) ; else { console.log("cheatstart", "bottom:100"); btn.mouseEnabled = false; var end = Laya.stage.height - height - btn.height - 20; console.log("y:" + end); Laya.timer.once(1000, this, () => { btn.mouseEnabled = true; this.showbanner(); Laya.Tween.to(btn, { y: end }, 500, null, Laya.Handler.create(this, () => { if (complete != null) { complete(); } })); }); } }, true); } } showBanner(success = null, fail = null) { if (!Laya.Browser.onWeiXin) return; var ran = GameTools.RandomANumber(0, 3); let ad = GuangGao.bannerAdUnitId; let bannerAd = Laya.Browser.window.wx.createBannerAd({ adUnitId: ad, style: { left: 0, top: 0, width: 460 } }); bannerAd.onLoad(() => { console.log("[LOG] Banner广告加载成功"); this.hideBanner(); this._bannerAd = bannerAd; let info = Laya.Browser.window.wx.getSystemInfoSync(); this._bannerAd.style.width = info.windowWidth; this._bannerAd.style.top = info.windowHeight - this._bannerAd.style.realHeight - 20; this._bannerAd.show(); success && success(this._bannerAd); }); bannerAd.onError(err => { console.log("[LOG] Banner广告加载失败"); console.log(err); fail && fail(); }); } hideBanner() { if (!Laya.Browser.onWeiXin) return; if (this._bannerAd) { this._bannerAd.hide(); this._bannerAd.destroy(); this._bannerAd = null; } } } GuangGao.videlAdUnitId = "adunit-8feb4e40536601ff"; GuangGao.bannerAdUnitId = "adunit-426c9d6299d18f7e"; GuangGao.afsfsaafsfsa = false; GuangGao.asfasfsaffsa = false; GuangGao.canshowbanner = true; GuangGao.bannerhigt = 0; class ResourcesPath { } ResourcesPath.mainscene = "subpackage/mainscene/LayaScene_mainscene/Conventional/mainscene.ls"; ResourcesPath.Character = [ "subpackage/gameresources/LayaScene_gameresources/Conventional/Character1.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Character2.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Character3.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Character4.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Character5.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Character6.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Character7.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Character8.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Character9.lh" ]; ResourcesPath.Prop = [ "subpackage/gameresources/LayaScene_gameresources/Conventional/CheckPoint1.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/CheckPoint2.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/FinishCircle.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/FinishCircle2.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/magnet.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail1.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail2.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail3.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail4.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail5.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail6.lh", "subpackage/gameresources/LayaScene_gameresources/Conventional/Nail7.lh" ]; class Dictionary { constructor() { this._items = {}; this.length = 0; } get container() { return this._items; } has(key) { return this._items.hasOwnProperty(key); } set(key, val) { if (!this.has(key)) { this.length++; } this._items[key] = val; } delete(key) { let val = null; if (this.has(key)) { val = this._items[key]; delete this._items[key]; this.length--; } return val; } get(key) { return this.has(key) ? this._items[key] : null; } values() { let values = []; for (let k in this._items) { if (this.has(k)) { values.push(this._items[k]); } } return values; } keys() { let keys = []; for (let k in this._items) { if (this.has(k)) { keys.push(k); } } return keys; } clear() { this._items = {}; this.length = 0; } } class NodeUtil { static GetChild(node, cond) { let queue = []; for (let i = 0; i < node.numChildren; i++) { queue.push(node.getChildAt(i)); } while (queue.length > 0) { let first = queue.shift(); if (cond(first)) { return first; } else { for (let i = 0; i < first.numChildren; i++) { queue.push(first.getChildAt(i)); } } } return null; } static GetChildByName(node, name) { return NodeUtil.GetChild(node, s => s.name == name); } static getChildren(node, cond) { let finded = []; let queue = []; for (let i = 0; i < node.numChildren; i++) { queue.push(node.getChildAt(i)); } while (queue.length > 0) { let first = queue.shift(); if (cond(first)) { finded.push(first); } for (let i = 0; i < first.numChildren; i++) { queue.push(first.getChildAt(i)); } } return finded; } static SetColliderInactive(sp) { let colliders = NodeUtil.getChildren(sp, s => s.getComponent(Laya.PhysicsCollider)); colliders.forEach(s => { let collider = s.getComponent(Laya.PhysicsCollider); if (collider) { collider.enabled = false; } }, this); } static SetColliderGroup(sp, _group) { let colliders = NodeUtil.getChildren(sp, s => s.getComponent(Laya.PhysicsCollider)); colliders.forEach(s => { let collisionGroup = _group; let collider = s.getComponent(Laya.PhysicsCollider); collider.collisionGroup = collisionGroup; }, this); } } NodeUtil.All = Laya.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER; NodeUtil.Body = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER1; NodeUtil.Head = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER2; NodeUtil.Citizen = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER3; class Transform3DHelper { static getForward(transform) { let forward = new Laya.Vector3(); transform.getForward(forward); Laya.Vector3.scale(forward, -1, forward); Laya.Vector3.normalize(forward, forward); return forward; } } var EventState; (function (EventState) { EventState[EventState["LoadComplete"] = 0] = "LoadComplete"; EventState[EventState["SceneInit"] = 1] = "SceneInit"; EventState[EventState["StageInit"] = 2] = "StageInit"; EventState[EventState["ShowModel"] = 3] = "ShowModel"; })(EventState || (EventState = {})); var StageState; (function (StageState) { StageState[StageState["Win"] = 0] = "Win"; StageState[StageState["Lose"] = 1] = "Lose"; StageState[StageState["Start"] = 2] = "Start"; StageState[StageState["BackMain"] = 3] = "BackMain"; StageState[StageState["StageCreateComPlete"] = 4] = "StageCreateComPlete"; StageState[StageState["Over"] = 5] = "Over"; StageState[StageState["Pause"] = 6] = "Pause"; StageState[StageState["Resume"] = 7] = "Resume"; })(StageState || (StageState = {})); class DispatcherManager { static EventOn(_mode, caller, fun, args = []) { DispatcherManager.instance.on(EventState[_mode], caller, fun, args); } static EventOff(_mode, caller, fun, args = []) { DispatcherManager.instance.off(EventState[_mode], caller, fun); } static EventTrigger(_mode, args = []) { DispatcherManager.instance.event(EventState[_mode], args); } static StageOn(_mode, caller, fun, args = []) { DispatcherManager.instance.on(StageState[_mode], caller, fun, args); } static StageOff(_mode, caller, fun, args = []) { DispatcherManager.instance.off(StageState[_mode], caller, fun); } static StageTrigger(_mode, args = []) { DispatcherManager.instance.event(StageState[_mode], args); } } DispatcherManager.instance = new Laya.EventDispatcher(); var Vector3$1 = Laya.Vector3; class RoleMoveBehav extends Laya.Script3D { constructor() { super(); this.start = false; this.Downhit = new Laya.HitResult(); this.FowardHit = new Laya.HitResult(); this.isdead = false; this.curpos = new Vector3$1(); this.offest = new Vector3$1(); this.curspeed = 0; } onAwake() { this.m_player = this.owner; DispatcherManager.StageOn(StageState.Start, this, this.Start); } Start() { this.start = true; } onUpdate() { if (!this.start) return; if (this.isdead) { this.ChangeDeadState(); return; } if (this.DownRayCheck) ; else { this.isdead = true; } if (this.FowardRayCheck) ; let foward = Transform3DHelper.getForward(this.m_player.transform); this.Move(foward, 0.2); } Move(_dir, _speed) { var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1); this.curspeed = sp; Vector3$1.scale(_dir, this.curspeed, this.offest); Vector3$1.add(this.m_player.transform.position, this.offest, this.curpos); Vector3$1.lerp(this.m_player.transform.position, this.curpos, 0.15, this.curpos); this.curpos = new Vector3$1(this.curpos.x, this.curpos.y, this.curpos.z); this.m_player.transform.position = this.curpos; } MoveRayJupde() { var isDownHit = false; var hitResult = new Laya.HitResult(); var boxCollider = new Laya.BoxColliderShape(0.2, 0.2, 0.2); 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); var dir = new Vector3$1(0, -100, 0); var to = new Vector3$1(0, 0, 0); Vector3$1.add(from, dir, to); if (AssetManager.Instance.mainscene.physicsSimulation.shapeCast(boxCollider, from, to, hitResult)) { if (hitResult != null) { if (this.Downhit.collider.collisionGroup == 1) { isDownHit = true; } } } return isDownHit; } get DownRayCheck() { var isDownHit = false; var boxCollider = new Laya.BoxColliderShape(0.2, 0.2, 0.2); 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); var dir = new Vector3$1(0, -100, 0); var to = new Vector3$1(0, 0, 0); Vector3$1.add(from, dir, to); if (AssetManager.Instance.mainscene.physicsSimulation.shapeCast(boxCollider, from, to, this.Downhit)) { if (this.Downhit != null) { console.log("111111111111", this.Downhit.collider.owner.name); if (this.Downhit.collider.collisionGroup == 1 || this.Downhit.collider.collisionGroup == 100) { isDownHit = true; } } } return isDownHit; } get FowardRayCheck() { var isFowardHit = false; 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); let foward = Transform3DHelper.getForward(this.m_player.transform); var FowardRay = new Laya.Ray(startPos, foward); if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this.FowardHit, 1)) { if (this.FowardHit) { console.log(this.FowardHit.collider.owner.name); console.log("前方有物体"); } if (this.FowardHit.collider.collisionGroup == 100) { console.log("射线打到npc了"); this.ForwardTarget = this.FowardHit.collider; isFowardHit = true; } } return isFowardHit; } ChangeDeadState() { this.destroy(); } } class PlayerManager { constructor() { this.trun = true; this.first = true; PlayerManager.ins = this; } static get Instance() { if (PlayerManager.ins == null) { return new PlayerManager(); } return PlayerManager.ins; } Init() { if (this.PlayerNode == null) { this.PlayerNode = new Laya.Sprite3D(); LevelManager.Instance.spritepool.addChild(this.PlayerNode); if (this.player == null) { let playerpref = AssetManager.Instance.Character.get(2); this.player = Laya.Sprite3D.instantiate(playerpref); this.PlayerNode.addChild(this.player); } } this.PlayerNode.transform.position = AssetManager.Instance.playerpos.transform.position.clone(); this.PlayerNode.transform.rotation = AssetManager.Instance.playerpos.transform.rotation.clone(); this.player.transform.localPosition = new Laya.Vector3(0, 0, 0); } EnablePlayer() { this.PlayerNode.addComponent(RoleMoveBehav); Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.OnMouseDown); } DisablePlayer() { let _move = this.PlayerNode.getComponent(RoleMoveBehav); if (_move) { _move.destroy(); } Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.OnMouseDown); } OnMouseDown() { if (this.first) { this.first = false; return; } if (this.trun) { this.PlayerNode.transform.rotationEuler = new Laya.Vector3(0, -90, 0); this.trun = !this.trun; } else { this.PlayerNode.transform.rotationEuler = new Laya.Vector3(0, 0, 0); this.trun = !this.trun; } } } class LevelManager { constructor() { LevelManager.ins = this; } static get Instance() { if (LevelManager.ins == null) { return new LevelManager(); } return LevelManager.ins; } RegEvent() { DispatcherManager.StageOn(StageState.Lose, this, this.GameLose); DispatcherManager.StageOn(StageState.Win, this, this.GameWin); DispatcherManager.StageOn(StageState.Pause, this, this.GamePause); DispatcherManager.StageOn(StageState.Resume, this, this.GameResume); } GameStart() { PlayerManager.Instance.Init(); PlayerManager.Instance.EnablePlayer(); } GameLose() { } GameWin() { } GamePause() { } GameResume() { } } class CameraManager { constructor() { this.poschazhi = new Laya.Vector3(); this.gengsuipos = new Laya.Vector3(); this.lllpos = new Laya.Vector3(); this.hights = 0; this.wights = 0; CameraManager.ins = this; DispatcherManager.StageOn(StageState.Start, this, this.CameraFollow); DispatcherManager.StageOn(StageState.Win, this, this.CameraCancelFollow); DispatcherManager.StageOn(StageState.Lose, this, this.CameraCancelFollow); } static get Instance() { if (CameraManager.ins == null) { return new CameraManager(); } return CameraManager.ins; } Init() { } CameraFollow() { this.hights = 0; this.wights = 0; Laya.Vector3.subtract(PlayerManager.Instance.PlayerNode.transform.position, this.camera.transform.position, this.poschazhi); Laya.timer.frameLoop(1, this, this.GenSui); } GenSui() { Laya.Vector3.subtract(PlayerManager.Instance.PlayerNode.transform.position, this.poschazhi, this.gengsuipos); this.hights = GameTools.Instance.lerp(this.hights, 1, 0.03); this.wights = GameTools.Instance.lerp(this.wights, 0.8, 0.02); this.gengsuipos = new Laya.Vector3(this.gengsuipos.x, this.gengsuipos.y, this.gengsuipos.z); Laya.Vector3.lerp(this.camera.transform.position, this.gengsuipos, 0.25, this.lllpos); this.lllpos = new Laya.Vector3(this.gengsuipos.x, this.lllpos.y, this.lllpos.z); this.camera.transform.position = this.lllpos; var qqqwe = new Laya.Quaternion(); var eyePos = new Laya.Vector3(this.gengsuipos.x, this.gengsuipos.y - 0.8, this.gengsuipos.z); Laya.Quaternion.lookAt(eyePos, PlayerManager.Instance.PlayerNode.transform.position, new Laya.Vector3(0, 1, 0), qqqwe); qqqwe.invert(qqqwe); Laya.Quaternion.slerp(this.camera.transform.rotation, qqqwe, 0.1, qqqwe); this.camera.transform.rotation = qqqwe; } CameraCancelFollow() { Laya.timer.clear(this, this.GenSui); } } class InGameView extends ui.InGameViewUI { constructor() { super(); InGameView.ins = this; } static get Instance() { if (InGameView.ins == null) { return new InGameView(); } return InGameView.ins; } OnShow() { console.log("游戏界面"); this.click.play(null, true); this.on(Laya.Event.MOUSE_DOWN, this, this.ClickStart); } ClickStart() { this.click.stop(); this.hand.visible = false; this.off(Laya.Event.MOUSE_DOWN, this, this.ClickStart); } OnHide() { } } class HomeView extends ui.HomeViewUI { constructor() { super(); HomeView.ins = this; } static get Instance() { if (HomeView.ins == null) { return new HomeView(); } return HomeView.ins; } OnShow() { console.log("主界面"); this.RegButton(); } RegButton() { this.StartBtn.clickHandler = new Laya.Handler(this, this.Start); } Start() { ViewManager.Instance.ShowView(ViewType.InGameView); DispatcherManager.StageTrigger(StageState.Start); } OnHide() { } } var ViewType; (function (ViewType) { ViewType[ViewType["InGameView"] = 0] = "InGameView"; ViewType[ViewType["HomeView"] = 1] = "HomeView"; ViewType[ViewType["GameResultView"] = 2] = "GameResultView"; ViewType[ViewType["PauseView"] = 3] = "PauseView"; ViewType[ViewType["UpGradeView"] = 4] = "UpGradeView"; ViewType[ViewType["SkinView"] = 5] = "SkinView"; ViewType[ViewType["TrialView"] = 6] = "TrialView"; ViewType[ViewType["BannerView"] = 7] = "BannerView"; })(ViewType || (ViewType = {})); class ViewManager { constructor() { this.showexportview = 0; this.popViewDic = []; this.ViewSprite = new Laya.Sprite(); this.OtherViewSprite = new Laya.Sprite(); ViewManager.ins = this; Laya.stage.addChild(this.ViewSprite); Laya.stage.addChild(this.OtherViewSprite); } static get Instance() { if (ViewManager.ins) { return ViewManager.ins; } else { return new ViewManager(); } } ShowView(_viewtype, data = null) { if (this.curView != null) { this.curView.OnHide(); this.curView.destroy(); this.curView.removeSelf(); } this.curView = this.CreateView(_viewtype); this.curView.name = ViewType[_viewtype]; this.ViewSprite.addChild(this.curView); this.curView.OnShow(data); } CloseView() { if (this.curView != null) { this.curView.OnHide(); this.curView.destroy(); this.curView.removeSelf(); } } OpenPopView(viewType, data = null) { var popView; if (this.popViewDic[viewType]) { popView = this.popViewDic[viewType]; this.OtherViewSprite.setChildIndex(popView, this.OtherViewSprite.numChildren - 1); popView.visible = true; } else { popView = this.CreateView(viewType); this.OtherViewSprite.addChild(popView); this.popViewDic[viewType] = popView; } popView.OnOpen(data); } ClosePopView(viewType) { var popView = this.popViewDic[viewType]; if (popView == null) { return; } popView.OnHide(); popView.visible = false; } ClearPopViews() { } CreateView(_viewtype) { switch (_viewtype) { case ViewType.InGameView: return new InGameView(); case ViewType.HomeView: return new HomeView(); } return null; } } class AssetManager { constructor() { this.Prop = new Dictionary(); this.Character = new Dictionary(); AssetManager.ins = this; DispatcherManager.EventOn(EventState.LoadComplete, this, this.Init); } static get Instance() { if (AssetManager.ins == null) { return new AssetManager(); } return AssetManager.ins; } Init() { Laya.stage.addChild(this.mainscene); this.maincamera = this.mainscene.getChildByName("Main Camera"); this.maincamera.enableHDR = false; CameraManager.Instance.camera = this.maincamera; let _sprite = new Laya.Sprite3D(); this.mainscene.addChild(_sprite); LevelManager.Instance.spritepool = _sprite; this.SetCharacterPos(); LevelManager.Instance.RegEvent(); LevelManager.Instance.GameStart(); ViewManager.Instance.ShowView(ViewType.HomeView); } getPref(name) { return this.Prop.get(name); } getRolePref(index) { return this.Character.get(index); } SetCharacterPos() { let _level = this.mainscene.getChildByName("level1"); for (let i = 0; i < _level.numChildren; i++) { let item = _level.getChildAt(i); if (item.name == "player") { this.playerpos = item; } else if (item.name == "role") { let _pref = this.getRolePref(1); let _player = Laya.Sprite3D.instantiate(_pref); LevelManager.Instance.spritepool.addChild(_player); _player.transform.position = item.transform.position.clone(); _player.transform.rotation = item.transform.rotation.clone(); NodeUtil.SetColliderGroup(_player, 100); } } } } class LoadView extends ui.LoadViewUI { constructor() { super(); this.progressnum = 0; this.fast = 0.07; this.slow = 0.005; this.End = false; this.EndProgress = false; LoadView.ins = this; Laya.stage.addChild(this); this.Init(); } static get Instance() { if (LoadView.ins == null) { return new LoadView(); } return LoadView.ins; } Init() { this.LoadScene(); Laya.timer.loop(1, this, this.UpdateProgress); this.height = Laya.stage.height; Laya.stage.on(Laya.Event.RESIZE, this, () => { this.height = Laya.stage.height; }); } UpdateProgress() { if (this.progressnum <= 0.7) { this.progressnum += this.fast; } else if (this.progressnum > 0.7 && this.progressnum < 0.99) { this.progressnum += this.slow; } else { if (this.End) { this.progressnum += this.slow; } } if (!this.EndProgress && this.progressnum >= 1) { this.EndProgress = true; this.progressnum = 1; Laya.timer.clear(this, this.UpdateProgress); this.LoadComplete(); } this.jindupro.value = this.progressnum; } Login() { WXSDK.AldEvent("开始登陆"); window['zzsdkui'].aliEvent('loading', { 'start': true }); if (Laya.Browser.onWeiXin) { this.LoginWx(); } else { this.LoginLocal(); } } LoginWx() { if (Laya.Browser.onWeiXin) { WXSDK.DengLu((res) => { if (res != "error") { WXSDK.AldEvent("微信登陆成功"); console.log("1微信登录成功:" + res); this.LoginLocal(); } else { this.LoginWx(); } }); } else { this.LoginLocal(); } } LoginLocal() { ServerManager.Instance.Login(null, Laya.Handler.create(this, this.LoginComplete), Laya.Handler.create(this, this.LoginFail)); } LoginComplete() { WXSDK.AldEvent("本地服务器登陆成功"); console.log("本地服务器登陆成功"); GuangGao.InitVideo(); if (Laya.Browser.onWeiXin) { this.LoadSubPackage(); } else { this.LoadScene(); } } LoginFail() { console.log("本地服务器登陆失败"); } LoadSubPackage() { Laya.Browser.window.wx.loadSubpackage({ name: 'subpackage', success: (res) => { WXSDK.AldEvent("分包1加载成功"); this.LoadSubPackage2(); }, fail: (res) => { this.LoadSubPackage(); } }); } LoadSubPackage2() { Laya.Browser.window.wx.loadSubpackage({ name: 'subpackage2', success: (res) => { WXSDK.AldEvent("分包2加载成功"); this.LoadScene(); }, fail: (res) => { this.LoadSubPackage2(); } }); } LoadScene() { Laya.Scene3D.load(ResourcesPath.mainscene, Laya.Handler.create(this, (sprite) => { this.mainscene = sprite; AssetManager.Instance.mainscene = this.mainscene; WXSDK.AldEvent("场景资源加载完毕"); this.LoadRole(); })); console.log("场景资源加载成功"); } LoadRole() { var arr = []; for (let i = 0; i < ResourcesPath.Character.length; i++) { let item = ResourcesPath.Character[i]; arr.push(item); } Laya.loader.create(arr, Laya.Handler.create(this, () => { for (let i = 0; i < ResourcesPath.Character.length; i++) { let model = Laya.loader.getRes(ResourcesPath.Character[i]); AssetManager.Instance.Character.set(i + 1, model); Laya.loader.clearRes(ResourcesPath.Character[i]); } console.log("玩家模型加载成功"); WXSDK.AldEvent("玩家模型加载完毕"); this.LoadResources(); })); } LoadResources() { var arr = []; for (let i = 0; i < ResourcesPath.Prop.length; i++) { let item = ResourcesPath.Prop[i]; arr.push(item); } Laya.loader.create(arr, Laya.Handler.create(this, () => { arr.forEach(s => { if (s.progress == 1) { let sp = Laya.loader.getRes(s.url); AssetManager.Instance.Prop.set(sp.name, sp); } else { console.log(`[LOG]${s.url}加载失败`); } }, this); console.log("道具模型加载成功"); WXSDK.AldEvent("道具模型加载完毕"); this.complete(); })); } complete() { this.End = true; this.slow = this.fast; DispatcherManager.EventTrigger(EventState.LoadComplete); } LoadComplete() { this.destroy(); } } class Main { constructor() { if (window["Laya3D"]) Laya3D.init(GameConfig.width, GameConfig.height); else Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]); Laya["Physics"] && Laya["Physics"].enable(); Laya["DebugPanel"] && Laya["DebugPanel"].enable(); Laya.stage.scaleMode = GameConfig.scaleMode; Laya.stage.screenMode = GameConfig.screenMode; Laya.stage.alignV = GameConfig.alignV; Laya.stage.alignH = GameConfig.alignH; Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson; if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true") Laya.enableDebugPanel(); if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"]) Laya["PhysicsDebugDraw"].enable(); if (GameConfig.stat) Laya.Stat.show(); Laya.alertGlobalError = true; Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION); } onVersionLoaded() { Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded)); } onConfigLoaded() { new LoadView(); } } new Main(); }()); //# sourceMappingURL=bundle.js.map