Forráskód Böngészése

Merge branch '0.6' of http://svn.ouj.com:3000/DWG/allstar into 0.6

hwt 6 éve
szülő
commit
7f353da7d9

BIN
assets/audio/bgm.mp3


BIN
assets/audio/getCoin.mp3


BIN
assets/audio/gift.mp3


BIN
assets/audio/signFail.mp3


BIN
assets/audio/signSuccess.mp3


BIN
assets/audio/updateBuilding.mp3


BIN
assets/resources/item/10006.png


+ 2 - 2
assets/resources/item/10006.png.meta

@@ -14,11 +14,11 @@
       "rotated": false,
       "offsetX": 0,
       "offsetY": 0,
-      "trimX": 0,
+      "trimX": 9,
       "trimY": 0,
       "width": 54,
       "height": 54,
-      "rawWidth": 54,
+      "rawWidth": 72,
       "rawHeight": 54,
       "borderTop": 0,
       "borderBottom": 0,

+ 10 - 25
assets/resources/prefabs/quest_popup.prefab

@@ -6881,7 +6881,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 54,
+      "width": 72,
       "height": 54
     },
     "_rotationX": 0,
@@ -6890,7 +6890,7 @@
     "_scaleY": 0.5,
     "_position": {
       "__type__": "cc.Vec2",
-      "x": -38.2,
+      "x": -28,
       "y": 0
     },
     "_skewX": 0,
@@ -6908,11 +6908,9 @@
       "__id__": 212
     },
     "_enabled": true,
-    "_spriteFrame": {
-      "__uuid__": "a431e9d4-d1fe-4f80-9895-56c829de53f7"
-    },
+    "_spriteFrame": null,
     "_type": 0,
-    "_sizeMode": 1,
+    "_sizeMode": 0,
     "_fillType": 0,
     "_fillCenter": {
       "__type__": "cc.Vec2",
@@ -7171,8 +7169,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 136,
-      "height": 78
+      "width": 130,
+      "height": 72
     },
     "_rotationX": 0,
     "_rotationY": 0,
@@ -7225,7 +7223,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 54,
+      "width": 72,
       "height": 54
     },
     "_rotationX": 0,
@@ -7234,7 +7232,7 @@
     "_scaleY": 0.5,
     "_position": {
       "__type__": "cc.Vec2",
-      "x": -38.2,
+      "x": -28,
       "y": 0
     },
     "_skewX": 0,
@@ -7252,11 +7250,9 @@
       "__id__": 223
     },
     "_enabled": true,
-    "_spriteFrame": {
-      "__uuid__": "a431e9d4-d1fe-4f80-9895-56c829de53f7"
-    },
+    "_spriteFrame": null,
     "_type": 0,
-    "_sizeMode": 1,
+    "_sizeMode": 0,
     "_fillType": 0,
     "_fillCenter": {
       "__type__": "cc.Vec2",
@@ -7706,17 +7702,6 @@
         "__id__": 206
       }
     ],
-    "giftFrames": [
-      {
-        "__uuid__": "a67b2a12-968e-47e3-aa33-7aa891777423"
-      },
-      {
-        "__uuid__": "a431e9d4-d1fe-4f80-9895-56c829de53f7"
-      },
-      {
-        "__uuid__": "10d5f93a-fbcf-46b6-a209-cd1420c680d1"
-      }
-    ],
     "starFrames": [
       {
         "__uuid__": "e6b7913b-c89b-4884-a050-ca04eccbc0c6"

+ 1 - 1
assets/scripts/Game.js

@@ -177,7 +177,7 @@ cc.Class({
             autoConnect: true,          // 自动连接
             reconnection: true,         // 断开自动重连
             reconnectionDelay: 5000,    // 重连间隔时间,单位秒
-            reconnectionAttempts: 10
+            reconnectionAttempts: 5
         })
 
         let seq = 1;

+ 7 - 1
assets/scripts/Tab.js

@@ -121,7 +121,13 @@ cc.Class({
         this.game = game
 
         this.loadFriendData().then((data) => { // 好友数据回调
-            Global.friendList = this.friends = data.users || [];
+            let _friendList = data.users || [];
+            // 过滤好友申请项
+            _friendList = _friendList.filter(n => {
+                return n.isApplied != 1
+            });
+
+            Global.friendList = this.friends = _friendList;
             this.noArtistTipNode.active = false;
             this.friendLayout();
         }).catch((err) => { // 捕获到报错

+ 3 - 2
assets/scripts/levelHome/LevelFriendHomeItem.js

@@ -286,11 +286,12 @@ cc.Class({
                 });
         }
 
+        this.addition = 1;
+
         // 当没有自己艺人, 也没有好友艺人入驻时, 这里还得区分主态和客态
         if (this.artists.length === 0) {
-            addAddItemToList(true);
             // 没有艺人不显示倍数
-            this.addition = 1;
+            addAddItemToList(true);
         } else {
 
             // 有艺人入驻要显示倍数

+ 3 - 2
assets/scripts/levelHome/LevelHomeItem.js

@@ -592,11 +592,12 @@ cc.Class({
                 });
         }
 
+        this.addition = 1;
+
         // 当没有自己艺人, 也没有好友艺人入驻时, 这里还得区分主态和客态
         if (this.artists.length === 0) {
-            addAddItemToList(true);
             // 没有艺人不显示倍数
-            this.addition = 1;
+            addAddItemToList(true);
         } else {
 
             // 有艺人入驻要显示倍数

+ 44 - 17
assets/scripts/net/Ws.js

@@ -201,9 +201,8 @@ function WsManager(url, opts) {
     this.reconnectionAttempts(opts.reconnectionAttempts || Infinity) //重连最大尝试次数
     this.timeout(null == opts.timeout ? 20000 : opts.timeout)
     this.logStyle = 'color:blue; font-size:16px;font-weight:bold;'
-    this.keepAliveInterval = 20000
-    this.keepAliveTimeout = null
-    this.keepAliveMsg = '0'
+    this.keepAliveInterval = 15000 //心跳包发送间隔
+    this.keepAliveTimeout = null //心跳包计时器
 
     this.autoConnect = opts.autoConnect !== false //是否自动连接
     if(this.autoConnect) {
@@ -233,25 +232,34 @@ WsManager.prototype.reconnect = function() {
             if(this.socket) {
                 this.socket.close()
             }
+            
             this._reconnectTimes += 1
-    
-            console.log(`%c [Socket正在尝试第${this._reconnectTimes}次重连]`, this.logStyle);
             this.readyState = 'reconnecting'
+
+            console.log(`%c [Socket正在尝试第${this._reconnectTimes}次重连]`, this.logStyle);
+
             setTimeout(() => {
                 this.socket = CC_WECHATGAME ? this.openWxConnect() : this.openH5Connect()
             }, this._reconnectionDelay);
         } else {
+            console.log(`%c [达到最大连续重连失败次数,已重置,30秒后重试]`, this.logStyle);
+
             if(this.socket) {
                 this.socket.close()
             }
-            console.log(`%c [达到最大重连失败次数,Socket关闭]`, this.logStyle);
+
+            this._reconnectTimes = 1
+            this.readyState = 'reconnecting'
+
+            setTimeout(() => {
+                this.socket = CC_WECHATGAME ? this.openWxConnect() : this.openH5Connect()
+            }, 30000);
         }
     }
 
 }
 
 WsManager.prototype.keepAlive = function() {
-    let alivemsg = this.keepAliveMsg
     this.keepAliveTimeout = setInterval(() => {
         if(this.readyState == 'open') {
             let payload = {
@@ -280,20 +288,26 @@ WsManager.prototype.openWxConnect = function() {
         this.emit('open', res)
         console.log(`%c [Socket连接成功: ${this.url.split("&token")[0]}]`, this.logStyle);
 
+        // 连接成功,重置重连次数
+        this._reconnectTimes = 1
+
         // 每隔一段时间发一个心跳包保持连接状态
         this.keepAlive()
     })
 
     _socket.onClose((res) => {
+        console.log(`%c [Socket连接被关闭: ${res}]`, this.logStyle)
+
+        clearInterval(this.keepAliveTimeout)
+
         this.readyState = 'closed'
         
         //只要关闭就重连(暂时性处理)
-        // if(this._reconnection) {
-        //     this.reconnect()
-        // }
+        if(this._reconnection) {
+            this.reconnect()
+        }
 
         this.emit('close', res)
-        console.log(`%c [Socket连接关闭: ${res}]`, this.logStyle)
     })
 
     _socket.onMessage((res) => {
@@ -304,6 +318,10 @@ WsManager.prototype.openWxConnect = function() {
     })
 
     _socket.onError((res) => {
+        console.log(`%c [Socket错误: ${res.errMsg}]`, this.logStyle);
+
+        clearInterval(this.keepAliveTimeout)
+
         if(this._reconnection) {
             if(this.readyState != 'reconnecting') {
                 this.readyState = 'error';
@@ -314,7 +332,6 @@ WsManager.prototype.openWxConnect = function() {
         }
 
         this.emit('error', res.errMsg)
-        console.log(`%c [Socket错误: ${res.errMsg}]`, this.logStyle);
     })
 
     return _socket
@@ -329,23 +346,30 @@ WsManager.prototype.openH5Connect = function() {
         this.emit('open', event)
         console.log(`%c [Socket连接成功: ${this.url.split("&token")[0]}]`, this.logStyle);
 
+        // 连接成功,重置重连次数
+        this._reconnectTimes = 1
+        
         // 每隔一段时间发一个心跳包保持连接状态
         this.keepAlive()
     }
 
     _socket.onclose = (event) => {
+        clearInterval(this.keepAliveTimeout)
+
         this.readyState = 'closed';
         let code = event.code
         let reason = event.reason
         let wasClean = event.wasClean
 
+        console.log(`%c [Socket连接被关闭: ${reason}]`, this.logStyle)
+
         //只要关闭就重连(暂时性处理)
-        // if(this._reconnection) {
-        //     this.reconnect()
-        // }
+        if(this._reconnection) {
+            this.reconnect()
+        }
 
         this.emit('close', event)
-        console.log(`%c [Socket连接关闭: ${reason}]`, this.logStyle)
+
     }
 
     _socket.onmessage = (event) => {
@@ -356,6 +380,10 @@ WsManager.prototype.openH5Connect = function() {
     }
 
     _socket.onerror = (event) => {
+        console.log(`%c [Socket错误: ${JSON.stringify(event)}]`, this.logStyle);
+
+        clearInterval(this.keepAliveTimeout)
+
         if(this._reconnection) {
             if(this.readyState != 'reconnecting') {
                 this.readyState = 'error';
@@ -366,7 +394,6 @@ WsManager.prototype.openH5Connect = function() {
         }
 
         this.emit(event)
-        console.log(`%c [Socket错误: ${JSON.stringify(event)}]`, this.logStyle);
     }
     return _socket
 }

+ 46 - 37
assets/scripts/quest/QuestMainItem.js

@@ -1,4 +1,6 @@
 const Api = require('../net/Api');
+const DWTool = require("../utils/DWTool");
+const itemList = require('../data/item');
 
 cc.Class({
     extends: cc.Component,
@@ -16,11 +18,6 @@ cc.Class({
             default: [],
             type: [cc.Node]
         },
-        giftFrames: {
-            tooltip: '奖励图片素材',
-            default: [],
-            type: [cc.SpriteFrame]
-        },
         starFrames: {
             tooltip: '星星图片素材',
             default: [],
@@ -79,15 +76,6 @@ cc.Class({
         } else {
             let level = sn == 0 ? 0 : sn - 1
             let nameLevelMap = ['I', 'II', 'III', 'IV', 'V']
-            let giftType
-            let giftCount
-            
-            this.giftMap.forEach(n => {
-                if(task[n] > 0) {
-                    giftType = n
-                    giftCount = task[n]
-                }
-            })
     
             // 设置当前任务标题
             this.questTitle.string = `${task.name}(${nameLevelMap[level]})`
@@ -101,9 +89,15 @@ cc.Class({
             // 设置任务阶段进度条
             let aimValue = task.aimValue > task.totalAimValue ? task.totalAimValue : task.aimValue
             this._setProgress(aimValue, task.totalAimValue)
-        
+            
+            this.giftItem = Object.assign({
+                itemCount: task.itemCount
+            }, itemList.find(n => {
+                return n.id == task.itemId
+            }))
+
             // 设置任务领取按钮
-            this._setGiftBtn(task.status, giftType, giftCount)
+            this._setGiftBtn(task.status)
         }
     },
 
@@ -138,15 +132,30 @@ cc.Class({
                 sn: this.task.sn
             },
             success: (res) => {
+                let updatRes = {
+                    coin: 0,
+                    diamond: 0,
+                    ticket: 0
+                }
+                if(this.giftItem.id == 10001) {
+                    updatRes.coin = this.giftItem.itemCount;
+                }
+
+                if(this.giftItem.id == 10002) {
+                    updatRes.diamond = this.giftItem.itemCount;
+                }
+
+                if(this.giftItem.id == 10003) {
+                    updatRes.ticket = this.giftItem.itemCount;
+                }
+
                 // 更新全局userInfo
-                this.quest.updateUserInfo(this.task.coin, this.task.diamond, this.task.ticket)
+                this.quest.updateUserInfo(updatRes.coin, updatRes.diamond, updatRes.ticket)
 
                 // 显示领取奖品动画
-                this.quest.showActGift({
-                    ticket: this.task.ticket,
-                    diamond: this.task.diamond,
-                    coin: this.task.coin
-                })
+                let showFrame = this.giftItem.giftFrame;
+                let showText = `${this.giftItem.name} x ${this.giftItem.itemCount}`
+                this.quest.showMainGift(showFrame, showText)
 
                 // 领取成功,更新当前按钮状态到下一阶段
                 if(this.sn < 5) {
@@ -166,10 +175,10 @@ cc.Class({
     /**
      * 设置任务领取状态按钮
      * @param {number} status 任务状态[0 : 未完成, 1 : 完成可领取, 2 : 完成已领取]
-     * @param {string} giftType 奖励类型[ticket: 艺人券, diamond: 钻石, coin: 金币]
-     * @param {number} giftCount 奖励数量
      */
-    _setGiftBtn (status, giftType, giftCount) {
+    _setGiftBtn (status) {
+        console.log(this.giftItem);
+
         this.questBtns.forEach(n => {
             n.active = false
         })
@@ -194,18 +203,18 @@ cc.Class({
 
         // 设置图标和数量
         if(status != 2) {
-            let countNode = cc.find('/count_label', btn)
-            let spriteNode = cc.find('/sprite', btn)
-            let giftSprite
-            this.giftMap.forEach((value, index) => {
-                if(value == giftType) {
-                    giftSprite = this.giftFrames[index]
-                }
-            })
-            
-    
-            countNode.getComponent('cc.Label').string = `${giftCount}`
-            spriteNode.getComponent('cc.Sprite').spriteFrame = giftSprite
+            DWTool.loadResSpriteFrame(`./item/${this.giftItem.picId}`)
+            .then((spriteFrame) => {
+                let countNode = cc.find('/count_label', btn)
+                let spriteNode = cc.find('/sprite', btn)
+
+                this.giftItem.giftFrame = spriteFrame
+
+                countNode.getComponent('cc.Label').string = `${this.giftItem.itemCount}`
+                spriteNode.getComponent('cc.Sprite').spriteFrame = spriteFrame
+            }).catch((err) => {
+                console.log(err);
+            });
         }
     },
 

+ 13 - 0
assets/scripts/quest/QuestPopup.js

@@ -190,6 +190,19 @@ cc.Class({
         })
     },
 
+    /**
+     * 显示领取奖励动画
+     * @param {cc.SpriteFrame} showFrame 图片素材
+     * @param {string} showText 显示文案
+     */
+    showMainGift (showFrame, showText) {
+        GameModule.audioMng.playGift()
+        this.mask.zIndex = 12
+        this.actGift.active = true
+        cc.find('/gift_sprite', this.actGift).getComponent('cc.Sprite').spriteFrame = showFrame
+        cc.find('/gift_label', this.actGift).getComponent('cc.Label').string = showText
+    },
+
     hideActGift () {
         this.mask.zIndex = 10
         this.actGift.active = false

+ 36 - 0
assets/scripts/utils/Bundle.js

@@ -38,6 +38,7 @@
              * @property {tutorial.Message.IReportData|null} [reportData] Message reportData
              * @property {string|null} [msg] Message msg
              * @property {tutorial.Message.IBuildingItems|null} [buildingItems] Message buildingItems
+             * @property {number|Long|null} [rUid] Message rUid
              */
     
             /**
@@ -112,6 +113,14 @@
             Message.prototype.buildingItems = null;
     
             /**
+             * Message rUid.
+             * @member {number|Long} rUid
+             * @memberof tutorial.Message
+             * @instance
+             */
+            Message.prototype.rUid = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
+    
+            /**
              * Creates a new Message instance using the specified properties.
              * @function create
              * @memberof tutorial.Message
@@ -149,6 +158,8 @@
                     writer.uint32(/* id 6, wireType 2 =*/50).string(message.msg);
                 if (message.buildingItems != null && message.hasOwnProperty("buildingItems"))
                     $root.tutorial.Message.BuildingItems.encode(message.buildingItems, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim();
+                if (message.rUid != null && message.hasOwnProperty("rUid"))
+                    writer.uint32(/* id 8, wireType 0 =*/64).int64(message.rUid);
                 return writer;
             };
     
@@ -204,6 +215,9 @@
                     case 7:
                         message.buildingItems = $root.tutorial.Message.BuildingItems.decode(reader, reader.uint32());
                         break;
+                    case 8:
+                        message.rUid = reader.int64();
+                        break;
                     default:
                         reader.skipType(tag & 7);
                         break;
@@ -280,6 +294,9 @@
                     if (error)
                         return "buildingItems." + error;
                 }
+                if (message.rUid != null && message.hasOwnProperty("rUid"))
+                    if (!$util.isInteger(message.rUid) && !(message.rUid && $util.isInteger(message.rUid.low) && $util.isInteger(message.rUid.high)))
+                        return "rUid: integer|Long expected";
                 return null;
             };
     
@@ -352,6 +369,15 @@
                         throw TypeError(".tutorial.Message.buildingItems: object expected");
                     message.buildingItems = $root.tutorial.Message.BuildingItems.fromObject(object.buildingItems);
                 }
+                if (object.rUid != null)
+                    if ($util.Long)
+                        (message.rUid = $util.Long.fromValue(object.rUid)).unsigned = false;
+                    else if (typeof object.rUid === "string")
+                        message.rUid = parseInt(object.rUid, 10);
+                    else if (typeof object.rUid === "number")
+                        message.rUid = object.rUid;
+                    else if (typeof object.rUid === "object")
+                        message.rUid = new $util.LongBits(object.rUid.low >>> 0, object.rUid.high >>> 0).toNumber();
                 return message;
             };
     
@@ -376,6 +402,11 @@
                     object.reportData = null;
                     object.msg = "";
                     object.buildingItems = null;
+                    if ($util.Long) {
+                        var long = new $util.Long(0, 0, false);
+                        object.rUid = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
+                    } else
+                        object.rUid = options.longs === String ? "0" : 0;
                 }
                 if (message.type != null && message.hasOwnProperty("type"))
                     object.type = options.enums === String ? $root.tutorial.Message.Type[message.type] : message.type;
@@ -391,6 +422,11 @@
                     object.msg = message.msg;
                 if (message.buildingItems != null && message.hasOwnProperty("buildingItems"))
                     object.buildingItems = $root.tutorial.Message.BuildingItems.toObject(message.buildingItems, options);
+                if (message.rUid != null && message.hasOwnProperty("rUid"))
+                    if (typeof message.rUid === "number")
+                        object.rUid = options.longs === String ? String(message.rUid) : message.rUid;
+                    else
+                        object.rUid = options.longs === String ? $util.Long.prototype.toString.call(message.rUid) : options.longs === Number ? new $util.LongBits(message.rUid.low >>> 0, message.rUid.high >>> 0).toNumber() : message.rUid;
                 return object;
             };
     

+ 4 - 1
protobuf/message.proto

@@ -109,7 +109,7 @@ message Message {
     string msg = 6;
 
     message BuildingItems {
-        
+
         int64 buildingId = 1;
 
         Item item = 2;
@@ -124,4 +124,7 @@ message Message {
         int32 count = 2;
     }
 
+    // receive uid
+    int64 rUid = 8;
+
 }