ManageBuildings.js 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  1. var reGameStates = require('GameStates');
  2. import date from "../Unit/date.js"
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. //MyMapNode
  7. //建筑物的节点
  8. BuildingsParent: {
  9. default: null,
  10. type: cc.Node,
  11. },
  12. //农舍
  13. Env_101_house_low: {
  14. default: null,
  15. type: cc.Prefab,
  16. serializable: true,
  17. },
  18. //单元楼
  19. Env_102_house_mid: {
  20. default: null,
  21. type: cc.Prefab,
  22. serializable: true,
  23. },
  24. //别墅
  25. Env_103_house_high: {
  26. default: null,
  27. type: cc.Prefab,
  28. serializable: true,
  29. },
  30. //蓝色城堡
  31. Env_104_BlueCastle: {
  32. default: null,
  33. type: cc.Prefab,
  34. serializable: true,
  35. },
  36. //粉色城堡
  37. Env_105_PinkCastle: {
  38. default: null,
  39. type: cc.Prefab,
  40. serializable: true,
  41. },
  42. //农田
  43. Labour_201_Farmland: {
  44. default: null,
  45. type: cc.Prefab,
  46. serializable: true,
  47. },
  48. //伐木场
  49. Labour_202_TimberYard: {
  50. default: null,
  51. type: cc.Prefab,
  52. serializable: true,
  53. },
  54. //矿坑
  55. Labour_203_MiningPit: {
  56. default: null,
  57. type: cc.Prefab,
  58. serializable: true,
  59. },
  60. //工厂
  61. Labour_204_Factory: {
  62. default: null,
  63. type: cc.Prefab,
  64. serializable: true,
  65. },
  66. //神农专用农田
  67. Labour_205_Holy_Farmland: {
  68. default: null,
  69. type: cc.Prefab,
  70. serializable: true,
  71. },
  72. Labour_206_Holy_Animal: {
  73. default: null,
  74. type: cc.Prefab,
  75. serializable: true,
  76. },
  77. //一级
  78. // 冷饮摊
  79. Shops_30101_ColdDrinkStall: {
  80. default: null,
  81. type: cc.Prefab,
  82. serializable: true,
  83. },
  84. //贩卖机
  85. Shops_30102_SalesMachine: {
  86. default: null,
  87. type: cc.Prefab,
  88. serializable: true,
  89. },
  90. //面包房
  91. Shops_30103_Bakery: {
  92. default: null,
  93. type: cc.Prefab,
  94. serializable: true,
  95. },
  96. //早餐车
  97. Shops_30104_BreakfastCar: {
  98. default: null,
  99. type: cc.Prefab,
  100. serializable: true,
  101. },
  102. //二级
  103. //饮茶店
  104. Shops_30201_TeaShop: {
  105. default: null,
  106. type: cc.Prefab,
  107. serializable: true,
  108. },
  109. //点心店
  110. Shops_30202_confectaurant: {
  111. default: null,
  112. type: cc.Prefab,
  113. serializable: true,
  114. },
  115. //美食店
  116. Shops_30203_GourmetRestaurant: {
  117. default: null,
  118. type: cc.Prefab,
  119. serializable: true,
  120. },
  121. //西餐厅
  122. Shops_30204_WesternRestaurant: {
  123. default: null,
  124. type: cc.Prefab,
  125. serializable: true,
  126. },
  127. //三级
  128. //花店
  129. Shops_30301_Florist: {
  130. default: null,
  131. type: cc.Prefab,
  132. serializable: true,
  133. },
  134. //美发店
  135. Shops_30302_HairSalon: {
  136. default: null,
  137. type: cc.Prefab,
  138. serializable: true,
  139. },
  140. //洋装店
  141. Shops_30303_DressShop: {
  142. default: null,
  143. type: cc.Prefab,
  144. serializable: true,
  145. },
  146. //珠宝店
  147. Shops_30304_JewelryStore: {
  148. default: null,
  149. type: cc.Prefab,
  150. serializable: true,
  151. },
  152. //电影院
  153. Shops_30305_Cinema: {
  154. default: null,
  155. type: cc.Prefab,
  156. serializable: true,
  157. },
  158. //特殊建筑
  159. //路灯
  160. Spe_401_StreetLamp: {
  161. default: null,
  162. type: cc.Prefab,
  163. serializable: true,
  164. },
  165. //绿化带
  166. Spe_402_GreenBelt: {
  167. default: null,
  168. type: cc.Prefab,
  169. serializable: true,
  170. },
  171. //花坛
  172. Spe_403_FlowerBed: {
  173. default: null,
  174. type: cc.Prefab,
  175. serializable: true,
  176. },
  177. //喷泉
  178. Spe_404_Pool: {
  179. default: null,
  180. type: cc.Prefab,
  181. serializable: true,
  182. },
  183. //警察局
  184. Spe_405_PoliceOffice: {
  185. default: null,
  186. type: cc.Prefab,
  187. serializable: true,
  188. },
  189. //游乐场
  190. Spe_406_Playground: {
  191. default: null,
  192. type: cc.Prefab,
  193. serializable: true,
  194. },
  195. BuildingArray: {
  196. default: [],
  197. type: [cc.Node],
  198. serializable: true,
  199. },
  200. /**
  201. * 定义一个场景预制对象
  202. */
  203. DressUpArray: {
  204. default: [],
  205. type: [cc.Prefab]
  206. }
  207. },
  208. onBuildHouse(index) {
  209. // cc.log(index);
  210. let mainCamera = GlobalD.game.MainCamera;
  211. let housing = null;
  212. //content button 设置的index
  213. //农舍
  214. if ('101' == index) {
  215. housing = cc.instantiate(this.Env_101_house_low);
  216. }
  217. //单元楼
  218. else if ('102' == index) {
  219. housing = cc.instantiate(this.Env_102_house_mid);
  220. }
  221. //别墅
  222. else if ('103' == index) {
  223. housing = cc.instantiate(this.Env_103_house_high);
  224. }
  225. else if ('104' == index) {
  226. housing = cc.instantiate(this.Env_104_BlueCastle);
  227. }
  228. else if ('105' == index) {
  229. housing = cc.instantiate(this.Env_105_PinkCastle);
  230. }
  231. //农田
  232. else if ('201' == index) {
  233. housing = cc.instantiate(this.Labour_201_Farmland);
  234. }
  235. //伐木场
  236. else if ('202' == index) {
  237. housing = cc.instantiate(this.Labour_202_TimberYard);
  238. }
  239. //矿坑
  240. else if ('203' == index) {
  241. housing = cc.instantiate(this.Labour_203_MiningPit);
  242. }
  243. //工厂
  244. else if ('204' == index) {
  245. housing = cc.instantiate(this.Labour_204_Factory);
  246. }
  247. //神农专用农田
  248. else if ('205' == index) {
  249. housing = cc.instantiate(this.Labour_205_Holy_Farmland);
  250. }
  251. else if ('206' == index) {
  252. housing = cc.instantiate(this.Labour_206_Holy_Animal);
  253. }
  254. //冷饮摊
  255. else if ('30101' == index) {
  256. housing = cc.instantiate(this.Shops_30101_ColdDrinkStall);
  257. }
  258. //贩卖机
  259. else if ('30102' == index) {
  260. housing = cc.instantiate(this.Shops_30102_SalesMachine);
  261. }
  262. //面包房
  263. else if ('30103' == index) {
  264. housing = cc.instantiate(this.Shops_30103_Bakery);
  265. }
  266. //早餐车
  267. else if ('30104' == index) {
  268. housing = cc.instantiate(this.Shops_30104_BreakfastCar);
  269. }
  270. //饮茶店
  271. else if ('30201' == index) {
  272. housing = cc.instantiate(this.Shops_30201_TeaShop);
  273. }
  274. //点心店
  275. else if ('30202' == index) {
  276. housing = cc.instantiate(this.Shops_30202_confectaurant);
  277. }
  278. //美食店
  279. else if ('30203' == index) {
  280. housing = cc.instantiate(this.Shops_30203_GourmetRestaurant);
  281. }
  282. //西餐厅
  283. else if ('30204' == index) {
  284. housing = cc.instantiate(this.Shops_30204_WesternRestaurant);
  285. }
  286. //花店
  287. else if ('30301' == index) {
  288. housing = cc.instantiate(this.Shops_30301_Florist);
  289. }
  290. //美发店
  291. else if ('30302' == index) {
  292. housing = cc.instantiate(this.Shops_30302_HairSalon);
  293. }
  294. //洋装店
  295. else if ('30303' == index) {
  296. housing = cc.instantiate(this.Shops_30303_DressShop);
  297. }
  298. //珠宝店
  299. else if ('30304' == index) {
  300. housing = cc.instantiate(this.Shops_30304_JewelryStore);
  301. }
  302. //电影院
  303. else if ('30305' == index) {
  304. housing = cc.instantiate(this.Shops_30305_Cinema);
  305. }
  306. //路灯
  307. else if ('401' == index) {
  308. housing = cc.instantiate(this.Spe_401_StreetLamp);
  309. }
  310. //绿化带
  311. else if ('402' == index) {
  312. housing = cc.instantiate(this.Spe_402_GreenBelt);
  313. }
  314. //花坛
  315. else if ('403' == index) {
  316. housing = cc.instantiate(this.Spe_403_FlowerBed);
  317. }
  318. //喷泉
  319. else if ('404' == index) {
  320. housing = cc.instantiate(this.Spe_404_Pool);
  321. }
  322. //警察局
  323. else if ('405' == index) {
  324. housing = cc.instantiate(this.Spe_405_PoliceOffice);
  325. }
  326. //游乐场
  327. else if ('406' == index) {
  328. housing = cc.instantiate(this.Spe_406_Playground);
  329. }
  330. housing.parent = this.BuildingsParent;
  331. let tempPos = housing.parent.convertToNodeSpace(mainCamera.node);
  332. let CanvasPos = GlobalD.game.Canvas.position;
  333. housing.setPosition(tempPos.x + CanvasPos.x, tempPos.y + CanvasPos.y);
  334. let buildingsInfo = housing.getComponent("buildingsInfo");
  335. //id用时间戳来记录
  336. buildingsInfo.buildInfo.id = new Date().getTime();//+= Math.random() * 1000000;
  337. this.SpawnBuildingDefaultValue(buildingsInfo);
  338. let buildingsTouch = housing.getComponent("buildingsTouch");
  339. // buildingsTouch.buildInfo = buildingsInfo.buildInfo;
  340. buildingsTouch.onEditorStatus(true);
  341. // housing.active = true;
  342. //收起菜单
  343. GlobalD.game._ManageUIScript.onHideMenu();
  344. //收起底部菜单栏
  345. GlobalD.game._ManageUIScript.onBottomMenuView(false);
  346. },
  347. start() {
  348. },
  349. //如果存储到有房子数据的话,把地图上的房屋都隐藏起来,或者删除
  350. //todo...
  351. onHideInitPosBuildings() {
  352. //删除对应层的子节点
  353. let tempNode = this.BuildingsParent.children;
  354. let length = tempNode.length;
  355. for (let i = length - 1; i >= 0; i--) {
  356. tempNode[i].active = false;
  357. }
  358. },
  359. /**
  360. * GameData里面处理的生成数据流程,生成建筑物
  361. */
  362. InitBuildings() {
  363. //如果有存储的数据,隐藏场景房屋节点
  364. // this.onHideInitPosBuildings();
  365. /**
  366. * 注释 spawnConfigLand 不初始化固定土地
  367. */
  368. //第一步初始化土地的网络数据
  369. this.spawnConfigLand(GlobalD.UserLeaseLand, true);
  370. /**
  371. * todo 之类初始化场景障碍物操作,如果不需要直接注释即可。
  372. * 村长和镇长
  373. * 初始化障碍物场景,装饰
  374. */
  375. // if(0 != GlobalD.Dapp.UserInfo.agent_level){
  376. // this.spawnDressUp();
  377. // }
  378. //先初始化网络数据
  379. // remove version: todo 去除旧的生成建筑逻辑
  380. // this.SpawnHouse();
  381. // cc.log('初始化场景建筑');
  382. let BuildingStateArray = GlobalD.GameData.GetBuildingStateArray();
  383. for (let i = 0; i < BuildingStateArray.length; i++) {
  384. if (BuildingStateArray[i] == 0) {
  385. if (this.BuildingArray[i])
  386. this.BuildingArray[i].active = false;
  387. }
  388. else {
  389. if (this.BuildingArray[i])
  390. this.BuildingArray[i].active = true;
  391. }
  392. }
  393. let BuildingNumArray = GlobalD.GameData.GetBuildingNumArray();
  394. // cc.log('BuildingNumArray',BuildingNumArray)
  395. for (let i = 3; i < this.BuildingArray.length; i++) {
  396. // cc.log('this.BuildingArray[' + i + ']=' + this.BuildingArray[i].getChildByName('Name').getComponent(cc.Label).string);
  397. if (this.BuildingArray[i])
  398. this.BuildingArray[i].getChildByName('Name').getChildByName('Num').getComponent(cc.Label).string = BuildingNumArray[i];
  399. }
  400. },
  401. //生成房子的默认值
  402. SpawnBuildingDefaultValue(buildingsInfo) {
  403. buildingsInfo.InitPos = false;
  404. buildingsInfo.InitWorkBuildingInfo = false;
  405. //激活状态,可运营
  406. buildingsInfo.buildInfo.isItActive = true;
  407. //设置销售状态
  408. buildingsInfo.buildInfo.isItSaleable = true;
  409. if (reGameStates.BuildType.Farmland == buildingsInfo.buildInfo.buildType) {
  410. buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetFoodTradeState() > 0 ? true : false;// GlobalD.GameData.GetFoodTradeState();
  411. // cc.log('初始化房子的信息:', buildingsInfo.buildInfo.buildingName, buildingsInfo.buildInfo.isItSaleable);
  412. }
  413. if (reGameStates.BuildType.MiningPit == buildingsInfo.buildInfo.buildType) {
  414. buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetMineralTradeState() > 0 ? true : false;// GlobalD.GameData.GetMineralTradeState();
  415. }
  416. if (reGameStates.BuildType.TimberYard == buildingsInfo.buildInfo.buildType) {
  417. buildingsInfo.buildInfo.isItSaleable = GlobalD.GameData.GetWoodTradeState() > 0 ? true : false;// GlobalD.GameData.GetWoodTradeState();
  418. }
  419. //设置一下,可查看信息
  420. if (reGameStates.BuildType.Housing !== buildingsInfo.buildInfo.buildType
  421. && reGameStates.BuildType.Special !== buildingsInfo.buildInfo.buildType
  422. /** 神农小镇固定土地关闭 基本的房屋信息,另外设置其他信息 */
  423. && reGameStates.BuildType.HolyFarmland !== buildingsInfo.buildInfo.buildType
  424. ) {
  425. buildingsInfo.node.getComponent('buildingsTouch').isShowBuildingInfo = true;
  426. }
  427. //设置消耗的体力值为工人的最低值 20
  428. //过高的话,会导致工人不工作
  429. // buildingsInfo.buildInfo.totalConsumption = 20;
  430. // cc.log('初始化房子的信息:', buildingsInfo.buildInfo.buildingName, buildingsInfo.buildInfo.isItSaleable)
  431. },
  432. //初始化场景的两个建筑
  433. SpawnDefaultHouse() {
  434. cc.log('初始化默认房子');
  435. //房子
  436. let housingTemp_house = this.onGetHousingPrefabFromName('Env_101_house_low');
  437. housingTemp_house.parent = this.BuildingsParent;
  438. var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(cc.v2(24, 23));
  439. housingTemp_house.setPosition(endPos.x, endPos.y);
  440. let buildingsInfo_house = housingTemp_house.getComponent("buildingsInfo");
  441. //id用时间戳来记录
  442. buildingsInfo_house.buildInfo.id = 101;//对应的id
  443. //设置tile的最底下的坐标,就是起始坐标
  444. buildingsInfo_house.buildInfo.startTilePos = cc.v2(24, 23);
  445. this.SpawnBuildingDefaultValue(buildingsInfo_house);
  446. //起始坐标,占位范围,是否占位
  447. GlobalD.game.addBuildTiled(buildingsInfo_house.buildInfo.id, buildingsInfo_house.buildInfo.startTilePos, buildingsInfo_house.buildInfo.occupyArea);
  448. //添加占位信息
  449. GlobalD.game.addBuilding(buildingsInfo_house);
  450. //农田
  451. let housingTemp_farmland = this.onGetHousingPrefabFromName('Labour_201_Farmland');
  452. housingTemp_farmland.parent = this.BuildingsParent;
  453. var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(cc.v2(26, 24));
  454. housingTemp_farmland.setPosition(endPos.x, endPos.y);
  455. let buildingsInfo_farmland = housingTemp_farmland.getComponent("buildingsInfo");
  456. //id用时间戳来记录
  457. buildingsInfo_farmland.buildInfo.id = 201;//对应的id
  458. //设置tile的最底下的坐标,就是起始坐标
  459. buildingsInfo_farmland.buildInfo.startTilePos = cc.v2(26, 24);
  460. this.SpawnBuildingDefaultValue(buildingsInfo_farmland);
  461. //起始坐标,占位范围,是否占位
  462. GlobalD.game.addBuildTiled(buildingsInfo_farmland.buildInfo.id, buildingsInfo_farmland.buildInfo.startTilePos, buildingsInfo_farmland.buildInfo.occupyArea);
  463. //添加占位信息
  464. GlobalD.game.addBuilding(buildingsInfo_farmland);
  465. },
  466. /**
  467. * 按钮调用
  468. * 回到用户自己的农场
  469. */
  470. onBackSelfFarmland() {
  471. //刷新一下自己的用户信息
  472. GlobalD.GameData.getSelfUserLandList(() => {
  473. this.spawnConfigLand(GlobalD.UserLeaseLand, true);
  474. //显示底部菜单栏
  475. GlobalD.game._ManageUIScript.onBottomMenuView(true);
  476. //收起其他用户场景后菜单操作
  477. GlobalD.game._ManageUIScript.onOtherFarmerView(false);
  478. })
  479. //更新自己的狗
  480. let _dogContainerScript = cc.find("Canvas/DogContainer").getComponent("DogContainer")
  481. _dogContainerScript.onGetSelfList();
  482. GlobalD.GameData.onSwitchAddressBg(GlobalD.Dapp.UserInfo.agent_level);
  483. },
  484. /**
  485. * 初始化后台配置的土地数据
  486. * 切换时候需要重置其他用户数据
  487. * @returns
  488. */
  489. spawnConfigLand(_userLeaseLand, bSelf) {
  490. if (GlobalD.ConfigLand == null) {
  491. console.error("GlobalD.ConfigLand 未初始化设置!");
  492. return;
  493. }
  494. if (_userLeaseLand == null) {
  495. console.error("_userLeaseLand 未初始化设置!");
  496. return;
  497. }
  498. let _configLand = GlobalD.ConfigLand;
  499. if (bSelf) {
  500. let _bInitFarmland = false;
  501. let _landBuildingsInfo = this.BuildingsParent.children;
  502. for (let i = _landBuildingsInfo.length - 1; i >= 0; i--) {
  503. let resetLandInfo = _landBuildingsInfo[i];
  504. if (resetLandInfo.name == "Labour_205_Holy_Farmland") {
  505. let leaseFarmlandInfoScript = resetLandInfo.getComponent("LeaseFarmlandInfo");
  506. //如果存在开锁的土地,重置状态
  507. if (!leaseFarmlandInfoScript.onGetUnlockLandState()) {
  508. leaseFarmlandInfoScript.onLockLand();
  509. }
  510. for (let j = 0; j < _userLeaseLand.length; j++) {
  511. //记录已经租赁的信息(租赁里面包含了seedInfo,如果有种植的话,对应的种植信息会有)
  512. if (_userLeaseLand[j].configLandId == leaseFarmlandInfoScript.initConfigLandId) {
  513. // console.log(leaseFarmlandInfoScript.initConfigLandId);
  514. let _leaseLandInfo = _userLeaseLand[j];
  515. leaseFarmlandInfoScript.setLeaseLandInfo(_leaseLandInfo, bSelf);
  516. }
  517. }
  518. _bInitFarmland = true;
  519. }
  520. }
  521. if (_bInitFarmland) {
  522. console.log("已经初始化过土地数据!");
  523. return;
  524. }
  525. //获取tiled的配置点
  526. let _tiledPosArray = GlobalD.TiledMap.onGetLandList();
  527. let _tiledPosArrayAni = GlobalD.TiledMap.onGetBreedList();
  528. console.log("_userLeaseLand", _userLeaseLand);
  529. console.log("_tiledPosArray:", _tiledPosArray);
  530. console.log("_tiledPosArrayAni",_tiledPosArrayAni);
  531. console.log("_configLand:", _configLand);
  532. if (_tiledPosArray.length != _configLand.length) {
  533. console.error("服务器土地id配置对应地图配置错误!")
  534. return;
  535. }
  536. //此时是第一次生成
  537. for (let i = 0; i < _configLand.length; i++) {
  538. let _index = _configLand[i].id - 1;
  539. let _spawnPos = _tiledPosArray[_index];
  540. //生成默认土地
  541. //农田
  542. let housingTemp_farmland = this.onGetHousingPrefabFromName('Labour_205_Holy_Farmland');
  543. housingTemp_farmland.parent = this.BuildingsParent;
  544. //cc.v2(_configLand[i].posX, _configLand[i].posY)
  545. var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(_spawnPos);
  546. housingTemp_farmland.setPosition(endPos.x, endPos.y);
  547. let leaseFarmlandInfoScript = housingTemp_farmland.getComponent("LeaseFarmlandInfo");
  548. //记录一下第一次初始化时候的id
  549. leaseFarmlandInfoScript.initConfigLandId = _configLand[i].id;
  550. // console.log(housingTemp_farmland.name +" = "+ leaseFarmlandInfoScript.initConfigLandId);
  551. //记录config的土地信息
  552. leaseFarmlandInfoScript.setConfigLandInfo(_configLand[i]);
  553. for (let j = 0; j < _userLeaseLand.length; j++) {
  554. //记录已经租赁的信息(租赁里面包含了seedInfo,如果有种植的话,对应的种植信息会有)
  555. if (_userLeaseLand[j].configLandId == _configLand[i].id) {
  556. let _leaseLandInfo = _userLeaseLand[j];
  557. leaseFarmlandInfoScript.setLeaseLandInfo(_leaseLandInfo, bSelf);
  558. }
  559. }
  560. let buildingsInfo_farmland = housingTemp_farmland.getComponent("buildingsInfo");
  561. //id用时间戳来记录
  562. buildingsInfo_farmland.buildInfo.id = _configLand[i].id;//对应的id
  563. /**
  564. * 服务器设置的农田 独立于其他游戏数据
  565. * 这步设置之后,addBuilding 时候不存储到 GameData_buildings
  566. */
  567. buildingsInfo_farmland.InitPosFromStore = true;
  568. //设置tile的最底下的坐标,就是起始坐标
  569. buildingsInfo_farmland.buildInfo.startTilePos = _spawnPos;
  570. this.SpawnBuildingDefaultValue(buildingsInfo_farmland);
  571. //起始坐标,占位范围,是否占位
  572. GlobalD.game.addBuildTiled(buildingsInfo_farmland.buildInfo.id, buildingsInfo_farmland.buildInfo.startTilePos, buildingsInfo_farmland.buildInfo.occupyArea);
  573. //添加占位信息
  574. GlobalD.game.addBuilding(buildingsInfo_farmland);
  575. }
  576. // console.log(this.BuildingsParent.children);
  577. } else {
  578. //访问其他用户时候,已经有土地了
  579. //重置土地信息
  580. let _landBuildingsInfo = this.BuildingsParent.children;
  581. for (let i = _landBuildingsInfo.length - 1; i >= 0; i--) {
  582. let resetLandInfo = _landBuildingsInfo[i];
  583. if (resetLandInfo.name == "Labour_205_Holy_Farmland") {
  584. let leaseFarmlandInfoScript = resetLandInfo.getComponent("LeaseFarmlandInfo");
  585. //如果存在开锁的土地,重置状态
  586. if (!leaseFarmlandInfoScript.onGetUnlockLandState()) {
  587. leaseFarmlandInfoScript.onLockLand();
  588. }
  589. //访问其他农场时候,全部不显示待租按钮
  590. leaseFarmlandInfoScript.onUnlockLand();
  591. for (let j = 0; j < _userLeaseLand.length; j++) {
  592. //记录已经租赁的信息(租赁里面包含了seedInfo,如果有种植的话,对应的种植信息会有)
  593. if (_userLeaseLand[j].configLandId == leaseFarmlandInfoScript.initConfigLandId) {
  594. let _leaseLandInfo = _userLeaseLand[j];
  595. leaseFarmlandInfoScript.setLeaseLandInfo(_leaseLandInfo, bSelf);
  596. }
  597. }
  598. }
  599. }
  600. // console.log("other:", this.BuildingsParent.children);
  601. }
  602. },
  603. /**
  604. * 初始化障碍物
  605. * 生成的预制信息,需要在 DressUpArray 添加对应的预制件,才可以添加
  606. */
  607. spawnDressUp() {
  608. //村长和镇长的区别,樱花树区别
  609. let agent_level = GlobalD.Dapp.UserInfo.agent_level; // 0普通用户,1 村长身份,2 镇长身份
  610. let _cherryTree = 2 === agent_level ? "Dress_505_SmallTree02" : "Dress_505_SmallTree01";
  611. let _temp = [
  612. //左边第一部分 ----start----
  613. {
  614. spawnName: "Dress_502_ChrisTree",
  615. startPos: cc.v2(14, 20)
  616. },
  617. //拱门
  618. {
  619. spawnName: "Dress_505_MainDoor01",
  620. startPos: cc.v2(18, 17)
  621. },
  622. {
  623. spawnName: "Dress_503_RailingGrassX",
  624. startPos: cc.v2(9, 20)
  625. },
  626. {
  627. spawnName: "Dress_503_RailingGrassX",
  628. startPos: cc.v2(7, 20)
  629. },
  630. //-----
  631. {
  632. spawnName: "Dress_505_FlowerBed",
  633. startPos: cc.v2(8, 22)
  634. },
  635. {
  636. spawnName: "Dress_505_FlowerBed",
  637. startPos: cc.v2(8, 23)
  638. },
  639. //喷泉
  640. {
  641. spawnName: "Dress_502_Fountain",
  642. startPos: cc.v2(10, 23)
  643. },
  644. {
  645. spawnName: "Dress_505_FlowerBed",
  646. startPos: cc.v2(11, 22)
  647. },
  648. {
  649. spawnName: "Dress_505_FlowerBed",
  650. startPos: cc.v2(11, 23)
  651. },
  652. {
  653. spawnName: "Dress_505_ChrisSanta",
  654. startPos: cc.v2(10, 25)
  655. },
  656. //-----
  657. //左边第一部分 ----end----
  658. //主路放两个灯和树
  659. {
  660. spawnName: "Dress_505_Streetlight",
  661. startPos: cc.v2(15, 29)
  662. },
  663. {
  664. spawnName: "Dress_505_Streetlight",
  665. startPos: cc.v2(18, 29)
  666. },
  667. {
  668. spawnName: "Dress_505_SmallTree",
  669. startPos: cc.v2(15, 30)
  670. },
  671. {
  672. spawnName: "Dress_505_SmallTree",
  673. startPos: cc.v2(18, 30)
  674. }
  675. ];
  676. //左边小麦区域
  677. // for (let x = 0; x < 3; x++) {
  678. // for (let y = 0; y < 2; y++) {
  679. // _temp.push({
  680. // spawnName: "Dress_502_Rice",
  681. // startPos: cc.v2(4 - x * 2, 30 - y * 2)
  682. // })
  683. // }
  684. // }
  685. //1倍土地部分木质花圃
  686. // for (let x = 0; x < 6; x++) {
  687. // for (let y = 0; y < 3; y++) {
  688. // _temp.push({
  689. // spawnName: "Dress_503_WhiteWoodRailingX",
  690. // startPos: cc.v2(18 + x, 14 - y * 3)
  691. // })
  692. // }
  693. // }
  694. //生成一个未盛开的樱花围绕,间隔1个空格 ---start ,镇长换成盛开的樱花
  695. // for (let x = 0; x < 3; x++) {
  696. // _temp.push({
  697. // spawnName: _cherryTree,
  698. // startPos: cc.v2(18 + x * 2, 17)
  699. // })
  700. // _temp.push({
  701. // spawnName: _cherryTree,
  702. // startPos: cc.v2(18 + x * 2, 5)
  703. // })
  704. // }
  705. // for (let y = 0; y < 7; y++) {
  706. // _temp.push({
  707. // spawnName: _cherryTree,
  708. // startPos: cc.v2(24, 17 - y * 2)
  709. // })
  710. // }
  711. //多倍区域
  712. // for (let x = 0; x < 3; x++) {
  713. // _temp.push({
  714. // spawnName: _cherryTree,
  715. // startPos: cc.v2(15 - x * 2, 14)
  716. // })
  717. // _temp.push({
  718. // spawnName: _cherryTree,
  719. // startPos: cc.v2(15 - x * 2, 2)
  720. // })
  721. // }
  722. //生成一个未盛开的樱花围绕,间隔1个空格 --- end
  723. //多倍土地部分木质花圃
  724. // for (let x = 0; x < 3; x++) {
  725. // for (let y = 0; y < 3; y++) {
  726. // _temp.push({
  727. // spawnName: "Dress_503_RailingGrassX",
  728. // startPos: cc.v2(15 - x * 2, 11 - y * 3)
  729. // })
  730. // }
  731. // }
  732. //生成番茄区域
  733. // for (let x = 0; x < 3; x++) {
  734. // for (let y = 0; y < 2; y++) {
  735. // _temp.push({
  736. // spawnName: "Dress_502_Tomato",
  737. // startPos: cc.v2(26 + x * 2, 30 - y * 2)
  738. // })
  739. // }
  740. // }
  741. //----中上别墅区域--start
  742. //生成中上三个别墅和三个树木
  743. for (let x = 0; x < 3; x++) {
  744. _temp.push({
  745. spawnName: "Dress_505_SmallTree",
  746. startPos: cc.v2(7 - x * 2, 6)
  747. })
  748. _temp.push({
  749. spawnName: "Dress_502_Villa",
  750. startPos: cc.v2(8 - x * 2, 8)
  751. })
  752. }
  753. //雪橇
  754. _temp.push({
  755. spawnName: "Dress_505_ChrisCar02",
  756. startPos: cc.v2(8, 10)
  757. })
  758. //圣诞门和栏杆
  759. for (let x = 0; x < 3; x++) {
  760. _temp.push({
  761. spawnName: "Dress_503_WhiteWoodRailingX",
  762. startPos: cc.v2(8 - x, 11)
  763. })
  764. }
  765. _temp.push({
  766. spawnName: "Dress_503_ChrisDoorX",
  767. startPos: cc.v2(5, 11)
  768. })
  769. for (let x = 0; x < 3; x++) {
  770. _temp.push({
  771. spawnName: "Dress_503_WhiteWoodRailingX",
  772. startPos: cc.v2(4 - x, 11)
  773. })
  774. }
  775. //门外区域
  776. _temp.push({
  777. spawnName: "Dress_502_florist",
  778. startPos: cc.v2(4, 15)
  779. })
  780. _temp.push({
  781. spawnName: "Dress_505_ChrisCar01",
  782. startPos: cc.v2(6, 16)
  783. })
  784. _temp.push({
  785. spawnName: "Dress_505_PondDuck",
  786. startPos: cc.v2(6, 14)
  787. })
  788. for (let y = 0; y < 3; y++) {
  789. _temp.push({
  790. spawnName: "Dress_504_ChrisRailingY",
  791. startPos: cc.v2(8, 16 - y)
  792. })
  793. }
  794. //樱花路
  795. for (let x = 0; x < 5; x++) {
  796. _temp.push({
  797. spawnName: _cherryTree,
  798. startPos: cc.v2(10 - x * 2, 17)
  799. })
  800. _temp.push({
  801. spawnName: _cherryTree,
  802. startPos: cc.v2(10 - x * 2, 19)
  803. })
  804. }
  805. //------end
  806. //----右边区域--start
  807. _temp.push({
  808. spawnName: "Dress_505_Pond",
  809. startPos: cc.v2(20, 3)
  810. })
  811. _temp.push({
  812. spawnName: "Dress_504_RailingGrassY",
  813. startPos: cc.v2(21, 3)
  814. })
  815. _temp.push({
  816. spawnName: "Dress_502_FruitTreeAndStool",
  817. startPos: cc.v2(23, 3)
  818. })
  819. //---- end
  820. for (let i = 0; i < _temp.length; i++) {
  821. for (let j = 0; j < this.DressUpArray.length; j++) {
  822. let _dressUpTemp = this.DressUpArray[j];
  823. if (_dressUpTemp.name == _temp[i].spawnName) {
  824. let prefab = cc.instantiate(_dressUpTemp);
  825. prefab.parent = this.BuildingsParent;
  826. let tipNode = prefab.getChildByName("Tip");
  827. if (tipNode) {
  828. tipNode.destroy();
  829. }
  830. let buildingsInfo = prefab.getComponent("buildingsInfo");
  831. //id用时间戳来记录
  832. buildingsInfo.buildInfo.id = new Date().getTime();//对应的id
  833. buildingsInfo.buildInfo.isItActive = false;
  834. //设置tile的最底下的坐标,就是起始坐标
  835. buildingsInfo.buildInfo.startTilePos = _temp[i].startPos;
  836. buildingsInfo.InitPos = false;
  837. buildingsInfo.InitStartPos = _temp[i].startPos;
  838. var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(_temp[i].startPos);
  839. prefab.setPosition(endPos.x, endPos.y);
  840. //起始坐标,占位范围,是否占位
  841. GlobalD.game.addBuildTiled(buildingsInfo.buildInfo.id, buildingsInfo.buildInfo.startTilePos, buildingsInfo.buildInfo.occupyArea);
  842. //添加占位信息
  843. GlobalD.game.addBuilding(buildingsInfo);
  844. // console.log(_dressUpTemp.name);
  845. //跳出里面一层循环
  846. break;
  847. }
  848. }
  849. }
  850. },
  851. //初始化场景建筑
  852. SpawnHouse: function () {
  853. let BuildingJSON = Object.assign([], GlobalD.GameData.GameData_buildings);
  854. //拿到数据后,清空 GlobalD.GameData.GameData_buildings 数据,下面再添加上去
  855. GlobalD.GameData.GameData_buildings.length = 0;
  856. // cc.log('BuildingJSON', BuildingJSON);
  857. // if (BuildingJSON.length == 0) {
  858. // //初始化默认房子
  859. // this.SpawnDefaultHouse();
  860. // return
  861. // };
  862. for (let i = 0; i < BuildingJSON.length; i++) {
  863. let HouseName = BuildingJSON[i].buildingNodeName;
  864. let housingTemp = this.onGetHousingPrefabFromName(HouseName);
  865. if (!housingTemp)
  866. cc.error('housingTemp', HouseName, housingTemp);
  867. //预制为空
  868. if (!housingTemp) continue;
  869. let buildingsInfo = housingTemp.getComponent("buildingsInfo");
  870. /**
  871. * 处理数据库数据冲突问题
  872. * 这里处理判断初始化位置是否被占用,占用了回收到仓库背包系统
  873. * BuildingJSON 看做旧的数据, 拿到旧数据 BuildingJSON[i].startTilePos 起始位置 ,生成对应预制的大小occupyArea
  874. * 来判断占位信息
  875. */
  876. // //全部回收
  877. // // 背包添加对应的建筑数量
  878. // GlobalD.game.PlusBuilding(buildingsInfo.buildInfo.buildingName);
  879. // // 删除上面生成的预制节点
  880. // housingTemp.destroy();
  881. // continue;
  882. let _canNotBuild = GlobalD.game.areTheraOverlappingAreas(BuildingJSON[i].startTilePos, buildingsInfo.buildInfo.occupyArea, 1);
  883. if (_canNotBuild) {
  884. // 背包添加对应的建筑数量
  885. GlobalD.game.PlusBuilding(buildingsInfo.buildInfo.buildingName);
  886. // 删除上面生成的预制节点
  887. housingTemp.destroy();
  888. //跳过生成
  889. continue;
  890. }
  891. housingTemp.parent = this.BuildingsParent;
  892. var endPos = GlobalD.TiledMap._getTheMiddleLocationFromtilePos(BuildingJSON[i].startTilePos);
  893. housingTemp.setPosition(endPos.x, endPos.y);
  894. //id用时间戳来记录
  895. buildingsInfo.buildInfo.id = BuildingJSON[i].buildingId;//对应的id
  896. //设置tile的最底下的坐标,就是起始坐标
  897. buildingsInfo.buildInfo.startTilePos = BuildingJSON[i].startTilePos;
  898. //初始化位置的坐标
  899. buildingsInfo.InitStartPos = BuildingJSON[i].startTilePos;
  900. this.SpawnBuildingDefaultValue(buildingsInfo);
  901. //目前应该只有商店,后面根据RunningCost来判断 todo.....
  902. // if (reGameStates.BuildType.Shop == buildingsInfo.buildInfo.buildType)
  903. {
  904. // buildingsInfo.buildInfo.isItSaleable = Number(BuildingJSON[i].isItSaleable) > 0 ? true : false;
  905. buildingsInfo.buildInfo.isItStopOperation = Number(BuildingJSON[i].isItStopOperation) > 0 ? true : false;
  906. //如果不可以运营的,加上牌子
  907. if (buildingsInfo.buildInfo.isItStopOperation) {
  908. GlobalD.game.onAddBuildingTipView(buildingsInfo);
  909. }
  910. }
  911. //建筑物的加成值
  912. buildingsInfo.buildInfo.consumeStrengthAddValue = Number(BuildingJSON[i].consumeStrengthAddValue);
  913. buildingsInfo.buildInfo.goodsPriceAddValue = Number(BuildingJSON[i].goodsPriceAddValue);
  914. /**
  915. * 判断是否占位的时候,需要进一步处理。放回背包,然后背包物品加上对应的数量
  916. */
  917. //起始坐标,占位范围,是否占位
  918. GlobalD.game.addBuildTiled(buildingsInfo.buildInfo.id, buildingsInfo.buildInfo.startTilePos, buildingsInfo.buildInfo.occupyArea);
  919. //添加占位信息
  920. GlobalD.game.addBuilding(buildingsInfo);
  921. }
  922. // console.log("GlobalD.GameData.GameData_buildings:", GlobalD.GameData.GameData_buildings);
  923. },
  924. onGetHousingPrefabFromName(HouseName) {
  925. let housing = null;
  926. //住宿地方
  927. if (HouseName == 'Env_101_house_low') {
  928. housing = cc.instantiate(this.Env_101_house_low);
  929. }
  930. else if (HouseName === 'Env_102_house_mid') {
  931. housing = cc.instantiate(this.Env_102_house_mid);
  932. }
  933. else if (HouseName == 'Env_103_house_high') {
  934. housing = cc.instantiate(this.Env_103_house_high);
  935. }
  936. else if (HouseName == 'Env_104_BlueCastle') {
  937. housing = cc.instantiate(this.Env_104_BlueCastle);
  938. }
  939. else if (HouseName == 'Env_105_PinkCastle') {
  940. housing = cc.instantiate(this.Env_105_PinkCastle);
  941. }
  942. //劳动地方
  943. else if (HouseName == 'Labour_201_Farmland') {
  944. housing = cc.instantiate(this.Labour_201_Farmland);
  945. }
  946. else if (HouseName == 'Labour_202_TimberYard') {
  947. housing = cc.instantiate(this.Labour_202_TimberYard);
  948. }
  949. else if (HouseName == 'Labour_203_MiningPit') {
  950. housing = cc.instantiate(this.Labour_203_MiningPit);
  951. }
  952. else if (HouseName == 'Labour_204_Factory') {
  953. housing = cc.instantiate(this.Labour_204_Factory);
  954. }
  955. //神农专用农田
  956. else if (HouseName == 'Labour_205_Holy_Farmland') {
  957. housing = cc.instantiate(this.Labour_205_Holy_Farmland);
  958. }
  959. //特殊建筑
  960. else if (HouseName == 'Spe_401_StreetLamp') {
  961. housing = cc.instantiate(this.Spe_401_StreetLamp);
  962. }
  963. else if (HouseName == 'Spe_402_GreenBelt') {
  964. housing = cc.instantiate(this.Spe_402_GreenBelt);
  965. }
  966. else if (HouseName == 'Spe_403_FlowerBed') {
  967. housing = cc.instantiate(this.Spe_403_FlowerBed);
  968. }
  969. else if (HouseName == 'Spe_404_Pool') {
  970. housing = cc.instantiate(this.Spe_404_Pool);
  971. }
  972. else if (HouseName == 'Spe_405_PoliceOffice') {
  973. housing = cc.instantiate(this.Spe_405_PoliceOffice);
  974. }
  975. else if (HouseName == 'Spe_406_Playground') {
  976. housing = cc.instantiate(this.Spe_406_Playground);
  977. }
  978. //商店类型
  979. else if (HouseName == 'Shops_30101_ColdDrinkStall') {
  980. housing = cc.instantiate(this.Shops_30101_ColdDrinkStall);
  981. }
  982. else if (HouseName == 'Shops_30102_SalesMachine') {
  983. housing = cc.instantiate(this.Shops_30102_SalesMachine);
  984. }
  985. else if (HouseName == 'Shops_30103_Bakery') {
  986. housing = cc.instantiate(this.Shops_30103_Bakery);
  987. }
  988. else if (HouseName == 'Shops_30104_BreakfastCar') {
  989. housing = cc.instantiate(this.Shops_30104_BreakfastCar);
  990. }
  991. else if (HouseName == 'Shops_30201_TeaShop') {
  992. housing = cc.instantiate(this.Shops_30201_TeaShop);
  993. }
  994. else if (HouseName == 'Shops_30202_confectaurant') {
  995. housing = cc.instantiate(this.Shops_30202_confectaurant);
  996. }
  997. else if (HouseName == 'Shops_30203_GourmetRestaurant') {
  998. housing = cc.instantiate(this.Shops_30203_GourmetRestaurant);
  999. }
  1000. else if (HouseName == 'Shops_30204_WesternRestaurant') {
  1001. housing = cc.instantiate(this.Shops_30204_WesternRestaurant);
  1002. }
  1003. else if (HouseName == 'Shops_30301_Florist') {
  1004. housing = cc.instantiate(this.Shops_30301_Florist);
  1005. }
  1006. else if (HouseName == 'Shops_30302_HairSalon') {
  1007. housing = cc.instantiate(this.Shops_30302_HairSalon);
  1008. }
  1009. else if (HouseName == 'Shops_30303_DressShop') {
  1010. housing = cc.instantiate(this.Shops_30303_DressShop);
  1011. }
  1012. else if (HouseName == 'Shops_30304_JewelryStore') {
  1013. housing = cc.instantiate(this.Shops_30304_JewelryStore);
  1014. }
  1015. else if (HouseName == 'Shops_30305_Cinema') {
  1016. housing = cc.instantiate(this.Shops_30305_Cinema);
  1017. }
  1018. return housing;
  1019. },
  1020. //获取预制的名字
  1021. onGetPrefabsBuildingName(index) {
  1022. //content button 设置的index
  1023. let buildingName = '';
  1024. //农舍
  1025. if ('101' == index) {
  1026. buildingName = 'Env_101_house_low';
  1027. }
  1028. //单元楼
  1029. else if ('102' == index) {
  1030. buildingName = 'Env_102_house_mid';
  1031. }
  1032. //别墅
  1033. else if ('103' == index) {
  1034. buildingName = 'Env_103_house_high';
  1035. }
  1036. //蓝色城堡
  1037. else if ('104' == index) {
  1038. buildingName = 'Env_104_BlueCastle';
  1039. }
  1040. //粉色城堡
  1041. else if ('105' == index) {
  1042. buildingName = 'Env_105_PinkCastle';
  1043. }
  1044. //农田
  1045. else if ('201' == index) {
  1046. buildingName = 'Labour_201_Farmland';
  1047. }
  1048. //伐木场
  1049. else if ('202' == index) {
  1050. buildingName = 'Labour_202_TimberYard';
  1051. }
  1052. //矿坑
  1053. else if ('203' == index) {
  1054. buildingName = 'Labour_203_MiningPit';
  1055. }
  1056. //工厂
  1057. else if ('204' == index) {
  1058. buildingName = 'Labour_204_Factory';
  1059. }
  1060. //神农专用农田
  1061. else if ('205' == index) {
  1062. buildingName = 'Labour_205_Holy_Farmland';
  1063. }
  1064. //冷饮摊
  1065. else if ('30101' == index) {
  1066. buildingName = 'Shops_30101_ColdDrinkStall';
  1067. }
  1068. //贩卖机
  1069. else if ('30102' == index) {
  1070. buildingName = 'Shops_30102_SalesMachine';
  1071. }
  1072. //面包房
  1073. else if ('30103' == index) {
  1074. buildingName = 'Shops_30103_Bakery';
  1075. }
  1076. //早餐车
  1077. else if ('30104' == index) {
  1078. buildingName = 'Shops_30104_BreakfastCar';
  1079. }
  1080. //饮茶店
  1081. else if ('30201' == index) {
  1082. buildingName = 'Shops_30201_TeaShop';
  1083. }
  1084. //点心店
  1085. else if ('30202' == index) {
  1086. buildingName = 'Shops_30202_confectaurant';
  1087. }
  1088. //美食店
  1089. else if ('30203' == index) {
  1090. buildingName = 'Shops_30203_GourmetRestaurant';
  1091. }
  1092. //西餐厅
  1093. else if ('30204' == index) {
  1094. buildingName = 'Shops_30204_WesternRestaurant';
  1095. }
  1096. //花店
  1097. else if ('30301' == index) {
  1098. buildingName = 'Shops_30301_Florist';
  1099. }
  1100. //美发店
  1101. else if ('30302' == index) {
  1102. buildingName = 'Shops_30302_HairSalon';
  1103. }
  1104. //洋装店
  1105. else if ('30303' == index) {
  1106. buildingName = 'Shops_30303_DressShop';
  1107. }
  1108. //珠宝店
  1109. else if ('30304' == index) {
  1110. buildingName = 'Shops_30304_JewelryStore';
  1111. }
  1112. //电影院
  1113. else if ('30305' == index) {
  1114. buildingName = 'Shops_30305_Cinema';
  1115. }
  1116. //路灯
  1117. else if ('401' == index) {
  1118. buildingName = 'Spe_401_StreetLamp';
  1119. }
  1120. //绿化带
  1121. else if ('402' == index) {
  1122. buildingName = 'Spe_402_GreenBelt';
  1123. }
  1124. //花坛
  1125. else if ('403' == index) {
  1126. buildingName = 'Spe_403_FlowerBed';
  1127. }
  1128. //喷泉
  1129. else if ('404' == index) {
  1130. buildingName = 'Spe_404_Pool';
  1131. }
  1132. //警察局
  1133. else if ('405' == index) {
  1134. buildingName = 'Spe_405_PoliceOffice';
  1135. }
  1136. //游乐场
  1137. else if ('406' == index) {
  1138. buildingName = 'Spe_406_Playground';
  1139. }
  1140. return buildingName;
  1141. },
  1142. Grant() {
  1143. },
  1144. Sale() {
  1145. },
  1146. Exchange() {
  1147. }
  1148. });