public UILabel mLabel; //文本框 /// <summary> /// 设置数据并显示 /// </summary> /// <param name="data">聊天数据</param> /// <param name="pos">坐标,世界坐标</param> /// <param name="call">回调</param> public void SetData(SendReceiveGameChat data, Vector3 pos, eChatTextDirectionType dType) { //设置位置 transform.position = pos; gameObject.SetActive(true); eGameChatContentType _type = (eGameChatContentType)data.chatType; if (_type == eGameChatContentType.Chat)//普通文字 { mLabel.text = data.content; } else if (_type == eGameChatContentType.TexTVoice)//文字语音 { List <ConfigDada> conList = ConfigManager.GetConfigs <TSTGameTxtChatConfig>(); ConfigDada conData = conList.Find(o => o.conIndex == data.faceIndex.ToString()); if (conData == null) { return; } TSTGameTxtChatConfig con = conData as TSTGameTxtChatConfig; mLabel.text = con.name; string voice = data.sex == 1 ? con.soundNameman : con.soundNamewoman; SoundProcess.PlaySound("ChatSound/" + voice); } mBg.width = 20 + mLabel.width;//设置背景长度 DelayRun(2, () => { gameObject.SetActive(false); }); }
/// <summary> /// 显示文字聊天 /// </summary> /// <param name="chat"></param> private void PlayTxtVoiceChat(SendReceiveGameChat chat) { mTxtChatSp.gameObject.SetActive(true); List <ConfigDada> mRulelist = mRulelist = ConfigManager.GetConfigs <TSTGameTxtChatConfig>(); for (int i = 0; i < mRulelist.Count; i++) { TSTGameTxtChatConfig config = mRulelist[i] as TSTGameTxtChatConfig; if (config.id == chat.faceIndex) { mTxtChatSp.GetComponentInChildren <UILabel>().text = config.name; mTxtChatSp.GetComponent <UISprite>().width = mTxtChatSp.GetComponentInChildren <UILabel>().width + 70; int sex = 1; GoldFlowerPlayer player = null; if (XXGoldFlowerGameModel.Inst.mPlayerInfoDic.TryGetValue(chat.fromSeatId, out player)) { sex = player.sex; } if (sex == 1) { SoundProcess.PlaySound("ChatSound/" + config.soundNameman); } else { SoundProcess.PlaySound("ChatSound/" + config.soundNamewoman); } StopCoroutine("DelayHideTxtChat"); StartCoroutine("DelayHideTxtChat"); } } }
private TSTGameTxtChatConfig mCon; //配置表 /// <summary> /// 设置数据并显示 /// </summary> /// <param name="con">配置表</param> /// <param name="call">点击回调方法</param> public void SetData(TSTGameTxtChatConfig con, CallBack <int> call) { mCon = con; mClickCall = call; mLabel.text = mCon.name; }