"use strict";vartslib=require("tslib");functiongetTexture(e){returnengine.Texture.from(getAssetByUUID(e).uuid)}functiongetTextureByName(e){returngetTexture(engine.getAssetByName(e).uuid)}varprops={};functionprepareProps(){vare=getProps();engine.injectProp(props,e)}functioninjectProps(e){engine.injectProp(props,e)}varTurntable=function(t){functione(){vare=t.call(this)||this;returne._vertical_Y=props.vertical||20,e._horizontal_X=props.horizontal||20,e._prizeIndex=0,e._boxArray=[],e._boxIndex=0,e.tweenTime=props.tweenTime||200,e.slowTweenTime=props.slowTweenTime||200,e.circleNumber=0,e.turntableOrder=[1,2,3,5,8,7,6,4],e.recordID=-1,e.boxPrizeIndex=-1,e.slowDown=!1,e.isStop=!1,e.automaticFlag=!0,e}returntslib.__extends(e,t),e.prototype.initData=function(e){this.initTurntable(e),this.setNodeOrder()},e.prototype.initTurntable=function(e){vart=null;this._turnTableNode&&(this.removeChild(this._turnTableNode),this._turnTableNode=null,this._boxArray=[],this._prizeIndex=0,this._boxIndex=0),t=this._turnTableNode=newengine.Container,this.addChild(t);for(vari=0;i<3;i++)for(varn,r,o,a,s,h,p=0;p<3;p++){1==p&&1==i||(n=newengine.Container,r=this.getImage("unchecked",1),o=this.getImage("checked",0),n.width=Math.max(r.width,o.width),this._singleNodeWidth=this._singleNodeWidth?this._singleNodeWidth:n.width,n.height=Math.max(r.height,o.height),n.x=p*(n.width+this._horizontal_X),n.y=i*(n.height+this._vertical_Y),n.addChild(r),n.addChild(o),a=newengine.Sprite(engine.Texture.fromImage(e[this._prizeIndex].img)),s=e[this._prizeIndex].id,a.width=props.icon_width,a.height=props.icon_height,a.x=(n.width-a.width)/2+props.icon_X,a.y=(n.height-a.height)/2+props.icon_Y,n.prizeID=s,n.addChild(a),(h=newengine.Label).fillColor=props.prizeName_color,h.size=props.prizeName_size,h.width=r.width,h.textAlign=engine.TEXT_ALIGN.CENTER,h.x=0,h.y=props.prizeName_Ypos,h.text=this.fixTitle(e[this._prizeIndex].name),n.addChild(h),this._prizeIndex++,this._boxArray.push(n),t.addChild(n))}t.x=(750-(3*this._singleNodeWidth+2*this._horizontal_X))/2},e.prototype.setNodeOrder=function(){for(vare=[],t=0;t<this.turntableOrder.length;t++){vari=this.turntableOrder[t];e.push(this._boxArray[i-1])}this._boxArray=e},e.prototype.fixTitle=function(e){if(!e)return"";if(e.split("").length<props.prizeName_maxLength)returne;for(vart="",i=0;i<props.prizeName_retainLength;i++)t+=e.split("")[i];returnt+="..."},e.prototype.getImage=function(e,t){vari=newengine.Sprite(getTextureByName(e));returni.x=0,i.y=0,i.alpha=t,i.name=e,i},e.prototype.automaticRotate=function(){vare=this;console.log("enter the automatic rotate");vart=this._boxArray[this._boxIndex].getChildByName("checked");if(this.tweenTime=1e3,!this.automaticFlag)returnthis._boxIndex=0,this.tweenTime=props.tweenTime||200,voidengine.Tween.removeTweens(t);engine.Tween.get(t).to({alpha:1},this.tweenTime/2).to({alpha:0},this.tweenTime/2).call(function(){e._boxIndex++,e._boxIndex>=e._boxArray.length&&(e._boxIndex=0),e.automaticRotate()})},e.prototype.startDraw=function(){vare=this;this.automaticFlag=!1;vart=this._boxArray[this._boxIndex].getChildByName("checked");this.isStop?engine.Tween.removeTweens(t):(this.slowDown&&(this._boxIndex!=this.getNodeIndexOFprize()?this.tweenTime+=this.slowTweenTime:(this.isStop=!0,this.twinkle(t),this.automaticFlag=!0)),engine.Tween.get(t).to({alpha:1},this.tweenTime/2).to({alpha:0},this.tweenTime/2).call(function(){e.circleNumber>=props.circleNumber&&e.getSlowStart()==e._boxIndex&&(e.slowDown=!0),e._boxIndex++,e._boxIndex>=e._boxArray.length&&(e._boxIndex=0,e.circleNumber++),e.startDraw()}))},e.prototype.getSlowStart=function(){if(this.recordID<0)return-1;vare=this.getNodeIndexOFprize();returne<4?e+4:e-4},e.prototype.getNodeIndexOFprize=function(){if(this.recordID<0)return-1;for(vare=0;e<this._boxArray.length;e++){if(this._boxArray[e].prizeID===this.recordID)returne}return-1},e.prototype.twinkle=function(e){engine.Tween.removeTweens(e);vart=1;engine.Tween.get(e,{loop:!0}).to({alpha:0},30).to({alpha:1},30).call(function(){return5<t?(engine.Tween.removeTweens(e),voidengine.globalEvent.dispatchEvent("jiugong-turntable-change-over")):voidt++})},e.prototype.setRecordID=function(e){this.recordID=e},e.prototype.reset=function(){this._boxArray.forEach(function(e){engine.Tween.removeTweens(e.getChildByName("checked"))}),this._boxIndex=0,this.tweenTime=props.tweenTime||200,this.slowTweenTime=props.slowTweenTime||200,this.circleNumber=0,this.recordID=-1,this.boxPrizeIndex=-1,this.slowDown=!1,this.isStop=!1,this.automaticFlag=!0;for(vare=0;e<this._boxArray.length;e++){this._boxArray[e].getChildByName("checked").alpha=0}},e}(engine.Container),GameView=function(e){functiont(){returne.call(this)||this}returntslib.__extends(t,e),t.prototype.setup=function(){vare;this._hasSetup||(this._hasSetup=!0,e=this._turntable=newTurntable,this.addChild(e))},t.prototype.setPrizeData=function(e){this._turntable.initData(e),this._turntable.automaticRotate()},t.prototype.startDraw=function(){this._turntable.startDraw()},t.prototype.setRecordID=function(e){this._turntable.setRecordID(e)},t.prototype.reset=function(){this._turntable.reset()},t.prototype.setSetup=function(){this._hasSetup=!1},t}(engine.Container),GameWrapper=function(t){functione(){vare=t.call(this)||this;returnengine.globalEvent.addEventListener("jiugong-turntable-change-init",e.init,e),engine.globalEvent.addEventListener("jiugong-turntable-change-prizeData",e.initPrizeData,e),engine.globalEvent.addEventListener("jiugong-turntable-change-start",e.start,e),engine.globalEvent.addEventListener("jiugong-turntable-change-winPrize",e.winPrize,e),engine.globalEvent.addEventListener("jiugong-turntable-change-reset",e.reset,e),engine.globalEvent.addEventListener("jiugong-turntable-change-abnormal",e.reset,e),e}returntslib.__extends(e,t),e.prototype.init=function(e){vart=this._gameView=newGameView;this.addChild(t),this._gameView.setup()},e.prototype.initPrizeData=function(e){this._gameView.setSetup(),this._gameView.setPrizeData(e.data.resources)},e.prototype.start=function(e){this._gameView.startDraw()},e.prototype.winPrize=function(e){this._gameView.setRecordID(e.data.prizeID)},e.prototype.reset=function(){this._gameView.reset()},e}(engine.Container);functionindex(e){returnprepareProps(),injectProps(e),newGameWrapper}module.exports=index;