| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896 |
- var reGameStates = require('GameStates');
- import date from "../Unit/date.js"
- cc.Class({
- extends: cc.Component,
- properties: {
- //MyMapNode
- //建筑物的节点
- BuildingsParent: {
- default: null,
- type: cc.Node,
- },
- //农舍
- Env_101_house_low: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //单元楼
- Env_102_house_mid: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //别墅
- Env_103_house_high: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //蓝色城堡
- Env_104_BlueCastle: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //粉色城堡
- Env_105_PinkCastle: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //农田
- Labour_201_Farmland: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //伐木场
- Labour_202_TimberYard: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //矿坑
- Labour_203_MiningPit: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //工厂
- Labour_204_Factory: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //神农专用农田
- Labour_205_Holy_Farmland: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //一级
- // 冷饮摊
- Shops_30101_ColdDrinkStall: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //贩卖机
- Shops_30102_SalesMachine: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //面包房
- Shops_30103_Bakery: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //早餐车
- Shops_30104_BreakfastCar: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //二级
- //饮茶店
- Shops_30201_TeaShop: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //点心店
- Shops_30202_confectaurant: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //美食店
- Shops_30203_GourmetRestaurant: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //西餐厅
- Shops_30204_WesternRestaurant: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //三级
- //花店
- Shops_30301_Florist: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //美发店
- Shops_30302_HairSalon: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //洋装店
- Shops_30303_DressShop: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //珠宝店
- Shops_30304_JewelryStore: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //电影院
- Shops_30305_Cinema: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //特殊建筑
- //路灯
- Spe_401_StreetLamp: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //绿化带
- Spe_402_GreenBelt: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //花坛
- Spe_403_FlowerBed: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //喷泉
- Spe_404_Pool: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //警察局
- Spe_405_PoliceOffice: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- //游乐场
- Spe_406_Playground: {
- default: null,
- type: cc.Prefab,
- serializable: true,
- },
- BuildingArray: {
- default: [],
- type: [cc.Node],
- serializable: true,
- },
- },
- onBuildHouse(index) {
- // cc.log(index);
- let mainCamera = GlobalD.game.MainCamera;
- let housing = null;
- //content button 设置的index
- //农舍
- if ('101' == index) {
- housing = cc.instantiate(this.Env_101_house_low);
- }
- //单元楼
- else if ('102' == index) {
- housing = cc.instantiate(this.Env_102_house_mid);
- }
- //别墅
- else if ('103' == index) {
- housing = cc.instantiate(this.Env_103_house_high);
- }
- else if ('104' == index) {
- housing = cc.instantiate(this.Env_104_BlueCastle);
- }
- else if ('105' == index) {
- housing = cc.instantiate(this.Env_105_PinkCastle);
- }
- //农田
- else if ('201' == index) {
- housing = cc.instantiate(this.Labour_201_Farmland);
- }
- //伐木场
- else if ('202' == index) {
- housing = cc.instantiate(this.Labour_202_TimberYard);
- }
- //矿坑
- else if ('203' == index) {
- housing = cc.instantiate(this.Labour_203_MiningPit);
- }
- //工厂
- else if ('204' == index) {
- housing = cc.instantiate(this.Labour_204_Factory);
- }
- //神农专用农田
- else if ('205' == index) {
- housing = cc.instantiate(this.Labour_205_Holy_Farmland);
- }
- //冷饮摊
- else if ('30101' == index) {
- housing = cc.instantiate(this.Shops_30101_ColdDrinkStall);
- }
- //贩卖机
- else if ('30102' == index) {
- housing = cc.instantiate(this.Shops_30102_SalesMachine);
- }
- //面包房
- else if ('30103' == index) {
- housing = cc.instantiate(this.Shops_30103_Bakery);
- }
- //早餐车
- else if ('30104' == index) {
- housing = cc.instantiate(this.Shops_30104_BreakfastCar);
- }
- //饮茶店
- else if ('30201' == index) {
- housing = cc.instantiate(this.Shops_30201_TeaShop);
- }
- //点心店
- else if ('30202' == index) {
- housing = cc.instantiate(this.Shops_30202_confectaurant);
- }
- //美食店
- else if ('30203' == index) {
- housing = cc.instantiate(this.Shops_30203_GourmetRestaurant);
- }
- //西餐厅
- else if ('30204' == index) {
- housing = cc.instantiate(this.Shops_30204_WesternRestaurant);
- }
- //花店
- else if ('30301' == index) {
- housing = cc.instantiate(this.Shops_30301_Florist);
- }
- //美发店
- else if ('30302' == index) {
- housing = cc.instantiate(this.Shops_30302_HairSalon);
- }
- //洋装店
- else if ('30303' == index) {
- housing = cc.instantiate(this.Shops_30303_DressShop);
- }
- //珠宝店
- else if ('30304' == index) {
- housing = cc.instantiate(this.Shops_30304_JewelryStore);
- }
- //电影院
- else if ('30305' == index) {
- housing = cc.instantiate(this.Shops_30305_Cinema);
- }
- //路灯
- else if ('401' == index) {
- housing = cc.instantiate(this.Spe_401_StreetLamp);
- }
- //绿化带
- else if ('402' == index) {
- housing = cc.instantiate(this.Spe_402_GreenBelt);
- }
- //花坛
- else if ('403' == index) {
- housing = cc.instantiate(this.Spe_403_FlowerBed);
- }
- //喷泉
- else if ('404' == index) {
- housing = cc.instantiate(this.Spe_404_Pool);
- }
- //警察局
- else if ('405' == index) {
- housing = cc.instantiate(this.Spe_405_PoliceOffice);
- }
- //游乐场
- else if ('406' == index) {
- housing = cc.instantiate(this.Spe_406_Playground);
- }
- housing.parent = this.BuildingsParent;
- let tempPos = housing.parent.convertToNodeSpace(mainCamera.node);
- let CanvasPos = GlobalD.game.Canvas.position;
- housing.setPosition(tempPos.x + CanvasPos.x, tempPos.y + CanvasPos.y);
- let buildingsInfo = housing.getComponent("buildingsInfo");
- //id用时间戳来记录
- buildingsInfo.buildInfo.id = new Date().getTime();//+= Math.random() * 1000000;
- this.SpawnBuildingDefaultValue(buildingsInfo);
- let buildingsTouch = housing.getComponent("buildingsTouch");
- // buildingsTouch.buildInfo = buildingsInfo.buildInfo;
- buildingsTouch.onEditorStatus(true);
- // housing.active = true;
- //收起菜单
- GlobalD.game._ManageUIScript.onHideMenu();
- //收起底部菜单栏
- GlobalD.game._ManageUIScript.onBottomMenuView(false);
- },
- start() {
- },
- //如果存储到有房子数据的话,把地图上的房屋都隐藏起来,或者删除
- //todo...
- onHideInitPosBuildings() {
- //删除对应层的子节点
- let tempNode = this.BuildingsParent.children;
- let length = tempNode.length;
- for (let i = length - 1; i >= 0; i--) {
- tempNode[i].active = false;
- }
- },
- /**
- * GameData里面处理的生成数据流程,生成建筑物
- */
- InitBuildings() {
- //如果有存储的数据,隐藏场景房屋节点
- // this.onHideInitPosBuildings();
- /**
- * 注释 spawnConfigLand 不初始化固定土地
- */
- //第一步初始化土地的网络数据
- this.spawnConfigLand();
- //先初始化网络数据
- this.SpawnHouse();
- // cc.log('初始化场景建筑');
- let BuildingStateArray = GlobalD.GameData.GetBuildingStateArray();
- for (let i = 0; i < BuildingStateArray.length; i++) {
- if (BuildingStateArray[i] == 0) {
- if (this.BuildingArray[i])
- this.BuildingArray[i].active = false;
- }
- else {
- if (this.BuildingArray[i])
- this.BuildingArray[i].active = true;
- }
- }
- let BuildingNumArray = GlobalD.GameData.GetBuildingNumArray();
- // cc.log('BuildingNumArray',BuildingNumArray)
- for (let i = 3; i < this.BuildingArray.length; i++) {
- // cc.log('this.BuildingArray[' + i + ']=' + this.BuildingArray[i].getChildByName('Name').getComponent(cc.Label).string);
- if (this.BuildingArray[i])
- this.BuildingArray[i].getChildByName('Name').getChildByName('Num').getComponent(cc.Label).string = BuildingNumArray[i];
- }
- },
- //生成房子的默认值
- SpawnBuildingDefaultValue(buildingsInfo) {
- buildingsInfo.InitPos = false;
- buildingsInfo.InitWorkBuildingInfo = false;
- //激活状态,可运营
- buildingsInfo.buildInfo.isItActive = true;
- //设置销售状态
- buildingsInfo.buildInfo.isItSaleable = true;
- if (reGameStates.BuildType.Farmland == buildingsInfo.buildInfo.buildType) {
- buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetFoodTradeState() > 0 ? true : false;// GlobalD.GameData.GetFoodTradeState();
- // cc.log('初始化房子的信息:', buildingsInfo.buildInfo.buildingName, buildingsInfo.buildInfo.isItSaleable);
- }
- if (reGameStates.BuildType.MiningPit == buildingsInfo.buildInfo.buildType) {
- buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetMineralTradeState() > 0 ? true : false;// GlobalD.GameData.GetMineralTradeState();
- }
- if (reGameStates.BuildType.TimberYard == buildingsInfo.buildInfo.buildType) {
- buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetWoodTradeState() > 0 ? true : false;// GlobalD.GameData.GetWoodTradeState();
- }
- //设置一下,可查看信息
- if (reGameStates.BuildType.Housing !== buildingsInfo.buildInfo.buildType
- && reGameStates.BuildType.Special !== buildingsInfo.buildInfo.buildType
- /** 神农小镇固定土地关闭 基本的房屋信息,另外设置其他信息 */
- && reGameStates.BuildType.HolyFarmland !== buildingsInfo.buildInfo.buildType
- ) {
- buildingsInfo.node.getComponent('buildingsTouch').isShowBuildingInfo = true;
- }
- //设置消耗的体力值为工人的最低值 20
- //过高的话,会导致工人不工作
- // buildingsInfo.buildInfo.totalConsumption = 20;
- // cc.log('初始化房子的信息:', buildingsInfo.buildInfo.buildingName, buildingsInfo.buildInfo.isItSaleable)
- },
- //初始化场景的两个建筑
- SpawnDefaultHouse() {
- cc.log('初始化默认房子');
- //房子
- let housingTemp_house = this.onGetHousingPrefabFromName('Env_101_house_low');
- housingTemp_house.parent = this.BuildingsParent;
- var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(cc.v2(24, 23));
- housingTemp_house.setPosition(endPos.x, endPos.y);
- let buildingsInfo_house = housingTemp_house.getComponent("buildingsInfo");
- //id用时间戳来记录
- buildingsInfo_house.buildInfo.id = 101;//对应的id
- //设置tile的最底下的坐标,就是起始坐标
- buildingsInfo_house.buildInfo.startTilePos = cc.v2(24, 23);
- this.SpawnBuildingDefaultValue(buildingsInfo_house);
- //起始坐标,占位范围,是否占位
- GlobalD.game.addBuildTiled(buildingsInfo_house.buildInfo.id, buildingsInfo_house.buildInfo.startTilePos, buildingsInfo_house.buildInfo.occupyArea);
- //添加占位信息
- GlobalD.game.addBuilding(buildingsInfo_house);
- //农田
- let housingTemp_farmland = this.onGetHousingPrefabFromName('Labour_201_Farmland');
- housingTemp_farmland.parent = this.BuildingsParent;
- var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(cc.v2(26, 24));
- housingTemp_farmland.setPosition(endPos.x, endPos.y);
- let buildingsInfo_farmland = housingTemp_farmland.getComponent("buildingsInfo");
- //id用时间戳来记录
- buildingsInfo_farmland.buildInfo.id = 201;//对应的id
- //设置tile的最底下的坐标,就是起始坐标
- buildingsInfo_farmland.buildInfo.startTilePos = cc.v2(26, 24);
- this.SpawnBuildingDefaultValue(buildingsInfo_farmland);
- //起始坐标,占位范围,是否占位
- GlobalD.game.addBuildTiled(buildingsInfo_farmland.buildInfo.id, buildingsInfo_farmland.buildInfo.startTilePos, buildingsInfo_farmland.buildInfo.occupyArea);
- //添加占位信息
- GlobalD.game.addBuilding(buildingsInfo_farmland);
- },
- //初始化后台配置的土地数据
- spawnConfigLand() {
- if (GlobalD.ConfigLand == null) {
- console.error("GlobalD.ConfigLand 未初始化设置!");
- return;
- }
- if (GlobalD.UserLeaseLand == null) {
- console.error("GlobalD.UserLeaseLand 未初始化设置!");
- return;
- }
- let _configLand = GlobalD.ConfigLand;
- let _userLeaseLand = GlobalD.UserLeaseLand;
- // console.log(_configLand, _userLeaseLand);
- // console.log(this.node.getComponent("ManageUI"));
- let _buildingView = this.node.getComponent("ManageUI").BuildView.getComponent('BuildingView');
- for (let i = 0; i < _configLand.length; i++) {
- //生成默认土地
- //农田
- let housingTemp_farmland = this.onGetHousingPrefabFromName('Labour_205_Holy_Farmland');
- housingTemp_farmland.parent = this.BuildingsParent;
- var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(cc.v2(_configLand[i].posX, _configLand[i].posY));
- housingTemp_farmland.setPosition(endPos.x, endPos.y);
- let leaseFarmlandInfoScript = housingTemp_farmland.getComponent("LeaseFarmlandInfo");
- //记录config的土地信息
- leaseFarmlandInfoScript.setConfigLandInfo(_configLand[i]);
- for (let j = 0; j < _userLeaseLand.length; j++) {
- //记录已经租赁的信息(租赁里面包含了seedInfo,如果有种植的话,对应的种植信息会有)
- if (_userLeaseLand[j].configLandId == _configLand[i].id) {
- let _leaseLandInfo = _userLeaseLand[j];
- leaseFarmlandInfoScript.setLeaseLandInfo(_leaseLandInfo);
- //todo 后续看看如何刷新,现在走的是开始刷新一次
- if (_leaseLandInfo.isPlant === 1) {
- let _workingBuilding = housingTemp_farmland.getComponent("WorkingBuilding");
- let _spriteFrame;
- switch (_leaseLandInfo.seedInfo.picture) {
- case "Cabbage":
- _spriteFrame = _buildingView.fruitSpriteFrame[0];
- break;
- case "Potato":
- _spriteFrame = _buildingView.fruitSpriteFrame[1];
- break;
- case "Carrot":
- _spriteFrame = _buildingView.fruitSpriteFrame[2];
- break;
- case "Broccoli":
- _spriteFrame = _buildingView.fruitSpriteFrame[3];
- break;
- case "Tomato":
- _spriteFrame = _buildingView.fruitSpriteFrame[4];
- break;
- case "Squash":
- _spriteFrame = _buildingView.fruitSpriteFrame[5];
- break;
- case "Eggplant":
- _spriteFrame = _buildingView.fruitSpriteFrame[6];
- break;
- case "Pepper":
- _spriteFrame = _buildingView.fruitSpriteFrame[7];
- break;
- default:
- break;
- }
- //拿到土地的成熟期来判断
- // let _plantStart = Date.parse(_leaseLandInfo.plantStart.replace(/-/g, '/'))
- // let _currentDay = _plantStart.getTime() - new Date().getTime(); //date.datedifference(date.formatTime(new Date()), _leaseLandInfo.plantStart);
- //种植日期加成熟期
- let _endMilli = date.addDayTranMillisecond(_leaseLandInfo.plantStart, _leaseLandInfo.seedInfo.maturity);
- let _currentMilli = new Date().getTime();
- let _ratio = _currentMilli / _endMilli;
- if (_ratio <= 0.3) {
- _workingBuilding.onSetGrow(1, _spriteFrame);
- //测试,后面删除
- // leaseFarmlandInfoScript.onShowHarvest();
- } else if (_ratio < 1) {
- _workingBuilding.onSetGrow(2, _spriteFrame);
- } else {
- //成熟阶段
- _workingBuilding.onSetGrow(3, _spriteFrame);
- //todo,如果时间小的,走收获,收获成果实
- // console.log("土地:", _userLeaseLand[j].configLandId, "已经成熟,可以操作收取果实了!!");
- //todo 土地可收获状态
- leaseFarmlandInfoScript.onShowHarvest();
- }
- }
- }
- }
- let buildingsInfo_farmland = housingTemp_farmland.getComponent("buildingsInfo");
- //id用时间戳来记录
- buildingsInfo_farmland.buildInfo.id = _configLand[i].id;//对应的id
- /**
- * 服务器设置的农田 独立于其他游戏数据
- * 这步设置之后,addBuilding 时候不存储到 GameData_buildings
- */
- buildingsInfo_farmland.InitPosFromStore = true;
- //设置tile的最底下的坐标,就是起始坐标
- buildingsInfo_farmland.buildInfo.startTilePos = cc.v2(_configLand[i].posX, _configLand[i].posY);
- this.SpawnBuildingDefaultValue(buildingsInfo_farmland);
- //起始坐标,占位范围,是否占位
- GlobalD.game.addBuildTiled(buildingsInfo_farmland.buildInfo.id, buildingsInfo_farmland.buildInfo.startTilePos, buildingsInfo_farmland.buildInfo.occupyArea);
- //添加占位信息
- GlobalD.game.addBuilding(buildingsInfo_farmland);
- }
- },
- //初始化场景建筑
- SpawnHouse: function () {
- let BuildingJSON = Object.assign([], GlobalD.GameData.GameData_buildings);
- //拿到数据后,清空 GlobalD.GameData.GameData_buildings 数据,下面再添加上去
- GlobalD.GameData.GameData_buildings.length = 0;
- // cc.log('BuildingJSON', BuildingJSON);
- // if (BuildingJSON.length == 0) {
- // //初始化默认房子
- // this.SpawnDefaultHouse();
- // return
- // };
- for (let i = 0; i < BuildingJSON.length; i++) {
- let HouseName = BuildingJSON[i].buildingNodeName;
- let housingTemp = this.onGetHousingPrefabFromName(HouseName);
- if (!housingTemp)
- cc.error('housingTemp', HouseName, housingTemp);
- //预制为空
- if (!housingTemp) return;
- let buildingsInfo = housingTemp.getComponent("buildingsInfo");
- /**
- * 处理数据库数据冲突问题
- * 这里处理判断初始化位置是否被占用,占用了回收到仓库背包系统
- * BuildingJSON 看做旧的数据, 拿到旧数据 BuildingJSON[i].startTilePos 起始位置 ,生成对应预制的大小occupyArea
- * 来判断占位信息
- */
- let _canNotBuild = GlobalD.game.areTheraOverlappingAreas(BuildingJSON[i].startTilePos, buildingsInfo.buildInfo.occupyArea, 1);
- if (_canNotBuild) {
- // 背包添加对应的建筑数量
- GlobalD.game.PlusBuilding(buildingsInfo.buildInfo.buildingName);
- // 删除上面生成的预制节点
- housingTemp.destroy();
- //跳过生成
- continue;
- }
- housingTemp.parent = this.BuildingsParent;
- var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(BuildingJSON[i].startTilePos);
- housingTemp.setPosition(endPos.x, endPos.y);
- //id用时间戳来记录
- buildingsInfo.buildInfo.id = BuildingJSON[i].buildingId;//对应的id
- //设置tile的最底下的坐标,就是起始坐标
- buildingsInfo.buildInfo.startTilePos = BuildingJSON[i].startTilePos;
- //初始化位置的坐标
- buildingsInfo.InitStartPos = BuildingJSON[i].startTilePos;
- this.SpawnBuildingDefaultValue(buildingsInfo);
- //目前应该只有商店,后面根据RunningCost来判断 todo.....
- // if (reGameStates.BuildType.Shop == buildingsInfo.buildInfo.buildType)
- {
- // buildingsInfo.buildInfo.isItSaleable = Number(BuildingJSON[i].isItSaleable) > 0 ? true : false;
- buildingsInfo.buildInfo.isItStopOperation = Number(BuildingJSON[i].isItStopOperation) > 0 ? true : false;
- //如果不可以运营的,加上牌子
- if (buildingsInfo.buildInfo.isItStopOperation) {
- GlobalD.game.onAddBuildingTipView(buildingsInfo);
- }
- }
- //建筑物的加成值
- buildingsInfo.buildInfo.consumeStrengthAddValue = Number(BuildingJSON[i].consumeStrengthAddValue);
- buildingsInfo.buildInfo.goodsPriceAddValue = Number(BuildingJSON[i].goodsPriceAddValue);
- /**
- * 判断是否占位的时候,需要进一步处理。放回背包,然后背包物品加上对应的数量
- */
- //起始坐标,占位范围,是否占位
- GlobalD.game.addBuildTiled(buildingsInfo.buildInfo.id, buildingsInfo.buildInfo.startTilePos, buildingsInfo.buildInfo.occupyArea);
- //添加占位信息
- GlobalD.game.addBuilding(buildingsInfo);
- }
- // console.log("GlobalD.GameData.GameData_buildings:", GlobalD.GameData.GameData_buildings);
- },
- onGetHousingPrefabFromName(HouseName) {
- let housing = null;
- //住宿地方
- if (HouseName == 'Env_101_house_low') {
- housing = cc.instantiate(this.Env_101_house_low);
- }
- else if (HouseName === 'Env_102_house_mid') {
- housing = cc.instantiate(this.Env_102_house_mid);
- }
- else if (HouseName == 'Env_103_house_high') {
- housing = cc.instantiate(this.Env_103_house_high);
- }
- else if (HouseName == 'Env_104_BlueCastle') {
- housing = cc.instantiate(this.Env_104_BlueCastle);
- }
- else if (HouseName == 'Env_105_PinkCastle') {
- housing = cc.instantiate(this.Env_105_PinkCastle);
- }
- //劳动地方
- else if (HouseName == 'Labour_201_Farmland') {
- housing = cc.instantiate(this.Labour_201_Farmland);
- }
- else if (HouseName == 'Labour_202_TimberYard') {
- housing = cc.instantiate(this.Labour_202_TimberYard);
- }
- else if (HouseName == 'Labour_203_MiningPit') {
- housing = cc.instantiate(this.Labour_203_MiningPit);
- }
- else if (HouseName == 'Labour_204_Factory') {
- housing = cc.instantiate(this.Labour_204_Factory);
- }
- //神农专用农田
- else if (HouseName == 'Labour_205_Holy_Farmland') {
- housing = cc.instantiate(this.Labour_205_Holy_Farmland);
- }
- //特殊建筑
- else if (HouseName == 'Spe_401_StreetLamp') {
- housing = cc.instantiate(this.Spe_401_StreetLamp);
- }
- else if (HouseName == 'Spe_402_GreenBelt') {
- housing = cc.instantiate(this.Spe_402_GreenBelt);
- }
- else if (HouseName == 'Spe_403_FlowerBed') {
- housing = cc.instantiate(this.Spe_403_FlowerBed);
- }
- else if (HouseName == 'Spe_404_Pool') {
- housing = cc.instantiate(this.Spe_404_Pool);
- }
- else if (HouseName == 'Spe_405_PoliceOffice') {
- housing = cc.instantiate(this.Spe_405_PoliceOffice);
- }
- else if (HouseName == 'Spe_406_Playground') {
- housing = cc.instantiate(this.Spe_406_Playground);
- }
- //商店类型
- else if (HouseName == 'Shops_30101_ColdDrinkStall') {
- housing = cc.instantiate(this.Shops_30101_ColdDrinkStall);
- }
- else if (HouseName == 'Shops_30102_SalesMachine') {
- housing = cc.instantiate(this.Shops_30102_SalesMachine);
- }
- else if (HouseName == 'Shops_30103_Bakery') {
- housing = cc.instantiate(this.Shops_30103_Bakery);
- }
- else if (HouseName == 'Shops_30104_BreakfastCar') {
- housing = cc.instantiate(this.Shops_30104_BreakfastCar);
- }
- else if (HouseName == 'Shops_30201_TeaShop') {
- housing = cc.instantiate(this.Shops_30201_TeaShop);
- }
- else if (HouseName == 'Shops_30202_confectaurant') {
- housing = cc.instantiate(this.Shops_30202_confectaurant);
- }
- else if (HouseName == 'Shops_30203_GourmetRestaurant') {
- housing = cc.instantiate(this.Shops_30203_GourmetRestaurant);
- }
- else if (HouseName == 'Shops_30204_WesternRestaurant') {
- housing = cc.instantiate(this.Shops_30204_WesternRestaurant);
- }
- else if (HouseName == 'Shops_30301_Florist') {
- housing = cc.instantiate(this.Shops_30301_Florist);
- }
- else if (HouseName == 'Shops_30302_HairSalon') {
- housing = cc.instantiate(this.Shops_30302_HairSalon);
- }
- else if (HouseName == 'Shops_30303_DressShop') {
- housing = cc.instantiate(this.Shops_30303_DressShop);
- }
- else if (HouseName == 'Shops_30304_JewelryStore') {
- housing = cc.instantiate(this.Shops_30304_JewelryStore);
- }
- else if (HouseName == 'Shops_30305_Cinema') {
- housing = cc.instantiate(this.Shops_30305_Cinema);
- }
- return housing;
- },
- //获取预制的名字
- onGetPrefabsBuildingName(index) {
- //content button 设置的index
- let buildingName = '';
- //农舍
- if ('101' == index) {
- buildingName = 'Env_101_house_low';
- }
- //单元楼
- else if ('102' == index) {
- buildingName = 'Env_102_house_mid';
- }
- //别墅
- else if ('103' == index) {
- buildingName = 'Env_103_house_high';
- }
- //蓝色城堡
- else if ('104' == index) {
- buildingName = 'Env_104_BlueCastle';
- }
- //粉色城堡
- else if ('105' == index) {
- buildingName = 'Env_105_PinkCastle';
- }
- //农田
- else if ('201' == index) {
- buildingName = 'Labour_201_Farmland';
- }
- //伐木场
- else if ('202' == index) {
- buildingName = 'Labour_202_TimberYard';
- }
- //矿坑
- else if ('203' == index) {
- buildingName = 'Labour_203_MiningPit';
- }
- //工厂
- else if ('204' == index) {
- buildingName = 'Labour_204_Factory';
- }
- //神农专用农田
- else if ('205' == index) {
- buildingName = 'Labour_205_Holy_Farmland';
- }
- //冷饮摊
- else if ('30101' == index) {
- buildingName = 'Shops_30101_ColdDrinkStall';
- }
- //贩卖机
- else if ('30102' == index) {
- buildingName = 'Shops_30102_SalesMachine';
- }
- //面包房
- else if ('30103' == index) {
- buildingName = 'Shops_30103_Bakery';
- }
- //早餐车
- else if ('30104' == index) {
- buildingName = 'Shops_30104_BreakfastCar';
- }
- //饮茶店
- else if ('30201' == index) {
- buildingName = 'Shops_30201_TeaShop';
- }
- //点心店
- else if ('30202' == index) {
- buildingName = 'Shops_30202_confectaurant';
- }
- //美食店
- else if ('30203' == index) {
- buildingName = 'Shops_30203_GourmetRestaurant';
- }
- //西餐厅
- else if ('30204' == index) {
- buildingName = 'Shops_30204_WesternRestaurant';
- }
- //花店
- else if ('30301' == index) {
- buildingName = 'Shops_30301_Florist';
- }
- //美发店
- else if ('30302' == index) {
- buildingName = 'Shops_30302_HairSalon';
- }
- //洋装店
- else if ('30303' == index) {
- buildingName = 'Shops_30303_DressShop';
- }
- //珠宝店
- else if ('30304' == index) {
- buildingName = 'Shops_30304_JewelryStore';
- }
- //电影院
- else if ('30305' == index) {
- buildingName = 'Shops_30305_Cinema';
- }
- //路灯
- else if ('401' == index) {
- buildingName = 'Spe_401_StreetLamp';
- }
- //绿化带
- else if ('402' == index) {
- buildingName = 'Spe_402_GreenBelt';
- }
- //花坛
- else if ('403' == index) {
- buildingName = 'Spe_403_FlowerBed';
- }
- //喷泉
- else if ('404' == index) {
- buildingName = 'Spe_404_Pool';
- }
- //警察局
- else if ('405' == index) {
- buildingName = 'Spe_405_PoliceOffice';
- }
- //游乐场
- else if ('406' == index) {
- buildingName = 'Spe_406_Playground';
- }
- return buildingName;
- },
- Grant() {
- },
- Sale() {
- },
- Exchange() {
- }
- });
|