/// <summary> /// 设置牌型和倍率 /// </summary> /// <param name="type"></param> /// <param name="beilv"></param> public void SetCardType(bool show, int type, int beilv) { mCardTypeLabel.gameObject.SetActive(show); mCardBeiLvLabel.gameObject.SetActive(show); mCardTypeLabel.spriteName = "niu_" + type; if (show) { int sex = NiuniuModel.Inst.mPlayerInfoDic[mSeatId].sex; string last = "boy"; if (sex == 1) { last = "boy"; } else { last = "girl"; } SoundProcess.PlaySound("NN/niu_" + type + "_" + last); } if (beilv <= 0) { mCardBeiLvLabel.gameObject.SetActive(false); } else { mCardBeiLvLabel.gameObject.SetActive(true); mCardBeiLvLabel.spriteName = "word_x" + beilv; } mCardBeiLvLabel.MakePixelPerfect(); mCardBeiLvLabel.MakePixelPerfect(); }
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="seatId"></param> private IEnumerator StartRandomZhuang(int seatId, List <int> list) { mRandomZhuangDown = false; TenPlayerUI player = null; for (int k = 0; k < 4; k++) { for (int i = 0; i < list.Count; i++) { if (TryGetPlayer(list[i], out player)) { player.SetRandomZhuangAnimState(true); yield return(new WaitForSeconds(0.15f)); player.SetRandomZhuangAnimState(false); } } } for (int i = 0; i < TenModel.Inst.mSeatList.Count; i++) { if (TryGetPlayer(TenModel.Inst.mSeatList[i], out player)) { player.SetZhuangState(false); if (TenModel.Inst.mSeatList[i] != seatId) { player.SetQiangZhuangResult(false, 0); } } } for (int i = 0; i < TenModel.Inst.mGameedSeatIdList.Count; i++) { if (TryGetPlayer(TenModel.Inst.mGameedSeatIdList[i], out player)) { player.SetRandomZhuangAnimState(false); } } if (TryGetPlayer(seatId, out player)) { mFlyZhuang.gameObject.SetActive(true); mFlyZhuang.gameObject.transform.position = mFlyZhuangPosition; Hashtable args = new Hashtable(); List <object> finishargs = new List <object>(); args.Add("easeType", iTween.EaseType.linear); args.Add("time", 0.4f); args.Add("oncomplete", "OnRandomZhuangFlyFinish"); args.Add("oncompleteparams", seatId); args.Add("oncompletetarget", gameObject); args.Add("position", player.GetZhuangPosition()); iTween.MoveTo(mFlyZhuang, args); } yield return(new WaitForSeconds(0.4f)); mRandomZhuangDown = true; //开始声音 SoundProcess.PlaySound("Ten/SDB_wrnn_start"); }
/// <summary> /// 设置输赢数量 /// </summary> /// <param name="score"></param> public void SetWinLoseScore(float score) { mWinLoseLabel.gameObject.SetActive(true); UISprite sp = mWinLoseLabel.gameObject.GetComponentInChildren <UISprite>(); if (sp != null) { sp.spriteName = score > 0 ? "win_bg" : "lose_bg"; } mWinLoseLabel.bitmapFont = score > 0 ? mWinAtlas : mLoseAtlas; mWinLoseLabel.text = score > 0 ? "+" + score : score + ""; TweenPosition p = mWinLoseLabel.gameObject.AddComponent <TweenPosition>(); p.from = mWinScorePos; p.to = mWinScorePos + new Vector3(0, 110, 0); p.duration = 0.5f; p.AddOnFinished(() => { Destroy(p); Invoke("DelayHideWinScore", 2.0f); }); // if (score > 0) { SoundProcess.PlaySound("Ten/SDB_chip_fall"); } }
public static void PlayMusic(string szMusicName) { if (szMusicName == "") { return; } if (m_szNowMusicName == szMusicName) { return; } if (m_szNowMusicName == "") { m_szNowMusicName = szMusicName; } m_szNowMusicName = szMusicName; m_szSetMusicName = szMusicName; m_fGradualChange = 1.0f; AudioSource AudioObj = m_aMusicPlayList[m_iNowMusicIndex]; m_iNowMusicVolume = AudioObj.volume; if (m_iNowMusicIndex < m_aMusicPlayList.Count) { AudioObj = m_aMusicPlayList[m_iNowMusicIndex]; AudioObj.clip = GetSoundClip(m_sMusicPath, m_szSetMusicName); AudioObj.Play(); AudioObj.volume = 0.5f; } // SoundProcess.SetMusicVolume(m_fMusicVolume); }
/// <summary> /// 换庄 /// </summary> /// <param name="data"></param> public void NetOnChangZhuang(TenOnChangZhuang data) { if (data.random) { StartCoroutine(StartRandomZhuang(data.zhuangSeatId, data.randomSeatList)); } else { ChangZhuang(data.zhuangSeatId); //开始声音 SoundProcess.PlaySound("Ten/SDB_wrnn_start"); } }
// Use this for initialization void Start() { //不可销毁对象 GameObject.DontDestroyOnLoad(this); gameObject.AddComponent <SetTimeout>(); //初始化模块 InitModule(); //游戏网络 InitNetWork(); // InitDelay(); // CallBack call = () => { NetProcess.InitNetWork(GameManager.Instance.Ip, GameManager.Instance.port); //初始化创建管理器 InitSceneMgr(); //初始化音效管理器 SoundProcess.Create(); InitSixSdkManager(); #if YYVOICE //开启YY语音 YYsdkManager.Create(); #endif //加载配置信息 LoadConfig(() => { LoginController loading = Global.Inst.GetController <LoginController>(); loading.OpenWindow(); }); SoundProcess.PlayMusic("BGSOUND"); }; if (mUseUrl) { GetIp(call); } else { call(); } }
public void PlayChatVoice(int index, int sex) { //if (ConfigManager.Create().mChatConfig.data[0].voice.Length > index) { int id = 1; //配置表里面取//ConfigManager.Create().mChatConfig.data[0].voice[index]; if (sex == 1) //男 { SoundProcess.PlaySound(VOICE_CHAT_MAN + id); } else { SoundProcess.PlaySound(VOICE_CHAT_WOMAN + id); } } }
private Dictionary <int, GameObject> mVoiceDic = new Dictionary <int, GameObject>(); //语音聊天喇叭 #region 互动表情 /// <summary> /// 添加一个互动表情 /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="con"></param> public void AddOneInteractionFace(Vector3 from, Vector3 to, SendReceiveGameChat data) { List <ConfigDada> conList = ConfigManager.GetConfigs <TSTHuDongFaceConfig>(); TSTHuDongFaceConfig con = null; for (int i = 0; i < conList.Count; i++) { TSTHuDongFaceConfig temp = conList[i] as TSTHuDongFaceConfig; if (temp.id == data.faceIndex) { con = temp; break; } } if (con == null) { return; } GameObject go = NGUITools.AddChild(mItemRoot, mItem); go.gameObject.SetActive(true); TweenPosition tween = go.GetComponent <TweenPosition>(); UISprite sp = go.GetComponent <UISprite>(); SpriteAnimation anim = go.GetComponent <SpriteAnimation>(); //设置起始点和目标点 mFrom.position = from; mTo.position = to; from = mFrom.localPosition; to = mTo.localPosition; //飞行动画和表情动画 sp.spriteName = con.foreName + "0"; tween.duration = 0.4f; string sound = con.sound; tween.AddOnFinished(() => { anim.SetBegin(con.foreName, 1, con.length); anim.SetDalayDestory(4.0f); SoundProcess.PlaySound("HuDongFaceSound/" + sound); }); tween.from = from; tween.to = to; tween.PlayForward(); }
/// <summary> /// 播放声音 /// </summary> /// <param name="data"></param> public void PlaySound(MJoptInfoData data) { switch (data.ins) { case eMJInstructionsType.PENG: case eMJInstructionsType.GANG: case eMJInstructionsType.HU: PlayInsVoice(data); break; case eMJInstructionsType.HIT: SoundProcess.PlaySound(VOICE_HITCARD); //播放打牌的声音 PlayCardVoice(data.cards[0], data.seatId); break; case eMJInstructionsType.MO: //摸牌 //SoundProcess.PlaySound(VOICE_GETCARD);//播放摸牌的声音 break; } }
/// <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"); } } }
/// <summary> /// 播放牌声音 /// </summary> /// <param name="cardId">牌id</param> /// <param name="seatId">座位号</param> private void PlayCardVoice(int cardId, int seatId) { int sex = MJGameModel.Inst.mRoomPlayers[seatId].sex;//性别 string card = cardId.ToString(); ConfigDada con = ConfigManager.GetConfigs <MJGameCardVoiceConfig>().Find(o => o.conIndex.Equals(card)); if (con != null) { MJGameCardVoiceConfig voiceCon = con as MJGameCardVoiceConfig; if (voiceCon.voice == null || voiceCon.voice.Length == 0) { return; } int index = Random.Range(0, voiceCon.voice.Length); //随机选一个声音 if (sex == 1) //男 { SoundProcess.PlaySound(VOICE_MJ_MAN + voiceCon.voice[index]); } else//女 { SoundProcess.PlaySound(VOICE_MJ_WOMAN + voiceCon.voice[index]); } } }
public void OnVoiceChange(UISlider slider) { SoundProcess.SetEffectVolume(slider.value); //GameModel.Inst.mLastSoundVolume = SoundProcess.SoundVolume; }
public void OnMusicChange(UISlider slider) { SoundProcess.SetMusicVolume(slider.value); //GameModel.Inst.mLastMusicVolume = SoundProcess.MusicVolume; }
/// <summary> /// 音乐改变 /// </summary> public void OnMusicValueChange() { SoundProcess.SetMusicVolume(mMusic.value); }
/// <summary> /// 播放操作声音 /// </summary> /// <param name="data"></param> private void PlayInsVoice(MJoptInfoData data) { if (data.ins == eMJInstructionsType.YPDX)//一炮多响 { if (data.seatIdList != null) { string ins = data.ins.GetHashCode().ToString(); for (int i = 0; i < data.seatIdList.Count; i++) { int sex = MJGameModel.Inst.mRoomPlayers[data.seatIdList[i]].sex;//性别 ConfigDada con = ConfigManager.GetConfigs <MJGameInsVoiceConfig>().Find(o => o.conIndex.Equals(ins)); MJGameInsVoiceConfig voiceCon = con as MJGameInsVoiceConfig; if (voiceCon == null || voiceCon.voice == null || voiceCon.voice.Length == 0) { return; } int index = Random.Range(0, voiceCon.voice.Length); //随机选一个声音 if (sex == 1) //男 { SoundProcess.PlaySound(VOICE_INS_MAN + voiceCon.voice[index]); } else//女 { SoundProcess.PlaySound(VOICE_INS_WOMAN + voiceCon.voice[index]); } } } } else if (data.ins == eMJInstructionsType.PENG || data.ins == eMJInstructionsType.GANG)//碰和杠 { string ins = data.ins.GetHashCode().ToString(); int sex = MJGameModel.Inst.mRoomPlayers[data.seatId].sex;//性别 ConfigDada con = ConfigManager.GetConfigs <MJGameInsVoiceConfig>().Find(o => o.conIndex.Equals(ins)); MJGameInsVoiceConfig voiceCon = con as MJGameInsVoiceConfig; if (voiceCon == null || voiceCon.voice == null || voiceCon.voice.Length == 0) { return; } int index = Random.Range(0, voiceCon.voice.Length); //随机选一个声音 if (sex == 1) //男 { SoundProcess.PlaySound(VOICE_INS_MAN + voiceCon.voice[index]); } else//女 { SoundProcess.PlaySound(VOICE_INS_WOMAN + voiceCon.voice[index]); } //if (data.ins == eMJInstructionsType.GANG)//杠要播放刮风和下雨的声音 //SoundProcess.PlaySound(VOICE_INS_OTHER + voiceCon.subTypeVoice[data.type]); } else if (data.ins == eMJInstructionsType.HU) { string ins = data.ins.GetHashCode().ToString(); int sex = MJGameModel.Inst.mRoomPlayers[data.seatId].sex;//性别 ConfigDada con = ConfigManager.GetConfigs <MJGameInsVoiceConfig>().Find(o => o.conIndex.Equals(ins)); MJGameInsVoiceConfig voiceCon = con as MJGameInsVoiceConfig; if (voiceCon == null || voiceCon.voice == null || voiceCon.voice.Length == 0) { return; } string str = sex == 1 ? VOICE_INS_MAN : VOICE_INS_WOMAN; if ((eHuThrType)data.thrType != eHuThrType.NONE && voiceCon.thrTypeVoice != null && voiceCon.thrTypeVoice.Length > data.thrType)//第三级类型 { SoundProcess.PlaySound(str + voiceCon.thrTypeVoice[data.thrType]); return; } if ((eHuSubType)data.subType != eHuSubType.NONE && voiceCon.subTypeVoice != null && voiceCon.subTypeVoice.Length > data.subType)//第二级类型 { SoundProcess.PlaySound(str + voiceCon.subTypeVoice[data.subType]); return; } if ((eHuType)data.type != eHuType.NONE && voiceCon.voice != null && voiceCon.voice.Length > data.type)//第一级类型 { SoundProcess.PlaySound(str + voiceCon.voice[data.type]); return; } } }
/// <summary> /// 音效改变 /// </summary> public void OnVoiceValueChange() { SoundProcess.SetEffectVolume(mVoice.value); }
void OnClick() { Debug.Log("click " + gameObject.name); SoundProcess.PlaySound("Other/BtnClick", 0.7f); }
/// <summary> /// 设置牌型和倍率 /// </summary> /// <param name="type"></param> /// <param name="beilv"></param> public void SetCardType(bool show, int point, int beilv, bool isSelf = false) { mRetObj.SetActive(show); mCardTypeLabel.gameObject.SetActive(show); mCardBeiLvLabel.gameObject.SetActive(show); Debug.Log("倍率===" + beilv); string retStr = GetShowPrompt(point); mCardTypeLabel.text = retStr; if (show) { int sex = TenModel.Inst.mPlayerInfoDic[mSeatId].sex; string last = "boy"; if (sex == 1) { last = "1"; } else { last = "2"; } string soundStr = ""; switch (point) { case 500: soundStr = "wx"; break; case 600: soundStr = "tw"; break; case 700: soundStr = "rwx"; break; case -1: soundStr = "baodian"; break; default: soundStr = point.ToString(); break; } if (!isSelf) { SoundProcess.PlaySound("Ten/" + soundStr + "_" + last); } } if (beilv <= 0) { mCardBeiLvLabel.gameObject.SetActive(false); } else { mCardBeiLvLabel.gameObject.SetActive(true); mCardBeiLvLabel.spriteName = "word_x" + beilv; } mCardBeiLvLabel.MakePixelPerfect(); mCardBeiLvLabel.MakePixelPerfect(); }