{"version":3,"file":"index.js","sources":["src/custom/turnplate/src/props.ts","src/custom/turnplate/src/game/utils.ts","src/custom/turnplate/src/game/GameWrapper.ts","src/custom/turnplate/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn engine.Texture.from(getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + getAssetByName(name).uuid;\n\treturn inst;\n}\n\nexport function getStage(){\n\treturn engine.gameStage.stage;\n}","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport {injectProps,props} from \"../props\";\nimport { getTextureByName, getStage } from \"./utils\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tconstructor() {\n\t\tsuper();\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t\tengine.globalEvent.addEventListener('turnplate-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('turnplate-start', this.start, this);\n\t}\n\n\tturnplate\n\tturnplateBg\n\t_turnplateBG\n\twheelPrizeRotation=[]\n\titems=[]\n\titemsCon=[]\n\titemsLabel=[]\n\titemsIcon=[]\n\n\tsetup(){\n\t\tthis.turnplate = new engine.Container();\n\t\tthis.turnplate.x=0\n\t\tthis.turnplate.y=0\n\t\tthis.turnplate.rotation=-90;\n\t\tthis.turnplate.width = props.diameter;\n\t\tthis.turnplate.height = props.diameter;\n\t\tthis.turnplate.anchorX=this.turnplate.width/2\n\t\tthis.turnplate.anchorY=this.turnplate.height/2\n\t\tthis.addChild(this.turnplate)\n\n\t\tthis._turnplateBG = new engine.Container();\n\t\tthis._turnplateBG.width = props.diameter;\n\t\tthis._turnplateBG.height = props.diameter;\n\t\tthis._turnplateBG.anchorX=this.turnplate.width/2\n\t\tthis._turnplateBG.anchorY=this.turnplate.height/2\n\t\tthis._turnplateBG.rotation=props.rotationBg;\n\t\tthis.turnplate.addChild(this._turnplateBG)\n\t\t\n\t\tthis.turnplateBg = new engine.Sprite(getTextureByName('大转盘背景'));\n\t\tthis.turnplateBg.x=0;\n\t\tthis.turnplateBg.y=0;\n\t\tthis.turnplateBg.width=this.turnplate.width;\n\t\tthis.turnplateBg.height=this.turnplate.height;\n\t\tthis._turnplateBG.addChild(this.turnplateBg)\n\t}\n\n\tprizes\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\t\n\t\tthis.prizes=event.data.prizes\n\t\tconsole.log(this.prizes)\n\n\t\tfor(let i=0;i<this.items.length;i++){\n\t\t\tthis.itemsCon[i].removeChild(this.itemsLabel[i])\n\t\t\tthis.itemsCon[i].removeChild(this.itemsIcon[i])\n\t\t\tthis.items[i].removeChild(this.itemsCon[i])\n\t\t\tthis.turnplate.removeChild(this.items[i])\n\t\t}\n\n\t\tfor(let i=0;i<this.prizes.length;i++){\n\t\t\tthis.items[i] = new engine.Container();\n\t\t\tthis.itemsCon[i] = new engine.Container();\n\t\t\tthis.itemsCon[i].x=props.prizesRadius\n\t\t\tthis.itemsCon[i].rotation=90;\n\t\t\tthis.items[i].x=this.turnplate.width/2\n\t\t\tthis.items[i].y=this.turnplate.height/2\n\t\t\tthis.turnplate.addChild(this.items[i])\n\t\t\tthis.itemsLabel[i] = new engine.Label();\n\t\t\t\n\t\t\tthis.itemsLabel[i].text=this.prizes[i].name;\n\t\t\tthis.itemsLabel[i].width=200;\n\t\t\tthis.itemsLabel[i].x=-this.itemsLabel[i].width/2\n\t\t\tthis.itemsLabel[i].textAlign=\"center\";\n\t\t\tthis.itemsLabel[i].fillColor=props.nameColor;\n\t\t\tthis.itemsLabel[i].size=props.nameSize;\n\n\t\t\tthis.itemsIcon[i] =new engine.Sprite();\n\t\t\tthis.itemsIcon[i].width=props.iconSize[0]\n\t\t\tthis.itemsIcon[i].height=props.iconSize[1]\n\t\t\tthis.itemsIcon[i].x=-this.itemsIcon[i].width/2;\n\t\t\tthis.itemsIcon[i].y=props.iconY\n\t\t\tthis.itemsIcon[i].texture =engine.Texture.from(this.prizes[i].icon)\n\t\t\tthis.itemsCon[i].addChild(this.itemsLabel[i])\n\t\t\tthis.itemsCon[i].addChild(this.itemsIcon[i])\n\t\t\tthis.items[i].addChild(this.itemsCon[i])\n\n\t\t\tlet _rotation=(i)*(360/this.prizes.length)\n\t\t\tthis.items[i].rotation=_rotation\n\t\t\tthis.wheelPrizeRotation[this.prizes[i].prizeId]=_rotation;\n\t }\n\t this.turnplate.rotation=-90;\n\t engine.Tween.removeTweens(this.turnplate)\n\t engine.Tween.get( this.turnplate,{loop:true})\n\t\t.to({rotation:360-90}, 5000,)\n\t}\n\n\tstart(event: engine.Event) {\n\t\t//this.turnplate.rotation=-90;\n\t\tinjectProps(event.data);\n\t\tengine.Tween.removeTweens(this.turnplate)\n\t\tlet prizeId=event.data.prizeId\n\t\tengine.Tween.get( this.turnplate )\n\t\t.to({rotation:7200-this.wheelPrizeRotation[prizeId]-90}, 8000,engine.Ease.circInOut)\n\t\t.wait(500)\n\t\t.call(()=>{\n\t\t\tthis.turnplate.rotation=360-this.wheelPrizeRotation[prizeId]+0.001-90\n\t\t\tengine.globalEvent.dispatchEvent('turnplate-over', {\n\t\t\t\tprizeId\n\t\t\t});\n\t\t\t// disRect.visible=false;\n\t\t\t// if(prizeId!=\"thanks\"){\n\t\t\t// \t\tnext(\"success\",args)\n\t\t\t// }else{\n\t\t\t// \t\tnext(\"failed\",args)\n\t\t\t// }\n\t\t})\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;UCNe,gBAAgB,CAAC,IAAI;KACpC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;;CCFD;KAAiCA,qCAAgB;KAEhD;SAAA,YACC,iBAAO,SAIP;SAKD,wBAAkB,GAAC,EAAE,CAAA;SACrB,WAAK,GAAC,EAAE,CAAA;SACR,cAAQ,GAAC,EAAE,CAAA;SACX,gBAAU,GAAC,EAAE,CAAA;SACb,eAAS,GAAC,EAAE,CAAA;SAZX,KAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACzD,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACzE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;;MACzE;KAWD,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;SACxC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAC,CAAC,CAAA;SAClB,IAAI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