ManageBuildings.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. var reGameStates = require('GameStates');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. //MyMapNode
  6. //建筑物的节点
  7. BuildingsParent: {
  8. default: null,
  9. type: cc.Node,
  10. },
  11. //农舍
  12. Env_101_house_low: {
  13. default: null,
  14. type: cc.Prefab,
  15. serializable: true,
  16. },
  17. //单元楼
  18. Env_102_house_mid: {
  19. default: null,
  20. type: cc.Prefab,
  21. serializable: true,
  22. },
  23. //别墅
  24. Env_103_house_high: {
  25. default: null,
  26. type: cc.Prefab,
  27. serializable: true,
  28. },
  29. //蓝色城堡
  30. Env_104_BlueCastle: {
  31. default: null,
  32. type: cc.Prefab,
  33. serializable: true,
  34. },
  35. //粉色城堡
  36. Env_105_PinkCastle: {
  37. default: null,
  38. type: cc.Prefab,
  39. serializable: true,
  40. },
  41. //农田
  42. Labour_201_Farmland: {
  43. default: null,
  44. type: cc.Prefab,
  45. serializable: true,
  46. },
  47. //伐木场
  48. Labour_202_TimberYard: {
  49. default: null,
  50. type: cc.Prefab,
  51. serializable: true,
  52. },
  53. //矿坑
  54. Labour_203_MiningPit: {
  55. default: null,
  56. type: cc.Prefab,
  57. serializable: true,
  58. },
  59. //工厂
  60. Labour_204_Factory: {
  61. default: null,
  62. type: cc.Prefab,
  63. serializable: true,
  64. },
  65. //一级
  66. // 冷饮摊
  67. Shops_30101_ColdDrinkStall: {
  68. default: null,
  69. type: cc.Prefab,
  70. serializable: true,
  71. },
  72. //贩卖机
  73. Shops_30102_SalesMachine: {
  74. default: null,
  75. type: cc.Prefab,
  76. serializable: true,
  77. },
  78. //面包房
  79. Shops_30103_Bakery: {
  80. default: null,
  81. type: cc.Prefab,
  82. serializable: true,
  83. },
  84. //早餐车
  85. Shops_30104_BreakfastCar: {
  86. default: null,
  87. type: cc.Prefab,
  88. serializable: true,
  89. },
  90. //二级
  91. //饮茶店
  92. Shops_30201_TeaShop: {
  93. default: null,
  94. type: cc.Prefab,
  95. serializable: true,
  96. },
  97. //点心店
  98. Shops_30202_confectaurant: {
  99. default: null,
  100. type: cc.Prefab,
  101. serializable: true,
  102. },
  103. //美食店
  104. Shops_30203_GourmetRestaurant: {
  105. default: null,
  106. type: cc.Prefab,
  107. serializable: true,
  108. },
  109. //西餐厅
  110. Shops_30204_WesternRestaurant: {
  111. default: null,
  112. type: cc.Prefab,
  113. serializable: true,
  114. },
  115. //三级
  116. //花店
  117. Shops_30301_Florist: {
  118. default: null,
  119. type: cc.Prefab,
  120. serializable: true,
  121. },
  122. //美发店
  123. Shops_30302_HairSalon: {
  124. default: null,
  125. type: cc.Prefab,
  126. serializable: true,
  127. },
  128. //洋装店
  129. Shops_30303_DressShop: {
  130. default: null,
  131. type: cc.Prefab,
  132. serializable: true,
  133. },
  134. //珠宝店
  135. Shops_30304_JewelryStore: {
  136. default: null,
  137. type: cc.Prefab,
  138. serializable: true,
  139. },
  140. //电影院
  141. Shops_30305_Cinema: {
  142. default: null,
  143. type: cc.Prefab,
  144. serializable: true,
  145. },
  146. //特殊建筑
  147. //路灯
  148. Spe_401_StreetLamp: {
  149. default: null,
  150. type: cc.Prefab,
  151. serializable: true,
  152. },
  153. //绿化带
  154. Spe_402_GreenBelt: {
  155. default: null,
  156. type: cc.Prefab,
  157. serializable: true,
  158. },
  159. //花坛
  160. Spe_403_FlowerBed: {
  161. default: null,
  162. type: cc.Prefab,
  163. serializable: true,
  164. },
  165. //喷泉
  166. Spe_404_Pool: {
  167. default: null,
  168. type: cc.Prefab,
  169. serializable: true,
  170. },
  171. //警察局
  172. Spe_405_PoliceOffice: {
  173. default: null,
  174. type: cc.Prefab,
  175. serializable: true,
  176. },
  177. //游乐场
  178. Spe_406_Playground: {
  179. default: null,
  180. type: cc.Prefab,
  181. serializable: true,
  182. },
  183. BuildingArray: {
  184. default: [],
  185. type: [cc.Node],
  186. serializable: true,
  187. },
  188. },
  189. onBuildHouse(index) {
  190. // cc.log(index);
  191. let mainCamera = GlobalD.game.MainCamera;
  192. let housing = null;
  193. //content button 设置的index
  194. //农舍
  195. if ('101' == index) {
  196. housing = cc.instantiate(this.Env_101_house_low);
  197. }
  198. //单元楼
  199. else if ('102' == index) {
  200. housing = cc.instantiate(this.Env_102_house_mid);
  201. }
  202. //别墅
  203. else if ('103' == index) {
  204. housing = cc.instantiate(this.Env_103_house_high);
  205. }
  206. else if ('104' == index) {
  207. housing = cc.instantiate(this.Env_104_BlueCastle);
  208. }
  209. else if ('105' == index) {
  210. housing = cc.instantiate(this.Env_105_PinkCastle);
  211. }
  212. //农田
  213. else if ('201' == index) {
  214. housing = cc.instantiate(this.Labour_201_Farmland);
  215. }
  216. //伐木场
  217. else if ('202' == index) {
  218. housing = cc.instantiate(this.Labour_202_TimberYard);
  219. }
  220. //矿坑
  221. else if ('203' == index) {
  222. housing = cc.instantiate(this.Labour_203_MiningPit);
  223. }
  224. //工厂
  225. else if ('204' == index) {
  226. housing = cc.instantiate(this.Labour_204_Factory);
  227. }
  228. //冷饮摊
  229. else if ('30101' == index) {
  230. housing = cc.instantiate(this.Shops_30101_ColdDrinkStall);
  231. }
  232. //贩卖机
  233. else if ('30102' == index) {
  234. housing = cc.instantiate(this.Shops_30102_SalesMachine);
  235. }
  236. //面包房
  237. else if ('30103' == index) {
  238. housing = cc.instantiate(this.Shops_30103_Bakery);
  239. }
  240. //早餐车
  241. else if ('30104' == index) {
  242. housing = cc.instantiate(this.Shops_30104_BreakfastCar);
  243. }
  244. //饮茶店
  245. else if ('30201' == index) {
  246. housing = cc.instantiate(this.Shops_30201_TeaShop);
  247. }
  248. //点心店
  249. else if ('30202' == index) {
  250. housing = cc.instantiate(this.Shops_30202_confectaurant);
  251. }
  252. //美食店
  253. else if ('30203' == index) {
  254. housing = cc.instantiate(this.Shops_30203_GourmetRestaurant);
  255. }
  256. //西餐厅
  257. else if ('30204' == index) {
  258. housing = cc.instantiate(this.Shops_30204_WesternRestaurant);
  259. }
  260. //花店
  261. else if ('30301' == index) {
  262. housing = cc.instantiate(this.Shops_30301_Florist);
  263. }
  264. //美发店
  265. else if ('30302' == index) {
  266. housing = cc.instantiate(this.Shops_30302_HairSalon);
  267. }
  268. //洋装店
  269. else if ('30303' == index) {
  270. housing = cc.instantiate(this.Shops_30303_DressShop);
  271. }
  272. //珠宝店
  273. else if ('30304' == index) {
  274. housing = cc.instantiate(this.Shops_30304_JewelryStore);
  275. }
  276. //电影院
  277. else if ('30305' == index) {
  278. housing = cc.instantiate(this.Shops_30305_Cinema);
  279. }
  280. //路灯
  281. else if ('401' == index) {
  282. housing = cc.instantiate(this.Spe_401_StreetLamp);
  283. }
  284. //绿化带
  285. else if ('402' == index) {
  286. housing = cc.instantiate(this.Spe_402_GreenBelt);
  287. }
  288. //花坛
  289. else if ('403' == index) {
  290. housing = cc.instantiate(this.Spe_403_FlowerBed);
  291. }
  292. //喷泉
  293. else if ('404' == index) {
  294. housing = cc.instantiate(this.Spe_404_Pool);
  295. }
  296. //警察局
  297. else if ('405' == index) {
  298. housing = cc.instantiate(this.Spe_405_PoliceOffice);
  299. }
  300. //游乐场
  301. else if ('406' == index) {
  302. housing = cc.instantiate(this.Spe_406_Playground);
  303. }
  304. housing.parent = this.BuildingsParent;
  305. let tempPos = housing.parent.convertToNodeSpace(mainCamera.node);
  306. let CanvasPos = GlobalD.game.Canvas.position;
  307. housing.setPosition(tempPos.x + CanvasPos.x, tempPos.y + CanvasPos.y);
  308. let buildingsInfo = housing.getComponent("buildingsInfo");
  309. //id用时间戳来记录
  310. buildingsInfo.buildInfo.id = new Date().getTime();//+= Math.random() * 1000000;
  311. this.SpawnBuildingDefaultValue(buildingsInfo);
  312. let buildingsTouch = housing.getComponent("buildingsTouch");
  313. // buildingsTouch.buildInfo = buildingsInfo.buildInfo;
  314. buildingsTouch.onEditorStatus(true);
  315. // housing.active = true;
  316. //收起菜单
  317. GlobalD.game._ManageUIScript.onHideMenu();
  318. //收起底部菜单栏
  319. GlobalD.game._ManageUIScript.onBottomMenuView(false);
  320. },
  321. start() {
  322. },
  323. //如果存储到有房子数据的话,把地图上的房屋都隐藏起来,或者删除
  324. //todo...
  325. onHideInitPosBuildings() {
  326. //删除对应层的子节点
  327. let tempNode = this.BuildingsParent.children;
  328. let length = tempNode.length;
  329. for (let i = length - 1; i >= 0; i--) {
  330. tempNode[i].active = false;
  331. }
  332. },
  333. //初始化建筑
  334. InitBuildings() {
  335. //先初始化网络数据
  336. this.SpawnHouse();
  337. // cc.log('初始化场景建筑');
  338. let BuildingStateArray = GlobalD.GameData.GetBuildingStateArray();
  339. for (let i = 0; i < BuildingStateArray.length; i++) {
  340. if (BuildingStateArray[i] == 0) {
  341. this.BuildingArray[i].active = false;
  342. }
  343. else {
  344. this.BuildingArray[i].active = true;
  345. }
  346. }
  347. let BuildingNumArray = GlobalD.GameData.GetBuildingNumArray();
  348. // cc.log('BuildingNumArray',BuildingNumArray)
  349. for (let i = 3; i < this.BuildingArray.length; i++) {
  350. // cc.log('this.BuildingArray[i]='+this.BuildingArray[i].getChildByName('Name').getComponent(cc.Label).string);
  351. this.BuildingArray[i].getChildByName('Name').getChildByName('Num').getComponent(cc.Label).string = BuildingNumArray[i];
  352. }
  353. //初始化两个默认的建筑
  354. //
  355. },
  356. //生成房子的默认值
  357. SpawnBuildingDefaultValue(buildingsInfo) {
  358. buildingsInfo.InitPos = false;
  359. buildingsInfo.InitWorkBuildingInfo = false;
  360. //激活状态,可运营
  361. buildingsInfo.buildInfo.isItActive = true;
  362. //设置销售状态
  363. buildingsInfo.buildInfo.isItSaleable = true;
  364. if (reGameStates.BuildType.Farmland == buildingsInfo.buildInfo.buildType) {
  365. buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetFoodTradeState() > 0 ? true : false;// GlobalD.GameData.GetFoodTradeState();
  366. // cc.log('初始化房子的信息:', buildingsInfo.buildInfo.buildingName, buildingsInfo.buildInfo.isItSaleable);
  367. }
  368. if (reGameStates.BuildType.MiningPit == buildingsInfo.buildInfo.buildType) {
  369. buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetMineralTradeState() > 0 ? true : false;// GlobalD.GameData.GetMineralTradeState();
  370. }
  371. if (reGameStates.BuildType.TimberYard == buildingsInfo.buildInfo.buildType) {
  372. buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetWoodTradeState() > 0 ? true : false;// GlobalD.GameData.GetWoodTradeState();
  373. }
  374. //先设置一下,可查看信息
  375. if (reGameStates.BuildType.Housing !== buildingsInfo.buildInfo.buildType
  376. && reGameStates.BuildType.Special !== buildingsInfo.buildInfo.buildType) {
  377. buildingsInfo.node.getComponent('buildingsTouch').isShowBuildingInfo = true;
  378. }
  379. //设置消耗的体力值为工人的最低值 20
  380. //过高的话,会导致工人不工作
  381. // buildingsInfo.buildInfo.totalConsumption = 20;
  382. // cc.log('初始化房子的信息:', buildingsInfo.buildInfo.buildingName, buildingsInfo.buildInfo.isItSaleable)
  383. },
  384. //初始化场景的两个建筑
  385. SpawnDefaultHouse() {
  386. cc.log('初始化默认房子');
  387. //房子
  388. let housingTemp_house = this.onGetHousingPrefabFromName('Env_101_house_low');
  389. housingTemp_house.parent = this.BuildingsParent;
  390. var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(cc.v2(24, 23));
  391. housingTemp_house.setPosition(endPos.x, endPos.y);
  392. let buildingsInfo_house = housingTemp_house.getComponent("buildingsInfo");
  393. //id用时间戳来记录
  394. buildingsInfo_house.buildInfo.id = 101;//对应的id
  395. //设置tile的最底下的坐标,就是起始坐标
  396. buildingsInfo_house.buildInfo.startTilePos = cc.v2(24, 23);
  397. this.SpawnBuildingDefaultValue(buildingsInfo_house);
  398. //起始坐标,占位范围,是否占位
  399. GlobalD.game.addBuildTiled(buildingsInfo_house.buildInfo.id, buildingsInfo_house.buildInfo.startTilePos, buildingsInfo_house.buildInfo.occupyArea);
  400. //添加占位信息
  401. GlobalD.game.addBuilding(buildingsInfo_house);
  402. //农田
  403. let housingTemp_farmland = this.onGetHousingPrefabFromName('Labour_201_Farmland');
  404. housingTemp_farmland.parent = this.BuildingsParent;
  405. var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(cc.v2(26, 24));
  406. housingTemp_farmland.setPosition(endPos.x, endPos.y);
  407. let buildingsInfo_farmland = housingTemp_farmland.getComponent("buildingsInfo");
  408. //id用时间戳来记录
  409. buildingsInfo_farmland.buildInfo.id = 201;//对应的id
  410. //设置tile的最底下的坐标,就是起始坐标
  411. buildingsInfo_farmland.buildInfo.startTilePos = cc.v2(26, 24);
  412. this.SpawnBuildingDefaultValue(buildingsInfo_farmland);
  413. //起始坐标,占位范围,是否占位
  414. GlobalD.game.addBuildTiled(buildingsInfo_farmland.buildInfo.id, buildingsInfo_farmland.buildInfo.startTilePos, buildingsInfo_farmland.buildInfo.occupyArea);
  415. //添加占位信息
  416. GlobalD.game.addBuilding(buildingsInfo_farmland);
  417. },
  418. //初始化场景建筑
  419. SpawnHouse: function () {
  420. let BuildingJSON = GlobalD.GameData.GameData_buildings;
  421. cc.log('BuildingJSON', BuildingJSON);
  422. // if (BuildingJSON.length == 0) {
  423. // //初始化默认房子
  424. // this.SpawnDefaultHouse();
  425. // return
  426. // };
  427. //如果有存储的数据,隐藏场景房屋节点
  428. this.onHideInitPosBuildings();
  429. for (let i = 0; i < BuildingJSON.length; i++) {
  430. // cc.log(i);
  431. // if (BuildingJSON[i].isDefault) continue;
  432. let HouseName = BuildingJSON[i].buildingNodeName;
  433. let housingTemp = this.onGetHousingPrefabFromName(HouseName);
  434. if (!housingTemp)
  435. cc.error('housingTemp', HouseName, housingTemp);
  436. //预制为空
  437. if (!housingTemp) return;
  438. housingTemp.parent = this.BuildingsParent;
  439. // var str= JSON.stringify(BuildingJSON);
  440. var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(BuildingJSON[i].startTilePos);
  441. // let HousePosition = BuildingJSON[i].Position;
  442. // cc.log('x=' + HousePosition.x + 'y=' + HousePosition.y);
  443. housingTemp.setPosition(endPos.x, endPos.y);
  444. let buildingsInfo = housingTemp.getComponent("buildingsInfo");
  445. //id用时间戳来记录
  446. buildingsInfo.buildInfo.id = BuildingJSON[i].buildingId;//对应的id
  447. //设置tile的最底下的坐标,就是起始坐标
  448. buildingsInfo.buildInfo.startTilePos = BuildingJSON[i].startTilePos;
  449. //初始化位置的坐标
  450. buildingsInfo.InitStartPos = BuildingJSON[i].startTilePos;
  451. this.SpawnBuildingDefaultValue(buildingsInfo);
  452. //目前应该只有商店,后面根据RunningCost来判断 todo.....
  453. // if (reGameStates.BuildType.Shop == buildingsInfo.buildInfo.buildType)
  454. {
  455. // buildingsInfo.buildInfo.isItSaleable = Number(BuildingJSON[i].isItSaleable) > 0 ? true : false;
  456. buildingsInfo.buildInfo.isItStopOperation = Number(BuildingJSON[i].isItStopOperation) > 0 ? true : false;
  457. //如果不可以运营的,加上牌子
  458. if (buildingsInfo.buildInfo.isItStopOperation) {
  459. GlobalD.game.onAddBuildingTipView(buildingsInfo);
  460. }
  461. }
  462. //建筑物的加成值
  463. buildingsInfo.buildInfo.consumeStrengthAddValue = Number(BuildingJSON[i].consumeStrengthAddValue);
  464. buildingsInfo.buildInfo.goodsPriceAddValue = Number(BuildingJSON[i].goodsPriceAddValue);
  465. // cc.log('buildingsInfo', buildingsInfo);
  466. //起始坐标,占位范围,是否占位
  467. GlobalD.game.addBuildTiled(buildingsInfo.buildInfo.id, buildingsInfo.buildInfo.startTilePos, buildingsInfo.buildInfo.occupyArea);
  468. //添加占位信息
  469. GlobalD.game.addBuilding(buildingsInfo);
  470. }
  471. },
  472. onGetHousingPrefabFromName(HouseName) {
  473. let housing = null;
  474. //住宿地方
  475. if (HouseName == 'Env_101_house_low') {
  476. housing = cc.instantiate(this.Env_101_house_low);
  477. }
  478. else if (HouseName === 'Env_102_house_mid') {
  479. housing = cc.instantiate(this.Env_102_house_mid);
  480. }
  481. else if (HouseName == 'Env_103_house_high') {
  482. housing = cc.instantiate(this.Env_103_house_high);
  483. }
  484. else if (HouseName == 'Env_104_BlueCastle') {
  485. housing = cc.instantiate(this.Env_104_BlueCastle);
  486. }
  487. else if (HouseName == 'Env_105_PinkCastle') {
  488. housing = cc.instantiate(this.Env_105_PinkCastle);
  489. }
  490. //劳动地方
  491. else if (HouseName == 'Labour_201_Farmland') {
  492. housing = cc.instantiate(this.Labour_201_Farmland);
  493. }
  494. else if (HouseName == 'Labour_202_TimberYard') {
  495. housing = cc.instantiate(this.Labour_202_TimberYard);
  496. }
  497. else if (HouseName == 'Labour_203_MiningPit') {
  498. housing = cc.instantiate(this.Labour_203_MiningPit);
  499. }
  500. else if (HouseName == 'Labour_204_Factory') {
  501. housing = cc.instantiate(this.Labour_204_Factory);
  502. }
  503. //特殊建筑
  504. else if (HouseName == 'Spe_401_StreetLamp') {
  505. housing = cc.instantiate(this.Spe_401_StreetLamp);
  506. }
  507. else if (HouseName == 'Spe_402_GreenBelt') {
  508. housing = cc.instantiate(this.Spe_402_GreenBelt);
  509. }
  510. else if (HouseName == 'Spe_403_FlowerBed') {
  511. housing = cc.instantiate(this.Spe_403_FlowerBed);
  512. }
  513. else if (HouseName == 'Spe_404_Pool') {
  514. housing = cc.instantiate(this.Spe_404_Pool);
  515. }
  516. else if (HouseName == 'Spe_405_PoliceOffice') {
  517. housing = cc.instantiate(this.Spe_405_PoliceOffice);
  518. }
  519. else if (HouseName == 'Spe_406_Playground') {
  520. housing = cc.instantiate(this.Spe_406_Playground);
  521. }
  522. //商店类型
  523. else if (HouseName == 'Shops_30101_ColdDrinkStall') {
  524. housing = cc.instantiate(this.Shops_30101_ColdDrinkStall);
  525. }
  526. else if (HouseName == 'Shops_30102_SalesMachine') {
  527. housing = cc.instantiate(this.Shops_30102_SalesMachine);
  528. }
  529. else if (HouseName == 'Shops_30103_Bakery') {
  530. housing = cc.instantiate(this.Shops_30103_Bakery);
  531. }
  532. else if (HouseName == 'Shops_30104_BreakfastCar') {
  533. housing = cc.instantiate(this.Shops_30104_BreakfastCar);
  534. }
  535. else if (HouseName == 'Shops_30201_TeaShop') {
  536. housing = cc.instantiate(this.Shops_30201_TeaShop);
  537. }
  538. else if (HouseName == 'Shops_30202_confectaurant') {
  539. housing = cc.instantiate(this.Shops_30202_confectaurant);
  540. }
  541. else if (HouseName == 'Shops_30203_GourmetRestaurant') {
  542. housing = cc.instantiate(this.Shops_30203_GourmetRestaurant);
  543. }
  544. else if (HouseName == 'Shops_30204_WesternRestaurant') {
  545. housing = cc.instantiate(this.Shops_30204_WesternRestaurant);
  546. }
  547. else if (HouseName == 'Shops_30301_Florist') {
  548. housing = cc.instantiate(this.Shops_30301_Florist);
  549. }
  550. else if (HouseName == 'Shops_30302_HairSalon') {
  551. housing = cc.instantiate(this.Shops_30302_HairSalon);
  552. }
  553. else if (HouseName == 'Shops_30303_DressShop') {
  554. housing = cc.instantiate(this.Shops_30303_DressShop);
  555. }
  556. else if (HouseName == 'Shops_30304_JewelryStore') {
  557. housing = cc.instantiate(this.Shops_30304_JewelryStore);
  558. }
  559. else if (HouseName == 'Shops_30305_Cinema') {
  560. housing = cc.instantiate(this.Shops_30305_Cinema);
  561. }
  562. return housing;
  563. },
  564. //获取预制的名字
  565. onGetPrefabsBuildingName(index) {
  566. //content button 设置的index
  567. let buildingName = '';
  568. //农舍
  569. if ('101' == index) {
  570. buildingName = 'Env_101_house_low';
  571. }
  572. //单元楼
  573. else if ('102' == index) {
  574. buildingName = 'Env_102_house_mid';
  575. }
  576. //别墅
  577. else if ('103' == index) {
  578. buildingName = 'Env_103_house_high';
  579. }
  580. //蓝色城堡
  581. else if ('104' == index) {
  582. buildingName = 'Env_104_BlueCastle';
  583. }
  584. //粉色城堡
  585. else if ('105' == index) {
  586. buildingName = 'Env_105_PinkCastle';
  587. }
  588. //农田
  589. else if ('201' == index) {
  590. buildingName = 'Labour_201_Farmland';
  591. }
  592. //伐木场
  593. else if ('202' == index) {
  594. buildingName = 'Labour_202_TimberYard';
  595. }
  596. //矿坑
  597. else if ('203' == index) {
  598. buildingName = 'Labour_203_MiningPit';
  599. }
  600. //工厂
  601. else if ('204' == index) {
  602. buildingName = 'Labour_204_Factory';
  603. }
  604. //冷饮摊
  605. else if ('30101' == index) {
  606. buildingName = 'Shops_30101_ColdDrinkStall';
  607. }
  608. //贩卖机
  609. else if ('30102' == index) {
  610. buildingName = 'Shops_30102_SalesMachine';
  611. }
  612. //面包房
  613. else if ('30103' == index) {
  614. buildingName = 'Shops_30103_Bakery';
  615. }
  616. //早餐车
  617. else if ('30104' == index) {
  618. buildingName = 'Shops_30104_BreakfastCar';
  619. }
  620. //饮茶店
  621. else if ('30201' == index) {
  622. buildingName = 'Shops_30201_TeaShop';
  623. }
  624. //点心店
  625. else if ('30202' == index) {
  626. buildingName = 'Shops_30202_confectaurant';
  627. }
  628. //美食店
  629. else if ('30203' == index) {
  630. buildingName = 'Shops_30203_GourmetRestaurant';
  631. }
  632. //西餐厅
  633. else if ('30204' == index) {
  634. buildingName = 'Shops_30204_WesternRestaurant';
  635. }
  636. //花店
  637. else if ('30301' == index) {
  638. buildingName = 'Shops_30301_Florist';
  639. }
  640. //美发店
  641. else if ('30302' == index) {
  642. buildingName = 'Shops_30302_HairSalon';
  643. }
  644. //洋装店
  645. else if ('30303' == index) {
  646. buildingName = 'Shops_30303_DressShop';
  647. }
  648. //珠宝店
  649. else if ('30304' == index) {
  650. buildingName = 'Shops_30304_JewelryStore';
  651. }
  652. //电影院
  653. else if ('30305' == index) {
  654. buildingName = 'Shops_30305_Cinema';
  655. }
  656. //路灯
  657. else if ('401' == index) {
  658. buildingName = 'Spe_401_StreetLamp';
  659. }
  660. //绿化带
  661. else if ('402' == index) {
  662. buildingName = 'Spe_402_GreenBelt';
  663. }
  664. //花坛
  665. else if ('403' == index) {
  666. buildingName = 'Spe_403_FlowerBed';
  667. }
  668. //喷泉
  669. else if ('404' == index) {
  670. buildingName = 'Spe_404_Pool';
  671. }
  672. //警察局
  673. else if ('405' == index) {
  674. buildingName = 'Spe_405_PoliceOffice';
  675. }
  676. //游乐场
  677. else if ('406' == index) {
  678. buildingName = 'Spe_406_Playground';
  679. }
  680. return buildingName;
  681. },
  682. });