/** * 截屏 * * */ private IEnumerator GetCapture(PlatformType platformType) { yield return(new WaitForEndOfFrame()); if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { picPath = Application.persistentDataPath; } else if (Application.platform == RuntimePlatform.WindowsPlayer) { picPath = Application.dataPath; } else if (Application.platform == RuntimePlatform.WindowsEditor) { picPath = Application.dataPath; picPath = picPath.Replace("/Assets", null); } picPath = picPath + "/screencapture.png"; MyDebug.Log("picPath:" + picPath); int width = Screen.width; int height = Screen.height; Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false); tex.ReadPixels(new Rect(0, 0, width, height), 0, 0, true); tex.Apply(); byte[] imagebytes = tex.EncodeToPNG(); //转化为png图 tex.Compress(false); //对屏幕缓存进行压缩 MyDebug.Log("imagebytes:" + imagebytes); if (File.Exists(picPath)) { File.Delete(picPath); } File.WriteAllBytes(picPath, imagebytes); //存储png图 Destroy(tex); shareAchievement(platformType); }
private IEnumerator LoadImg(string headIconPath) { //开始下载图片 if (headIconPath != null && headIconPath != "") { WWW www = new WWW(headIconPath); yield return(www); //下载完成,保存图片到路径filePath try { Texture2D texture2D = www.texture; byte[] bytes = texture2D.EncodeToPNG(); //将图片赋给场景上的Sprite Sprite tempSp = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0, 0)); HeadIcon.sprite = tempSp; } catch (Exception e) { MyDebug.Log("LoadImg" + e.Message); } } }
public LoginRequest(int id) { string data = null; MyDebug.Log("----------------4------------------"); headCode = APIS.LOGIN_REQUEST; LoginVo loginvo = new LoginVo(); Random ran = new Random(); string str = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000); loginvo.openId = id.ToString(); MyDebug.Log("----------------5------------------"); loginvo.nickName = "test" + id; loginvo.headIcon = "imgico221"; loginvo.unionid = "12732" + id; loginvo.province = "21s" + id; loginvo.city = "afafsdf"; loginvo.sex = 1; loginvo.IP = GlobalDataScript.getInstance().getIpAddress(); data = JsonMapper.ToJson(loginvo); GlobalDataScript.loginVo = loginvo; GlobalDataScript.loginResponseData = new AvatarVO(); GlobalDataScript.loginResponseData.account = new Account(); GlobalDataScript.loginResponseData.account.city = loginvo.city; GlobalDataScript.loginResponseData.account.openid = loginvo.openId; GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName; GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon; GlobalDataScript.loginResponseData.account.unionid = loginvo.unionid; GlobalDataScript.loginResponseData.account.sex = loginvo.sex; GlobalDataScript.loginResponseData.IP = loginvo.IP; MyDebug.Log("----------------6------------------" + messageContent); messageContent = data; }
public void SetGameStatue(WWW mes) { if (!string.IsNullOrEmpty(mes.error)) { SocketEventHandle.Instance.iscloseLoading = true; ShowReEnterTipDialog("网络连接失败,检查网络后重试!"); return; } JsonData json = JsonMapper.ToObject <JsonData>(mes.text); if (json["code"].Equals("0")) { SocketEngine.Instance.SocketQuit(); string jm = json["data"].ToJson(); MyDebug.Log(jm); JsonData jd = JsonMapper.ToObject <JsonData>(jm); int kindId = int.Parse(jd["kindid"].ToString()); int serverId = int.Parse(jd["serverid"].ToString()); if (kindId == GlobalDataScript.NN_KIND_ID) { SocketNiuNiuEvent.instance.Init(); SocketNiuNiuEvent.instance.ConnectGameServerByServerID(serverId); SocketNiuNiuEvent.instance.isDisConnect = true; } else { SocketSSSEvent.instance.Init(); SocketSSSEvent.instance.isDisConnect = true; SocketSSSEvent.instance.ConnectGameServerByServerID(serverId); } } else { MySceneManager.instance.ScentToMain(); SocketEngine.Instance.SocketQuit(); } }
public void setUI(FinalGameEndItemVo itemData) { MyDebug.Log("--setUI--------------------Panel_Final_Item--------进入-----------------"); if (itemData.getIsMain()) { fangzhu.gameObject.SetActive(true); } else { fangzhu.gameObject.SetActive(false); } MyDebug.Log("--setUI--------------------Panel_Final_Item-------显示----------------"); nickName.text = itemData.getNickname(); ID.text = "ID:" + itemData.uuid + ""; if (itemData.getIsWiner() && itemData.scores > 0) { winer.SetActive(true); } if (itemData.getIsPaoshou() && itemData.dianpao > 0) { paoshou.SetActive(true); } feiCount.text = itemData.fei + ""; zimoCount.text = itemData.zimo + ""; jiepaoCount.text = itemData.jiepao + ""; dianpaoCount.text = itemData.dianpao + ""; angangCount.text = itemData.angang + ""; minggangCount.text = itemData.minggang + ""; finalScore.text = itemData.scores + ""; headIcon = itemData.getIcon(); StartCoroutine(LoadImg()); MyDebug.Log("--setUI--------------------Panel_Final_Item-------赋值完毕----------------"); }
private CustomSocket11() { try { socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //socket.Connect (new IPEndPoint (IPAddress.Parse ("192.168.0.107"), 1101)); socket.Connect(APIS.socketUrl, 1101); if (socket.Connected) { socket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallBack), socket); } } catch (ArgumentNullException e) { MyDebug.Log("argumentNullException: = " + e); //Console.WriteLine (" {0}", e); } catch (SocketException e) { MyDebug.Log("SocketException == " + e); //Console.WriteLine ("SocketException:{0}", e); } }
public void onReturnOnlineResponse(ClientResponse response) { //1.显示剩余牌的张数和圈数 JsonData msgData = JsonMapper.ToObject(response.message); string surplusCards = msgData ["surplusCards"].ToString(); _data.remainCardNum = int.Parse(surplusCards) + 1; _uiHelper.updateRemainCardNum(); int gameRound = int.Parse(msgData ["gameRound"].ToString()); _tableView.remainRoundText.text = gameRound + ""; GlobalData.getInstance().remainRoundCount = gameRound; try { _data.putoutIndex = int.Parse(msgData ["curAvatarIndex"].ToString()); _data.putoutPoint = int.Parse(msgData ["putOffCardPoint"].ToString()); _data.pickIndex = int.Parse(msgData ["pickAvatarIndex"].ToString()); if (msgData.Keys.Contains("currentCardPoint")) { _data.pickPoint = int.Parse(msgData ["currentCardPoint"].ToString()); } } catch (Exception e) { Debug.Log(e.ToString()); } var Hand = _uiHelper.getCardGOs(Direction.B).Hand; if (_data.pickIndex == _data.myIndex || (Hand.Count % 3 == 2)) //把摸的牌放对位置 { if (_data.pickPoint == -2) { var lastCard = Hand [Hand.Count - 1]; _data.pickPoint = lastCard.GetComponent <MyHandCardView> ().getPoint(); _uiHelper.rangeMyHandCard(true); } else { if ((Hand.Count) % 3 != 1) { MyDebug.Log("摸牌" + _data.pickPoint); _uiHelper.removeMyHandCard(_data.pickPoint, 1); _uiHelper.rangeMyHandCard(false); _uiHelper.addPickCard(_data.myIndex, _data.pickPoint); } } MyHandCardView.isPutout = true; } else { if (_data.pickIndex != _data.putoutIndex) { _uiHelper.rangeOtherHandCard(_data.pickIndex, 1); } } //光标指向打牌人 var Table = _uiHelper.getCardGOs(_data.putoutIndex).Table; if (Table.Count == 0) //刚启动 { } else { _uiHelper.lastCardOnTable = Table [Table.Count - 1]; _uiHelper.addPointer(_uiHelper.lastCardOnTable); } }
public LoginRequest(string data) { MyDebug.Log("----------------4------------------"); headCode = APIS.LOGIN_REQUEST; /** * LoginVo loginvo = new LoginVo (); * if (data != null) { * MyDebug.Log (data.toJson()); * try { * * loginvo.openId = (string)data ["openid"]; * loginvo.nickName = (string)data ["nickname"]; * loginvo.headIcon = (string)data ["headimgurl"]; * loginvo.unionid = (string)data ["unionid"]; * loginvo.province = (string)data ["province"]; * loginvo.city = (string)data ["city"]; * string sex = data ["sex"].ToString(); * loginvo.sex = int.Parse(sex); * loginvo.IP = GlobalDataScript.getInstance().getIpAddress(); * } catch (Exception e) { * MyDebug.Log ("微信接口有变动!" + e.Message); * TipsManagerScript.getInstance ().setTips ("请先打开你的微信客户端"); * return; * } * } else { * * } * * * MyDebug.Log ("loginvo.IP" + loginvo.IP); * **/ if (data == null) { LoginVo loginvo = new LoginVo(); Random ran = new Random(); string str = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000); loginvo.openId = "133333333"; MyDebug.Log("----------------5------------------"); loginvo.nickName = "11112322444"; loginvo.headIcon = "imgico221"; loginvo.unionid = "12732233"; loginvo.province = "21sfsd"; loginvo.city = "afafsdf"; loginvo.sex = 1; loginvo.IP = GlobalDataScript.getInstance().getIpAddress(); data = JsonMapper.ToJson(loginvo); GlobalDataScript.loginVo = loginvo; GlobalDataScript.loginResponseData = new AvatarVO(); GlobalDataScript.loginResponseData.account = new Account(); GlobalDataScript.loginResponseData.account.city = loginvo.city; GlobalDataScript.loginResponseData.account.openid = loginvo.openId; GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName; GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon; GlobalDataScript.loginResponseData.account.unionid = loginvo.city; GlobalDataScript.loginResponseData.account.sex = loginvo.sex; GlobalDataScript.loginResponseData.IP = loginvo.IP; } MyDebug.Log("----------------6------------------" + messageContent); messageContent = data; }
public bool compareType(int[] oldCardArray, int[] newCardArray) { if (oldCardArray == null || oldCardArray.Length == 0) { return(false); } if (newCardArray == null || newCardArray.Length == 0) { return(false); } CARDTYPE type1 = getType(oldCardArray); CARDTYPE type2 = getType(newCardArray); MyDebug.Log("compareType+++++++++++++++=====" + type1 + "/////" + type2); if (type1 == type2) { int[] oldCard = new int[oldCardArray.Length]; for (int i = 0; i < oldCardArray.Length; i++) { if (oldCardArray[i] < 52) { oldCard[i] = oldCardArray[i] % 13; } else { oldCard[i] = oldCardArray[i]; // 大小王判断 } } // 从小到大排序 Array.Sort(oldCard); int[] newCard = new int[newCardArray.Length]; for (int i = 0; i < newCardArray.Length; i++) { if (newCardArray[i] < 52) { newCard[i] = newCardArray[i] % 13; } else { newCard[i] = newCardArray[i]; } } // 从小到大排序 Array.Sort(newCard); if (type1 == CARDTYPE.c1) //单牌 { if (oldCard[0] < newCard[0]) { return(true); } } else if (type1 == CARDTYPE.c2 && oldCard[1] < 52 && oldCard[0] != 0 && oldCard[0] != 12) // 对子 { if (oldCard[0] < newCard[0]) { return(true); } } else if (type1 == CARDTYPE.c112233) //连对 { if (newCard.Length == oldCard.Length && oldCard[0] < newCard[0]) { return(true); } } // else if(type1 == CARDTYPE.c311) {//三带2 // List<int>[] a = getCount(oldCard); // List<int>[] b = getCount(newCard); // if( (int)a[2][0] < (int)b[2][0]) { // return true; // } //} else if (type1 == CARDTYPE.c1112223456) //飞机带翅膀 { List <int>[] a = getCount(oldCard); List <int>[] b = getCount(newCard); if (oldCard.Length == newCard.Length && (int)a[2][0] < (int)b[2][0]) { return(true); } } else if (type1 == CARDTYPE.c12345) //顺子 { if (oldCard.Length == newCard.Length && oldCard[0] < newCard[0]) { return(true); } } else if (type1 == CARDTYPE.c4) //炸弹 { if (oldCard[0] < newCard[0]) { return(true); } } else if (type1 == CARDTYPE.c111122) //四带二lan { if (oldCard[0] < newCard[0]) { return(true); } } } else { if (type2 == CARDTYPE.c4) //后面的是炸弹 { return(true); } } return(false); }
public LoginRequest(string data) { headCode = APIS.LOGIN_REQUEST; LoginVo loginvo = new LoginVo(); if (data != null) { MyDebug.Log(data); try { loginvo = JsonMapper.ToObject <LoginVo>(data); /*LitJson.JsonData dataJson = JsonMapper.ToObject<JsonData>(data); * * loginvo.openId = (string)dataJson ["openid"]; * loginvo.nickName = (string)dataJson ["nickname"]; * loginvo.headIcon = (string)dataJson ["headimgurl"]; * loginvo.unionid = (string)dataJson ["unionid"]; * loginvo.province = (string)dataJson ["province"]; * loginvo.city = (string)dataJson ["city"]; * string sex = dataJson ["sex"].ToString(); * loginvo.sex = int.Parse(sex); * loginvo.IP = GlobalDataScript.getInstance().getIpAddress(); */ } catch (Exception e) { MyDebug.Log("微信接口有变动!" + e.Message); TipsManagerScript.getInstance().setTips("请先打开你的微信客户端"); return; } } else { } MyDebug.Log("loginvo.IP" + loginvo.IP); if (data == null) { //LoginVo loginvo = new LoginVo (); System.Random ran = new System.Random(); string str = ran.Next(100, 1000) + "for" + ran.Next(2000, 5000); loginvo.openId = SystemInfo.deviceUniqueIdentifier; loginvo.nickName = SystemInfo.deviceUniqueIdentifier; loginvo.headIcon = "imgicon"; loginvo.unionid = "127"; loginvo.province = "21sfsd"; loginvo.city = "afafsdf"; loginvo.sex = 1; loginvo.IP = GlobalDataScript.getInstance().getIpAddress(); data = JsonMapper.ToJson(loginvo); GlobalDataScript.loginVo = loginvo; GlobalDataScript.loginResponseData = new AvatarVO(); GlobalDataScript.loginResponseData.account = new Account(); GlobalDataScript.loginResponseData.account.city = loginvo.city; GlobalDataScript.loginResponseData.account.openid = loginvo.openId; GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName; GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon; GlobalDataScript.loginResponseData.account.unionid = loginvo.city; GlobalDataScript.loginResponseData.account.sex = loginvo.sex; GlobalDataScript.loginResponseData.IP = loginvo.IP; } messageContent = data; }
public void AddResponse(ClientResponse response) { MyDebug.Log(response.headCode); callBackResponseList.Add(response); MyDebug.Log("----" + response.headCode); }
private void DispatchHandle(ClientResponse response) { MyDebug.Log(response.headCode + "==========================="); switch (response.headCode) { case APIS.CLOSE_RESPONSE: TipsManagerScript.getInstance.setTips(LocalizationManager.GetInstance.GetValue("KEY.20013")); CustomSocket.Instance.CloseSocket(); break; case APIS.LOGIN_RESPONSE: if (loginReply != null) { loginReply(response); } break; case APIS.CREATEROOM_RESPONSE: if (createRoomReply != null) { createRoomReply(response); } break; case APIS.JOIN_ROOM_RESPONSE: if (joinRoomReply != null) { joinRoomReply(response); } break; case APIS.STARTGAME_RESPONSE_NOTICE: if (startGameReply != null) { startGameReply(response); } //startResply = response; //Invoke("StartReplyInvoke", 0.1f); break; case APIS.BACK_BANKER: if (backBanker != null) { backBanker(response); } break; case APIS.BACK_XIAZHU: if (backXiaZhu != null) { backXiaZhu(response); } break; case APIS.MPPICKCARD_RESPONSE: if (MPsendCard != null) { MPsendCard(response); } break; case APIS.PICKCARD_RESPONSE: if (pickCardReply != null) { pickCardReply(response); } //pickCardResply = response; //StartCoroutine(PickReplyInvoke()); break; case APIS.OTHER_PICKCARD_RESPONSE_NOTICE: if (otherPickCardReply != null) { otherPickCardReply(response); } break; case APIS.CHUPAI_RESPONSE: if (otherPutOutCardReply != null) { otherPutOutCardReply(response); } break; case APIS.JOIN_ROOM_NOICE: if (otherJoinRoomReply != null) { otherJoinRoomReply(response); } break; case APIS.CHIPAI_RESPONSE: if (otherChiReply != null) { otherChiReply(response); } break; case APIS.PENGPAI_RESPONSE: if (otherPentReply != null) { otherPentReply(response); } break; case APIS.GANGPAI_RESPONSE: if (gangReply != null) { gangReply(response); } break; case APIS.OTHER_GANGPAI_NOICE: if (otherGangReply != null) { otherGangReply(response); } break; case APIS.RETURN_INFO_RESPONSE: actionBtnReply(response); //actioonResply = response; //StartCoroutine(ActionInvoke()); break; case APIS.HUPAI_RESPONSE: if (huReply != null) { huReply(response); } break; case APIS.HUPAIALL_RESPONSE: if (gameOverReply != null) { gameOverReply(response); } break; case APIS.GAMEOVERALL_RESPONSE: if (ALLgameOverReply != null) { ALLgameOverReply(response); } break; case APIS.OUT_ROOM_RESPONSE: if (quitRoomReply != null) { quitRoomReply(response); } break; case APIS.headRESPONSE: break; case APIS.USER_SHOW_CARD: if (userShowCard != null) { userShowCard(response); } break; case APIS.DISSOLIVE_ROOM_RESPONSE: if (response.message == null) { ShowExit(); } if (dissolveRoomReply != null) { dissolveRoomReply(response); } break; case APIS.DISSOLIVE_ROOM_REQUEST: if (dissloveRoomReq != null) { dissloveRoomReq(response); } break; case APIS.PrepareGame_MSG_RESPONSE: if (readyReply != null) { readyReply(response); } break; case APIS.MicInput_Response: if (micInputReply != null) { micInputReply(response); } break; case APIS.MessageBox_Notice: if (messageBoxReply != null) { messageBoxReply(response); } break; case APIS.ERROR_RESPONSE: if (serviceErrorReply != null) { serviceErrorReply(response); } break; case APIS.BACK_LOGIN_RESPONSE: backResply = response; BackReplyInvoke(); break; case APIS.CARD_CHANGE: if (cardChangeReply != null) { cardChangeReply(response); } break; case APIS.OFFLINE_NOTICE: if (offlineReply != null) { offlineReply(response); } break; case APIS.RETURN_ONLINE_RESPONSE: if (returnGameReply != null) { returnGameReply(response); } break; case APIS.PRIZE_RESPONSE: if (giftReply != null) { giftReply(response); } break; case APIS.Game_FollowBander_Notice: if (followBankerReply != null) { followBankerReply(response); } break; case APIS.ONLINE_NOTICE: if (onlineReply != null) { onlineReply(response); } break; case APIS.GAME_BROADCAST: if (broadcastNoticeReply != null) { broadcastNoticeReply(response); } break; case APIS.CONTACT_INFO_RESPONSE: if (contactInfoReply != null) { contactInfoReply(response); } break; case APIS.HOST_UPDATEDRAW_RESPONSE: if (lotteryReply != null) { lotteryReply(response); } break; case APIS.ZHANJI_REPORTER_REPONSE: if (recordReply != null) { recordReply(response); } break; case APIS.ZHANJI_DETAIL_REPORTER_REPONSE: if (recordDetailReply != null) { recordDetailReply(response); } break; case APIS.GAME_BACK_PLAY_RESPONSE: if (gameBattleReply != null) { gameBattleReply(response); } break; case APIS.TIP_MESSAGE: TipsManagerScript.getInstance.setTips(response.message); break; case APIS.OTHER_TELE_LOGIN: if (otherDeviceLoginReply != null) { otherDeviceLoginReply(response); } break; case APIS.REFRESH_PLAYER_STATE: if (playerStateReply != null) { playerStateReply(response); } break; case APIS.ROOM_OPTION: if (roomOptionReply != null) { roomOptionReply(response); } break; case APIS.SetRoomMark: if (setRoomMark != null) { setRoomMark(response); } break; } }