|
|
@@ -83,7 +83,22 @@ cc.Class({
|
|
|
Selecteded_Fruit_Sprite: cc.SpriteFrame,
|
|
|
|
|
|
//需要切换节点顺序的父节点
|
|
|
- container: cc.Node
|
|
|
+ container: cc.Node,
|
|
|
+
|
|
|
+ //商城的列表
|
|
|
+ mySeedList: [],
|
|
|
+ myFruitList: [],
|
|
|
+ seedPrefab: cc.Prefab,
|
|
|
+ fruitPrefab: cc.Prefab,
|
|
|
+
|
|
|
+ seedSpriteFrame: {
|
|
|
+ default: [],
|
|
|
+ type: [cc.SpriteFrame]
|
|
|
+ },
|
|
|
+ fruitSpriteFrame: {
|
|
|
+ default: [],
|
|
|
+ type: [cc.SpriteFrame]
|
|
|
+ },
|
|
|
},
|
|
|
HiddenAll() {
|
|
|
|
|
|
@@ -100,9 +115,99 @@ cc.Class({
|
|
|
if (this.Fruit.active)
|
|
|
this.Fruit.active = false;
|
|
|
},
|
|
|
- start(){
|
|
|
+ start() {
|
|
|
//默认设置第一个节点为 最上面
|
|
|
this.EvnBtn.setSiblingIndex(10);
|
|
|
+
|
|
|
+
|
|
|
+ //获取种子和果实
|
|
|
+ GlobalD.GameData.getWarehouseSeedAndFruit((res, vaule) => {
|
|
|
+ this.mySeedList = vaule.data.seed;
|
|
|
+ this.myFruitList = vaule.data.fruit;
|
|
|
+
|
|
|
+ console.log(this.mySeedList, this.myFruitList);
|
|
|
+ for (let i = 0; i < this.mySeedList.length; i++) {
|
|
|
+ //没有种子数量不显示 todo 看看后续需不需要处理删除
|
|
|
+ if (this.mySeedList[i].amount < 1) continue;
|
|
|
+
|
|
|
+ let _seed = cc.instantiate(this.seedPrefab);
|
|
|
+ _seed.parent = this.Seed;
|
|
|
+ let _seedScript = _seed.getComponent("Content_Button");
|
|
|
+ //设置一个生成点
|
|
|
+ let _spawnScript = _seed.getComponent("Content_seed");
|
|
|
+ _spawnScript.SpawnPoint = cc.find("Canvas/SpawnParent/SpawnPoint");
|
|
|
+ _seedScript.NumLabel.string = this.mySeedList[i].amount;
|
|
|
+ _seedScript.NameLabel.string = this.mySeedList[i].name;
|
|
|
+ switch (this.mySeedList[i].picture) {
|
|
|
+ case "Cabbage":
|
|
|
+ _seedScript.bgSprite.spriteFrame = this.seedSpriteFrame[0];
|
|
|
+ break;
|
|
|
+ case "Potato":
|
|
|
+ _seedScript.bgSprite.spriteFrame = this.seedSpriteFrame[1];
|
|
|
+ break;
|
|
|
+ case "Carrot":
|
|
|
+ _seedScript.bgSprite.spriteFrame = this.seedSpriteFrame[2];
|
|
|
+ break;
|
|
|
+ case "Broccoli":
|
|
|
+ _seedScript.bgSprite.spriteFrame = this.seedSpriteFrame[3];
|
|
|
+ break;
|
|
|
+ case "Tomato":
|
|
|
+ _seedScript.bgSprite.spriteFrame = this.seedSpriteFrame[4];
|
|
|
+ break;
|
|
|
+ case "Squash":
|
|
|
+ _seedScript.bgSprite.spriteFrame = this.seedSpriteFrame[5];
|
|
|
+ break;
|
|
|
+ case "Eggplant":
|
|
|
+ _seedScript.bgSprite.spriteFrame = this.seedSpriteFrame[6];
|
|
|
+ break;
|
|
|
+ case "Pepper":
|
|
|
+ _seedScript.bgSprite.spriteFrame = this.seedSpriteFrame[7];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i = 0; i < this.myFruitList.length; i++) {
|
|
|
+ let _fruit = cc.instantiate(this.fruitPrefab);
|
|
|
+ _fruit.parent = this.Fruit;
|
|
|
+ _fruit.zIndex = 999;
|
|
|
+ let _fruitScript = _fruit.getComponent("Content_Button");
|
|
|
+ _fruitScript.NumLabel.string = 1;
|
|
|
+ _fruitScript.NameLabel.string = this.myFruitList[i].name;
|
|
|
+ _fruitScript.Name = this.myFruitList[i].name;
|
|
|
+ _fruitScript.SNB = this.myFruitList[i].priceSnb;
|
|
|
+ _fruitScript.Synopsis = "出售SNB";
|
|
|
+
|
|
|
+ switch (this.myFruitList[i].picture) {
|
|
|
+ case "Cabbage":
|
|
|
+ _fruitScript.bgSprite.spriteFrame = this.seedSpriteFrame[0];
|
|
|
+ break;
|
|
|
+ case "Potato":
|
|
|
+ _fruitScript.bgSprite.spriteFrame = this.seedSpriteFrame[1];
|
|
|
+ break;
|
|
|
+ case "Carrot":
|
|
|
+ _fruitScript.bgSprite.spriteFrame = this.seedSpriteFrame[2];
|
|
|
+ break;
|
|
|
+ case "Broccoli":
|
|
|
+ _fruitScript.bgSprite.spriteFrame = this.seedSpriteFrame[3];
|
|
|
+ break;
|
|
|
+ case "Tomato":
|
|
|
+ _fruitScript.bgSprite.spriteFrame = this.seedSpriteFrame[4];
|
|
|
+ break;
|
|
|
+ case "Squash":
|
|
|
+ _fruitScript.bgSprite.spriteFrame = this.seedSpriteFrame[5];
|
|
|
+ break;
|
|
|
+ case "Eggplant":
|
|
|
+ _fruitScript.bgSprite.spriteFrame = this.seedSpriteFrame[6];
|
|
|
+ break;
|
|
|
+ case "Pepper":
|
|
|
+ _fruitScript.bgSprite.spriteFrame = this.seedSpriteFrame[7];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
//切换建筑的面板
|
|
|
onSwitchBuildingContent(event, index) {
|
|
|
@@ -121,12 +226,12 @@ cc.Class({
|
|
|
this.SeedBtn.getComponent(cc.Sprite).spriteFrame = this.Normal_Seed_Sprite;
|
|
|
this.FruitBtn.getComponent(cc.Sprite).spriteFrame = this.Normal_Fruit_Sprite;
|
|
|
|
|
|
- this.EvnBtn.setContentSize(100,54);
|
|
|
- this.LabourBtn.setContentSize(100,54);
|
|
|
- this.ShopBtn.setContentSize(100,54);
|
|
|
- this.SpeBuildingBtn.setContentSize(100,54);
|
|
|
- this.SeedBtn.setContentSize(100,54);
|
|
|
- this.FruitBtn.setContentSize(100,54);
|
|
|
+ this.EvnBtn.setContentSize(100, 54);
|
|
|
+ this.LabourBtn.setContentSize(100, 54);
|
|
|
+ this.ShopBtn.setContentSize(100, 54);
|
|
|
+ this.SpeBuildingBtn.setContentSize(100, 54);
|
|
|
+ this.SeedBtn.setContentSize(100, 54);
|
|
|
+ this.FruitBtn.setContentSize(100, 54);
|
|
|
|
|
|
this.EvnBtn.y = -5;
|
|
|
this.LabourBtn.y = -5;
|
|
|
@@ -144,10 +249,10 @@ cc.Class({
|
|
|
this.Env.active = true;
|
|
|
this.SelectedFrame.parent = this.Building00;
|
|
|
this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.Building00.getComponent('Content_Button').Name, this.Building00.getComponent('Content_Button').Price, this.Building00.getComponent('Content_Button').Synopsis);
|
|
|
-
|
|
|
+
|
|
|
//设置节点顺序
|
|
|
this.EvnBtn.setSiblingIndex(10);
|
|
|
- this.EvnBtn.setContentSize(86,88);
|
|
|
+ this.EvnBtn.setContentSize(86, 88);
|
|
|
}
|
|
|
//劳动
|
|
|
else if ('1' == index) {
|
|
|
@@ -156,9 +261,9 @@ cc.Class({
|
|
|
this.Labour.active = true;
|
|
|
this.SelectedFrame.parent = this.Building10;
|
|
|
this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.Building10.getComponent('Content_Button').Name, this.Building10.getComponent('Content_Button').Price, this.Building10.getComponent('Content_Button').Synopsis);
|
|
|
-
|
|
|
+
|
|
|
this.LabourBtn.setSiblingIndex(10);
|
|
|
- this.LabourBtn.setContentSize(86,88);
|
|
|
+ this.LabourBtn.setContentSize(86, 88);
|
|
|
}
|
|
|
//商铺
|
|
|
else if ('2' == index) {
|
|
|
@@ -169,9 +274,9 @@ cc.Class({
|
|
|
this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.Building20.getComponent('Content_Button').Name, this.Building20.getComponent('Content_Button').Price, this.Building20.getComponent('Content_Button').Synopsis);
|
|
|
|
|
|
this.ShopBtn.setSiblingIndex(10);
|
|
|
- this.ShopBtn.setContentSize(86,88);
|
|
|
+ this.ShopBtn.setContentSize(86, 88);
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
//特殊
|
|
|
else if ('3' == index) {
|
|
|
this.SpeBuildingBtn.y = -20;
|
|
|
@@ -181,8 +286,8 @@ cc.Class({
|
|
|
this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.Building30.getComponent('Content_Button').Name, this.Building30.getComponent('Content_Button').Price, this.Building30.getComponent('Content_Button').Synopsis);
|
|
|
|
|
|
this.SpeBuildingBtn.setSiblingIndex(10);
|
|
|
- this.SpeBuildingBtn.setContentSize(86,88);
|
|
|
- }
|
|
|
+ this.SpeBuildingBtn.setContentSize(86, 88);
|
|
|
+ }
|
|
|
//种子
|
|
|
else if ('4' == index) {
|
|
|
this.SeedBtn.y = -20;
|
|
|
@@ -190,31 +295,14 @@ cc.Class({
|
|
|
this.Seed.active = true;
|
|
|
this.SelectedFrame.parent = this.Building40;
|
|
|
|
|
|
- GlobalD.GameData.getMallSeed(function(res, vaule)
|
|
|
- {
|
|
|
- let Synopsis = "成熟期:"+maturity;
|
|
|
- this.ManageUI.getComponent('ManageUI').onSetButtonInfo(vaule.data[0].name, vaule.data[0].price, Synopsis);
|
|
|
- });
|
|
|
-
|
|
|
- // "id": 1,
|
|
|
- // "mallType": "0",
|
|
|
- // "picture": null,
|
|
|
- // "name": "白菜种子",
|
|
|
- // "maturity": 100,
|
|
|
- // "planting": 100,
|
|
|
- // "harvestQuantity": 2500,
|
|
|
- // "harvestCount": 2500,
|
|
|
- // "harvestName": "大白菜",
|
|
|
- // "price": 99,
|
|
|
- // "amount": 0,
|
|
|
- // "withered": 200,
|
|
|
- // "createTime": "2022-01-10 16:45:18",
|
|
|
- // "updateTime": "2022-01-10 16:45:26"
|
|
|
- // },
|
|
|
-
|
|
|
+ if (this.mySeedList.length > 0) {
|
|
|
+ let Synopsis = "成熟期:" + this.mySeedList[0].maturity;
|
|
|
+ this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.mySeedList[0].name, this.mySeedList[0].priceSnb, Synopsis);
|
|
|
+ }
|
|
|
+
|
|
|
this.SeedBtn.setSiblingIndex(10);
|
|
|
- this.SeedBtn.setContentSize(86,88);
|
|
|
- }
|
|
|
+ this.SeedBtn.setContentSize(86, 88);
|
|
|
+ }
|
|
|
//果实
|
|
|
else if ('5' == index) {
|
|
|
this.FruitBtn.y = -20;
|
|
|
@@ -222,28 +310,15 @@ cc.Class({
|
|
|
this.Fruit.active = true;
|
|
|
this.SelectedFrame.parent = this.Building50;
|
|
|
|
|
|
- // {
|
|
|
- // "id": 1,
|
|
|
- // "picture": null,
|
|
|
- // "name": "白菜",
|
|
|
- // "priceSnb": 99,
|
|
|
- // "priceCnt": 9.9,
|
|
|
- // "createTime": "2022-01-10 16:45:18",
|
|
|
- // "updateTime": "2022-01-10 16:45:26"
|
|
|
- // }
|
|
|
-
|
|
|
- GlobalD.GameData.getMallSeed(function(res, vaule)
|
|
|
- {
|
|
|
- let Price = 'Snb:'+vaule.data[0].priceSnb+' Cnt:'+vaule.data[0].priceCnt;
|
|
|
- let Synopsis = "成熟期:"+maturity;
|
|
|
- this.ManageUI.getComponent('ManageUI').onSetButtonInfo(vaule.data[0].name, Price, Synopsis);
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
+ if (this.myFruitList.length > 0) {
|
|
|
+ let Synopsis = "这是个" + this.myFruitList[0].name + "果实!";
|
|
|
+ this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.myFruitList[0].name, this.myFruitList[0].priceSnb, Synopsis);
|
|
|
+ }
|
|
|
+
|
|
|
this.FruitBtn.setSiblingIndex(10);
|
|
|
- this.FruitBtn.setContentSize(86,88);
|
|
|
+ this.FruitBtn.setContentSize(86, 88);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//切换节点顺序
|
|
|
// this.switch();
|