bundle.js 18 KB

1
  1. !function(){"use strict";var extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var CaseUtils={MathUtils:function(){function MathUtils(){}return MathUtils.getRandom=function(min,max){return Math.round(Math.random()*(max-min))+min},MathUtils}(),CaseCfgLoader:function(){function CaseCfgLoader(){}return CaseCfgLoader.loadCfg=function(complete){var defcfg="config/caseconfig.json",cfgList=[defcfg,"custom/config.json"];Laya.loader.load(cfgList,Laya.Handler.create(null,function(params){CaseCfgLoader._cfgdata=Laya.loader.getRes("custom/config.json"),CaseCfgLoader._defaultdata=Laya.loader.getRes(defcfg),complete&&complete.run()}))},Object.defineProperty(CaseCfgLoader,"caseCfg",{get:function(){return CaseCfgLoader._cfgdata},enumerable:!0,configurable:!0}),CaseCfgLoader.getCaseCfgByKey=function(key){var cusv=CaseCfgLoader._cfgdata[key];return cusv||(cusv=CaseCfgLoader._defaultdata[key]),cusv},CaseCfgLoader._cfgdata=null,CaseCfgLoader._defaultdata=null,CaseCfgLoader}()},GameUtilsConst=function(){function GameUtilsConst(){}return GameUtilsConst.SECONDLOOP="SecondLoop",GameUtilsConst}(),GameControlScript=function(_super){function GameControlScript(){var _this=_super.call(this)||this;return _this._bgSoundChannel=null,_this._totalDelta=0,_this._storeDic={},GameControlScript._instance||(GameControlScript._instance=_this),Laya.stage.frameLoop(1,_this,_this.onFrameLoop),_this}return __extends(GameControlScript,_super),GameControlScript.getInstance=function(){return GameControlScript._instance},GameControlScript.prototype.playMusic=function(bgm){this._bgSoundChannel=Laya.SoundManager.playMusic(bgm,0)},GameControlScript.prototype.pauseBgMusic=function(){this._bgSoundChannel&&this._bgSoundChannel.pause()},GameControlScript.prototype.resumeBgMusic=function(){this._bgSoundChannel&&this._bgSoundChannel.resume()},GameControlScript.prototype.playSound=function(sound){Laya.SoundManager.playSound(sound,1)},GameControlScript.prototype.onFrameLoop=function(){var delta=Laya.timer.delta;this._totalDelta+=delta,this._totalDelta<1e3||(this._totalDelta-=1e3,Laya.stage.event(GameUtilsConst.SECONDLOOP))},GameControlScript.prototype.setKeyVale=function(key,value){this._storeDic[key]=value},GameControlScript.prototype.getKeyVale=function(key){return this._storeDic[key]},GameControlScript._instance=null,GameControlScript}(Laya.Script),DropEndDialog=function(_super){function DropEndDialog(){var _this=_super.call(this)||this;return _this.bgimg=null,_this.gobtn=null,_this.endTxt1=null,_this.endTxt2=null,_this.endTxt4=null,_this.endTxt3=null,_this.endTxt5=null,_this.rewardIcon=null,_this}return __extends(DropEndDialog,_super),DropEndDialog.prototype.dropRedPackages=function(){},DropEndDialog.prototype.onEnable=function(){var value=GameControlScript.getInstance().getKeyVale("score")||"0",score=CaseUtils.CaseCfgLoader.getCaseCfgByKey("score");this.endTxt2.text=""+value;var cnstr2_2=CaseUtils.CaseCfgLoader.getCaseCfgByKey("cnstr2_2");this.endTxt3.text=cnstr2_2.txt,this.rewardIcon.visible=!1;var cnstr2cfg=CaseUtils.CaseCfgLoader.getCaseCfgByKey("cnstr2"),cnstr2_1=CaseUtils.CaseCfgLoader.getCaseCfgByKey("cnstr2_1"),cnstr2="29元";this.endTxt1.text="29元",this.endTxt1.fontSize=cnstr2cfg.fontsize,this.endTxt1.color=cnstr2cfg.color,this.endTxt2.fontSize=cnstr2_1.fontsize,this.endTxt2.color=cnstr2_1.color,this.endTxt3.fontSize=cnstr2_2.fontsize,this.endTxt3.color=cnstr2_2.color;var htmlDiv=new Laya.HTMLDivElement;htmlDiv.style.width=Laya.stage.width,htmlDiv.style.align="center";var html="<span style='color:#000000;font-size:36px;align:center;'>"+cnstr2cfg.txt+"</span><span style='color:#d8a620;font-size:36px'>29元</span><span style='color:#000000;font-size:36px'>"+cnstr2_2.txt+"</span>";htmlDiv.innerHTML=html,this.owner.addChild(htmlDiv),htmlDiv.pos(0,this.endTxt1.y-10),this.endTxt1.visible=this.endTxt2.visible=this.endTxt3.visible=!1,this.endTxt1.text=this.endTxt2.text=this.endTxt3.text="";var totalWid=this.endTxt1.textWidth+this.endTxt2.textWidth+this.endTxt3.textWidth+20;if(this.endTxt1.x=this.owner.width/2-totalWid/2,this.endTxt2.x=this.endTxt1.x+this.endTxt1.textWidth+10,this.endTxt3.x=this.endTxt2.x+this.endTxt2.textWidth+10,score){var rewardScore=void 0;for(var key in score)if(score.hasOwnProperty(key)){var element=score[key];value>=element.range[0]&&(rewardScore=element)}var cnstr3=CaseUtils.CaseCfgLoader.getCaseCfgByKey("cnstr3"),endcardText=CaseUtils.CaseCfgLoader.getCaseCfgByKey("endcardText");this.endTxt4.text=cnstr3.txt.replace("{1}",""+rewardScore.percent),this.endTxt4.fontSize=cnstr3.fontsize,this.endTxt4.color=cnstr3.color,this.endTxt5.text=endcardText.txt,this.endTxt5.fontSize=endcardText.fontsize,this.endTxt5.color=endcardText.color,this.rewardIcon.visible=!0,this.rewardIcon.skin="custom/"+rewardScore.reward}else this.endTxt4.text="",this.endTxt5.text="";this.bgimg.on("mousedown",this,function(){window.playableSDK.sendEvent("clickFinishDownloadBar",{section:"section3",area:"area1"}),window.playableSDK.openAppStore()}),window.playableSDK.sendEvent("finishPlayPlayable"),1==CaseUtils.CaseCfgLoader.getCaseCfgByKey("autoopenstore")&&Laya.timer.once(3e3,this,function(){window.playableSDK.openAppStore(),window.playableSDK.sendEvent("autoClick",{section:"section3"})})},DropEndDialog.prototype.onDisable=function(){},DropEndDialog.prototype.onDestroy=function(){},DropEndDialog}(Laya.Script),MainScene=function(_super){function MainScene(){var _this=_super.call(this)||this;return _this.startBox=null,_this.dropBox=null,_this}return __extends(MainScene,_super),MainScene.prototype.onEnable=function(){GameControlScript.getInstance().playMusic("custom/bgm.mp3")},MainScene.prototype.emulateComplete=function(){},MainScene.prototype.onCfgLoad=function(){},MainScene.prototype.onSecondLoop=function(){},MainScene.prototype.onDisable=function(){},MainScene.prototype.onDestroy=function(){},MainScene}(Laya.Scene),DropView=function(_super){function DropView(){var _this=_super.call(this)||this;return _this.cdtimes=0,_this.dropBox=null,_this.cdimg=null,_this.scoreTxt1=null,_this.scoreTxt2=null,_this.scoreProgress=null,_this.bgimg=null,_this.gaptimes=0,_this._deltaSecs=0,_this.totaltimes=0,_this.redpackages=[],_this.cdTxt=null,_this._lastDropX=0,_this.downloadBtn=null,_this.scoreBox=null,_this}return __extends(DropView,_super),DropView.prototype.emulateComplete=function(){var _this=this;this.dropBox.height=Laya.Browser.window.height,this.cdtimes=CaseUtils.CaseCfgLoader.getCaseCfgByKey("cdtimes")||0,this.gaptimes=CaseUtils.CaseCfgLoader.getCaseCfgByKey("gaptimes"),this.totaltimes=CaseUtils.CaseCfgLoader.getCaseCfgByKey("totaltimes"),this.redpackages=CaseUtils.CaseCfgLoader.getCaseCfgByKey("redpackages");var cnstr1=CaseUtils.CaseCfgLoader.getCaseCfgByKey("cnstr1");this.scoreTxt1.text=cnstr1.txt,this.scoreTxt1.fontSize=cnstr1.fontsize,this.scoreTxt1.color=cnstr1.color;var cnscore=CaseUtils.CaseCfgLoader.getCaseCfgByKey("cnscore");this.scoreTxt2.fontSize=cnscore.fontsize,this.scoreTxt2.color=cnscore.color,this.scoreTxt2.text="0",this.cdTxt.text="",this.scoreBox.alpha=0,Laya.stage.on("package_rain_start",this,function(){Laya.stage.on("SecondLoop",_this,_this.onSecondLoop),Laya.Tween.to(_this.scoreBox,{alpha:1},200)}),this.downloadBtn.on("mousedown",this,function(){window.playableSDK.sendEvent("clickDownloadBar",{section:"section2",area:"area1"}),window.playableSDK.openAppStore()})},DropView.prototype.onSecondLoop=function(){if(this.cdtimes<=0){if(this.cdTxt.text="",0==this.cdtimes&&this.timer.frameLoop(1,this,this.onFrameLoop),this.cdtimes<=-1){var tarvalue=this.scoreProgress.value-1/this.totaltimes;Laya.Tween.to(this.scoreProgress,{value:tarvalue},1e3)}this.scoreProgress.value<=0&&(Laya.stage.off("SecondLoop",this,this.onSecondLoop),this.timer.clear(this,this.onFrameLoop),this.dropBox.visible=!1,this.showEndDialog())}this.cdtimes--},DropView.prototype.onFrameLoop=function(){this._deltaSecs+=Laya.timer.delta,this._deltaSecs<1e3*this.gaptimes||(this._deltaSecs%=1e3*this.gaptimes,this.dropRedPackages())},DropView.prototype.dropRedPackages=function(){var _this=this;console.log("dropRedPackages >>>> ");var rand=CaseUtils.MathUtils.getRandom(0,this.redpackages.length-1),pcfg=this.redpackages[rand],redpackage=Laya.Pool.getItemByClass("Laya.Image",Laya.Image);redpackage.skin="custom/"+pcfg.package;var ranX=CaseUtils.MathUtils.getRandom(30,Laya.stage.width-120);redpackage.x=this._lastDropX=ranX,redpackage.y=0;CaseUtils.CaseCfgLoader.getCaseCfgByKey("cnstr1");redpackage.on("mousedown",this,function(){GameControlScript.getInstance().playSound("custom/effect1.mp3");var value=GameControlScript.getInstance().getKeyVale("score")||0;value+=pcfg.value,GameControlScript.getInstance().setKeyVale("score",value),_this.scoreTxt2.text=""+value;var scoreTxt=Laya.Pool.getItemByClass("Laya.Text",Laya.Text),cnaddscore=CaseUtils.CaseCfgLoader.getCaseCfgByKey("cnaddscore");scoreTxt.fontSize=cnaddscore.fontsize,scoreTxt.color=cnaddscore.color,scoreTxt.text="+"+pcfg.value,scoreTxt.x=redpackage.x+redpackage.width/2-scoreTxt.width/2;var tmpY=redpackage.y;scoreTxt.y=tmpY,_this.dropBox.addChild(scoreTxt);var timel=new Laya.TimeLine;timel.addLabel("label0",0).to(scoreTxt,{y:tmpY-100},200).addLabel("label1",0).to(scoreTxt,{alpha:0},500,null).addLabel("label2",0).to(scoreTxt,{alpha:0},500,null),timel.on("complete",_this,function(){Laya.Pool.recoverByClass(scoreTxt.removeSelf())}),timel.play(),redpackage.visible=!1,Laya.Tween.clearTween(redpackage),redpackage.removeSelf()}),this.dropBox.addChild(redpackage);var dropt=CaseUtils.CaseCfgLoader.getCaseCfgByKey("droptimes")||2;Laya.Tween.to(redpackage,{y:Laya.stage.height},1e3*dropt,null,Laya.Handler.create(this,function(){Laya.Pool.recoverByClass(redpackage.removeSelf())}))},DropView.prototype.showScore=function(score){},DropView.prototype.showEndDialog=function(){Laya.Scene.load("DropEndDialog.scene",Laya.Handler.create(this,function(endDialog){endDialog.popup()}))},DropView.prototype.onDisable=function(){},DropView.prototype.onDestroy=function(){},DropView}(Laya.Box),EmulateChildrenScript=function(_super){function EmulateChildrenScript(){return _super.call(this)||this}return __extends(EmulateChildrenScript,_super),EmulateChildrenScript.prototype.onEnable=function(){this.owner.__holdNodeList=[],this.retainNodes(this.owner);var emulateComplete=this.owner.emulateComplete;emulateComplete&&emulateComplete.apply(this.owner)},EmulateChildrenScript.prototype.retainNodes=function(tmpNode){if(tmpNode instanceof Laya.Sprite){var childrenNum=tmpNode.numChildren;if(!(childrenNum<=0))for(var index=0;index<childrenNum;index++){var element=tmpNode.getChildAt(index),el_var=element.var;el_var&&""!=el_var?(this.owner[el_var]=element,this.owner.__holdNodeList.push(element)):element.name&&""!=element.name&&(this.owner[element.name]=element,this.owner.__holdNodeList.push(element)),this.retainNodes(element)}}},EmulateChildrenScript.prototype.releaseNodes=function(){for(var __holdNodeList=this.owner.__holdNodeList,index=0,len=__holdNodeList.length;index<len;index++){var element=__holdNodeList[index];this.owner[element.name]=null,this.owner.__holdNodeList=[]}},EmulateChildrenScript.prototype.onDestroy=function(){this.releaseNodes()},EmulateChildrenScript}(Laya.Script),StartPanel=function(_super){function StartPanel(){var _this=_super.call(this)||this;return _this.downloadBtn=null,_this.startBtn=null,_this.tipimg=null,_this.tipTxt=null,_this.maskBox=null,_this.powerByLabel=null,_this}return __extends(StartPanel,_super),StartPanel.prototype.emulateComplete=function(){var _this=this;this.maskBox.height=Laya.stage.height,window.playableSDK.sendEvent("loadMainScene"),this.startBtn.on("mousedown",this,function(){window.playableSDK.sendEvent("startPlayPlayable"),window.playableSDK.sendEvent("clickContent",{section:"section1",area:"area2"}),Laya.stage.event("package_rain_start"),_this.removeSelf()}),this.maskBox.on("mousedown",this,function(){window.playableSDK.sendEvent("startPlayPlayable"),window.playableSDK.sendEvent("clickContent",{section:"section1",area:"area2"}),Laya.stage.event("package_rain_start"),_this.removeSelf()}),this.downloadBtn.on("mousedown",this,function(){window.playableSDK.sendEvent("clickDownloadBar",{section:"section1",area:"area1"}),window.playableSDK.openAppStore()});var caseCfg=CaseUtils.CaseCfgLoader.getCaseCfgByKey("bannerText");this.tipTxt.text=caseCfg.txt,this.tipTxt.fontSize=caseCfg.fontsize,this.tipTxt.color=caseCfg.color,this.powerByLabel.y=Laya.stage.height-30},StartPanel}(Laya.Box),DownloadBtnScript=function(_super){function DownloadBtnScript(){var _this=_super.call(this)||this;return _this.oldtime=0,_this}return __extends(DownloadBtnScript,_super),DownloadBtnScript.prototype.onEnable=function(){var downloadBtn=this.owner,timel=new Laya.TimeLine;timel.to(downloadBtn,{scaleX:this.maxScale,scaleY:this.maxScale},500,null,0).to(downloadBtn,{scaleX:1,scaleY:1},500,null,0),timel.play(0,!0)},DownloadBtnScript.prototype.clickHandler=function(){},DownloadBtnScript.prototype.onUpdate=function(){Laya.timer.delta>=300&&console.log("update >>>>>>>"+Laya.timer.delta)},DownloadBtnScript.prototype.onDestroy=function(){this.owner.offAll()},DownloadBtnScript}(Laya.Script),GameConfig=function(){function GameConfig(){}return GameConfig.init=function(){var reg=Laya.ClassUtils.regClass;reg("script/DropEndDialog.ts",DropEndDialog),reg("script/MainScene.ts",MainScene),reg("script/DropView.ts",DropView),reg("caseUtils/EmulateChildrenScript.ts",EmulateChildrenScript),reg("script/StartPanel.ts",StartPanel),reg("caseUtils/DownloadBtnScript.ts",DownloadBtnScript)},GameConfig.width=750,GameConfig.height=1624,GameConfig.scaleMode="fixedwidth",GameConfig.screenMode="vertical",GameConfig.alignV="middle",GameConfig.alignH="center",GameConfig.startScene="MainScene.scene",GameConfig.sceneRoot="",GameConfig.debug=!1,GameConfig.stat=!1,GameConfig.physicsDebug=!1,GameConfig.exportSceneToJson=!0,GameConfig}();GameConfig.init();var AdapterScript=function(_super){function AdapterScript(){var _this=_super.call(this)||this;return Laya.stage.on(Laya.Event.FOCUS,_this,_this.onStageFocus),Laya.stage.on(Laya.Event.BLUR,_this,_this.onStageBLUR),Laya.stage.on(Laya.Event.RESIZE,_this,_this.onStageResize),Laya.SoundManager.autoStopMusic=!0,AdapterScript._instance||(AdapterScript._instance=_this),_this}return __extends(AdapterScript,_super),AdapterScript.getInstance=function(){return AdapterScript._instance},AdapterScript.prototype.onStageResize=function(){this.resizeScreen2()},AdapterScript.prototype.resizeScreen=function(){var stageWidth=Laya.stage.width,stageHeight=Laya.stage.height,designWidth=Laya.stage.designWidth,designHeight=Laya.stage.designHeight;Laya.stage.scaleMode,Laya.Browser.pixelRatio,Laya.Browser.clientWidth,Laya.Browser.clientHeight,Laya.stage.screenMode;return"center"==Laya.stage.alignH?stageWidth>designWidth&&(Laya.stage.x=stageWidth/2-designWidth/2):"right"==Laya.stage.alignH?Laya.stage.x=stageWidth-designWidth:"left"==Laya.stage.alignH&&(Laya.stage.x=0),"middle"==Laya.stage.alignV?stageHeight>designHeight&&(Laya.stage.y=stageHeight/2-designHeight/2):"bottom"==Laya.stage.alignV?Laya.stage.y=stageHeight-designHeight:"top"==Laya.stage.alignV&&(Laya.stage.y=0),!1},AdapterScript.prototype.resizeScreen2=function(){var stageWidth=Laya.stage.width,stageHeight=Laya.stage.height,pixelRatio=Laya.Browser.pixelRatio,screenWidth=Laya.Browser.clientWidth,screenHeight=Laya.Browser.clientHeight;Laya.stage.alignH===Laya.Stage.ALIGN_LEFT?Laya.stage.offset.x=0:Laya.stage.alignH===Laya.Stage.ALIGN_RIGHT?Laya.stage.offset.x=screenWidth-stageWidth:Laya.stage.offset.x=.5*(screenWidth-stageWidth)/pixelRatio,Laya.stage.alignV===Laya.Stage.ALIGN_TOP?Laya.stage.offset.y=0:Laya.stage.alignV===Laya.Stage.ALIGN_BOTTOM?Laya.stage.offset.y=screenHeight-stageWidth:Laya.stage.offset.y=.5*(screenHeight-stageHeight)/pixelRatio,Laya.stage.offset.x=Math.round(Laya.stage.offset.x),Laya.stage.offset.y=Math.round(Laya.stage.offset.y)},AdapterScript.isIphoneX=function(){Laya.Browser.pixelRatio;var screenWidth=Laya.Browser.clientWidth,screenHeight=Laya.Browser.clientHeight;return 375==screenWidth&&812==screenHeight||812==screenWidth&&375==screenHeight},AdapterScript.prototype.onStageBLUR=function(param){GameControlScript.getInstance().pauseBgMusic()},AdapterScript.prototype.onStageFocus=function(param){GameControlScript.getInstance().resumeBgMusic()},AdapterScript._instance=null,AdapterScript}(Laya.Script);new(function(){function Main(){window.Laya3D?Laya3D.init(GameConfig.width,GameConfig.height):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,(GameConfig.debug||"true"==Laya.Utils.getQueryString("debug"))&&Laya.enableDebugPanel(),GameConfig.physicsDebug&&Laya.PhysicsDebugDraw&&Laya.PhysicsDebugDraw.enable(),GameConfig.stat&&Laya.Stat.show(),Laya.stage.addComponent(AdapterScript),Laya.stage.addComponent(GameControlScript),CaseUtils.CaseCfgLoader.loadCfg(Laya.Handler.create(this,this.onCfgLoad))}return Main.prototype.onCfgLoad=function(){Laya.ResourceVersion.enable("version.json",Laya.Handler.create(this,this.onVersionLoaded),Laya.ResourceVersion.FILENAME_VERSION)},Main.prototype.onVersionLoaded=function(){Laya.AtlasInfoManager.enable("fileconfig.json",Laya.Handler.create(this,this.onConfigLoaded))},Main.prototype.onConfigLoaded=function(){GameConfig.startScene&&Laya.Scene.open(GameConfig.startScene)},Main}())}();