/// <summary> /// 显示聊天信息 /// </summary> /// <param name="mRoomMsgInfo"></param> private void RefreshRoomMsgInfo(RoomMsgInfo mRoomMsgInfo) { if (mUIGameModel.GetUser(mRoomMsgInfo.UID) != null) { int pos = GameLogicMgr.Instance.getPlayerIndex(mUIGameModel.GetUser(mRoomMsgInfo.UID).RoomOrder); mPlayerItems[pos].ShowRoomMsgInfo(mRoomMsgInfo); } }
protected override void SendParameter(NetWriter writer, ActionParam actionParam) { if (actionParam.HasValue) { RoomMsgInfo requestPack = actionParam.GetValue <RoomMsgInfo>(); writer.writeString("RoomMessage", JsonUtil.SerializeObject(requestPack)); } }
protected override void SendParameter(NetWriter writer, ActionParam actionParam) { RoomMsgInfo msg = new RoomMsgInfo() { Content = System.Text.Encoding.Default.GetBytes(actionParam.Get <string>("Content")), UID = 885999, }; //writer.writeString("RoomMessage", JsonConvert.SerializeObject(msg)); writer.writeString("RoomMessage", LitJson.JsonMapper.ToJson(msg)); }
protected override void DecodePackage(NetReader reader) { string msg = reader.readString(); //RoomMsgInfo roomMessage = JsonConvert.DeserializeObject<RoomMsgInfo>(reader.readString()); RoomMsgInfo roomMessage = LitJson.JsonMapper.ToObject <RoomMsgInfo>(reader.readString()); //RoomMessage roomMessage = ProtoBufUtils.Deserialize<RoomMessage>(reader.readBytes()); Debug.Log(msg); Debug.Log(roomMessage.UID); Debug.Log(System.Text.Encoding.Default.GetString(roomMessage.Content)); }
public void StopReconding() { ViSpeakRecorder.Instance.StopRecording(); byte[] buffer = _list.ToArray(); //Debug.Log("Length : " + buffer.Length.ToString()); RoomMsgInfo msg = new RoomMsgInfo() { UID = mUIMainModel.PlayerInfo.UserId, MsgType = RoomMsgType.Sound, Content = buffer }; ActionParam actionParam = new ActionParam(msg); Net.Instance.Send((int)ActionType.RoomChatReq, null, actionParam); }
private void OnSendCommonInfoClick(GameObject go) { MsgInfo info = new MsgInfo(); info.MsgContent = go.GetComponent <UILabel>().text; info.MsgIndex = int.Parse(go.name.Replace("ChatInfo", "")); RoomMsgInfo msg = new RoomMsgInfo() { UID = mUIMainModel.PlayerInfo.UserId, MsgType = RoomMsgType.SimpleText, Content = Encoding.UTF8.GetBytes(JsonUtil.SerializeObject(info)) }; ActionParam actionParam = new ActionParam(msg); Net.Instance.Send((int)ActionType.RoomChatReq, null, actionParam); OnCloseClick(null); }
private void OnExpressionClick() { //Send表情请求 RoomMsgInfo msg = new RoomMsgInfo() { UID = mUIMainModel.PlayerInfo.UserId, MsgType = RoomMsgType.Image, Content = Encoding.UTF8.GetBytes(expressionPrefabName) }; ActionParam actionParam = new ActionParam(msg); Net.Instance.Send(1108, null, actionParam); if (OnCloseClick != null) { OnCloseClick(); } }
private void OnSendInfoClick(GameObject go) { if (string.IsNullOrEmpty(mChatInput.value)) { UIDialogMgr.Instance.ShowDialog("聊天信息不能为空"); return; } RoomMsgInfo msg = new RoomMsgInfo() { UID = mUIMainModel.PlayerInfo.UserId, MsgType = RoomMsgType.Text, Content = Encoding.UTF8.GetBytes(mChatInput.value) }; ActionParam actionParam = new ActionParam(msg); Net.Instance.Send((int)ActionType.RoomChatReq, null, actionParam); OnCloseClick(null); }
private void OnBtnClick() { PropParameter propParam = new PropParameter() { idFrom = this.idFrom, idTo = this.idTo, propPrefabName = this.propPrefabName }; //发送道具请求 RoomMsgInfo msg = new RoomMsgInfo() { UID = mUIMainModel.PlayerInfo.UserId, MsgType = RoomMsgType.Prop, Content = Encoding.UTF8.GetBytes(JsonUtil.SerializeObject(propParam)) }; ActionParam actionParam = new ActionParam(msg); Net.Instance.Send(1108, null, actionParam); }
/// <summary> /// 显示聊天信息 /// </summary> /// <param name="mRoomMsgInfo"></param> public void ShowRoomMsgInfo(RoomMsgInfo mRoomMsgInfo) { if (mRoomMsgInfo != null) { if (mRoomMsgInfo.MsgType == RoomMsgType.SimpleText) { MsgInfo info = JsonUtil.DeserializeObject <MsgInfo>(Encoding.UTF8.GetString(mRoomMsgInfo.Content)); mUIChatItem.ShowChatInfo(info.MsgContent); MahjongAudioMgr.Instance.PlayChatSound(mUserInfo.Sex, info.MsgIndex, PlayerPrefs.GetInt(PrefsConstant.AudioType, 0)); } else if (mRoomMsgInfo.MsgType == RoomMsgType.Sound) { MahjongAudioMgr.Instance.PauseBGM(true); ViSpeak.Instance.PlayReconding(mRoomMsgInfo.Content, PlayGM); } else if (mRoomMsgInfo.MsgType == RoomMsgType.Image) { //显示表情 Debug.Log("---------------------------------------显示表情---------------------------------"); GameObject expressionPrefab = Resources.Load <GameObject>("ExpressionPrefab/" + Encoding.UTF8.GetString(mRoomMsgInfo.Content)); GameObject expressionObject = GameObject.Instantiate(expressionPrefab); expressionObject.SetParent(mUIExpressionItem.transform); expressionObject.transform.localPosition = new Vector3(0, 0, 0); expressionObject.transform.localScale = new Vector3(60, 60, 60); Destroy(expressionObject, 3); } else if (mRoomMsgInfo.MsgType == RoomMsgType.Prop) { //显示表情 Debug.Log("---------------------------------------显示道具---------------------------------"); ShowProp(mRoomMsgInfo); } else { mUIChatItem.ShowChatInfo(Encoding.UTF8.GetString(mRoomMsgInfo.Content)); } } }
private void ShowProp(RoomMsgInfo mRoomMsgInfo) { //获取所有玩家 mPlayerItems.Clear(); mPlayerItems.Add(UIGameWindow.Instance.CacheTrans.FindComponent <PlayerInfoItem>("Root/ContainerBottom/PlayerInfo")); mPlayerItems.Add(UIGameWindow.Instance.CacheTrans.FindComponent <PlayerInfoItem>("Root/ContainerRight/PlayerInfo")); mPlayerItems.Add(UIGameWindow.Instance.CacheTrans.FindComponent <PlayerInfoItem>("Root/ContainerTop/PlayerInfo")); mPlayerItems.Add(UIGameWindow.Instance.CacheTrans.FindComponent <PlayerInfoItem>("Root/ContainerLeft/PlayerInfo")); PropParameter parameter = JsonUtil.DeserializeObject <PropParameter>(Encoding.UTF8.GetString(mRoomMsgInfo.Content)); int pos1 = GameLogicMgr.Instance.getPlayerIndex(mUIGameModel.GetUser(parameter.idFrom).RoomOrder); int pos2 = GameLogicMgr.Instance.getPlayerIndex(mUIGameModel.GetUser(parameter.idTo).RoomOrder); var startPos = mPlayerItems[pos1].transform.Find("InfoGroup/HeadIcon").transform.position; var targetPos = mPlayerItems[pos2].transform.Find("InfoGroup/HeadIcon").transform.position; var propItem = GameObject.Instantiate(Resources.Load <GameObject>("PropPrefab/" + parameter.propPrefabName)).GetComponent <PropController>(); propItem.mPosFrom = startPos; propItem.mPosTo = targetPos; propItem.Play(); }
protected override void DecodePackage(NetReader reader) { responsePack = JsonUtil.DeserializeObject <RoomMsgInfo>(reader.readString()); UIModelMgr.Instance.GetModel <UIGameModel>().RefreshRoomMsgInfo(responsePack); }
public void RefreshRoomMsgInfo(RoomMsgInfo msg) { ValueChangeArgs ve = new ValueChangeArgs(UIGameModelConst.KEY_RoomMsgInfo, msg, msg); DispatchValueUpdateEvent(ve); }