Example #1
0
 onClickPutCard: function () {   // Gaming状态下出牌
     var canPut = this.canPutCardCheck();
     if (!canPut) {
         return;
     }
     var data = this.roomData;
     var cards = this.readyCards;
     netEngine.send('putCard', {roomId: data.roomId, cards: cards});
     this.player.init();
 },
Example #2
0
 onClickPrepare: function () {   // Waiting状态下点击右下角的准备按钮以准备或取消准备
     var data = this.roomData;
     var myIdx = data.ids.indexOf(hongshi.userData.id);
     var readyState = data.readyStates[myIdx];
     var toPrepare = true;
     if (readyState == 'ready') {
         toPrepare = false;
     }
     netEngine.send('roomPrepare', {roomId: data.roomId, prepare: toPrepare});
 },
Example #3
0
 data.ids.forEach((id)=>{
     if (id != hongshi.userData.id) {
         if (hongshi.playersInfo == null) {
             hongshi.playersInfo = {};
         }
         if (hongshi.playersInfo[id] == null) {
             netEngine.send('getPlayerInfo', {id: id}, (data)=>{
                 hongshi.playersInfo[id] = data;
             });
         }
     }
 });
 onClickCancel: function () {
     if (this.game == null) {
         cc.log('quitGameRequestPanel.onClickCancel:error:no game!');
         return;
     }
     var roomData = this.game.roomData;
     var data = {
         roomId: roomData.roomId,
         request: false,
         isInitiator: false
     };
     netEngine.send('quitGameRequest', data);
 },
Example #5
0
 nativeLoader.loadNativeWithCallbackFilePath(share_id, share_url, (filepath)=>{
     console.log('share:filepath=' + filepath);
     netEngine.send('test', {a: 'begin'});
     if (filepath == null) {
         cc.log('share error: filepath is null!!');
         netEngine.send('test', {a: 'begin error & return'});
         return;
     }
     var info = {
         shareTo: "0",
         mediaType: "2",
         imagePath: "" + filepath,
         thumbSize: "120",
         url: "http://huaban.com/",
         title: "我在欢乐红十打牌,赶快来啊",
         text:   "房间号:" + hongshi.userData.roomId + "," +
                 "游戏局数:" + this.roomData.config.totTurn + "," + 
                 "有亮必跟:" + (this.roomData.config.youliangbigen ? "是" : "否") + "," +
                 "平局翻倍:" + (this.roomData.config.pingjufanbei ? "是" : "否")
     };
     netEngine.send('test', info);
     SDKManager.share(info);
 });
Example #6
0
 netEngine.send('login', sendData, (data)=>{
     if (data == null) {
         var registerData = {};
         // 如果是微信登陆
         if (info != null) {
             registerData = {
                 uid: info.uid,
                 name: info.nickName,
                 avatarUrl: info.avatarUrl,
                 sex: info.sex,
                 city: info.city,
                 language: info.language,
                 isVip: info.isVip,
                 province: info.province,
                 country: info.country,
                 privilege: JSON.stringify(info.privilege),
                 unionid: info.unionid,
                 ip: hongshi.userData.ip
             };
         }
         // 如果不是微信登陆
         else {
             registerData = {
                 uid: uid,
                 name: '游客' + uid,
                 avatarUrl: "http://wx.qlogo.cn/mmopen/Q3auHgzwzM6QaUUp10ojCU23hItZVZ1fFMWpTIo93Z1IBykhLka0xhDbOdic9ssyVdBvCF79ftibCaOJzyHmXEEwJa0AYwsKAFHacRKIjibAKM/0",
                 sex: Math.floor(Math.random() * 3),
                 city: '杭州',
                 language: '中文',
                 isVip: Math.floor(Math.random() * 2),
                 province: '浙江省',
                 country: '中国',
                 privilege: null,
                 unionid: '游客unionId-' + uid,
                 ip: hongshi.userData.ip
             };
         }
         netEngine.send('register', registerData, (resData)=>{
             if (resData.result == true) {
                 hongshi.userData = resData.userData;
                 cc.director.loadScene('scenes/Hall');
             }
         });
     }
     else {
         hongshi.userData = data;
         cc.director.loadScene('scenes/Hall');
     }
 });
 confirm: function () {
     if (this._checkNum()) {
         var roomId = this._getNum();
         netEngine.send('joinRoom', {roomId: roomId}, (data)=>{
             cc.log('EnterRoom afterClick: ' + JSON.stringify(data));
             if (data.roomExist) {
                 hongshi.userData.roomId = this._getNum();
                 cc.director.loadScene('scenes/Game'); 
             }
             else {
                 ui.createScreenMsg('房间号不存在,请重新输入');
                 this.numList = [];
                 this.showNum();
             }
         });
     }
 },
 ScreenShoter.screenShot((filepath)=>{
     console.log('share:filepath=' + filepath);
     if (filepath == null) {
         cc.log('share error: filepath is null!!');
         netEngine.send('test', {a: 'begin error & return'});
         return;
     }
     var info = {
         shareTo: "1",
         mediaType: "2",
         imagePath: "" + filepath,
         thumbSize: "120",
         url: "http://huaban.com/",
         title: "我在欢乐红十打牌,赶快来啊",
         text: "房间号:" + hongshi.userData.roomId
     };
     SDKManager.share(info);
 });
Example #9
0
 onClickPass: function () {  // Gaming状态下Pass
     var data = this.roomData;
     var startIdx = this.roomData.ids.indexOf(hongshi.userData.id);
     if (startIdx == -1) {
         return;
     }
     
     this.player.init();
     var canNotPut = false;
     for (var i = 1; i < 4; i ++) {
         var idx = (startIdx + i) % 4;
         if (this.roomData.putCards[idx].length > 0) {
             canNotPut = true;
             break;
         }
     }
     if (!canNotPut) {
         ui.createScreenMsg('您必须出至少一张牌');
     }
     else {
         netEngine.send('putCard', {roomId: data.roomId, cards: []});
     }
 },
Example #10
0
SDKManager.handleAfterLogin = function () {
    if (this.userPlugin) {
        
        var uid = "" + this.userPlugin.getUserID();
        var info = JSON.parse(this.userPlugin.callStringFuncWithParam('getUserInfo'));

        if (info != null) {
            uid = info.uid;
        }
        // 暂时设置userData.id,下面login或者register返回的数据里面会有id的修改的
        hongshi.userData.id = uid;

        var sendData = {
            uid: uid,
            ip: hongshi.userData.ip,
        };
        netEngine.send('login', sendData, (data)=>{
            if (data == null) {
                var registerData = {};
                // 如果是微信登陆
                if (info != null) {
                    registerData = {
                        uid: info.uid,
                        name: info.nickName,
                        avatarUrl: info.avatarUrl,
                        sex: info.sex,
                        city: info.city,
                        language: info.language,
                        isVip: info.isVip,
                        province: info.province,
                        country: info.country,
                        privilege: JSON.stringify(info.privilege),
                        unionid: info.unionid,
                        ip: hongshi.userData.ip
                    };
                }
                // 如果不是微信登陆
                else {
                    registerData = {
                        uid: uid,
                        name: '游客' + uid,
                        avatarUrl: "http://wx.qlogo.cn/mmopen/Q3auHgzwzM6QaUUp10ojCU23hItZVZ1fFMWpTIo93Z1IBykhLka0xhDbOdic9ssyVdBvCF79ftibCaOJzyHmXEEwJa0AYwsKAFHacRKIjibAKM/0",
                        sex: Math.floor(Math.random() * 3),
                        city: '杭州',
                        language: '中文',
                        isVip: Math.floor(Math.random() * 2),
                        province: '浙江省',
                        country: '中国',
                        privilege: null,
                        unionid: '游客unionId-' + uid,
                        ip: hongshi.userData.ip
                    };
                }
                netEngine.send('register', registerData, (resData)=>{
                    if (resData.result == true) {
                        hongshi.userData = resData.userData;
                        cc.director.loadScene('scenes/Hall');
                    }
                });
            }
            else {
                hongshi.userData = data;
                cc.director.loadScene('scenes/Hall');
            }
        });
    }

};
Example #11
0
 _showRedOrNot: function (showRed) {
     netEngine.send('showRed', {roomId: this.roomData.roomId, showRed: showRed});
 },
Example #12
0
    handle_Waiting: function (data) {
        this.recordState = 'Waiting';
        this.liangHongNode.active = false;
        this.optionNode.active = false;
        this.prepareLayout.active = true;
        this.inviteFriendButton.active = (data.turn == 1);
        if (data.turn == 1 && data.ids[0] == hongshi.userData.id) { // 第一盘并且我是房主
            this.prepareButton.active = false;
            var otherReady = true;
            for (var i = 1; i < 4; i++) {
                if (data.readyStates[i] != 'ready') {
                    otherReady = false;
                    break;
                }
            }
            this.beginButton.active = otherReady;
        }
        else {
            this.prepareButton.active = true;
            this.beginButton.active = false;
        }
        this.waitingShowRedLayout.active = false;
        this.passNodeList.forEach((node)=>{
            node.active = false;
        });
        this.player.init();
        var startIdx = data.ids.indexOf(hongshi.userData.id);
        var otherReady = true;
        for (var i = 0; i < 4; i ++) {
            var idx = (startIdx + i) % 4;
            if (data.ids[idx] == null) {
                this.otherPlayerList[i].node.active = false;
            }
            else {
                this.otherPlayerList[i].node.active = true;
            }
            var innerData = {};
            innerData.id = data.ids[idx];
            innerData.point = data.points[idx];
            if (data.readyStates[idx] == 'ready') {
                innerData.prepared = true;
            }
            else {
                innerData.prepared = false;
            }
            if (data.turn == 1 && idx == 0) {
                innerData.prepared = true;
            }
            innerData.leftCards = data.cards[idx];
            this.otherPlayerList[i].updateWaitingState(innerData);
        }
        if (data.readyStates[startIdx] == 'ready') {    // 说明我已经准备好了,则按钮显示内容为"取消"
            this.prepareLabel.string = "取消";
        }
        else {                          // 说明还没有准备,则按钮显示内容为"准备"
            this.prepareLabel.string = "准备";
        }
        // Waiting阶段不需要时钟,移到toolStorePlace
        this.toolStorePlace.converToNodeWithTime(this.toolStorePlace.node, data.timer);

        // Achevement信息 
        this.achievementPanel.active = (data.turn == 1);
        var roomIdString = "";
        for (var i = 10; i < 1000000; i *= 10) {
            if (data.roomId < i) 
                roomIdString += "0";
        }
        roomIdString += data.roomId;
        this.ac_roomIdLabel.string = roomIdString;
        this.ac_basicPointLabel.string = "1";
        this.ac_turnLabel.string = data.config.totTurn;
        this.ac_biGenLabel.string = (data.config.youliangbigen ? "是" : "否");
        this.ac_doubleLabel.string = (data.config.pingjufanbei ? "是" : "否");
        // gameData信息
        this.gameDataShow(data);
        
        // 获得其他玩家的信息
        var startIdx = data.ids.indexOf(hongshi.userData.id);

        for (var i = 0; i < 4; i ++) {
            let ii = i;
            var idx = (startIdx + ii) % 4;
            var id = data.ids[idx];
            if (hongshi.playersInfo == null) {
                hongshi.playersInfo = {};
            }
            if (hongshi.playersInfo[id] == null) {
                netEngine.send('getPlayerInfo', {id: id}, (data)=>{
                    hongshi.playersInfo[id] = data;
                    cc.log('getPlayerInfo:' + JSON.stringify(data));
                    this.otherPlayerList[ii].updatePlayerInfo(data);
                });
            }
            else {
                this.otherPlayerList[ii].updatePlayerInfo(hongshi.playersInfo[id]);
            }
        }

        data.ids.forEach((id)=>{
            if (id != hongshi.userData.id) {
                if (hongshi.playersInfo == null) {
                    hongshi.playersInfo = {};
                }
                if (hongshi.playersInfo[id] == null) {
                    netEngine.send('getPlayerInfo', {id: id}, (data)=>{
                        hongshi.playersInfo[id] = data;
                    });
                }
            }
        });

        // OfflinePanel 
        this.offlinePanel.active = false;

        // starClick
        if (data.turn == 1) {
            this.starClick_leaveRoomNode.active = true;
            this.starClick_requestQuitGameNode.active = false;
        }
        else {
            this.starClick_leaveRoomNode.active = false;
            this.starClick_requestQuitGameNode.active = true;
        }
    },
Example #13
0
 onClick: function () {
     netEngine.send('roomPrepare', {roomId: hongshi.userData.roomId, prepare: true});
 },