ManageBuildings.js 25 KB

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