(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 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); } } 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["RefreshPro"] = 8] = "RefreshPro"; })(StageState || (StageState = {})); var RoleState; (function (RoleState) { RoleState[RoleState["Die"] = 0] = "Die"; RoleState[RoleState["Sky"] = 1] = "Sky"; RoleState[RoleState["OnLand"] = 2] = "OnLand"; RoleState[RoleState["Land"] = 3] = "Land"; RoleState[RoleState["Arriver"] = 4] = "Arriver"; })(RoleState || (RoleState = {})); 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(); 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; } } class ResourcesPath { } ResourcesPath.Yan = "yan"; ResourcesPath.YanHua = "yanhua"; ResourcesPath.Nail1 = "Nail1"; ResourcesPath.Nail2 = "Nail2"; ResourcesPath.Nail3 = "Nail3"; ResourcesPath.Nail4 = "Nail4"; ResourcesPath.Nail5 = "Nail5"; ResourcesPath.Nail6 = "Nail6"; ResourcesPath.Nail7 = "Nail7"; ResourcesPath.Coin = "Coin"; ResourcesPath.FinishCircle = "FinishCircle"; ResourcesPath.Speed = "speed"; ResourcesPath.Ramp = "Ramp"; ResourcesPath.mainscene = "subpackage/res/mainscene/LayaScene_mainscene/Conventional/mainscene.ls"; ResourcesPath.Character = [ "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Character1.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Character2.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Character3.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Character4.lh" ]; ResourcesPath.Prop = [ "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/FinishCircle.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/FinishCircle2.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail1.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail2.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail3.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail4.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail5.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail6.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Nail7.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/yan.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/yanhua.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/flag.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Coin.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/Ramp.lh", "subpackage2/res/gameresources/LayaScene_gameresources/Conventional/speed.lh", ]; ResourcesPath.fogcolor = [ new Laya.Vector3(0.5803922, 0.8431373, 1), new Laya.Vector3(216 / 255, 142 / 255, 247 / 255), new Laya.Vector3(180 / 255, 1, 217 / 255) ]; var Vector3$1 = Laya.Vector3; class WallBehav extends Laya.Script3D { constructor() { super(); this._hitres = new Laya.HitResult(); this.crash = false; this._hitres2 = new Laya.HitResult(); } onAwake() { this._gameobject = this.owner; } onStart() { var startPos = new Vector3$1(this._gameobject.transform.position.x, this._gameobject.transform.position.y, this._gameobject.transform.position.z); let _up = new Laya.Vector3(0, 1, 0); var FowardRay = new Laya.Ray(startPos, _up); if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this._hitres, 1)) { if (this._hitres.collider.collisionGroup == 2) { let _wall = this._hitres.collider.owner.parent; if (this.crash) { NodeUtil.SetColliderInactive(this._gameobject); let _pre = AssetManager.Instance.getPref(ResourcesPath.Yan); let yan = Laya.Sprite3D.instantiate(_pre); LevelManager.Instance.spritepool.addChild(yan); yan.transform.position = this._gameobject.transform.position.clone(); yan.transform.scale = new Laya.Vector3(0.5, 0.5, 0.5); this.destroy(); this._gameobject.destroy(); } else { this.FallDown(); } let _behav = _wall.addComponent(WallBehav); } } else { if (this.crash) { NodeUtil.SetColliderInactive(this._gameobject); let _pre = AssetManager.Instance.getPref(ResourcesPath.Yan); let yan = Laya.Sprite3D.instantiate(_pre); LevelManager.Instance.spritepool.addChild(yan); yan.transform.position = this._gameobject.transform.position.clone(); yan.transform.scale = new Laya.Vector3(0.5, 0.5, 0.5); this.destroy(); this._gameobject.destroy(); } } } onUpdate() { if (this.crash) { NodeUtil.SetColliderInactive(this._gameobject); let _pre = AssetManager.Instance.getPref(ResourcesPath.Yan); let yan = Laya.Sprite3D.instantiate(_pre); LevelManager.Instance.spritepool.addChild(yan); yan.transform.position = this._gameobject.transform.position.clone(); yan.transform.scale = new Laya.Vector3(0.5, 0.5, 0.5); this.destroy(); this._gameobject.destroy(); return; } this.Down(); } Crash() { NodeUtil.SetColliderInactive(this._gameobject); let _pre = AssetManager.Instance.getPref(ResourcesPath.Yan); let yan = Laya.Sprite3D.instantiate(_pre); LevelManager.Instance.spritepool.addChild(yan); yan.transform.position = this._gameobject.transform.position.clone(); yan.transform.scale = new Laya.Vector3(0.5, 0.5, 0.5); this.destroy(); this._gameobject.destroy(); } FallDown() { Laya.timer.loop(1, this, this.Down); } Down() { var startPos = new Vector3$1(this._gameobject.transform.position.x, this._gameobject.transform.position.y + 0.1, this._gameobject.transform.position.z); let _down = new Laya.Vector3(0, -0.1, 0); var FowardRay = new Laya.Ray(startPos, _down); if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this._hitres2, 0.2)) { if (this._hitres2 != null && (this._hitres2.collider.collisionGroup == 1 || this._hitres2.collider.collisionGroup == 2)) { Laya.timer.clear(this, this.Down); } else { let _posy = this._gameobject.transform.position.y -= 0.03; this._gameobject.transform.position = new Laya.Vector3(this._gameobject.transform.position.x, _posy, this._gameobject.transform.position.z); } } else { let _posy = this._gameobject.transform.position.y -= 0.03; this._gameobject.transform.position = new Laya.Vector3(this._gameobject.transform.position.x, _posy, this._gameobject.transform.position.z); } } } var VoiceType; (function (VoiceType) { VoiceType[VoiceType["crashrole"] = 0] = "crashrole"; VoiceType[VoiceType["crashwall"] = 1] = "crashwall"; VoiceType[VoiceType["win"] = 2] = "win"; VoiceType[VoiceType["lose"] = 3] = "lose"; VoiceType[VoiceType["fly"] = 4] = "fly"; VoiceType[VoiceType["speedup"] = 5] = "speedup"; VoiceType[VoiceType["coin"] = 6] = "coin"; })(VoiceType || (VoiceType = {})); var BGMType; (function (BGMType) { BGMType[BGMType["bgm"] = 0] = "bgm"; })(BGMType || (BGMType = {})); class AudioManager { static voiceres(_type) { return "subpackage2/res/music/" + VoiceType[_type] + ".mp3"; } static bgmres(_type) { return "subpackage2/res/music/" + BGMType[_type] + ".mp3"; } static ClearAudio() { Laya.SoundManager.stopAllSound(); } static StopMusic() { Laya.SoundManager.stopMusic(); } static PlayBGM(_type) { if (!this.play) return; Laya.SoundManager.playMusic(this.bgmres(_type), 0); Laya.SoundManager.musicVolume = 0.5; } static PlayVoice(_type, _loop = false) { if (!this.play) return; var loop = _loop ? 0 : 1; Laya.SoundManager.playSound(this.voiceres(_type), loop); } } AudioManager.play = true; class CoinBehav extends Laya.Script3D { constructor() { super(); } onAwake() { this._gameobject = this.owner; Laya.timer.loop(1, this, this.Rotate); } OnTouch() { AudioManager.PlayVoice(VoiceType.coin); Laya.timer.clear(this, this.Rotate); this.destroy(); } Rotate() { this._gameobject.transform.rotate(new Laya.Vector3(0, 0.05, 0)); } } var Vector3$2 = Laya.Vector3; var Quaternion = Laya.Quaternion; class MateMove extends Laya.Script3D { constructor() { super(); this._speed = 0.2; this.testspeed = 0.3; this.Tag_Head = false; this.start = false; this.isdead = false; this.geted = false; this._arriver = false; this._destination = false; this.GravityTime = 0; this.ChargeSpeed = 0; this.ChargeTime = 0; this.Downhit = new Laya.HitResult(); this.FowardHit = new Laya.HitResult(); this._forward = new Vector3$2(0, 0, 0); this._up = new Vector3$2(0, 1, 0); this.CanJump = false; this.JumpTime = 0; this.JumpSpeed = 0.3; this.JumpSpeedUp = 1; this.targetPos = new Vector3$2(0, 0, 0); this.forW = new Vector3$2(0, 0, 0); this.RoleList = []; this.MovePointList = []; this.MoveRotateList = []; this._foward = new Laya.Vector3(0, 0, 0); this._MovetarPos = new Laya.Vector3(0, 0, 0); this.curpos2 = new Vector3$2(); this.offest2 = new Vector3$2(); this.curspeed2 = 0; this.curpos = new Vector3$2(); this.offest = new Vector3$2(); this.curspeed = 0; DispatcherManager.StageOn(StageState.Start, this, this.GameStart); } onAwake() { this._gameobject = this.owner; this._transform = this._gameobject.transform; this._quaternion = new Quaternion(); this._animator = this._gameobject.getComponent(Laya.Animator); } onUpdate() { if (!this.start) return; if (this.isdead) { this.RoleDie(); this.ChangeState(RoleState.Die); return; } if (this._destination) return; if (this.Tag_Head) { this.RefreshUI(); if (this.DownRayCheck) { if (this.curstate == RoleState.OnLand) { this._gameobject.transform.position = new Vector3$2(this._gameobject.transform.position.x, this.Downhit.point.y, this._gameobject.transform.position.z); if (this.Downhit.collider.owner.parent.name == "speed") { AudioManager.PlayVoice(VoiceType.speedup); this.SpeedUp(0.6, 0.1); } else if (this.Downhit.collider.owner.parent.name == "Ramp") { AudioManager.PlayVoice(VoiceType.fly); this.SpeedUp(0.3, 0.2); this.Jump(); } } else if (this.curstate == RoleState.Sky) { var distance = this._gameobject.transform.position.y - this.Downhit.point.y; if (distance < 0.5) { var leropos = new Vector3$2(this._gameobject.transform.position.x, this.Downhit.point.y, this._gameobject.transform.position.z); Vector3$2.lerp(this._gameobject.transform.position, leropos, 0.3, leropos); this._gameobject.transform.position = leropos; this.ChangeState(RoleState.OnLand); } } } else { this.ChangeState(RoleState.Sky); } if (this.FowardRayCheck) ; let foward = Transform3DHelper.getForward(this._gameobject.transform); this.Move(foward); this.Gravity(); } else { if (!this.geted) return; if (this._arriver) { if (this.DownRayCheck) { if (this.curstate == RoleState.OnLand) { this._gameobject.transform.position = new Vector3$2(this._gameobject.transform.position.x, this.Downhit.point.y, this._gameobject.transform.position.z); } else if (this.curstate == RoleState.Sky) { var distance = this._gameobject.transform.position.y - this.Downhit.point.y; if (distance < 0.5) { var leropos = new Vector3$2(this._gameobject.transform.position.x, this.Downhit.point.y, this._gameobject.transform.position.z); Vector3$2.lerp(this._gameobject.transform.position, leropos, 0.3, leropos); this._gameobject.transform.position = leropos; this.ChangeState(RoleState.OnLand); } } } else { this.ChangeState(RoleState.Sky); } this.RoleMoveFun(); this.Gravity(); } else { this.MoveToGroup(); } } if (this._gameobject.transform.position.y < -15) { this.FallDown(); } } RefreshUI() { let pre = PlayerManager.Instance.RefreshPro(); let count = this.RoleList.length; let data = {}; data["pre"] = pre; data["count"] = count; DispatcherManager.StageTrigger(StageState.RefreshPro, [data]); } GameStart() { this.start = true; if (this.Tag_Head) this.ChangeState(RoleState.OnLand); Laya.timer.loop(2, this, this.SetNewMovePoint, [this._transform]); } Start(model) { if (this.geted) return; this.targetmodel = model.getChildByName("followpos"); this.geted = true; this.ChangeState(RoleState.OnLand); } ChangeState(state) { if (this.curstate == state) return; this.curstate = state; switch (this.curstate) { case RoleState.Die: this.DIE(); break; case RoleState.Sky: this.SKY(); break; case RoleState.OnLand: this.ONLAND(); break; case RoleState.Arriver: this.ARRIVER(); break; } } ONLAND() { if (this.Tag_Head) { this._animator.play("run"); this._animator.speed = 2; } else { if (this.geted) { this._animator.play("run"); this._animator.speed = 2; } else { this._animator.play("idle"); } } } SKY() { this._animator.play("sky"); } ARRIVER() { this._destination = true; Laya.timer.clear(this, this.SetNewMovePoint); this._animator.play("win"); if (this.Tag_Head) { GameManager.Instance.GameWin(); for (let i = 0; i < this.RoleList.length; i++) { let item = this.RoleList[i].getComponent(MateMove); if (item) { item.ARRIVER(); } } } } DIE() { Laya.timer.clear(this, this.SetNewMovePoint); this._gameobject.active = false; if (this.Tag_Head && this.RoleList.length == 0) { GameManager.Instance.GameLose(); } this.destroy(); } FallDown() { Laya.timer.clear(this, this.SetNewMovePoint); GameManager.Instance.GameLose(); AudioManager.PlayVoice(VoiceType.lose); WXSDK.Shake(true); this.destroy(); } SetMoveTarger(_point, _rotate) { if (_point) { this._MovetarPos = _point; this._gameobject.transform.position = this._MovetarPos.clone(); this._gameobject.transform.rotationEuler = _rotate.clone(); this.MovePointList.push(_point); if (this.MovePointList.length > 100) { this.MovePointList.shift(); } this.MoveRotateList.push(_rotate); if (this.MoveRotateList.length > 100) { this.MoveRotateList.shift(); } } } RoleMoveFun() { Quaternion.lookAt(this._MovetarPos, this._transform.position, this._up, this._quaternion); this._quaternion.invert(this._quaternion); Quaternion.slerp(this._transform.rotation, this._quaternion, 0.1, this._quaternion); this._transform.rotation = this._quaternion.clone(); let _rotationEuler = this._transform.rotationEuler.clone(); _rotationEuler.x = 0; _rotationEuler.z = 0; this._transform.rotationEuler = _rotationEuler; } SetNewMovePoint(_transform) { if (this.Tag_Head) { var _movePos = _transform.position.clone(); var _point = new Laya.Vector3(_movePos.x, _movePos.y, _movePos.z); var _rotate = _transform.rotationEuler.clone(); this.MovePointList.push(_point); if (this.MovePointList.length > 200) { this.MovePointList.shift(); } this.MoveRotateList.push(_rotate); if (this.MoveRotateList.length > 200) { this.MoveRotateList.shift(); } for (let i = 0; i < this.RoleList.length; i++) { var _script = this.RoleList[i].getComponent(MateMove); if (_script) { var _id = this.MovePointList.length - 1 - (i + 1) * 10; _script.SetMoveTarger(this.MovePointList[_id], this.MoveRotateList[_id]); } } } } RoleDie() { if (this.RoleList.length == 0) { return; } var _newHand = this.RoleList[0]; var _script = _newHand.getComponent(MateMove); if (_script) { _script._gameobject.transform.rotationEuler = this._gameobject.transform.rotationEuler.clone(); _script.Tag_Head = true; PlayerManager.Instance.player = _script._gameobject; _script.RoleList = []; for (let i = 1; i < this.RoleList.length; i++) { _script.RoleList.push(this.RoleList[i]); } } } MoveToGroup() { this.targetPos = this.targetmodel.transform.position; let tarPos = this.targetPos; let speed = 0.05; Vector3$2.subtract(tarPos, this._transform.position, this._forward); Vector3$2.normalize(this._forward, this._forward); this._forward = new Vector3$2(this._forward.x * speed, this._forward.y * speed, this._forward.z * speed); this._transform.translate(this._forward, false); if (Vector3$2.distance(this._transform.position, tarPos) < 0.1) { this.ArriverTargetPos(); return; } Quaternion.lookAt(tarPos, this._transform.position, this._up, this._quaternion); this._quaternion.invert(this._quaternion); Quaternion.slerp(this._transform.rotation, this._quaternion, 0.1, this._quaternion); this._transform.rotation = this._quaternion.clone(); } Move(_dir) { let speed = this.testspeed; if (this.ChargeTime > 0) { this.ChargeTime -= 0.01; speed = speed + this.ChargeSpeed; } else { this.ChargeSpeed = GameTools.Instance.lerp(this.ChargeSpeed, 0, 0.1); speed = speed + this.ChargeSpeed; this.ChargeTime = 0; } this.curspeed = GameTools.Instance.lerp(this.curspeed, speed, 0.1); Vector3$2.scale(_dir, this.curspeed, this.offest); Vector3$2.add(this._gameobject.transform.position, this.offest, this.curpos); Vector3$2.lerp(this._gameobject.transform.position, this.curpos, 0.15, this.curpos); if (this.CanJump) { this.JumpTime += 0.8; var Height = this.JumpSpeed * this.JumpTime * 1.9 - (this.JumpTime * this.JumpTime * this.JumpSpeedUp); if (Height > 0) { this.curpos = new Vector3$2(this.curpos.x, this.curpos.y + Height, this.curpos.z); } else { this.CanJump = false; } this.curpos = new Vector3$2(this.curpos.x, this.curpos.y + 0.8, this.curpos.z); this._gameobject.transform.position = this.curpos; } else { this.curpos = new Vector3$2(this.curpos.x, this.curpos.y, this.curpos.z); this._gameobject.transform.position = this.curpos; } } ArriverTargetPos() { this._gameobject.transform.position = this.targetmodel.transform.position.clone(); this._gameobject.transform.rotationEuler = this.targetmodel.transform.rotationEuler.clone(); this._arriver = true; } get DownRayCheck() { var startPos = new Vector3$2(this._gameobject.transform.position.x, this._gameobject.transform.position.y + 0.1, this._gameobject.transform.position.z); let foward = new Laya.Vector3(0, -1, 0); var FowardRay = new Laya.Ray(startPos, foward); var isDownHit = false; if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this.Downhit, 1)) { if (this.Downhit != null) { if (this.Downhit.collider.collisionGroup == 1) { isDownHit = true; } } } return isDownHit; } get FowardRayCheck() { var isFowardHit = false; var startPos = new Vector3$2(this._gameobject.transform.position.x, this._gameobject.transform.position.y + 0.1, this._gameobject.transform.position.z); let foward = Transform3DHelper.getForward(this._gameobject.transform); var FowardRay = new Laya.Ray(startPos, foward); if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(FowardRay, this.FowardHit, 0.1)) { if (this.FowardHit) { console.log(this.FowardHit.collider.owner.parent.name); console.log("前方有物体"); } if (this.FowardHit.collider.collisionGroup == 100) { console.log("射线打到npc了"); this.ForwardTarget = this.FowardHit.collider; isFowardHit = true; let _mate = this.FowardHit.collider.owner.parent.getComponent(MateMove); if (_mate) { let _model; if (this.RoleList.length > 0) { _model = this.RoleList[this.RoleList.length - 1]; } else { _model = this._gameobject; } _mate.Start(_model); let target = this.FowardHit.collider.owner.parent; if (!this.JudgeEqual(target)) { this.RoleList.push(target); } } AudioManager.PlayVoice(VoiceType.crashrole); WXSDK.Shake(); } else if (this.FowardHit.collider.collisionGroup == 2) { this.isdead = true; let _wall = this.FowardHit.collider.owner.parent; let _behav = _wall.getComponent(WallBehav); if (_behav) { _behav.Crash(); } else { _behav = _wall.addComponent(WallBehav); _behav.crash = true; } AudioManager.PlayVoice(VoiceType.crashwall); WXSDK.Shake(); } else if (this.FowardHit.collider.collisionGroup == 3) { this.Crash(); } else if (this.FowardHit.collider.collisionGroup == 200) { this.ChangeState(RoleState.Arriver); AudioManager.PlayVoice(VoiceType.win); WXSDK.Shake(true); } } return isFowardHit; } Crash() { let target = this.FowardHit.collider.owner.parent; switch (target.name) { case "Ramp": AudioManager.PlayVoice(VoiceType.fly); this.SpeedUp(0.8, 0.3); this.Jump(); break; case "Coin": let _behav = target.getComponent(CoinBehav); if (_behav) { _behav.OnTouch(); } target.destroy(); break; } } Gravity() { if (this.curstate == RoleState.Sky) { if (this.ChargeSpeed > 0.001) { this.GravityTime += 0.008; } else { this.GravityTime += 0.010; } var hight = this.GravityTime * this.GravityTime; this._gameobject.transform.position = new Vector3$2(this._gameobject.transform.position.x, this._gameobject.transform.position.y - hight, this._gameobject.transform.position.z + hight / 2); } } Jump() { this.CanJump = true; this.JumpTime = 0; } SpeedUp(_speed, _time) { if (this.ChargeTime < _time) { this.ChargeTime += 0.1; } if (this.ChargeSpeed < _speed) { this.ChargeSpeed += 0.2; } } JudgeEqual(_model) { for (let i = 0; i < this.RoleList.length; i++) { let item = this.RoleList[i]; if (item == _model) { return true; } } return false; } } class PlayerManager { constructor() { this.canmove = false; this.trun = true; PlayerManager.ins = this; } static get Instance() { if (PlayerManager.ins == null) { return new PlayerManager(); } return PlayerManager.ins; } Init() { this.Direction = AccountManager.Instance.curplayerData.LevelDirection; let playerpref = AssetManager.Instance.Character.get(1); this.player = Laya.Sprite3D.instantiate(playerpref); LevelManager.Instance.spritepool.addChild(this.player); this.player.transform.position = AssetManager.Instance.playerpos.transform.position.clone(); this.player.transform.rotation = AssetManager.Instance.playerpos.transform.rotation.clone(); this.trun = true; } RefreshPro() { let startpoint = AssetManager.Instance.playerpos.transform.position.clone(); let Z = startpoint.z; let finishpoint = AssetManager.Instance.finishpoint.z; let distance = finishpoint - Z; let pro = this.player.transform.position.z / distance; return pro; } EnablePlayer() { let _move = this.player.addComponent(MateMove); _move.Tag_Head = true; this.ListenOn(); } ListenOn() { Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.OnMouseDown); } ListenOff() { Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.OnMouseDown); } DisablePlayer() { let _move = this.player.getComponent(MateMove); if (_move) { _move.destroy(); } } OnMouseDown() { if (this.Direction == 1) { if (this.trun) { this.player.transform.rotationEuler = new Laya.Vector3(0, -90, 0); this.trun = !this.trun; } else { this.player.transform.rotationEuler = new Laya.Vector3(0, 0, 0); this.trun = !this.trun; } } else if (this.Direction == 2) { if (this.trun) { this.player.transform.rotationEuler = new Laya.Vector3(0, 90, 0); this.trun = !this.trun; } else { this.player.transform.rotationEuler = new Laya.Vector3(0, 0, 0); this.trun = !this.trun; } } } } var REG = Laya.ClassUtils.regClass; var ui; (function (ui) { class GameResultViewUI extends Laya.Scene { constructor() { super(); } createChildren() { super.createChildren(); this.createView(GameResultViewUI.uiView); } } GameResultViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,13,14,10", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 29 }, { "type": "Image", "props": { "y": 210, "x": 90.5, "var": "WinBox", "skin": "Main/lanshandi.png", "alpha": 1 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": -140, "x": 24, "skin": "Main/shenglilo.png" }, "compId": 5 }, { "type": "Image", "props": { "y": 151, "x": 52.5, "skin": "Main/shangkuan.png" }, "compId": 6, "child": [{ "type": "Image", "props": { "y": 150, "x": 90.5, "skin": "Main/jinbidi.png" }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 27, "x": 86, "skin": "Main/jinbihud.png" }, "compId": 8 }, { "type": "Image", "props": { "y": 20, "x": 30, "skin": "Main/jinbi.png" }, "compId": 9 }, { "type": "Text", "props": { "y": -101, "x": 6, "width": 241, "var": "Win_GoldNum", "valign": "middle", "text": "888", "height": 69, "fontSize": 92, "font": "Microsoft YaHei", "color": "#92501d", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 10 }] }] }, { "type": "Button", "props": { "y": 470, "x": 82, "var": "Win_VideoBtn", "stateNum": 1, "skin": "Main/dihong.png" }, "compId": 12, "child": [{ "type": "Image", "props": { "y": 39, "x": 45, "skin": "Main/shipin.png" }, "compId": 13 }, { "type": "Image", "props": { "y": 40.5, "x": 158, "skin": "Main/sanbeilingqu.png" }, "compId": 14 }] }, { "type": "Button", "props": { "y": 631, "x": 185, "var": "Win_BackBtn", "stateNum": 1, "skin": "Main/buyongxieix.png" }, "compId": 15 }] }, { "type": "Image", "props": { "y": 210, "x": 90.5, "var": "FailBox", "skin": "Main/beijing.png", "alpha": 1 }, "compId": 17, "child": [{ "type": "Image", "props": { "y": -140, "x": 24, "skin": "Main/tongguanshi-lo.png" }, "compId": 18 }, { "type": "Image", "props": { "y": 151, "x": 52.5, "skin": "Main/shangshudi.png" }, "compId": 19, "child": [{ "type": "Image", "props": { "y": 150, "x": 90.5, "skin": "Main/qinandi.png" }, "compId": 20, "child": [{ "type": "Image", "props": { "y": 27, "x": 86, "skin": "Main/jinbihud.png" }, "compId": 21 }, { "type": "Image", "props": { "y": 20, "x": 30, "skin": "Main/jinbi.png" }, "compId": 22 }, { "type": "Text", "props": { "y": -101, "x": 6, "width": 241, "var": "Fail_GoldNum", "valign": "middle", "text": "888", "height": 69, "fontSize": 92, "font": "Microsoft YaHei", "color": "#3660ab", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 23 }] }] }, { "type": "Button", "props": { "y": 470, "x": 82, "var": "Fail_VideoBtn", "stateNum": 1, "skin": "Main/ludi.png" }, "compId": 24, "child": [{ "type": "Image", "props": { "y": 39, "x": 45, "skin": "Main/shipin.png" }, "compId": 25 }, { "type": "Image", "props": { "y": 39, "x": 157, "skin": "Main/sanbeilingqu.png" }, "compId": 26 }] }, { "type": "Button", "props": { "y": 631, "x": 185, "var": "Fail_BackBtn", "stateNum": 1, "skin": "Main/buyongxeixie.png" }, "compId": 27 }] }], "loadList": ["Main/chunhei.png", "Main/lanshandi.png", "Main/shenglilo.png", "Main/shangkuan.png", "Main/jinbidi.png", "Main/jinbihud.png", "Main/jinbi.png", "Main/dihong.png", "Main/shipin.png", "Main/sanbeilingqu.png", "Main/buyongxieix.png", "Main/beijing.png", "Main/tongguanshi-lo.png", "Main/shangshudi.png", "Main/qinandi.png", "Main/ludi.png", "Main/buyongxeixie.png"], "loadList3D": [] }; ui.GameResultViewUI = GameResultViewUI; REG("ui.GameResultViewUI", GameResultViewUI); 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": 963, "x": 204, "var": "StartBtn", "stateNum": 1, "skin": "Main/dianjikaishi.png" }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 72, "x": 209, "width": 86, "var": "shou", "skin": "Main/shou.png", "scaleY": 1, "scaleX": 1, "pivotY": 46, "pivotX": 43, "height": 92 }, "compId": 19 }] }, { "type": "Button", "props": { "y": 754, "x": 0, "stateNum": 1, "skin": "Main/gengduo.png", "name": "MoreFunBtn" }, "compId": 9 }, { "type": "Button", "props": { "y": 754, "x": 605, "var": "SkinBtn", "stateNum": 1, "skin": "Main/shangdain.png" }, "compId": 10 }, { "type": "Button", "props": { "y": 630, "x": 605, "var": "SignBtn", "stateNum": 1, "skin": "Main/qiandao.png" }, "compId": 11 }, { "type": "Image", "props": { "y": 95, "x": 557, "width": 164, "skin": "Main/qiandi.png", "height": 55 }, "compId": 13, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "skin": "Main/qian.png" }, "compId": 15 }, { "type": "Text", "props": { "y": 0, "x": 54, "width": 110, "var": "GoldNum", "valign": "middle", "text": "99999", "height": 55, "fontSize": 40, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 18 }] }, { "type": "Box", "props": { "y": 160.5, "x": 127.5, "width": 487, "var": "ProBox", "height": 81 }, "compId": 21, "child": [{ "type": "ProgressBar", "props": { "y": 30, "x": 68, "width": 352, "value": 0, "skin": "Main/guandi-3.png", "height": 22 }, "compId": 20 }, { "type": "Image", "props": { "y": 11.5, "x": 20, "skin": "Main/guandi.png" }, "compId": 22, "child": [{ "type": "Text", "props": { "y": 9, "x": 1, "width": 56, "var": "NowLevelNum", "valign": "middle", "text": "10", "height": 40, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 23 }] }, { "type": "Image", "props": { "y": 12, "x": 414, "skin": "Main/zhongdian.png" }, "compId": 24 }] }, { "type": "Button", "props": { "y": 36, "x": 32, "var": "SetBtn", "stateNum": 1, "skin": "Main/shezhi.png" }, "compId": 26 }, { "type": "Image", "props": { "visible": false, "var": "SetPanel", "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "13,15,15,15", "right": 0, "left": 0, "bottom": 0 }, "compId": 48, "child": [{ "type": "Image", "props": { "y": 466, "x": 118.5, "skin": "Main/Background Pop up ads.png" }, "compId": 29, "child": [{ "type": "Image", "props": { "y": 40, "x": 73, "skin": "Main/Bouton policy privacy.png", "name": "shake" }, "compId": 30, "child": [{ "type": "Image", "props": { "y": 15, "x": 43, "skin": "Main/zhenfu.png" }, "compId": 33 }, { "type": "Image", "props": { "y": 25, "x": 121, "skin": "Main/kaigdi.png" }, "compId": 35, "child": [{ "type": "Image", "props": { "y": 9, "x": 94, "skin": "Main/OFF.png" }, "compId": 38 }, { "type": "Image", "props": { "y": 9, "x": 23, "skin": "Main/ON.png" }, "compId": 39 }] }, { "type": "Image", "props": { "y": 25, "x": 206, "skin": "Main/bodong.png", "name": "on" }, "compId": 41 }, { "type": "Image", "props": { "y": 25, "x": 121, "skin": "Main/boodong-2.png", "name": "off" }, "compId": 40 }, { "type": "Button", "props": { "y": 26, "x": 121, "width": 171, "var": "shakebtn", "height": 41 }, "compId": 49 }] }, { "type": "Image", "props": { "y": 151.5, "x": 73, "skin": "Main/Bouton policy privacy.png", "name": "sound" }, "compId": 31, "child": [{ "type": "Image", "props": { "y": 20, "x": 47, "skin": "Main/yinfu.png" }, "compId": 34 }, { "type": "Image", "props": { "y": 25, "x": 121, "skin": "Main/kaigdi.png" }, "compId": 42, "child": [{ "type": "Image", "props": { "y": 9, "x": 94, "skin": "Main/OFF.png" }, "compId": 43 }, { "type": "Image", "props": { "y": 9, "x": 23, "skin": "Main/ON.png" }, "compId": 44 }] }, { "type": "Image", "props": { "y": 25, "x": 206, "skin": "Main/bodong.png", "name": "on" }, "compId": 45 }, { "type": "Image", "props": { "y": 25, "x": 121, "skin": "Main/boodong-2.png", "name": "off" }, "compId": 46 }, { "type": "Button", "props": { "y": 26, "x": 121, "width": 171, "var": "soundbtn", "height": 41 }, "compId": 50 }] }, { "type": "Button", "props": { "y": -46, "x": -35, "var": "CloseSetBtn", "stateNum": 1, "skin": "Main/guanbi.png" }, "compId": 47 }] }] }], "animations": [{ "nodes": [{ "target": 19, "keyframes": { "scaleY": [{ "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 0 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 5 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 10 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 15 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleY", "index": 20 }], "scaleX": [{ "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 0 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 5 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 10 }, { "value": 0.8, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 15 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 19, "key": "scaleX", "index": 20 }] } }], "name": "handclick", "id": 1, "frameRate": 24, "action": 0 }], "loadList": ["Main/dianjikaishi.png", "Main/shou.png", "Main/gengduo.png", "Main/shangdain.png", "Main/qiandao.png", "Main/qiandi.png", "Main/qian.png", "Main/guandi-3.png", "Main/guandi.png", "Main/zhongdian.png", "Main/shezhi.png", "Main/chunhei.png", "Main/Background Pop up ads.png", "Main/Bouton policy privacy.png", "Main/zhenfu.png", "Main/kaigdi.png", "Main/OFF.png", "Main/ON.png", "Main/bodong.png", "Main/boodong-2.png", "Main/yinfu.png", "Main/guanbi.png"], "loadList3D": [] }; 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": "Box", "props": { "y": 123, "x": 116.5, "width": 487, "visible": true, "var": "ProBox", "height": 81 }, "compId": 8, "child": [{ "type": "ProgressBar", "props": { "y": 30, "x": 68, "width": 352, "var": "jindupro", "value": 0, "skin": "Main/guandi-3.png", "height": 22 }, "compId": 9 }, { "type": "Image", "props": { "y": 11.5, "x": 20, "skin": "Main/guandi.png" }, "compId": 10, "child": [{ "type": "Text", "props": { "y": 9, "x": 1, "width": 56, "var": "NowLevelNum", "valign": "middle", "text": "10", "height": 40, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 11 }] }, { "type": "Image", "props": { "y": 12, "x": 414, "skin": "Main/zhongdian.png" }, "compId": 12 }] }, { "type": "Image", "props": { "y": 181.5, "x": 251.5, "visible": true, "skin": "Main/shuliandi.png" }, "compId": 13, "child": [{ "type": "Text", "props": { "y": 0, "x": 28, "width": 161, "var": "CountTxt", "valign": "middle", "text": "小人数量:22", "height": 45, "fontSize": 24, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 14 }] }], "loadList": ["Main/guandi-3.png", "Main/guandi.png", "Main/zhongdian.png", "Main/shuliandi.png"], "loadList3D": [] }; 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/beijing.png", "sizeGrid": "10,14,12,10", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 4 }, { "type": "ProgressBar", "props": { "y": 1018, "x": 165, "var": "jindupro", "skin": "Load/ss.png" }, "compId": 3 }, { "type": "Image", "props": { "y": 160, "x": 105, "skin": "Load/title.png" }, "compId": 5 }, { "type": "Image", "props": { "y": 1062, "x": 292.5, "skin": "Load/jiazaizhon.png" }, "compId": 7 }], "loadList": ["Load/beijing.png", "Load/ss.png", "Load/title.png", "Load/jiazaizhon.png"], "loadList3D": [] }; ui.LoadViewUI = LoadViewUI; REG("ui.LoadViewUI", LoadViewUI); class ReviveViewUI extends Laya.Scene { constructor() { super(); } createChildren() { super.createChildren(); this.createView(ReviveViewUI.uiView); } } ReviveViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,13,14,10", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 15 }, { "type": "Button", "props": { "y": 711, "x": 172.5, "var": "ReviveBtn", "stateNum": 1, "skin": "Main/dihong.png" }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 39, "x": 41, "skin": "Main/shipin.png" }, "compId": 5 }, { "type": "Image", "props": { "y": 39, "x": 162, "skin": "Main/fuhuowenzi.png" }, "compId": 6 }] }, { "type": "Button", "props": { "y": 888, "x": 294, "var": "BackBtn", "stateNum": 1, "skin": "Main/fanhuiwenzi.png" }, "compId": 7 }, { "type": "Box", "props": { "y": 315, "x": 116.5, "width": 487, "var": "ProBox", "height": 81 }, "compId": 8, "child": [{ "type": "ProgressBar", "props": { "y": 30, "x": 68, "width": 352, "skin": "Main/guandi-3.png", "height": 22 }, "compId": 9 }, { "type": "Image", "props": { "y": 11.5, "x": 20, "skin": "Main/guandi.png" }, "compId": 10, "child": [{ "type": "Text", "props": { "y": 9, "x": 1, "width": 56, "var": "NowLevelNum", "valign": "middle", "text": "10", "height": 40, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 11 }] }, { "type": "Image", "props": { "y": 12, "x": 414, "skin": "Main/zhongdian.png" }, "compId": 12 }] }, { "type": "Image", "props": { "y": 192, "x": 80.5, "skin": "Main/wenzi.png" }, "compId": 13 }], "loadList": ["Main/chunhei.png", "Main/dihong.png", "Main/shipin.png", "Main/fuhuowenzi.png", "Main/fanhuiwenzi.png", "Main/guandi-3.png", "Main/guandi.png", "Main/zhongdian.png", "Main/wenzi.png"], "loadList3D": [] }; ui.ReviveViewUI = ReviveViewUI; REG("ui.ReviveViewUI", ReviveViewUI); class SignViewUI extends Laya.Scene { constructor() { super(); } createChildren() { super.createChildren(); this.createView(SignViewUI.uiView); } } SignViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "top": 0, "skin": "Main/chunhei.png", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 72 }, { "type": "Image", "props": { "y": 143, "x": 60.5, "skin": "Main/qinad-d.png" }, "compId": 5, "child": [{ "type": "Image", "props": { "y": 12, "x": 188, "skin": "Main/qiriqiandao.png" }, "compId": 6 }, { "type": "Box", "props": { "y": 102, "x": 18, "width": 180, "height": 200 }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 8, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第1天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 9 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 12, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 14 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 11, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 10 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 15 }] }, { "type": "Box", "props": { "y": 102, "x": 209.5, "width": 180, "height": 200 }, "compId": 17, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 18, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第2天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 19 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 20, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 21 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 22, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 23 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 24 }] }, { "type": "Box", "props": { "y": 102, "x": 402, "width": 180, "height": 200 }, "compId": 25, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 26, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第3天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 27 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 28, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 29 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 30, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 31 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 32 }] }, { "type": "Box", "props": { "y": 318, "x": 18, "width": 180, "height": 200 }, "compId": 33, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 36, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第4天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 37 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 38, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 39 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 40, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 41 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 42 }] }, { "type": "Box", "props": { "y": 318, "x": 209, "width": 180, "height": 200 }, "compId": 34, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 43, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第5天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 44 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 45, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 46 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 47, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 48 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 49 }] }, { "type": "Box", "props": { "y": 318, "x": 402, "width": 180, "height": 200 }, "compId": 35, "child": [{ "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/pitongkuan.png" }, "compId": 50, "child": [{ "type": "Text", "props": { "y": 10, "x": 9, "width": 153, "valign": "middle", "text": "第6天", "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 51 }] }, { "type": "Image", "props": { "y": 76, "x": 67, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 52, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 53 }] }, { "type": "Image", "props": { "y": 0, "x": 4.5, "skin": "Main/heizha.png", "name": "complete" }, "compId": 54, "child": [{ "type": "Image", "props": { "y": 63, "x": 29, "skin": "Main/yihuode.png" }, "compId": 55 }] }, { "type": "Button", "props": { "top": 0, "right": 0, "name": "btn", "left": 0, "bottom": 0 }, "compId": 56 }] }, { "type": "Box", "props": { "y": 536, "x": 23, "width": 553, "height": 196 }, "compId": 57, "child": [{ "type": "Image", "props": { "y": -2, "x": 77, "skin": "Main/qitiankuang.png" }, "compId": 58, "child": [{ "type": "Text", "props": { "y": 42, "x": 42, "width": 78, "valign": "middle", "text": "第7天", "rotation": -45, "pivotY": 17, "pivotX": 39, "height": 33, "fontSize": 28, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 59 }] }, { "type": "Image", "props": { "y": 66.5, "x": 276.5, "skin": "Main/jinbi.png", "name": "icon" }, "compId": 60, "child": [{ "type": "Text", "props": { "y": 69, "x": -11, "width": 68, "valign": "middle", "text": "x100", "name": "coinnum", "height": 32, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 61 }] }, { "type": "Image", "props": { "y": -2, "x": 76, "width": 433, "skin": "Main/heizha.png", "sizeGrid": "63,54,82,55", "name": "complete", "height": 198 }, "compId": 62, "child": [{ "type": "Image", "props": { "y": 42.5, "x": 160, "skin": "Main/yihuode.png" }, "compId": 63 }] }, { "type": "Button", "props": { "y": 0, "x": 77, "width": 431, "name": "btn", "height": 196 }, "compId": 64 }] }] }, { "type": "Image", "props": { "y": 70, "x": 556, "width": 164, "skin": "Main/qiandi.png", "height": 55 }, "compId": 65, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "skin": "Main/qian.png" }, "compId": 66 }, { "type": "Text", "props": { "y": 0, "x": 54, "width": 110, "var": "GoldNum", "valign": "middle", "text": "99999", "height": 55, "fontSize": 40, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 67 }] }, { "type": "Button", "props": { "y": 921, "x": 172.5, "var": "VideoSign", "stateNum": 1, "skin": "Main/bd-d.png" }, "compId": 68, "child": [{ "type": "Image", "props": { "y": 39, "x": 42, "skin": "Main/ship.png" }, "compId": 69 }, { "type": "Image", "props": { "y": 39, "x": 156, "skin": "Main/minf.png" }, "compId": 70 }] }, { "type": "Button", "props": { "y": 1074, "x": 274, "stateNum": 1, "skin": "Main/buyong.png", "name": "NoBtn" }, "compId": 71 }], "loadList": ["Main/chunhei.png", "Main/qinad-d.png", "Main/qiriqiandao.png", "Main/pitongkuan.png", "Main/jinbi.png", "Main/heizha.png", "Main/yihuode.png", "Main/qitiankuang.png", "Main/qiandi.png", "Main/qian.png", "Main/bd-d.png", "Main/ship.png", "Main/minf.png", "Main/buyong.png"], "loadList3D": [] }; ui.SignViewUI = SignViewUI; REG("ui.SignViewUI", SignViewUI); })(ui || (ui = {})); 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.on(Laya.Event.MOUSE_DOWN, this, this.ClickStart); this.RefreshUI(); this.height = Laya.stage.height; Laya.stage.on(Laya.Event.RESIZE, this, () => { this.height = Laya.stage.height; }); DispatcherManager.StageOn(StageState.RefreshPro, this, this.SetProValue); } ClickStart() { this.off(Laya.Event.MOUSE_DOWN, this, this.ClickStart); } RefreshUI() { let stage = AccountManager.Instance.curplayerData.STAGE; this.NowLevelNum.text = stage + ""; } SetProValue(data) { this.jindupro.value = data["pre"]; this.CountTxt.text = "小人数量:" + (Number(data["count"]) + 1); } OnHide() { DispatcherManager.StageOff(StageState.RefreshPro, this, this.SetProValue); } } class Global { } Global.VERSION = "1.0.0"; Global.CFG = "123"; var HttpRequest = Laya.HttpRequest; var Event = Laya.Event; const JtSniperApiUrl = "https://waveapi.xwxgame.com/"; class TeamWave { } TeamWave.DengLu = "user/login"; TeamWave.KaiShi = "game/start"; TeamWave.JieShu = "game/play"; TeamWave.QianDao = "sign/sign"; TeamWave.Chengjiu = "achievement/getRewards"; TeamWave.Config = "config/table"; TeamWave.FenXiang = "fission/share"; TeamWave.LiXian = "fission/offline"; TeamWave.vd = "fission/vd"; TeamWave.FuHuo = "game/revival"; TeamWave.gadagdag = "treasure/click"; TeamWave.Invite = "invite/getRewards"; TeamWave.Lottery = "lottery/lottery"; TeamWave.ShareGetSkin = "theme/fission"; TeamWave.WearEquip = "theme/equip"; TeamWave.BuyEquip = "theme/buy"; TeamWave.ShouQuan = "user/auth"; TeamWave.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 + TeamWave.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 == TeamWave.KaiShi || protocol == TeamWave.JieShu || protocol == TeamWave.vd || protocol == TeamWave.Lottery || protocol == TeamWave.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 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.RefreshUI(); this.RegButton(); this.handclick.play(null, true); } RegButton() { this.StartBtn.clickHandler = new Laya.Handler(this, this.Start); this.SetBtn.clickHandler = new Laya.Handler(this, this.ShowSetPanel); this.CloseSetBtn.clickHandler = new Laya.Handler(this, this.HideSetPanel); this.shakebtn.clickHandler = new Laya.Handler(this, this.ClickShake); this.soundbtn.clickHandler = new Laya.Handler(this, this.ClickSound); this.height = Laya.stage.height; Laya.stage.on(Laya.Event.RESIZE, this, () => { this.height = Laya.stage.height; }); } RefreshUI() { let stage = AccountManager.Instance.curplayerData.STAGE; this.NowLevelNum.text = stage + ""; this.GoldNum.text = AccountManager.Instance.curplayerData.GainAccount("money"); } Start() { var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }]; ServerManager.Instance.SendHttp(TeamWave.KaiShi, agrs, Laya.Handler.create(this, (data) => { GameManager.play_id = data.play_id; PlayerManager.Instance.EnablePlayer(); this.handclick.stop(); this.shou.visible = false; ViewManager.Instance.ShowView(ViewType.InGameView); DispatcherManager.StageTrigger(StageState.Start); }), null); } GameStart() { } ShowSetPanel() { this.SetPanel.visible = true; let shakeon = this.SetPanel.getChildAt(0).getChildByName("shake").getChildByName("on"); let shakeoff = this.SetPanel.getChildAt(0).getChildByName("shake").getChildByName("off"); let soundon = this.SetPanel.getChildAt(0).getChildByName("sound").getChildByName("on"); let soundoff = this.SetPanel.getChildAt(0).getChildByName("sound").getChildByName("off"); soundon.visible = AudioManager.play; soundoff.visible = !soundon.visible; shakeon.visible = WXSDK.shake; shakeoff.visible = !shakeon.visible; } HideSetPanel() { this.SetPanel.visible = false; } ClickSound() { let soundon = this.SetPanel.getChildAt(0).getChildByName("sound").getChildByName("on"); let soundoff = this.SetPanel.getChildAt(0).getChildByName("sound").getChildByName("off"); AudioManager.play = !AudioManager.play; soundon.visible = AudioManager.play; soundoff.visible = !soundon.visible; if (AudioManager.play) { AudioManager.PlayBGM(BGMType.bgm); } else { AudioManager.StopMusic(); } } ClickShake() { let shakeon = this.SetPanel.getChildAt(0).getChildByName("shake").getChildByName("on"); let shakeoff = this.SetPanel.getChildAt(0).getChildByName("shake").getChildByName("off"); WXSDK.shake = !WXSDK.shake; shakeon.visible = WXSDK.shake; shakeoff.visible = !shakeon.visible; } OnHide() { } } class ReviveView extends ui.ReviveViewUI { constructor() { super(); ReviveView.ins = this; } static get Instance() { if (ReviveView.ins == null) { return new ReviveView(); } return ReviveView.ins; } OnShow() { this.height = Laya.stage.height; Laya.stage.on(Laya.Event.RESIZE, this, () => { this.height = Laya.stage.height; }); } OnHide() { } } class GameResultView extends ui.GameResultViewUI { constructor() { super(); GameResultView.ins = this; } static get Instance() { if (GameResultView.ins == null) { return new GameResultView(); } return GameResultView.ins; } OnShow(data) { this._result = data; if (data) { this.WinBox.visible = true; this.FailBox.visible = false; } else { this.WinBox.visible = false; this.FailBox.visible = true; } LevelManager.Instance.BackMain(); this.RefreshUI(); this.RegButton(); this.height = Laya.stage.height; Laya.stage.on(Laya.Event.RESIZE, this, () => { this.height = Laya.stage.height; }); } RegButton() { this.Win_BackBtn.clickHandler = new Laya.Handler(this, this.BackHome); this.Win_VideoBtn.clickHandler = new Laya.Handler(this, this.WinVideoGet); this.Fail_BackBtn.clickHandler = new Laya.Handler(this, this.BackHome); this.Fail_VideoBtn.clickHandler = new Laya.Handler(this, this.LoseVideoGet); } RefreshUI() { this.Win_GoldNum.text = AccountManager.Instance.curplayerData.LevelReward(this._result) + ""; this.Fail_GoldNum.text = AccountManager.Instance.curplayerData.LevelReward(this._result) + ""; } WinVideoGet() { } LoseVideoGet() { } BackHome() { let stage = AccountManager.Instance.curplayerData.STAGE; var iswin = this._result ? "1" : "0"; var coinnum = AccountManager.Instance.curplayerData.LevelReward(this._result) + ""; var args = [{ "t": AccountManager.Instance.ServerTime.toString() }, { "play_id": GameManager.play_id }, { "win": iswin }, { "money": coinnum }]; ServerManager.Instance.SendHttp(TeamWave.JieShu, args, Laya.Handler.create(this, this.Success), null); } Success() { GameManager.Instance.GameOver(); } OnHide() { } } var ViewType; (function (ViewType) { ViewType[ViewType["InGameView"] = 0] = "InGameView"; ViewType[ViewType["HomeView"] = 1] = "HomeView"; ViewType[ViewType["GameResultView"] = 2] = "GameResultView"; ViewType[ViewType["SkinView"] = 3] = "SkinView"; ViewType[ViewType["TrialView"] = 4] = "TrialView"; ViewType[ViewType["ReviveView"] = 5] = "ReviveView"; })(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(); case ViewType.ReviveView: return new ReviveView(); case ViewType.GameResultView: return new GameResultView(); } return null; } } class CameraManager { constructor() { this.LeftPosition = new Laya.Vector3(3.65, 5.72, -4.52); this.LeftRotate = new Laya.Vector3(-24, 145, 0); this.RightPosition = new Laya.Vector3(-3.78, 4.87, -4.46); this.RightRotate = new Laya.Vector3(-24, -145, 0); 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() { let Direction = AccountManager.Instance.curplayerData.LevelDirection; if (Direction == 1) { this.camera.transform.position = this.LeftPosition; this.camera.transform.rotationEuler = this.LeftRotate; } else { this.camera.transform.position = this.RightPosition; this.camera.transform.rotationEuler = this.RightRotate; } this.CameraFollow(); } CameraFollow() { this.hights = 0; this.wights = 0; Laya.Vector3.subtract(PlayerManager.Instance.player.transform.position, this.camera.transform.position, this.poschazhi); Laya.timer.frameLoop(1, this, this.GenSui); } GenSui() { Laya.Vector3.subtract(PlayerManager.Instance.player.transform.position, this.poschazhi, this.gengsuipos); this.hights = GameTools.Instance.lerp(this.hights, 1, 0.03); this.wights = GameTools.Instance.lerp(this.wights, 1, 0.05); 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; } CameraCancelFollow() { Laya.timer.clear(this, this.GenSui); } } 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); DispatcherManager.StageOn(StageState.Over, this, this.GameStart); } GameStart() { PlayerManager.Instance.Init(); CameraManager.Instance.Init(); ViewManager.Instance.ShowView(ViewType.HomeView); AudioManager.PlayBGM(BGMType.bgm); } GameLose() { PlayerManager.Instance.ListenOff(); Laya.timer.once(500, this, () => { ViewManager.Instance.ShowView(ViewType.GameResultView, false); }); AudioManager.StopMusic(); } GameWin() { PlayerManager.Instance.ListenOff(); Laya.timer.once(500, this, () => { ViewManager.Instance.ShowView(ViewType.GameResultView, true); }); AudioManager.StopMusic(); } GamePause() { } GameResume() { } BackMain() { for (let i = this.spritepool.numChildren - 1; i >= 0; i--) { let child = this.spritepool.getChildAt(i); let _well = child.getComponent(WallBehav); if (_well) { _well.destroy(); } let _matemove = child.getComponent(MateMove); if (_matemove) { _matemove.destroy(); } child.removeSelf(); child.destroy(); child = 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() { this.mainscene.enableFog = true; this.mainscene.fogStart = 25; this.mainscene.fogRange = 40; this.mainscene.fogColor = new Laya.Vector3(138 / 255, 78 / 255, 188 / 255); Laya.stage.addChild(this.mainscene); this.maincamera = this.mainscene.getChildByName("Main Camera"); this.maincamera.clearColor = new Laya.Vector4(138 / 255, 78 / 255, 188 / 255, 1); this.maincamera.enableHDR = false; CameraManager.Instance.camera = this.maincamera; this.camerapos = this.maincamera.transform.position.clone(); this.camerarotate = this.maincamera.transform.rotationEuler.clone(); let _sprite = new Laya.Sprite3D(); this.mainscene.addChild(_sprite); LevelManager.Instance.spritepool = _sprite; this.SetCharacterPos(); LevelManager.Instance.RegEvent(); LevelManager.Instance.GameStart(); } getPref(name) { return this.Prop.get(name); } getRolePref(index) { return this.Character.get(index); } SetCharacterPos() { GameManager.STAGE = -1; let _level = this.mainscene.getChildByName("levelgg"); let stage = AccountManager.Instance.curplayerData.STAGE; let levelname = "level" + stage; for (let i = 0; i < _level.numChildren; i++) { let item = _level.getChildAt(i); if (item.name != levelname) { item.active = false; } else { item.active = true; this.curstage = item; } } for (let i = 0; i < this.curstage.numChildren; i++) { let item = this.curstage.getChildAt(i); if (item.name == "player") { this.playerpos = Laya.Sprite3D.instantiate(item); } else if (item.name == "barrier") { let _pref = this.getPref(ResourcesPath.Nail2); let _cube = Laya.Sprite3D.instantiate(_pref); LevelManager.Instance.spritepool.addChild(_cube); _cube.transform.position = item.transform.position.clone(); _cube.transform.rotation = item.transform.rotation.clone(); _cube.transform.scale = item.transform.scale.clone(); _cube.name = ResourcesPath.Nail2; NodeUtil.SetColliderGroup(_cube, 2); } 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(); let _mate = _player.addComponent(MateMove); NodeUtil.SetColliderGroup(_player, 100); } else if (item.name == "speed") { let _pref = this.getPref(ResourcesPath.Speed); let _cube = Laya.Sprite3D.instantiate(_pref); LevelManager.Instance.spritepool.addChild(_cube); _cube.transform.position = item.transform.position.clone(); _cube.transform.rotation = item.transform.rotation.clone(); _cube.transform.scale = item.transform.scale.clone(); _cube.name = ResourcesPath.Speed; NodeUtil.SetColliderGroup(item, 1); } else if (item.name == "Ramp") { let _pref = this.getPref(ResourcesPath.Ramp); let _cube = Laya.Sprite3D.instantiate(_pref); LevelManager.Instance.spritepool.addChild(_cube); _cube.transform.position = item.transform.position.clone(); _cube.transform.rotation = item.transform.rotation.clone(); _cube.transform.scale = item.transform.scale.clone(); _cube.name = ResourcesPath.Ramp; NodeUtil.SetColliderGroup(item, 1); } else if (item.name == "bridge") { NodeUtil.SetColliderGroup(item, 1); } else if (item.name == "Coin") { let _pref = this.getPref(ResourcesPath.Coin); let _cube = Laya.Sprite3D.instantiate(_pref); LevelManager.Instance.spritepool.addChild(_cube); _cube.transform.position = item.transform.position.clone(); _cube.transform.rotation = item.transform.rotation.clone(); _cube.transform.scale = item.transform.scale.clone(); _cube.name = ResourcesPath.Coin; let coinbehav = _cube.addComponent(CoinBehav); NodeUtil.SetColliderGroup(_cube, 3); } else if (item.name == "FinishCircle") { let _pref = this.getPref(ResourcesPath.FinishCircle); let _cube = Laya.Sprite3D.instantiate(_pref); LevelManager.Instance.spritepool.addChild(_cube); _cube.transform.position = item.transform.position.clone(); _cube.transform.rotation = item.transform.rotation.clone(); _cube.transform.scale = item.transform.scale.clone(); _cube.name = ResourcesPath.FinishCircle; this.finishpoint = item.transform.position.clone(); NodeUtil.SetColliderGroup(_cube, 200); } } } } class GameManager { constructor() { GameManager.ins = this; } static get Instance() { if (GameManager.ins == null) { return new GameManager(); } return GameManager.ins; } GameLose() { DispatcherManager.StageTrigger(StageState.Lose); } GameWin() { DispatcherManager.StageTrigger(StageState.Win); } GameOver() { AssetManager.Instance.SetCharacterPos(); DispatcherManager.StageTrigger(StageState.Over); } } GameManager.STAGE = -1; 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"]); } LevelReward(win) { let stage = Number(this.GainAccount("stage")) + 1; let levelinfo = this.GainCollocation("mission"); for (var key in levelinfo) { let item = levelinfo[key]; if (item.ID == stage) { if (win) { return Number(item.win); } else { return Number(item.lose); } } } return null; } get LevelDirection() { let stage = this.STAGE; let levelinfo = this.GainCollocation("mission"); for (var key in levelinfo) { let item = levelinfo[key]; if (item.ID == stage) { return Number(item.direction); } } return null; } get STAGE() { if (GameManager.STAGE == -1) { GameManager.STAGE = Number(this.GainAccount("stage")) + 1; if (GameManager.STAGE > 30) { GameManager.STAGE = GameTools.RandomANumber(1, 30); } } return GameManager.STAGE; } 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 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(TeamWave.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(TeamWave.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(TeamWave.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; } } 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 = "subpackage2/res/share/shareimage.png"; 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 = "subpackage2/res/share/shareimage.png"; 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: "subpackage2/res/share/shareimage.png", query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString() }); } static AldEvent(eventName, key = "用户id", value = "") { } static AldStart(stageId) { } static AldEnd(stageId, isComplete) { } } 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; 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 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.Login(); 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("开始登陆"); 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; if (Laya.Browser.onWeiXin) { Laya.Browser.window.wx.showShareMenu({ withShareTicket: true }); Laya.Browser.window.wx.onShareAppMessage(function () { return { title: "组团一起浪", imageUrl: "subpackage2/res/share/shareimage.png", }; }); Laya.Browser.window.wx.onShow((option) => { var shareTicket = option.shareTicket; var userId = option.query.userId; var shareTitle = option.query.shareTitle; Main.SceneNum = option.scene; WXSDK.querychannel = option.query.channel; WXSDK.shareOpenId = option.query.userId; console.log("scene:", option.scene); if (WXSDK.querychannel != null) { console.log("onShow channel is:", WXSDK.querychannel); } if (option.referrerInfo) { WXSDK.referrerInfoappId = option.referrerInfo.appId; console.log("onShow appId is:", option.referrerInfo.appId); } }); if (!Laya.Browser.onWeiXin) return; const updateManager = Laya.Browser.window.wx.getUpdateManager(); updateManager.onCheckForUpdate(function (res) { console.log("最新版本:" + res.hasUpdate); }); updateManager.onUpdateReady(function () { Laya.Browser.window.wx.showModal({ showCancel: false, title: '更新提示', content: '新版本已经准备好,是否重启应用?', success(res) { updateManager.applyUpdate(); }, fail(res) { updateManager.applyUpdate(); } }); }); } 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(); } } Main.SceneNum = "123"; new Main(); }()); //# sourceMappingURL=bundle.js.map