ManageBuildings.js 42 KB

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