瀏覽代碼

完成道具产出逻辑

SunnyLinSD 6 年之前
父節點
當前提交
4afffa0b9b

+ 1 - 0
assets/scripts/Game.js

@@ -257,6 +257,7 @@ cc.Class({
 
             if(decodeMsg.buildingItems) {
                 console.log(decodeMsg.buildingItems);
+                GameEvent.fire(GameNotificationKey.ReceiveLevelHomeItemPropUpdate, decodeMsg.buildingItems);
             }
 
         })

+ 0 - 11
assets/scripts/levelHome/LevelHome.js

@@ -163,16 +163,6 @@ cc.Class({
         });
          //房间解锁通知,用来触发是否显示入驻艺人通知(因为通知需要随机出现在没有艺人的房间,所以需要在LevelHome这一层来处理)
         GameEvent.on(GameNotificationKey.LevelHomeItemUnlock, this, this.randomResidentTip);
-
-        GameEvent.on(GameNotificationKey.ReceiveLevelHomeItemPropUpdate, this, (props) => {
-            for (const key in props) {
-                if (temp.hasOwnProperty(key)) {
-                    const element = props[key];
-                    console.log(element);
-                }
-            }
-          
-        });
     },
 
     /**
@@ -433,7 +423,6 @@ cc.Class({
 
         GameEvent.off(GameNotificationKey.ReloadLevelHomeData, this);
         GameEvent.off(GameNotificationKey.ResetLevelHomePaddingBottom, this);
-        GameEvent.off(GameNotificationKey.ReceiveLevelHomeItemPropUpdate, this);
         GameEvent.off(GameNotificationKey.LevelHomeItemUnlock, this);
     },
 

+ 11 - 1
assets/scripts/levelHome/LevelHomeItem.js

@@ -251,6 +251,7 @@ cc.Class({
         GameEvent.off(GameNotificationKey.ResidentArtist, this);
         GameEvent.off(GameNotificationKey.RefreshLevelHomeArtistList, this);
         GameEvent.off(GameNotificationKey.LevelHomeItemBuildingAllFull, this);
+        GameEvent.off(GameNotificationKey.ReceiveLevelHomeItemPropUpdate, this);
     },
 
     setEventListener() {
@@ -325,6 +326,13 @@ cc.Class({
                 this.pickupCoinWithNoIncom(this.coinArray[i], showAnim);
             }
         })
+
+        GameEvent.on(GameNotificationKey.ReceiveLevelHomeItemPropUpdate, this, (buildingItem) => {
+
+            if (buildingItem.buildingId != this.buildingInfo.buildingId) { return; }
+            console.log(buildingItem);
+            this.showProp(buildingItem.item);
+        });
     },
 
     // 解锁建筑事件
@@ -398,10 +406,12 @@ cc.Class({
         if (!this.isHasProp) {
             this.isHasProp = true;
             this.propScript.init(this.buildingInfo.buildingId, propData, (showFrame, showText) => {
-                this.propScript = null;
                 this.isHasProp = false; 
                 // 显示领取动画
                 this.parent.showActGift(showFrame, showText)
+
+                this.propScript.node.active = false;
+                this.propScript.node.position = cc.v2(150, -108);
             });
             if (isPlayAnimation) {
                 this.propScript.showAnimation();

+ 1 - 1
assets/scripts/levelHome/LevelHomePropItem.js

@@ -67,8 +67,8 @@ cc.Class({
                 let showFrame = this.propSprite.spriteFrame;
                 let showText = `${this.propData.name} x ${this.propData.count}`
                 this.pickupCallback(showFrame, showText);
-                this.node.destroy();
                 
+
             }, (err) => {
                 console.log(err);
             })