chore: extract voice system from actor

This commit is contained in:
Kazhnuz 2020-07-24 19:55:11 +02:00
parent bf23dd2056
commit 799a532523
2 changed files with 20 additions and 20 deletions

View file

@ -20,8 +20,6 @@ function Hero:new(world, x, y, owner, charnumber)
self:initSprite()
self:initChoregraphySystem()
self:initVoices()
self.side = "heroes"
end
@ -53,8 +51,6 @@ function Hero:setActive()
self.world.cursor:set(self.startx, self.starty, "cursorMove")
--self:talk("turnstart")
self.directionPrevious = self.direction
end
@ -343,22 +339,6 @@ function Hero:animationEnded(animation)
end
end
function Hero:initVoices()
self:addVoiceEffect("move")
self:addVoiceEffect("turnstart")
end
function Hero:addVoiceEffect(name)
local completename = self.owner.name .. "_" .. name
local path = "datas/gamedata/characters/" .. self.owner.name .. "/voices/" .. name .. ".wav"
self.assets:newSFX(completename, path)
end
function Hero:talk(name)
local completename = self.owner.name .. "_" .. name
self.assets.sfx[completename]:play()
end
-- DRAW FUNCTIONS
-- Draw everything related to the hero

View file

@ -13,6 +13,7 @@ function HeroFighter:new(owner, character, id)
self.super.new(self, owner, true, id)
self.statusbar = StatusBar(self)
self:initVoices()
self.action = nil
@ -47,6 +48,7 @@ end
function HeroFighter:startAction()
core.debug:print("cbs/heroFighter", "launching the action menu")
self.action = nil
self:talk("turnstart")
self.turnSystem.scene.menu:set( self )
end
@ -120,6 +122,24 @@ function HeroFighter:setPP(value, relative)
self.statusbar:updatePP()
end
-- VOICE SYSTEM
function HeroFighter:initVoices()
self:addVoiceEffect("move")
self:addVoiceEffect("turnstart")
end
function HeroFighter:addVoiceEffect(name)
local completename = self.name .. "_" .. name
local path = "datas/gamedata/characters/" .. self.name .. "/voices/" .. name .. ".wav"
self.assets:newSFX(completename, path)
end
function HeroFighter:talk(name)
local completename = self.name .. "_" .. name
self.assets.sfx[completename]:play()
end
-- DRAW FUNCTIONS
function HeroFighter:drawIcon(x, y)
local iconID = 1