|
@@ -92,7 +92,7 @@ cc.Class({
|
|
this.bottomScript = bottomNode.getComponent('LevelHomeBottom'); this.bottomScript.init(this.cityId);
|
|
this.bottomScript = bottomNode.getComponent('LevelHomeBottom'); this.bottomScript.init(this.cityId);
|
|
this.scrollView.content.addChild(bottomNode);
|
|
this.scrollView.content.addChild(bottomNode);
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
this.setEventLisenter();
|
|
this.setEventLisenter();
|
|
|
|
|
|
// 监听小游戏隐藏到后台事件
|
|
// 监听小游戏隐藏到后台事件
|
|
@@ -161,7 +161,7 @@ cc.Class({
|
|
this.resetPaddingBottom();
|
|
this.resetPaddingBottom();
|
|
|
|
|
|
});
|
|
});
|
|
- //房间解锁通知,用来触发是否显示入驻艺人通知(因为通知需要随机出现在没有艺人的房间,所以需要在LevelHome这一层来处理)
|
|
|
|
|
|
+ //房间解锁通知,用来触发是否显示入驻艺人通知(因为通知需要随机出现在没有艺人的房间,所以需要在LevelHome这一层来处理)
|
|
GameEvent.on(GameNotificationKey.LevelHomeItemUnlock, this, this.randomResidentTip);
|
|
GameEvent.on(GameNotificationKey.LevelHomeItemUnlock, this, this.randomResidentTip);
|
|
},
|
|
},
|
|
|
|
|
|
@@ -208,85 +208,85 @@ cc.Class({
|
|
getNetworkData(callback) {
|
|
getNetworkData(callback) {
|
|
|
|
|
|
this.getUserBuildings()
|
|
this.getUserBuildings()
|
|
- .then((responseData) => {
|
|
|
|
-
|
|
|
|
- // 清空数据
|
|
|
|
- this.buildingInfos = [];
|
|
|
|
-
|
|
|
|
- // 满级后去别的城市就置零
|
|
|
|
- GameModule.userInfo.levelHomeItemFullCount = 0;
|
|
|
|
-
|
|
|
|
- let sortArray = responseData.buildings.sort((a, b) => {
|
|
|
|
- return a.buildingId < b.buildingId;
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // 离线收益金币数量
|
|
|
|
- let offlineGrossIncome = 0;
|
|
|
|
- sortArray.map((value, index, array) => {
|
|
|
|
- let model = Global.BuildingManager.getBuildingInfo(this.cityId, value.buildingId, value.level)
|
|
|
|
- this._unlockBuilding[index] = model.isUnlocked ? 1 : 0;
|
|
|
|
- if (model.isFull() && this.cityId === Global.devCityId) {
|
|
|
|
- try {
|
|
|
|
- GameEvent.fire(GameNotificationKey.LevelHomeItemBuildingFull);
|
|
|
|
- } catch (error) {
|
|
|
|
- console.log(error);
|
|
|
|
|
|
+ .then((responseData) => {
|
|
|
|
+
|
|
|
|
+ // 清空数据
|
|
|
|
+ this.buildingInfos = [];
|
|
|
|
+
|
|
|
|
+ // 满级后去别的城市就置零
|
|
|
|
+ GameModule.userInfo.levelHomeItemFullCount = 0;
|
|
|
|
+
|
|
|
|
+ let sortArray = responseData.buildings.sort((a, b) => {
|
|
|
|
+ return a.buildingId < b.buildingId;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 离线收益金币数量
|
|
|
|
+ let offlineGrossIncome = 0;
|
|
|
|
+ sortArray.map((value, index, array) => {
|
|
|
|
+ let model = Global.BuildingManager.getBuildingInfo(this.cityId, value.buildingId, value.level)
|
|
|
|
+ this._unlockBuilding[index] = model.isUnlocked ? 1 : 0;
|
|
|
|
+ if (model.isFull() && this.cityId === Global.devCityId) {
|
|
|
|
+ try {
|
|
|
|
+ GameEvent.fire(GameNotificationKey.LevelHomeItemBuildingFull);
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log(error);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- model.coinCount = value.coinCount;
|
|
|
|
- model.artists = value.artists || [];
|
|
|
|
- if (model.artists.length > 0) { // 有艺人入驻的情况
|
|
|
|
-
|
|
|
|
- let addition = 0;
|
|
|
|
- for (let i = 0; i < model.artists.length; i++) {
|
|
|
|
- let artist = model.artists[i];
|
|
|
|
- addition += artist.stationJobLevel + 1;
|
|
|
|
|
|
+ model.coinCount = value.coinCount;
|
|
|
|
+ model.artists = value.artists || [];
|
|
|
|
+ if (model.artists.length > 0) { // 有艺人入驻的情况
|
|
|
|
+
|
|
|
|
+ let addition = 0;
|
|
|
|
+ for (let i = 0; i < model.artists.length; i++) {
|
|
|
|
+ let artist = model.artists[i];
|
|
|
|
+ addition += artist.stationJobLevel + 1;
|
|
|
|
+ }
|
|
|
|
+ offlineGrossIncome += (model.coinCount * (model.rate * addition));
|
|
|
|
+
|
|
|
|
+ } else { // 无艺人入驻时
|
|
|
|
+ offlineGrossIncome += (model.coinCount * model.rate);
|
|
}
|
|
}
|
|
- offlineGrossIncome += (model.coinCount * (model.rate * addition));
|
|
|
|
|
|
+ this.buildingInfos.push(model);
|
|
|
|
+ });
|
|
|
|
|
|
- } else { // 无艺人入驻时
|
|
|
|
- offlineGrossIncome += (model.coinCount * model.rate);
|
|
|
|
- }
|
|
|
|
- this.buildingInfos.push(model);
|
|
|
|
- });
|
|
|
|
|
|
+ this._unlockBuilding = this._unlockBuilding.reverse();
|
|
|
|
+
|
|
|
|
+ // GameModule.userInfo.setUserInfo(responseData.user);
|
|
|
|
|
|
- this._unlockBuilding = this._unlockBuilding.reverse();
|
|
|
|
|
|
+ // this.resetPaddingBottom();
|
|
|
|
|
|
- // GameModule.userInfo.setUserInfo(responseData.user);
|
|
|
|
|
|
+ callback && callback();
|
|
|
|
|
|
- // this.resetPaddingBottom();
|
|
|
|
|
|
+ // 开始设置建筑
|
|
|
|
+ this.configBuildings();
|
|
|
|
|
|
- callback && callback();
|
|
|
|
|
|
+ // 离线收益处理
|
|
|
|
+ this.configOffIncome(sortArray, offlineGrossIncome)
|
|
|
|
|
|
- // 开始设置建筑
|
|
|
|
- this.configBuildings();
|
|
|
|
|
|
+ return this.getBuildingItems();
|
|
|
|
+ })
|
|
|
|
+ .then((buildingItems) => {
|
|
|
|
|
|
- // 离线收益处理
|
|
|
|
- this.configOffIncome(sortArray, offlineGrossIncome)
|
|
|
|
|
|
+ for (const buildingId in buildingItems) {
|
|
|
|
|
|
- return this.getBuildingItems();
|
|
|
|
- })
|
|
|
|
- .then((buildingItems) => {
|
|
|
|
-
|
|
|
|
- for (const buildingId in buildingItems) {
|
|
|
|
-
|
|
|
|
- let itemScript;
|
|
|
|
- let filterList = this.buildings.filter( item => item.buildingInfo.buildingId === parseInt(buildingId) ) || [];
|
|
|
|
- if (filterList.length > 0) {
|
|
|
|
- itemScript = filterList[0];
|
|
|
|
- if (buildingItems.hasOwnProperty(buildingId)) {
|
|
|
|
- let prop = buildingItems[buildingId];
|
|
|
|
- itemScript.showProp(prop, false);
|
|
|
|
|
|
+ let itemScript;
|
|
|
|
+ let filterList = this.buildings.filter(item => item.buildingInfo.buildingId === parseInt(buildingId)) || [];
|
|
|
|
+ if (filterList.length > 0) {
|
|
|
|
+ itemScript = filterList[0];
|
|
|
|
+ if (buildingItems.hasOwnProperty(buildingId)) {
|
|
|
|
+ let prop = buildingItems[buildingId];
|
|
|
|
+ itemScript.showProp(prop, false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- })
|
|
|
|
- .catch((err) => {
|
|
|
|
- console.log(err);
|
|
|
|
- });
|
|
|
|
|
|
+ })
|
|
|
|
+ .catch((err) => {
|
|
|
|
+ console.log(err);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
|
|
|
|
getUserBuildings() {
|
|
getUserBuildings() {
|
|
-
|
|
|
|
|
|
+
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
// 获取目标用户的建筑
|
|
// 获取目标用户的建筑
|
|
HomeApi.getUserBuildings(this.uid, this.cityId, (responseData) => {
|
|
HomeApi.getUserBuildings(this.uid, this.cityId, (responseData) => {
|
|
@@ -359,39 +359,41 @@ cc.Class({
|
|
},
|
|
},
|
|
|
|
|
|
randomResidentTip() {
|
|
randomResidentTip() {
|
|
- if (this.buildings && this.buildings.length > 0) {
|
|
|
|
- let noArtistBuildings = [];
|
|
|
|
- for (let i = 0; i < this.buildings.length; i++) {
|
|
|
|
- let itemScript = this.buildings[i];
|
|
|
|
- let buildingInfo = this.buildingInfos[i];
|
|
|
|
-
|
|
|
|
- if (buildingInfo.level == 0) {
|
|
|
|
- itemScript.setResidentTip(false);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ if (GameModule.userInfo.stars > 10) {
|
|
|
|
+ if (this.buildings && this.buildings.length > 0) {
|
|
|
|
+ let noArtistBuildings = [];
|
|
|
|
+ for (let i = 0; i < this.buildings.length; i++) {
|
|
|
|
+ let itemScript = this.buildings[i];
|
|
|
|
+ let buildingInfo = this.buildingInfos[i];
|
|
|
|
+
|
|
|
|
+ if (buildingInfo.level == 0) {
|
|
|
|
+ itemScript.setResidentTip(false);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
- if (buildingInfo.artists && buildingInfo.artists.length > 0) {
|
|
|
|
- itemScript.setResidentTip(false);
|
|
|
|
- } else {
|
|
|
|
- noArtistBuildings.push(itemScript);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (noArtistBuildings.length > 0) {
|
|
|
|
- let index = Math.floor(Math.random() * noArtistBuildings.length);
|
|
|
|
- for (let i = 0; i < noArtistBuildings.length; i++) {
|
|
|
|
- noArtistBuildings[i].setResidentTip(i == index);
|
|
|
|
|
|
+ if (buildingInfo.artists && buildingInfo.artists.length > 0) {
|
|
|
|
+ itemScript.setResidentTip(false);
|
|
|
|
+ } else {
|
|
|
|
+ noArtistBuildings.push(itemScript);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ if (noArtistBuildings.length > 0) {
|
|
|
|
+ let index = Math.floor(Math.random() * noArtistBuildings.length);
|
|
|
|
+ for (let i = 0; i < noArtistBuildings.length; i++) {
|
|
|
|
+ noArtistBuildings[i].setResidentTip(i == index);
|
|
|
|
+ }
|
|
|
|
|
|
- clearInterval(this.residentTipHideTimer);
|
|
|
|
- clearInterval(this.residentTipShowTimer);
|
|
|
|
|
|
+ clearInterval(this.residentTipHideTimer);
|
|
|
|
+ clearInterval(this.residentTipShowTimer);
|
|
|
|
|
|
- this.residentTipHideTimer = setInterval(() => {
|
|
|
|
- noArtistBuildings[index].setResidentTip(false);
|
|
|
|
- }, 5000);
|
|
|
|
|
|
+ this.residentTipHideTimer = setInterval(() => {
|
|
|
|
+ noArtistBuildings[index].setResidentTip(false);
|
|
|
|
+ }, 5000);
|
|
|
|
|
|
- this.residentTipShowTimer = setInterval(() => {
|
|
|
|
- this.randomResidentTip(false);
|
|
|
|
- }, 15000);
|
|
|
|
|
|
+ this.residentTipShowTimer = setInterval(() => {
|
|
|
|
+ this.randomResidentTip(false);
|
|
|
|
+ }, 15000);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -399,7 +401,7 @@ cc.Class({
|
|
/**
|
|
/**
|
|
* 显示领取动画
|
|
* 显示领取动画
|
|
*/
|
|
*/
|
|
- showActGift (showFrame, showText) {
|
|
|
|
|
|
+ showActGift(showFrame, showText) {
|
|
GameModule.audioMng.playGift()
|
|
GameModule.audioMng.playGift()
|
|
this.mask.active = true;
|
|
this.mask.active = true;
|
|
this.actGift.active = true;
|
|
this.actGift.active = true;
|
|
@@ -410,7 +412,7 @@ cc.Class({
|
|
/**
|
|
/**
|
|
* 关闭领取动画
|
|
* 关闭领取动画
|
|
*/
|
|
*/
|
|
- hideActGift () {
|
|
|
|
|
|
+ hideActGift() {
|
|
this.mask.active = false;
|
|
this.mask.active = false;
|
|
this.actGift.active = false;
|
|
this.actGift.active = false;
|
|
},
|
|
},
|