| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- /** 农场等级界面 */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class FarmLevelPanel extends cc.Component {
- @property({ type: cc.Sprite, displayName: '仓库' })
- scrollStore: cc.Sprite = null;
- @property({ type: cc.Sprite, displayName: '等级解锁' })
- scrollUnlock: cc.Sprite = null;
- @property({ type: cc.Label, displayName: '经验进度文本' })
- lblPro: cc.Label = null;
- @property({ type: cc.ProgressBar, displayName: '经验进度' })
- proExp: cc.ProgressBar = null;
- @property({ type: cc.Label, displayName: '等级' })
- lblLv: cc.Label = null;
- @property({ type: cc.Label, displayName: '名称' })
- lblName: cc.Label = null;
- @property({ type: cc.Sprite, displayName: '头像' })
- head: cc.Sprite = null;
- //解锁数组
- dataArr = [];
- curChooseId: number = 1;
- storeHasInit = false;
- async start() {
- this.scrollUnlock.node.active = true;
- this.scrollStore.node.active = false;
- let buildName = '';
- let buildUrl = '';
- let state = 0;
- let p = null;
- for (var i = 30001; i < 30010; i++) {
- let data: any = {};
- if (i == 30001) {
- buildName = '养鸡场';
- buildUrl = 'game/coregame/texture/main/main/enclosure_0';
- p = gData.gameData.getPastureDataMap(i);
- state = p.state;
- } else if (i == 30002) {
- buildName = '养牛场';
- buildUrl = 'game/coregame/texture/main/main/enclosure_1';
- p = gData.gameData.getPastureDataMap(i);
- state = p.state;
- } else if (i == 30003) {
- buildName = '养猪场';
- buildUrl = 'game/coregame/texture/main/main/enclosure_2';
- p = gData.gameData.getPastureDataMap(i);
- state = p.state;
- } else if (i == 30004) {
- buildName = gData.gameData.getTabByConfigID(i);
- buildUrl = 'game/coregame/texture/main/main/mapIcon_0';
- p = gData.gameData.getFactoryDataMap(i);
- state = p.state;
- } else if (i == 30005) {
- buildName = gData.gameData.getTabByConfigID(i);
- buildUrl = 'game/coregame/texture/main/main/mapIcon_1';
- p = gData.gameData.getFactoryDataMap(i);
- state = p.state;
- } else if (i == 30006) {
- buildName = gData.gameData.getTabByConfigID(i);
- buildUrl = 'game/coregame/texture/main/main/mapIcon_7';
- p = gData.gameData.getFactoryDataMap(i);
- state = p.state;
- } else if (i == 30007) {
- buildName = gData.gameData.getTabByConfigID(i);
- buildUrl = 'game/coregame/texture/main/main/mapIcon_4';
- p = gData.gameData.getFactoryDataMap(i);
- state = p.state;
- } else if (i == 30008) {
- buildName = gData.gameData.getTabByConfigID(i);
- buildUrl = 'game/coregame/texture/main/main/mapIcon_2';
- p = gData.gameData.getFactoryDataMap(i);
- state = p.state;
- } else if (i == 30009) {
- buildName = gData.gameData.getTabByConfigID(i);
- buildUrl = 'game/coregame/texture/main/main/mapIcon_3';
- p = gData.gameData.getFactoryDataMap(i);
- state = p.state;
- }
- data.buildName = buildName;
- data.buildUrl = buildUrl;
- data.state = state;
- this.dataArr.push(data);
- }
- this.scrollUnlock.node.emit('srollview-init', this.dataArr);
- if (gData.wechatData.nickName != '' && gData.wechatData.nickName != '点我授权提现') {
- this.lblName.string = `${gData.wechatData.nickName}的小农场`
- }
- else {
- this.lblName.string = `你的小农场`
- }
- let curLevel = gData.gameData.playerProp.gradeLevel;
- let needExp = gData.gameData.configs.UpgradeReward[curLevel].exp - gData.gameData.configs.UpgradeReward[curLevel - 1].exp;
- let curExp = gData.gameData.playerProp.farmExpValue - gData.gameData.configs.UpgradeReward[curLevel - 1].exp;
- this.lblLv.string = `等级:${curLevel}`;
- this.proExp.progress = curExp / needExp;
- this.lblPro.string = `${(Math.floor(curExp / needExp) * 100)}%`;
- if (gData.wechatData.avatar != '') {
- let result = await mk.loader.loadRemote(gData.wechatData.avatar + "?aaa=aa.jpg", null);
- if (result) {
- this.head.spriteFrame = new cc.SpriteFrame(result);
- }
- }
- }
- private clickToggleBtn(event, customEvenData) {
- mk.audio.playEffect('button');
- let id = parseInt(customEvenData);
- if (id == this.curChooseId)
- return;
- this.curChooseId = id;
- switch (id) {
- case 1:
- this.scrollUnlock.node.active = true;
- this.scrollStore.node.active = false;
- break;
- case 2:
- this.scrollUnlock.node.active = false;
- this.scrollStore.node.active = true;
- if (!this.storeHasInit) {
- this.scrollStore.node.emit('srollview-init', gData.gameData.configs.Product);
- this.storeHasInit = true;
- }
- break;
- }
- }
- }
|