SoundModel = SoundModel or BaseClass(BaseModel)
|
|
|
|
--npc 相同声音播放间隔
|
|
SoundModel.NPC_SOUND_INTERVAL = 10
|
|
|
|
function SoundModel:__init()
|
|
SoundModel.Instance = self
|
|
--NPC播放声音的时间
|
|
self.last_play_time = 0
|
|
--npc最后一次播放的声音
|
|
self.last_play_sound = ""
|
|
end
|
|
|
|
function SoundModel:getInstance()
|
|
if SoundModel.Instance == nil then
|
|
SoundModel.New();
|
|
end
|
|
return SoundModel.Instance;
|
|
end
|
|
|
|
function SoundModel:IsInLimitTime()
|
|
local insterval = Status.NowTime - self.last_play_time
|
|
if insterval > SoundModel.NPC_SOUND_INTERVAL then
|
|
return false
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
function SoundModel:PlayNpcSound(npc_id)
|
|
local cfg = Config.ConfigNpcSound.Sound[npc_id]
|
|
if cfg then
|
|
local sound = Trim(cfg.sound)
|
|
if sound ~= "" then
|
|
if sound == self.last_play_sound and self:IsInLimitTime() then
|
|
return
|
|
else
|
|
if lua_soundM then
|
|
--播放之前看看有咩有存在之前的音乐
|
|
|
|
if self.sound_id then
|
|
lua_soundM:StopEffect(self,LuaSoundManager.SOUND_TYPE.NPC,self.sound_id)
|
|
end
|
|
|
|
self.last_play_time = Status.NowTime
|
|
self.last_play_sound = Trim(cfg.sound)
|
|
self.sound_id = lua_soundM:PlayEffect(self, Trim(cfg.sound),false,LuaSoundManager.SOUND_TYPE.NPC)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function SoundModel:PlayTaskSound(task_id)
|
|
-- local cfg = Config.ConfigNpcSound.Task[task_id]
|
|
-- if cfg then
|
|
-- local sound = Trim(cfg.sound)
|
|
-- if sound ~= "" then
|
|
-- if lua_soundM then
|
|
-- --播放之前看看有咩有存在之前的音乐
|
|
|
|
-- if self.sound_id then
|
|
-- lua_soundM:StopEffect(self,LuaSoundManager.SOUND_TYPE.NPC,self.sound_id)
|
|
-- end
|
|
|
|
-- self.last_play_time = Status.NowTime
|
|
-- self.last_play_sound = Trim(cfg.sound)
|
|
-- self.sound_id = lua_soundM:PlayEffect(self, Trim(cfg.sound),false,LuaSoundManager.SOUND_TYPE.NPC)
|
|
-- end
|
|
-- end
|
|
-- end
|
|
lua_soundM:PlayUIEffectSound(LuaSoundManager.SOUND_UI.UPGRADE)
|
|
end
|
|
|
|
function SoundModel:PlayTaskCompleteSound(task_id)
|
|
local cfg = Config.ConfigNpcSound.Task[task_id]
|
|
if cfg then
|
|
local sound = Trim(cfg.sound)
|
|
if sound ~= "" then
|
|
if lua_soundM then
|
|
--播放之前看看有咩有存在之前的音乐
|
|
|
|
if self.sound_id then
|
|
lua_soundM:StopEffect(self,LuaSoundManager.SOUND_TYPE.NPC,self.sound_id)
|
|
end
|
|
|
|
self.last_play_time = Status.NowTime
|
|
self.last_play_sound = Trim(cfg.sound)
|
|
self.sound_id = lua_soundM:PlayEffect(self, Trim(cfg.sound),false,LuaSoundManager.SOUND_TYPE.NPC)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function SoundModel:PlayTaskAcceptSound(task_id)
|
|
local cfg = Config.ConfigNpcSound.AcceptTask[task_id]
|
|
if cfg then
|
|
local sound = Trim(cfg.sound)
|
|
if sound ~= "" then
|
|
if lua_soundM then
|
|
--播放之前看看有咩有存在之前的音乐
|
|
|
|
if self.sound_id then
|
|
lua_soundM:StopEffect(self,LuaSoundManager.SOUND_TYPE.NPC,self.sound_id)
|
|
end
|
|
|
|
self.last_play_time = Status.NowTime
|
|
self.last_play_sound = Trim(cfg.sound)
|
|
self.sound_id = lua_soundM:PlayEffect(self, Trim(cfg.sound),false,LuaSoundManager.SOUND_TYPE.NPC)
|
|
end
|
|
end
|
|
end
|
|
end
|