|
- -- 游戏逻辑相关的全局函数
-
- local BGMusicPlayer = require("luaScript.Tools.MusicPlayer")();
-
- --背景音乐的通用接口
- function playBGMusic(key, musicFileName)
-
- playConfig =
- {
- -- 唯一的名字,如果正在播的是这个名字,就忽略
- Name = key;
- -- 需要播放的声音列表,会从中随机一首
- Files = {musicFileName};
- -- 播放几率,[0-100]
- Rate = 100;
- -- 每批的间隔
- IntervalMin = 0;
- IntervalMax = 0;
- -- 一批播放多少次
- PlayCountMin = 1;
- PlayCountMax = 1;
- -- 循环多少批,0表示无限循环
- LoopCount = 0;
- -- 延迟几秒才开始播放
- DelayTime = 0;
- -- 声音停止时的淡出时间(秒)
- FadeOut = 0;
- }
- BGMusicPlayer.playBGMusic(playConfig);
- end
-
- function stopBGMusic()
- return BGMusicPlayer.stopBGMusic();
- end
-
- --音效的通用接口
- function playVoice(voiceFileName)
- local soundVolume = app.systemSetting.info.soundVolume
- local sound = cc.AudioController:getInstance():playSound(voiceFileName, false);
- if sound then
- sound:setGain(soundVolume)
- end
- return sound
- end
-
- function stopVoice(sound)
- if sound then
- cc.AudioController:getInstance():stopSound(sound)
- end
- end
-
-
- -------------------- MUSIC ---------------------------
-
- function playMusicLogin()
- playBGMusic("BG_Login", "res/sound/bg_login.ogg")
- end
-
- function playMusicHall()
- playBGMusic("BG_Hall", "res/sound/bg_hall.ogg")
- end
-
- function playMusicRoom(index)
- if index == 0 then
- playBGMusic("BG_Room", "res/sound/room/bgmusic.ogg")
- else
- playBGMusic("BG_Room", "res/sound/room/bgm.ogg")
- end
- end
-
-
- -------------------- SOUND ---------------------------
-
- -- 播放发牌的音效
- function playVoiceGiveCard()
- playVoice("res/sound/g_flop.ogg")
- end
-
- --播放行为操作音效
- function playVoiceNiuX(NiuX,nUserId)
- if not NiuX then
- return
- end
- local memberInfo = app.room.roomInfo.memberList[nUserId]
- if memberInfo then
- local userInfo = json.decode(memberInfo.userInfo)
- if not userInfo then
- return
- end
-
- --男1女2,默认是男生
- local sexNum = userInfo.sex or 1
- --因为女生用的资源是0
- if tonumber(sexNum) == 2 then
- sexNum = 0
- end
-
- local sex = tostring(sexNum)
- local voiceName = ""
- if tonumber(sexNum) == 1 then
- voiceName = string.format("res/sound/room/gg_ogg/f0_nn%d.ogg", NiuX)
- else
- --女生或者人妖(可能性别保密)进这里播放
- voiceName = string.format("res/sound/room/mm_ogg/f1_nn%d.ogg", NiuX)
- end
-
- playVoice(voiceName)
- end
- end
-
- --播放不抢庄操作音效
- function playVoiceBuQiang(nUserId)
- local memberInfo = app.room.roomInfo.memberList[nUserId]
- if memberInfo then
- local userInfo = json.decode(memberInfo.userInfo)
- if not userInfo then
- return
- end
-
- --男1女2,默认是男生
- local sexNum = userInfo.sex or 1
- --因为女生用的资源是0
- if tonumber(sexNum) == 2 then
- sexNum = 0
- end
-
- local sex = tostring(sexNum)
- local voiceName = ""
- if tonumber(sexNum) == 1 then
- voiceName = "res/sound/room/buqiang_0.ogg"
- else
- --女生或者其他
- voiceName = "res/sound/room/buqiang_1.ogg"
- end
-
- playVoice(voiceName)
- end
- end
-
- --播放抢庄操作音效
- function playVoiceQiang(nUserId)
- local memberInfo = app.room.roomInfo.memberList[nUserId]
- if memberInfo then
- local userInfo = json.decode(memberInfo.userInfo)
- if not userInfo then
- return
- end
-
- --男1女2,默认是男生
- local sexNum = userInfo.sex or 1
- --因为女生用的资源是0
- if tonumber(sexNum) == 2 then
- sexNum = 0
- end
-
- local sex = tostring(sexNum)
- local voiceName = ""
- if tonumber(sexNum) == 1 then
- voiceName = "res/sound/room/qiangzhuang_0.ogg"
- else
- --女生或者其他
- voiceName = "res/sound/room/qiangzhuang_1.ogg"
- end
-
- playVoice(voiceName)
- end
- end
-
- --播放按钮点击音效
- function playBtnEffect()
- playVoice("res/sound/click.ogg")
- end
-
- --播放按钮关闭音效
- function playBtnCloseEffect()
- playVoice("res/sound/effect_return.ogg")
- end
-
- --播放标签页点击音效
- function playBtnTagEffect()
- playVoice("res/sound/effect_biaoqian.ogg")
- end
-
- --播放金币飞
- function playOneCoinEffect()
- playVoice("res/sound/room/coin_big.ogg")
- end
-
- --播放下注
- function playCoinsEffect()
- playVoice("res/sound/room/chips_to_table.ogg")
- end
-
- --播放下注
- function playCoinsFlyEffect()
- playVoice("res/sound/room/coins_fly.ogg")
- end
-
- --播放抢庄家音效
- function playVoiceRootBanker()
- playVoice("res/sound/room/random_banker_lianxu.ogg")
- end
-
- --播放成功失败音效
- function playEndVoice(cardFileName)
- local voiceName = string.format("res/sound/room/%s.ogg", cardFileName)
- playVoice(voiceName)
- end
-
- --播放闹钟
- function playClockVoice()
- local voiceName = "res/sound/time_over.ogg"
- playVoice(voiceName)
- end
|