Ejemplo n.º 1
0
 /// <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);
     }
 }
Ejemplo n.º 2
0
 protected override void SendParameter(NetWriter writer, ActionParam actionParam)
 {
     if (actionParam.HasValue)
     {
         RoomMsgInfo requestPack = actionParam.GetValue <RoomMsgInfo>();
         writer.writeString("RoomMessage", JsonUtil.SerializeObject(requestPack));
     }
 }
Ejemplo n.º 3
0
    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));
    }
Ejemplo n.º 4
0
    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));
    }
Ejemplo n.º 5
0
    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);
    }
Ejemplo n.º 6
0
    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);
    }
Ejemplo n.º 7
0
    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();
        }
    }
Ejemplo n.º 8
0
    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);
    }
Ejemplo n.º 9
0
    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);
    }
Ejemplo n.º 10
0
 /// <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));
         }
     }
 }
Ejemplo n.º 11
0
    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();
    }
Ejemplo n.º 12
0
 protected override void DecodePackage(NetReader reader)
 {
     responsePack = JsonUtil.DeserializeObject <RoomMsgInfo>(reader.readString());
     UIModelMgr.Instance.GetModel <UIGameModel>().RefreshRoomMsgInfo(responsePack);
 }
Ejemplo n.º 13
0
    public void RefreshRoomMsgInfo(RoomMsgInfo msg)
    {
        ValueChangeArgs ve = new ValueChangeArgs(UIGameModelConst.KEY_RoomMsgInfo, msg, msg);

        DispatchValueUpdateEvent(ve);
    }