const DWTool = require("./DWTool"); class ThemeManager { static setBuildItemColor(cityId, node) { var color; switch (cityId) { case 1: color = new cc.color('#41b3e9'); break; case 2: color = new cc.color('#81f9c8'); break; case 3: color = new cc.color('#ffffc0'); break; case 4: color = new cc.color('#360f5a'); break; case 5: color = new cc.color('#00ddf2'); break; default: color = new cc.color('#41b3e9'); break; } node.color = color; } static getSpriteFrameByPath(path) { let filePath = `resources/textures/building/${path}`; let uuid = cc.loader._getResUuid(filePath.slice(10), cc.Texture2D, true); let result = GameGlobal.buildRes.filter((item) => { return item._uuid === uuid }); if (result != null && result.length != undefined) { let texture = result[0]; return new cc.SpriteFrame(texture); } return null; } // LevelHomeItem 样式变化 static setItemBuildSpriteFrame(roomId, buildSprite) { if (GameGlobal.buildRes) { let picId = 30100 + parseInt(roomId); buildSprite.spriteFrame = this.getSpriteFrameByPath(`${picId}`); } else { DWTool.loadResSpriteFrame(`./textures/building/${picId}`) .then((spriteFrame) => { buildSprite.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } // 外墙顶部 static setItemPillarTopSpriteFrame(cityId, pillar) { if (GameGlobal.buildRes) { let spriteFrame = this.getSpriteFrameByPath(`30${cityId}33`); pillar.spriteFrame = spriteFrame; } else { DWTool.loadResSpriteFrame(`./textures/building/30${cityId}33`) .then((spriteFrame) => { pillar.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } // 外墙底部 static setItemPillarBottomSpriteFrame(cityId, pillar) { if (GameGlobal.buildRes) { let spriteFrame = this.getSpriteFrameByPath(`30${cityId}34`); pillar.spriteFrame = spriteFrame; } else { DWTool.loadResSpriteFrame(`./textures/building/30${cityId}34`) .then((spriteFrame) => { pillar.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } // 外墙右边 static setItemPillarRightSpriteFrame(cityId, pillar) { if (GameGlobal.buildRes) { let spriteFrame = this.getSpriteFrameByPath(`30${cityId}35`); pillar.spriteFrame = spriteFrame; } else { DWTool.loadResSpriteFrame(`./textures/building/30${cityId}35`) .then((spriteFrame) => { pillar.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } // 外墙左边 static setItemPillarLeftSpriteFrame(cityId, pillar) { if (GameGlobal.buildRes) { let spriteFrame = this.getSpriteFrameByPath(`30${cityId}36`); pillar.spriteFrame = spriteFrame; } else { DWTool.loadResSpriteFrame(`./textures/building/30${cityId}36`) .then((spriteFrame) => { pillar.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } static setItemPillarSpriteFrame(cityId, pillars) { if (GameGlobal.buildRes) { let spriteFrame = this.getSpriteFrameByPath(`${cityId}_pillar`); for (let i = 0; i < pillars.length; i++) { let sprite = pillars[i]; sprite.spriteFrame = spriteFrame; } } else { DWTool.loadResSpriteFrame(`./textures/building/${cityId}_pillar`) .then((spriteFrame) => { for (let i = 0; i < pillars.length; i++) { let sprite = pillars[i]; sprite.spriteFrame = spriteFrame; } }).catch((err) => { console.log(err); }); } } static setItemDownSpriteFrame(cityId, lockBottomBg) { if (GameGlobal.buildRes) { lockBottomBg.spriteFrame = this.getSpriteFrameByPath(`30${cityId}16`); } else { DWTool.loadResSpriteFrame(`./textures/building/30${cityId}16`) .then((spriteFrame) => { lockBottomBg.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } static setItemLockDownSpriteFrame(lockBottomBg) { if (GameGlobal.buildRes) { lockBottomBg.spriteFrame = this.getSpriteFrameByPath(`30137`); } else { DWTool.loadResSpriteFrame(`./textures/building/30137`) .then((spriteFrame) => { lockBottomBg.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } // LevelHome最底层一楼样式变化 static setBottomBuildSpriteFrame(cityId, buildSprite) { if (GameGlobal.buildRes) { buildSprite.spriteFrame = this.getSpriteFrameByPath(`30${cityId}38`); } else { DWTool.loadResSpriteFrame(`./textures/building/30${cityId}38`) .then((spriteFrame) => { buildSprite.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } // LevelHome最顶层楼顶样式变化 static setTopBgBuildSpriteFrame(cityId, buildSprite) { if (GameGlobal.buildRes) { buildSprite.spriteFrame = this.getSpriteFrameByPath(`30${cityId}31`); } else { DWTool.loadResSpriteFrame(`./textures/building/30${cityId}31`) .then((spriteFrame) => { buildSprite.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } static setTopCoverSpriteFrame(cityId, coverSprite) { if (GameGlobal.buildRes) { coverSprite.spriteFrame = this.getSpriteFrameByPath(`30${cityId}32`); } else { DWTool.loadResSpriteFrame(`./textures/building/30${cityId}32`) .then((spriteFrame) => { coverSprite.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); } } } module.exports = ThemeManager;