game: load at start character module
This commit is contained in:
parent
824fcb866b
commit
9a828197e5
2 changed files with 11 additions and 7 deletions
|
@ -26,16 +26,16 @@ local CharacterManager = Object:extend()
|
||||||
|
|
||||||
function CharacterManager:new(controller)
|
function CharacterManager:new(controller)
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
self.namelist = require "datas.characters"
|
self.namelist = require "datas.gamedata.characters"
|
||||||
self.list = {}
|
self.list = {}
|
||||||
self.team = require "datas.characters.baseteam"
|
self.team = require "datas.gamedata.characters.baseteam"
|
||||||
self.active = 1
|
self.active = 1
|
||||||
self:init()
|
self:init()
|
||||||
end
|
end
|
||||||
|
|
||||||
function CharacterManager:init()
|
function CharacterManager:init()
|
||||||
for k, v in pairs(self.namelist) do
|
for k, v in pairs(self.namelist) do
|
||||||
local dir = "datas/characters/" .. v .. ".lua"
|
local dir = "datas/gamedata/characters/" .. v .. ".lua"
|
||||||
local fileinfo = love.filesystem.getInfo(dir)
|
local fileinfo = love.filesystem.getInfo(dir)
|
||||||
if fileinfo ~= nil then
|
if fileinfo ~= nil then
|
||||||
self:initCharacter(v)
|
self:initCharacter(v)
|
||||||
|
@ -45,7 +45,7 @@ end
|
||||||
|
|
||||||
function CharacterManager:getCharacterData(charname)
|
function CharacterManager:getCharacterData(charname)
|
||||||
-- va eprmettre de récupérer les données d'un personnage
|
-- va eprmettre de récupérer les données d'un personnage
|
||||||
return require("datas.characters." .. charname)
|
return require("datas.gamedata.characters." .. charname)
|
||||||
end
|
end
|
||||||
|
|
||||||
function CharacterManager:initCharacter(id)
|
function CharacterManager:initCharacter(id)
|
||||||
|
|
|
@ -23,24 +23,28 @@
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local Game = Object:extend()
|
local Game = Object:extend()
|
||||||
|
local Characters = require "game.characters"
|
||||||
|
|
||||||
local binser = require "libs.binser"
|
local binser = require "libs.binser"
|
||||||
|
|
||||||
function Game:new()
|
function Game:new()
|
||||||
self.slot = -1
|
self.slot = -1
|
||||||
self.gametime = 0
|
self.gametime = 0
|
||||||
|
|
||||||
|
self.characters = Characters(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Game:setData(data)
|
function Game:setData(data)
|
||||||
local data = data
|
local data = data
|
||||||
self.gametime = data.gametime
|
self.gametime = data.gametime
|
||||||
|
self.characters:setData(data.characters)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Game:getData()
|
function Game:getData()
|
||||||
local data = {}
|
local data = {}
|
||||||
data.gametime = self.gametime
|
data.gametime = self.gametime
|
||||||
|
data.characters = self.characters:getData()
|
||||||
|
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue