GameClientView_21201.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. //////////////////////////////////////////////////////////////////////////
  2. //宏定义
  3. cc.Class({
  4. extends: cc.GameView,
  5. properties: {
  6. //m_btGPS:cc.Node,
  7. m_ActionPrefab:cc.Prefab,
  8. m_CardViewPrefab:cc.Prefab,
  9. //m_btChat: cc.Node,
  10. m_lLeftCardCount: cc.Label,
  11. // m_LeftCard:cc.Sprite,
  12. m_btOpation: cc.Button,
  13. m_Piao:cc.Node,
  14. m_BtXia1:cc.Toggle,
  15. m_BtXia2:cc.Node,
  16. m_BtXia5:cc.Node,
  17. m_MagicCtrl:cc.Node,
  18. m_Trustee:cc.Node,
  19. // m_LabHuangZhuang:cc.Label,
  20. // m_BirdNode:cc.Node,
  21. // m_BirdCard:[cc.Node],
  22. // m_CardFrame:[cc.SpriteFrame],
  23. m_RulesText:cc.Label,
  24. m_subsumlun:cc.Label,
  25. m_TableNumber:cc.Label,
  26. m_ClubNum:cc.Label,
  27. m_Dice:[cc.Node],
  28. m_Fengju:cc.Label,
  29. m_Rolldice:cc.Prefab,
  30. m_NewRolldice:cc.Node,
  31. m_noticeNode: cc.Node,
  32. m_gotFlowersNode: cc.Node,
  33. },
  34. ctor: function() {
  35. this.m_ActionArray = new Array();
  36. this.m_UserPosArr = new Array(
  37. cc.v2(575, 255),
  38. cc.v2(-580, 50),
  39. cc.v2(-580, -140),
  40. cc.v2(575, 50)
  41. );
  42. this.m_UserFaceArr = this.m_UserPosArr;
  43. // this.m_UserVoiceArr = new Array(
  44. // cc.v2(-262, 255),
  45. // cc.v2(-508, 50),
  46. // cc.v2(-508, -140),
  47. // cc.v2(500, 75)
  48. // );
  49. this.m_UserVoiceArr = this.m_UserFaceArr;
  50. this.m_UserChatArr = this.m_UserVoiceArr;
  51. this.m_ActionPos = new Array(
  52. cc.v2(0,180),
  53. cc.v2(-380,95),
  54. cc.v2(0,-160),
  55. cc.v2(380,30)
  56. );
  57. this.m_UserInfo = new Array(); //用户信息
  58. this.m_pIClientUserItem = new Array();
  59. this.m_WeaveCard = new Array(); //组合扑克
  60. this.m_bTrustee = new Array();
  61. this.m_bLeave = new Array(); //是否离开
  62. this.m_UserCnt = 4;
  63. this.m_bInit = false;
  64. this.m_strCheckIP = new Array(4);
  65. this.m_strCheckDistance = new Array(6);
  66. for(var i = 0; i < 4; i++)
  67. {
  68. this.m_strCheckIP[i] = new Array(3);// 0:id 1:昵称 2:ip
  69. }
  70. this.m_noticeArr = [];
  71. },
  72. start: function () {
  73. this.InitView();
  74. this.Init();
  75. },
  76. Init:function() {
  77. if(this.m_bInit == true) return;
  78. this.m_bInit = true;
  79. this.ResetData();
  80. //玩家头像信息
  81. for(var i=0;i<GameDef.GAME_PLAYER;i++) {
  82. this.m_UserInfo[i] = cc.instantiate(this.m_UserPrefab);
  83. this.m_UserNode.addChild(this.m_UserInfo[i]);
  84. this.m_UserInfo[i] = this.m_UserInfo[i].getComponent('UserPrefab_'+GameDef.KIND_ID);
  85. this.m_UserInfo[i].Init(this,i);
  86. this.m_UserInfo[i].node.active = false;
  87. }
  88. this.m_MagicCtrl = this.m_MagicCtrl.getComponent('HunPaiCtrl_'+GameDef.KIND_ID);
  89. this.m_MagicCtrl.SetEngine(this.m_GameClientEngine);
  90. this.m_CardView = cc.instantiate(this.m_CardViewPrefab).getComponent('CardView');
  91. this.m_CardNode.addChild(this.m_CardView.node);
  92. this.m_CardView.setClickSendCard(false);
  93. this.RectifyControl(window.SCENE_WIGHT, window.SCENE_HEIGHT);
  94. this.ShowPrefabDLG('MacInfo', this.m_NdPhoneNode);
  95. this.m_PiaoScore = 0;
  96. this.m_Trustee.active = false;
  97. this.m_RulesText.string = "";
  98. this.m_subsumlun.string = this.m_LbGameProgress.string;
  99. this.m_TableNumber.string = this.m_LbTableID.string;
  100. this.m_ClubNum.string = "";
  101. this.m_Fengju.string ="";
  102. },
  103. Fengju: function(cbQuan, cbFeng,display) {
  104. var directions = ["東", "南", "西", "北"];
  105. let cbQuanStr = directions[cbQuan];
  106. let cbFengStr = directions[cbFeng];
  107. this.m_Fengju.string = cbQuanStr + "風"+cbFengStr+"局";
  108. if(!display){
  109. this.m_Fengju.string = "";
  110. }
  111. },
  112. DiceNum: function(dice) {
  113. this.ShowDice(true);
  114. for (var i = 0; i < this.m_Dice.length; i++) {
  115. for (var j = 0; j < this.m_Dice[i].children.length; j++) {
  116. if (dice[i] == j + 1) {
  117. this.m_Dice[i].children[j].active = true;
  118. } else {
  119. this.m_Dice[i].children[j].active = false;
  120. }
  121. }
  122. }
  123. console.log("骰子数",dice)
  124. },
  125. //隐藏显示骰子
  126. ShowDice: function(bShow) {
  127. for (var i = 0; i < this.m_Dice.length; i++) {
  128. this.m_Dice[i].active = bShow;
  129. }
  130. },
  131. //摇骰子
  132. OnRollDice: function(dice) {
  133. let newRolldiceInstance = cc.instantiate(this.m_Rolldice);
  134. this.m_NewRolldice.addChild(newRolldiceInstance);
  135. this.m_NewRolldice.active = true;
  136. newRolldiceInstance.getComponent("Rolldice").rollDice(dice);
  137. this.scheduleOnce(() => {
  138. this.m_NewRolldice.active = false;
  139. newRolldiceInstance.destroy();
  140. }, 2);
  141. },
  142. ChangeCardBack:function(Index)
  143. {
  144. // this.m_LeftCard.spriteFrame = this.m_CardFrame[Index];
  145. },
  146. ResetData:function(){
  147. //this.m_Piao.active = false;
  148. this.SetGangOperator(0);
  149. for(var i =0;i<GameDef.GAME_PLAYER;++i){
  150. this.m_pIClientUserItem[i] = null;
  151. this.m_WeaveCard[i] = new Array(GameDef.MAX_WEAVE);
  152. this.m_bTrustee[i] = false;
  153. this.m_bLeave[i] = false;
  154. }
  155. this.m_wOutCardUser=INVALID_CHAIR;
  156. this.m_cbLeftCardCount = 0;
  157. this.m_lLeftCardCount.string='';
  158. },
  159. //用户信息更新
  160. OnUserEnter: function (pUserItem, wChairID) {
  161. this.Init();
  162. this.m_pIClientUserItem[wChairID] = pUserItem;
  163. this.m_UserInfo[wChairID].SetUserItem(pUserItem);
  164. this.m_UserInfo[wChairID].node.active = true;
  165. if (pUserItem.GetUserStatus() == US_READY) this.m_UserInfo[wChairID].SetReady(pUserItem);
  166. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  167. if(pGlobalUserData.dwUserID != pUserItem.GetUserID()) return;
  168. if(this.m_GameClientEngine.IsLookonMode() == false)
  169. {
  170. //邀请第三方好友暂未开放,先隐藏按钮
  171. // this.m_BtFriend.active = (this.m_GameClientEngine.m_dwRoomID != 0 && this.m_GameClientEngine.m_wGameProgress == 0);
  172. this.m_BtFriend.active =false;
  173. this.m_BtStart.active = pUserItem.GetUserStatus() == US_SIT;
  174. }
  175. //if(pUserItem.GetUserStatus() == US_READY) this.SetUserState(wChairID, 'Ready');
  176. //this.m_UserInfo[wChairID].SetOffLine(pUserItem.GetUserStatus() == US_OFFLINE)
  177. //this.scheduleOnce(function(){this.UpdateGPS();}, 5);
  178. // this.CheckIP();
  179. if(wChairID == GameDef.MYSELF_VIEW_ID){
  180. if(this.m_ChatControl == null){
  181. this.ShowPrefabDLG('ChatPrefab',this.node,function(Js){
  182. this.m_ChatControl = Js;
  183. this.m_ChatControl.ShowSendChat(false);
  184. this.m_ChatControl.InitHook(this);
  185. }.bind(this));
  186. }
  187. if(this.m_VoiceCtrl == null){
  188. this.ShowPrefabDLG('VoiceCtrl',this.node.getChildByName('VoiceNode'),function(Js){
  189. this.m_VoiceCtrl = Js;
  190. this.m_VoiceCtrl.InitVoice(this);
  191. var NdButton = this.m_VoiceCtrl.node.getChildByName('Voice').getChildByName('btVoice');
  192. NdButton.setPosition(570,-170);
  193. }.bind(this));
  194. }
  195. if(this.m_FaceExCtrl == null){
  196. this.ShowPrefabDLG('FaceExCtrl',this.m_AniNode,function(Js){
  197. this.m_FaceExCtrl = Js;
  198. }.bind(this));
  199. }
  200. //this.m_BtStart.active = !(this.m_GameClientEngine.IsLookonMode() || US_READY == pUserItem.GetUserStatus() || US_PLAYING == pUserItem.GetUserStatus());
  201. }
  202. },
  203. OnUserState: function (pUserItem, wChairID) {
  204. this.Init();
  205. this.m_pIClientUserItem[wChairID] = pUserItem;
  206. this.m_UserInfo[wChairID].OnUserOffLine(pUserItem.GetUserStatus() == US_OFFLINE);
  207. this.m_UserInfo[wChairID].SetReady(false);
  208. if (pUserItem.GetUserStatus() == US_READY) {
  209. this.m_UserInfo[wChairID].SetReady(true);
  210. this.m_GameClientEngine.PlayActionSound(pUserItem.GetChairID(), "ZHUNBEI");
  211. if(GameDef.MYSELF_VIEW_ID == wChairID)
  212. this.m_BtStart.active = false;
  213. }
  214. },
  215. OnUserLeave: function (pUserItem, wChairID) {
  216. this.Init();
  217. var ViewID = this.m_GameClientEngine.SwitchViewChairID(wChairID);
  218. for (var i in this.m_UserInfo) {
  219. this.m_UserInfo[i].UserLeave(pUserItem);
  220. }
  221. this.m_pIClientUserItem[wChairID] = null;
  222. },
  223. OnUserScore: function (pUserItem, wChairID) {
  224. // 初始化当前对象的状态
  225. this.Init();
  226. // 将用户项对象赋值给指定椅子ID的客户端用户项数组
  227. this.m_pIClientUserItem[wChairID] = pUserItem;
  228. // 更新指定椅子ID的用户信息对象中的分数
  229. this.m_UserInfo[wChairID].UpdateScore(pUserItem);
  230. },
  231. onLoadOthers:function()
  232. {
  233. },
  234. //调整控件
  235. RectifyControl:function(nWidth, nHeight) {
  236. //玩家信息
  237. for (var i = 0; i < GameDef.GAME_PLAYER; i++) {
  238. this.m_UserInfo[i].SetBenchmarkPos(this.m_UserPosArr[i]);
  239. }
  240. },
  241. OnBnClickedResultFriend:function() {
  242. cc.gSoundRes.PlaySound("Button");
  243. this.m_GameClientEngine.OnResultFriend();
  244. },
  245. OnBnClickedFriendBg:function() {
  246. this.m_WXShare.SetShowType(false);
  247. },
  248. OnBnClickedNextReady:function() {
  249. cc.gSoundRes.PlaySound("Button");
  250. this.m_GameClientEngine.OnNextReady();
  251. },
  252. OnBnClickedFollow:function(){
  253. this.m_GameClientEngine.OnFollow(0,0);
  254. },
  255. OnBnClickedNoAdd:function(){
  256. this.m_GameClientEngine.OnFollow(1,0);
  257. },
  258. OnBnClickedGiveUp:function(){
  259. this.m_GameClientEngine.OnGiveUp();
  260. },
  261. OnBnClickedFourTimes:function(){
  262. this.m_GameClientEngine.OnAddScore(1,0);
  263. },
  264. OnBnClickedEightTimes:function(){
  265. this.m_GameClientEngine.OnAddScore(2,0);
  266. },
  267. OnBnClickedSixteenTimes:function(){
  268. this.m_GameClientEngine.OnAddScore(3,0);
  269. },
  270. OnExitGameCallback:function () {
  271. if (cc.sys.OS_IOS == cc.sys.os) {
  272. jsb.reflection.callStaticMethod("AppActivity", "exitGame");
  273. } else {
  274. jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "exitGame", "()V");
  275. }
  276. },
  277. //取消托管
  278. OnBtCancelTrustee:function()
  279. {
  280. cc.gSoundRes.PlaySound("Button");
  281. this.m_GameClientEngine.OnCancelTrustee(false);
  282. },
  283. //设置托管
  284. SetTrustee:function( wTrusteeUser, bTrustee) {
  285. if(this.m_GameClientEngine.m_ReplayMode) return;
  286. //设置数据
  287. this.m_bTrustee[wTrusteeUser] = bTrustee;
  288. var wMeChairID = this.m_GameClientEngine.GetMeChairID();
  289. var ViewID = this.m_GameClientEngine.SwitchViewChairID(wTrusteeUser);
  290. this.m_UserInfo[ViewID].SetTrustee(bTrustee);
  291. if(wMeChairID == wTrusteeUser)
  292. {
  293. this.m_Trustee.active = bTrustee;
  294. }
  295. },
  296. SetBankerUser:function(wBankerUser) {
  297. //设置用户
  298. if (wBankerUser!=this.m_wBankerUser) {
  299. //设置变量
  300. this.m_wBankerUser=wBankerUser;
  301. for(var i=0;i<GameDef.GAME_PLAYER;i++) {
  302. if( this.m_UserInfo[i].node.active )
  303. this.m_UserInfo[i].SetBanker(i==wBankerUser);
  304. }
  305. }
  306. },
  307. SetCurrentUser(wCurrentUser) {
  308. var ViewID = this.m_GameClientEngine.SwitchViewChairID(wCurrentUser);
  309. for(let i = 0; i < GameDef.GAME_PLAYER; i++) {
  310. this.m_UserInfo[i].SetPlaying(ViewID == i);
  311. }
  312. this.m_CardView.SetCurrentUser(wCurrentUser);
  313. },
  314. //动作信息
  315. SetUserAction:function(wViewChairID,bUserAction,zimo){
  316. //回放回滚
  317. if( this.m_GameClientEngine.m_bRollBack ) return;
  318. // //设置变量
  319. if (wViewChairID < GameDef.GAME_PLAYER){
  320. if( this.m_ActionArray[wViewChairID] == null ){
  321. var ActionPrefab = cc.instantiate(this.m_ActionPrefab);
  322. var ActionNode = ActionPrefab.getComponent('ActionCtrl_'+GameDef.KIND_ID);
  323. this.m_AniNode.addChild(ActionPrefab);
  324. ActionPrefab.setPosition(this.m_ActionPos[wViewChairID]);
  325. this.m_ActionArray[wViewChairID] = ActionNode;
  326. }
  327. this.m_ActionArray[wViewChairID].SetAction(bUserAction,zimo);
  328. }
  329. },
  330. //出牌信息
  331. SetOutCardInfo:function(wViewChairID,cbCardData)
  332. {
  333. },
  334. //设置剩余
  335. SetLeftCardCount:function(cbLeftCardCount){
  336. if (this.m_cbLeftCardCount != cbLeftCardCount||cbLeftCardCount == 0){
  337. this.m_cbLeftCardCount = cbLeftCardCount;
  338. this.m_lLeftCardCount.string = cbLeftCardCount.toString();
  339. }
  340. return;
  341. },
  342. //基础积分
  343. SetCellScore:function(lCellScore){
  344. return;
  345. },
  346. //设置时间
  347. SetUserTimer:function(wChairID, wTimer){
  348. var cbNum = this.m_CardView.m_CenterViewCtrl.setTimerNum(true/*wChairID!=INVALID_CHAIR*/, wTimer);
  349. return true;
  350. },
  351. SetScoreInfo:function(wViewID,lScore){
  352. this.m_UserInfo[wViewID].SetUserScore(lScore);
  353. },
  354. SetPlayStatus:function(wChairID,cbStatus){
  355. },
  356. //设置离开
  357. SetLeave:function(wLeaveUser, bLeave){
  358. //校验数据
  359. if(wLeaveUser < 0 && wLeaveUser >= GameDef.GAME_PLAYER)
  360. {
  361. console.log("SetTrustee error 1 wLeaveUser < 0 && wLeaveUser >= GameDef.GAME_PLAYER");
  362. }
  363. if(this.m_bLeave[wLeaveUser] != bLeave)
  364. {
  365. //设置数据
  366. this.m_bLeave[wLeaveUser] = bLeave;
  367. this.m_UserInfo[wLeaveUser].SetLeave(bLeave);
  368. }
  369. },
  370. SetViewRoomInfo:function (dwRulesArr, dwServerRules){
  371. // this.UpdateClubID();
  372. //this.m_LbGameRules.string = GameDef.GetRulesStr(dwRulesArr, dwServerRules);
  373. this.m_RulesText.string = GameDef.GetRulesStr(dwServerRules,dwRulesArr);
  374. this.m_LbTableID.string = ''+this.m_GameClientEngine.m_dwRoomID;
  375. //if(this.m_btGPS != null) this.m_btGPS.active = GameDef.IsNoCheat(dwServerRules);
  376. var bShow = this.m_GameClientEngine.IsLookonMode();
  377. if (this.m_BtChat) this.m_BtChat.active = !bShow;
  378. //GBS功能暂停,暂时隐藏
  379. //if (this.m_BtGPS) this.m_BtGPS.active = !bShow;
  380. if (this.m_BtMenu) this.m_BtMenu.active = !bShow;
  381. this.m_MagicCtrl.node.active = false;
  382. },
  383. UpdateRoomProgress:function (){
  384. this.m_LbGameProgress.string = '圈數:'+GameDef.GetProgress(this.m_GameClientEngine.m_wGameProgress,this.m_GameClientEngine.m_dwServerRules) ;
  385. },
  386. // 0:隐藏所有 1:显示按钮 2:显示等待
  387. SetGangOperator:function(wValue)
  388. {
  389. if(wValue == 1)
  390. {
  391. this.m_Piao.active = true;
  392. this.m_BtXia1.check();
  393. this.m_PiaoScore = 1
  394. if(this.m_GameClientEngine.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_3)//飘123
  395. {
  396. this.m_BtXia2.active = true;
  397. this.m_BtXia5.active = false;
  398. }
  399. else if(this.m_GameClientEngine.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_5)//飘135
  400. {
  401. this.m_BtXia2.active = false;
  402. this.m_BtXia5.active = true;
  403. }
  404. }
  405. else
  406. {
  407. this.m_Piao.active = false;
  408. }
  409. },
  410. OnBtPiao:function(tag, data)
  411. {
  412. this.m_PiaoScore = parseInt(data);
  413. },
  414. OnBtEnterPiao:function()
  415. {
  416. cc.gSoundRes.PlaySound("Button");
  417. this.m_GameClientEngine.OnDoubleOperate(this.m_PiaoScore);
  418. this.SetGangOperator(2);
  419. },
  420. // OnBtShowGPS:function(){
  421. // if(this.m_GameClientEngine.m_dwRoomID == 0) return;
  422. // this.ShowGamePrefab('TableUserGPS', GameDef.KIND_ID,this.node, function(Js){
  423. // this.m_TableGPSCtrl = Js;
  424. // this.m_TableGPSCtrl.Init();
  425. // this.m_TableGPSCtrl.UpdateUserData();
  426. // this.m_GameClientEngine.GetTableUserGPS();
  427. // }.bind(this));
  428. // },
  429. // OnGPSAddress:function(GPSInfo){
  430. // this.CheckDistance(GPSInfo);
  431. // if(this.m_TableGPSCtrl)
  432. // {
  433. // for(var i = 0; i < GameDef.GAME_PLAYER; i++)
  434. // {
  435. // if(this.m_pIClientUserItem[i] != null)
  436. // {
  437. // this.m_TableGPSCtrl.SetUserAddress(this.m_pIClientUserItem[i]);
  438. // }
  439. // }
  440. // this.m_TableGPSCtrl.UpdateAddress(GPSInfo);
  441. // }
  442. // },
  443. SetMakeMagicIndex:function(index){
  444. if(this.m_MagicCtrl.node.active)
  445. {
  446. this.m_MagicCtrl.SetMakeMagicIndex(index);
  447. }
  448. },
  449. SetHuiPai:function(DingHui,CardData){
  450. if(this.m_MagicCtrl.node.active)
  451. {
  452. this.m_MagicCtrl.SetHuiPai(DingHui,CardData);
  453. }
  454. },
  455. ShockHuiPai:function(){
  456. if(this.m_MagicCtrl.node.active)
  457. {
  458. this.m_MagicCtrl.ShockHuiPai();
  459. }
  460. },
  461. SetCurrentAction:function(viewID){
  462. for (let i = 0; i < GameDef.GAME_PLAYER; i++) {
  463. if( this.m_UserInfo[i] != null )
  464. {
  465. this.m_UserInfo[i].SetCurrentAction(i == viewID);
  466. }
  467. }
  468. },
  469. // ShowBird:function(BirdCard, BirdCardCount)
  470. // {
  471. // var Self = this;
  472. // Self.scheduleOnce(function()
  473. // {
  474. // Self.m_BirdNode.active = true;
  475. // var BirdCardItem = new Array();
  476. // for(var i = 0; i < Self.m_BirdCard.length; i++)
  477. // {
  478. // Self.m_BirdCard[i].active = i < BirdCardCount;
  479. // if(i < BirdCardCount)
  480. // {
  481. // BirdCardItem[i] = Self.m_BirdCard[i].getComponent("CardItem");
  482. // BirdCardItem[i].SetCardData(BirdCard[i]);
  483. // }
  484. // }
  485. // Self.scheduleOnce(function(){ Self.m_BirdNode.active = false; }.bind(this), 2);
  486. // }.bind(this), 1);
  487. // },
  488. updateUserCount:function(){
  489. return;
  490. var UserCount = GameDef.GetPlayerCount();
  491. if (UserCount == 2 ){
  492. this.m_UserInfo[0].node.active = true;
  493. this.m_UserInfo[2].node.active = true;
  494. this.m_UserInfo[1].node.active = false;
  495. this.m_UserInfo[3].node.active = false;
  496. }else{
  497. for (var i = 0; i <GameDef.GAME_PLAYER; i++) {
  498. var wViewID = this.m_GameClientEngine.SwitchViewChairID(i);
  499. this.m_UserInfo[wViewID].node.active = i < UserCount;
  500. }
  501. }
  502. // this.m_TableGPSCtrl.SetUserCount(UserCount);
  503. },
  504. //黄庄次数
  505. // SetHuangZhuang:function(wCount)
  506. // {
  507. // this.m_LabHuangZhuang.string = wCount;
  508. // },
  509. //更新gps
  510. UpdateGPS:function()
  511. {
  512. this.m_GameClientEngine.GetTableUserGPS();
  513. },
  514. onGameBroadcast(noticeStr) {
  515. if(!!noticeStr == false/* || noticeStr.length <= 0 */) {
  516. return;
  517. }
  518. if (false == !!this.m_noticeNode) {
  519. return;
  520. }
  521. let showNoticeCb = () => {
  522. if (0 == this.m_noticeArr.length) {
  523. this._showBroadcast(noticeStr);
  524. } else {
  525. this.m_noticeArr.push(noticeStr);
  526. }
  527. };
  528. if (!this.m_noticeNode.active) {
  529. this.m_noticeNode.active = true;
  530. this.m_noticeNode.opacity = 0;
  531. cc.tween(this.m_noticeNode)
  532. .to(0.25, { opacity: 255 })
  533. .call(() => {
  534. showNoticeCb();
  535. })
  536. .start();
  537. } else {
  538. showNoticeCb();
  539. }
  540. },
  541. //游戏跑马灯
  542. _showBroadcast(str) {
  543. let noticeNode = this.m_noticeLab.node;
  544. noticeNode.stopAllActions();
  545. if(!!str == false || str.length <= 0) {
  546. return;
  547. }
  548. let newShowCb = () => {
  549. if (this.m_noticeArr.length <= 0) {
  550. cc.tween(this.m_noticeNode)
  551. .to(0.25, { opacity: 0 })
  552. .call(() => {
  553. this.m_noticeNode.active = false;
  554. this.m_noticeNode.opacity = 255;
  555. })
  556. .start();
  557. return;
  558. }
  559. this._showBroadcast(this.m_noticeArr.shift());
  560. };
  561. this.m_noticeLab.string = str;
  562. let startX = noticeNode.parent.width / 2 + 20;
  563. noticeNode.x = startX;
  564. this.scheduleOnce(() => {
  565. let endX = -startX - noticeNode.width;
  566. let moveTime = (noticeNode.parent.width + noticeNode.width) / 20;
  567. cc.tween(noticeNode)
  568. .to(moveTime, { x: endX })
  569. .call(newShowCb)
  570. .start();
  571. }, 0.25);
  572. },
  573. //展示补花
  574. showGotFlowers(viewID, isShow) {
  575. if (isNaN(viewID)) {
  576. return;
  577. }
  578. let showNode = this.m_gotFlowersNode.children[viewID];
  579. if (false == !!showNode) {
  580. return;
  581. }
  582. showNode.active = !!isShow;
  583. if (!isShow) {
  584. return;
  585. }
  586. showNode.getComponent("SpineAnimationCtrl").playAnimation();
  587. },
  588. //#region 工具函数
  589. //检测同ip
  590. CheckIP:function()
  591. {
  592. for(var i = 0; i < GameDef.GAME_PLAYER; i++)
  593. {
  594. this.m_strCheckIP[i] = new Array(3);// 0:id 1:昵称 2:ip
  595. this.m_strCheckIP[i][0] = 0;
  596. }
  597. var nIndex = 0;
  598. for(var i = 0; i < GameDef.GAME_PLAYER; i++)
  599. {
  600. if(this.m_pIClientUserItem[i] != null)
  601. {
  602. for(var j = i+1; j < GameDef.GAME_PLAYER; j++)
  603. {
  604. if(this.m_pIClientUserItem[j] != null)
  605. {
  606. if(this.m_pIClientUserItem[i].GetUserIP() == this.m_pIClientUserItem[j].GetUserIP())
  607. {
  608. //排重
  609. var bIHas = false;
  610. var bJHas = false;
  611. for(var k = 0; k < GameDef.GAME_PLAYER; k++)
  612. {
  613. if(this.m_strCheckIP[k][0] == 0) break;
  614. if(this.m_pIClientUserItem[i].GetUserID() == this.m_strCheckIP[k][0])
  615. {
  616. bIHas = true;
  617. }
  618. if(this.m_pIClientUserItem[j].GetUserID() == this.m_strCheckIP[k][0])
  619. {
  620. bJHas = true;
  621. }
  622. }
  623. if(bIHas == false)
  624. {
  625. this.m_strCheckIP[nIndex][0] = this.m_pIClientUserItem[i].GetUserID();
  626. this.m_strCheckIP[nIndex][1] = this.m_pIClientUserItem[i].GetNickName();
  627. this.m_strCheckIP[nIndex][2] = this.m_pIClientUserItem[i].GetUserIP();
  628. nIndex++;
  629. }
  630. if(bJHas == false)
  631. {
  632. this.m_strCheckIP[nIndex][0] = this.m_pIClientUserItem[j].GetUserID();
  633. this.m_strCheckIP[nIndex][1] = this.m_pIClientUserItem[j].GetNickName();
  634. this.m_strCheckIP[nIndex][2] = this.m_pIClientUserItem[j].GetUserIP();
  635. nIndex++;
  636. }
  637. }
  638. }
  639. }
  640. }
  641. }
  642. },
  643. //检测距离过近
  644. CheckDistance:function(GPSInfo)
  645. {
  646. for(var i = 0; i < 6; i++)
  647. {
  648. this.m_strCheckDistance[i] = null;
  649. }
  650. var nIndex = 0;
  651. for(var i = 0; i < GameDef.GAME_PLAYER; i++)
  652. {
  653. if(GPSInfo[i] == null) continue;
  654. for(var j = i+1; j < GameDef.GAME_PLAYER; j++)
  655. {
  656. if(GPSInfo[j] == null) continue;
  657. if( 0 != GPSInfo[i].dlongitude && 0 != GPSInfo[j].dlongitude)
  658. {
  659. var dis = this.GetDistance(GPSInfo[i].dlatitude, GPSInfo[i].dlongitude, GPSInfo[j].dlatitude, GPSInfo[j].dlongitude);
  660. if(dis < 0.05)//50米内
  661. {
  662. var tmpName = new Array(2);
  663. var tmpIndex = 0;
  664. for(var k = 0; k < GameDef.GAME_PLAYER; k++)
  665. {
  666. if(this.m_pIClientUserItem[k] != null)
  667. {
  668. var timUserID = this.m_pIClientUserItem[k].GetUserID() ;
  669. if(timUserID == GPSInfo[i].dwUserID || timUserID == GPSInfo[j].dwUserID)
  670. {
  671. tmpName[tmpIndex] = this.m_pIClientUserItem[k].GetNickName();
  672. tmpIndex++;
  673. }
  674. }
  675. }
  676. this.m_strCheckDistance[nIndex] = tmpName[0]+' 与 '+tmpName[1]+' 距离过近!'
  677. nIndex++;
  678. }
  679. }
  680. }
  681. }
  682. },
  683. //计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
  684. GetDistance : function (lat1,lng1,lat2,lng2)
  685. {
  686. var radLat1 = this._Rad(lat1);
  687. var radLat2 = this._Rad(lat2);
  688. var a = radLat1 - radLat2;
  689. var b = this._Rad(lng1) - this._Rad(lng2);
  690. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
  691. Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
  692. s = s *6378.137 ;// EARTH_RADIUS;
  693. s = Math.round(s * 10000) / 10000; //输出为公里
  694. return s;
  695. },
  696. _Rad :function(d){
  697. return d * Math.PI / 180.0;//经纬度转换成三角函数中度分表形式。
  698. },
  699. });