waves/public/assets/g/pick/src/reshub.js
2025-04-09 17:11:14 -05:00

1 line
1.9 KiB
JavaScript

var ResHub=function(e){this.layer=new cc.Layer,this.strValues=[],this.strValuesRubies=[];for(var t=790,r=0;r<playerData.res.length;r++){(i=new cc.Sprite("#box_soil_0"+(r+1).toString())).setPosition(30,t);var s=new cc.LabelTTF(playerData.res[r].toString(),"Press Start 2P",20);s.enableStroke(cc.color(0,0,0),2),s.setPosition(i.width+6,.5*i.height-3),s.anchorX=0,i.addChild(s),this.layer.addChild(i),this.strValues.push(s),t-=55}for(t=790,r=0;r<playerData.rubies.length;r++){var i;(i=new cc.Sprite("#rubies_"+r.toString())).setPosition(cc.winSize.width-20,t);var a=new cc.LabelTTF(playerData.rubies[r].toString(),"Press Start 2P",20);a.enableStroke(cc.color(0,0,0),2),a.setPosition(-6,.5*i.height-4),a.anchorX=1,i.addChild(a),this.layer.addChild(i),this.strValuesRubies.push(a),t-=63}e.addChild(this.layer)};ResHub.prototype={updateRes:function(e){e<this.strValues.length&&this.strValues[e].setString(playerData.res[e].toString())},updateResRubies:function(e){this.strValuesRubies[e].setString(playerData.rubies[e].toString())}};var framesHelper=["#helper_forest_spirit","#helper_mole","#helper_dwarf","#helper_woodpaker","#helper_cave","#helper_salamander","#helper_yeti","#helper_robo","#helper_demon","#helper_angel"],HelperHub=function(e){this.layer=new cc.Layer,this.strValues=[],this.icons=[];for(var t=0;t<framesHelper.length;t++){var r=new cc.Sprite(framesHelper[t]);r.setScale(.54),r.setPosition(0,190);var s=new cc.LabelTTF(playerData.helpers[t].toString(),"Press Start 2P",40);s.enableStroke(cc.color(0,0,0),3),s.x=.5*r.width,r.addChild(s),this.layer.addChild(r),this.icons.push(r),this.strValues.push(s),r.setVisible(!1)}for(this.booundX=30,e.addChild(this.layer),t=0;t<playerData.helpers.length;t++)playerData.helpers[t]&&HelperHub.prototype.addHelper.call(this,t)};HelperHub.prototype={addHelper:function(e){this.strValues[e].setString(playerData.helpers[e].toString()),this.icons[e].isVisible()||(this.icons[e].x=this.booundX,this.booundX+=63,this.icons[e].setVisible(!0))}};