feat(cbs): start adding character voices

This commit is contained in:
Kazhnuz 2019-08-19 15:34:52 +02:00
parent 7a8696726b
commit d84001c150
3 changed files with 25 additions and 0 deletions

View file

@ -25,6 +25,27 @@ function Hero:new(world, x, y, charid, charnumber)
self:initSprite() self:initSprite()
self:initChoregraphySystem() self:initChoregraphySystem()
self:initVoices()
end
-- ASSETS FUNCTIONS
-- Load and play assets needed by the character
function Hero:initVoices()
self:addVoiceEffect("move")
self:addVoiceEffect("turnstart")
end
function Hero:addVoiceEffect(name)
local completename = self.charid .. "_" .. name
local path = "datas/gamedata/characters/" .. self.charid .. "/voices/" .. name .. ".wav"
self.assets:newSFX(completename, path)
end
function Hero:talk(name)
local completename = self.charid .. "_" .. name
self.assets.sfx[completename]:play()
end end
-- INFO FUNCTIONS -- INFO FUNCTIONS
@ -49,6 +70,8 @@ function Hero:setActive()
self.world.cursor:set(self.startx, self.starty) self.world.cursor:set(self.startx, self.starty)
self.currentAction = "selectDirection" self.currentAction = "selectDirection"
self:talk("turnstart")
self.directionPrevious = self.direction self.directionPrevious = self.direction
end end
@ -186,6 +209,8 @@ function Hero:validateAction()
self.currentAction = "moving" self.currentAction = "moving"
self.dx, self.dy = self.world.cursor.x, self.world.cursor.y self.dx, self.dy = self.world.cursor.x, self.world.cursor.y
self:talk("move")
self.world.cursor:unset( ) self.world.cursor:unset( )
end end
end end