GameClientView_21201.js 27 KB

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