////////////////////////////////////////////////////////////////////////// //宏定义 cc.Class({ extends: cc.GameView, properties: { //m_btGPS:cc.Node, m_ActionPrefab:cc.Prefab, m_CardViewPrefab:cc.Prefab, //m_btChat: cc.Node, m_lLeftCardCount: cc.Label, // m_LeftCard:cc.Sprite, m_btOpation: cc.Button, m_Piao:cc.Node, m_BtXia1:cc.Toggle, m_BtXia2:cc.Node, m_BtXia5:cc.Node, m_MagicCtrl:cc.Node, m_Trustee:cc.Node, // m_LabHuangZhuang:cc.Label, // m_BirdNode:cc.Node, // m_BirdCard:[cc.Node], // m_CardFrame:[cc.SpriteFrame], m_RulesText:cc.Label, m_subsumlun:cc.Label, m_TableNumber:cc.Label, m_ClubNum:cc.Label, m_Dice:[cc.Node], m_Fengju:cc.Label, m_Rolldice:cc.Prefab, m_NewRolldice:cc.Node, m_noticeNode: cc.Node, m_gotFlowersNode: cc.Node, }, ctor: function() { this.m_ActionArray = new Array(); this.m_UserPosArr = new Array( cc.v2(575, 255), cc.v2(-580, 50), cc.v2(-580, -140), cc.v2(575, 50) ); this.m_UserFaceArr = this.m_UserPosArr; // this.m_UserVoiceArr = new Array( // cc.v2(-262, 255), // cc.v2(-508, 50), // cc.v2(-508, -140), // cc.v2(500, 75) // ); this.m_UserVoiceArr = this.m_UserFaceArr; this.m_UserChatArr = this.m_UserVoiceArr; this.m_ActionPos = new Array( cc.v2(0,180), cc.v2(-380,95), cc.v2(0,-160), cc.v2(380,30) ); this.m_UserInfo = new Array(); //用户信息 this.m_pIClientUserItem = new Array(); this.m_WeaveCard = new Array(); //组合扑克 this.m_bTrustee = new Array(); this.m_bLeave = new Array(); //是否离开 this.m_UserCnt = 4; this.m_bInit = false; this.m_strCheckIP = new Array(4); this.m_strCheckDistance = new Array(6); for(var i = 0; i < 4; i++) { this.m_strCheckIP[i] = new Array(3);// 0:id 1:昵称 2:ip } this.m_noticeArr = []; }, start: function () { this.InitView(); this.Init(); }, Init:function() { if(this.m_bInit == true) return; this.m_bInit = true; this.ResetData(); //玩家头像信息 for(var i=0;i { this.m_NewRolldice.active = false; newRolldiceInstance.destroy(); }, 2); }, ChangeCardBack:function(Index) { // this.m_LeftCard.spriteFrame = this.m_CardFrame[Index]; }, ResetData:function(){ //this.m_Piao.active = false; this.SetGangOperator(0); for(var i =0;i= GameDef.GAME_PLAYER) { console.log("SetTrustee error 1 wLeaveUser < 0 && wLeaveUser >= GameDef.GAME_PLAYER"); } if(this.m_bLeave[wLeaveUser] != bLeave) { //设置数据 this.m_bLeave[wLeaveUser] = bLeave; this.m_UserInfo[wLeaveUser].SetLeave(bLeave); } }, SetViewRoomInfo:function (dwRulesArr, dwServerRules){ // this.UpdateClubID(); //this.m_LbGameRules.string = GameDef.GetRulesStr(dwRulesArr, dwServerRules); this.m_RulesText.string = GameDef.GetRulesStr(dwServerRules,dwRulesArr); this.m_LbTableID.string = ''+this.m_GameClientEngine.m_dwRoomID; //if(this.m_btGPS != null) this.m_btGPS.active = GameDef.IsNoCheat(dwServerRules); var bShow = this.m_GameClientEngine.IsLookonMode(); if (this.m_BtChat) this.m_BtChat.active = !bShow; //GBS功能暂停,暂时隐藏 //if (this.m_BtGPS) this.m_BtGPS.active = !bShow; if (this.m_BtMenu) this.m_BtMenu.active = !bShow; this.m_MagicCtrl.node.active = false; }, UpdateRoomProgress:function (){ this.m_LbGameProgress.string = '圈數:'+GameDef.GetProgress(this.m_GameClientEngine.m_wGameProgress,this.m_GameClientEngine.m_dwServerRules) ; }, // 0:隐藏所有 1:显示按钮 2:显示等待 SetGangOperator:function(wValue) { if(wValue == 1) { this.m_Piao.active = true; this.m_BtXia1.check(); this.m_PiaoScore = 1 if(this.m_GameClientEngine.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_3)//飘123 { this.m_BtXia2.active = true; this.m_BtXia5.active = false; } else if(this.m_GameClientEngine.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_5)//飘135 { this.m_BtXia2.active = false; this.m_BtXia5.active = true; } } else { this.m_Piao.active = false; } }, OnBtPiao:function(tag, data) { this.m_PiaoScore = parseInt(data); }, OnBtEnterPiao:function() { cc.gSoundRes.PlaySound("Button"); this.m_GameClientEngine.OnDoubleOperate(this.m_PiaoScore); this.SetGangOperator(2); }, // OnBtShowGPS:function(){ // if(this.m_GameClientEngine.m_dwRoomID == 0) return; // this.ShowGamePrefab('TableUserGPS', GameDef.KIND_ID,this.node, function(Js){ // this.m_TableGPSCtrl = Js; // this.m_TableGPSCtrl.Init(); // this.m_TableGPSCtrl.UpdateUserData(); // this.m_GameClientEngine.GetTableUserGPS(); // }.bind(this)); // }, // OnGPSAddress:function(GPSInfo){ // this.CheckDistance(GPSInfo); // if(this.m_TableGPSCtrl) // { // for(var i = 0; i < GameDef.GAME_PLAYER; i++) // { // if(this.m_pIClientUserItem[i] != null) // { // this.m_TableGPSCtrl.SetUserAddress(this.m_pIClientUserItem[i]); // } // } // this.m_TableGPSCtrl.UpdateAddress(GPSInfo); // } // }, SetMakeMagicIndex:function(index){ if(this.m_MagicCtrl.node.active) { this.m_MagicCtrl.SetMakeMagicIndex(index); } }, SetHuiPai:function(DingHui,CardData){ if(this.m_MagicCtrl.node.active) { this.m_MagicCtrl.SetHuiPai(DingHui,CardData); } }, ShockHuiPai:function(){ if(this.m_MagicCtrl.node.active) { this.m_MagicCtrl.ShockHuiPai(); } }, SetCurrentAction:function(viewID){ for (let i = 0; i < GameDef.GAME_PLAYER; i++) { if( this.m_UserInfo[i] != null ) { this.m_UserInfo[i].SetCurrentAction(i == viewID); } } }, // ShowBird:function(BirdCard, BirdCardCount) // { // var Self = this; // Self.scheduleOnce(function() // { // Self.m_BirdNode.active = true; // var BirdCardItem = new Array(); // for(var i = 0; i < Self.m_BirdCard.length; i++) // { // Self.m_BirdCard[i].active = i < BirdCardCount; // if(i < BirdCardCount) // { // BirdCardItem[i] = Self.m_BirdCard[i].getComponent("CardItem"); // BirdCardItem[i].SetCardData(BirdCard[i]); // } // } // Self.scheduleOnce(function(){ Self.m_BirdNode.active = false; }.bind(this), 2); // }.bind(this), 1); // }, updateUserCount:function(){ return; var UserCount = GameDef.GetPlayerCount(); if (UserCount == 2 ){ this.m_UserInfo[0].node.active = true; this.m_UserInfo[2].node.active = true; this.m_UserInfo[1].node.active = false; this.m_UserInfo[3].node.active = false; }else{ for (var i = 0; i { if (0 == this.m_noticeArr.length) { this._showBroadcast(noticeStr); } else { this.m_noticeArr.push(noticeStr); } }; if (!this.m_noticeNode.active) { this.m_noticeNode.active = true; this.m_noticeNode.opacity = 0; cc.tween(this.m_noticeNode) .to(0.25, { opacity: 255 }) .call(() => { showNoticeCb(); }) .start(); } else { showNoticeCb(); } }, //游戏跑马灯 _showBroadcast(str) { let noticeNode = this.m_noticeLab.node; noticeNode.stopAllActions(); if(!!str == false || str.length <= 0) { return; } let newShowCb = () => { if (this.m_noticeArr.length <= 0) { cc.tween(this.m_noticeNode) .to(0.25, { opacity: 0 }) .call(() => { this.m_noticeNode.active = false; this.m_noticeNode.opacity = 255; }) .start(); return; } this._showBroadcast(this.m_noticeArr.shift()); }; this.m_noticeLab.string = str; let startX = noticeNode.parent.width / 2 + 20; noticeNode.x = startX; this.scheduleOnce(() => { let endX = -startX - noticeNode.width; let moveTime = (noticeNode.parent.width + noticeNode.width) / 20; cc.tween(noticeNode) .to(moveTime, { x: endX }) .call(newShowCb) .start(); }, 0.25); }, //展示补花 showGotFlowers(viewID, isShow) { if (isNaN(viewID)) { return; } let showNode = this.m_gotFlowersNode.children[viewID]; if (false == !!showNode) { return; } showNode.active = !!isShow; if (!isShow) { return; } showNode.getComponent("SpineAnimationCtrl").playAnimation(); }, //#region 工具函数 //检测同ip CheckIP:function() { for(var i = 0; i < GameDef.GAME_PLAYER; i++) { this.m_strCheckIP[i] = new Array(3);// 0:id 1:昵称 2:ip this.m_strCheckIP[i][0] = 0; } var nIndex = 0; for(var i = 0; i < GameDef.GAME_PLAYER; i++) { if(this.m_pIClientUserItem[i] != null) { for(var j = i+1; j < GameDef.GAME_PLAYER; j++) { if(this.m_pIClientUserItem[j] != null) { if(this.m_pIClientUserItem[i].GetUserIP() == this.m_pIClientUserItem[j].GetUserIP()) { //排重 var bIHas = false; var bJHas = false; for(var k = 0; k < GameDef.GAME_PLAYER; k++) { if(this.m_strCheckIP[k][0] == 0) break; if(this.m_pIClientUserItem[i].GetUserID() == this.m_strCheckIP[k][0]) { bIHas = true; } if(this.m_pIClientUserItem[j].GetUserID() == this.m_strCheckIP[k][0]) { bJHas = true; } } if(bIHas == false) { this.m_strCheckIP[nIndex][0] = this.m_pIClientUserItem[i].GetUserID(); this.m_strCheckIP[nIndex][1] = this.m_pIClientUserItem[i].GetNickName(); this.m_strCheckIP[nIndex][2] = this.m_pIClientUserItem[i].GetUserIP(); nIndex++; } if(bJHas == false) { this.m_strCheckIP[nIndex][0] = this.m_pIClientUserItem[j].GetUserID(); this.m_strCheckIP[nIndex][1] = this.m_pIClientUserItem[j].GetNickName(); this.m_strCheckIP[nIndex][2] = this.m_pIClientUserItem[j].GetUserIP(); nIndex++; } } } } } } }, //检测距离过近 CheckDistance:function(GPSInfo) { for(var i = 0; i < 6; i++) { this.m_strCheckDistance[i] = null; } var nIndex = 0; for(var i = 0; i < GameDef.GAME_PLAYER; i++) { if(GPSInfo[i] == null) continue; for(var j = i+1; j < GameDef.GAME_PLAYER; j++) { if(GPSInfo[j] == null) continue; if( 0 != GPSInfo[i].dlongitude && 0 != GPSInfo[j].dlongitude) { var dis = this.GetDistance(GPSInfo[i].dlatitude, GPSInfo[i].dlongitude, GPSInfo[j].dlatitude, GPSInfo[j].dlongitude); if(dis < 0.05)//50米内 { var tmpName = new Array(2); var tmpIndex = 0; for(var k = 0; k < GameDef.GAME_PLAYER; k++) { if(this.m_pIClientUserItem[k] != null) { var timUserID = this.m_pIClientUserItem[k].GetUserID() ; if(timUserID == GPSInfo[i].dwUserID || timUserID == GPSInfo[j].dwUserID) { tmpName[tmpIndex] = this.m_pIClientUserItem[k].GetNickName(); tmpIndex++; } } } this.m_strCheckDistance[nIndex] = tmpName[0]+' 与 '+tmpName[1]+' 距离过近!' nIndex++; } } } } }, //计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度 GetDistance : function (lat1,lng1,lat2,lng2) { var radLat1 = this._Rad(lat1); var radLat2 = this._Rad(lat2); var a = radLat1 - radLat2; var b = this._Rad(lng1) - this._Rad(lng2); var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2))); s = s *6378.137 ;// EARTH_RADIUS; s = Math.round(s * 10000) / 10000; //输出为公里 return s; }, _Rad :function(d){ return d * Math.PI / 180.0;//经纬度转换成三角函数中度分表形式。 }, });