feat(cbs): initial ennemy implementation

This commit is contained in:
Kazhnuz 2019-08-15 09:35:37 +02:00
parent 04fab227f8
commit 8787eb99e6
6 changed files with 54 additions and 6 deletions

View file

@ -0,0 +1,9 @@
return {
name = "Motobug",
fullname = "E-03 Motobug",
type = "badnics",
isAerial = false,
distAttack = false,
turns = 2,
move = 3,
}

View file

@ -0,0 +1,3 @@
return {
--{attack_name},
}

View file

@ -0,0 +1,12 @@
return {
hpmax = 200, --
ppmax = 50, --
attack = 10, --
power = 20, --
defense = 10, --
technic = 10, --
mind = 10, --
luck = 02, --
speed = 25, --
}

View file

@ -0,0 +1,15 @@
local EnnemyManager = Object:extend()
function EnnemyManager:new(controller)
self.controller = controller
end
function EnnemyManager:getEnnemyData(ennemy)
local data = require("datas.gamedata.ennemies." .. ennemy)
data.skills = require("datas.gamedata.ennemies." .. ennemy .. ".skills")
data.stats = require("datas.gamedata.ennemies." .. ennemy .. ".stats")
return data
end
return EnnemyManager

View file

@ -25,6 +25,7 @@
local Game = Object:extend() local Game = Object:extend()
local Characters = require "game.characters" local Characters = require "game.characters"
local Ennemies = require "game.ennemies"
local binser = require "core.modules.gamesystem.libs.binser" local binser = require "core.modules.gamesystem.libs.binser"
@ -36,6 +37,7 @@ function Game:new()
self.gametime = 0 self.gametime = 0
self.characters = Characters(self) self.characters = Characters(self)
self.ennemies = Ennemies(self)
end end
function Game:setData(data) function Game:setData(data)

View file

@ -3,11 +3,16 @@ local Ennemy = Battler:extend()
local gui = require "game.modules.gui" local gui = require "game.modules.gui"
function Ennemy:new(world, x, y) function Ennemy:new(world, x, y, id, number)
Ennemy.super.new(self, world, x, y, 0) Ennemy.super.new(self, world, x, y, 0)
self.isEnnemy = true self.isEnnemy = true
self.ennid = id or "motobug"
self.actionPerTurn = 2 self.actionPerTurn = 2
self:receiveDatas()
self.hp = self.data.stats.hpmax
self.pp = self.data.stats.ppmax
end end
function Ennemy:draw() function Ennemy:draw()
@ -22,7 +27,8 @@ function Ennemy:drawHUD()
love.graphics.setColor(0, 0, 0, 1) love.graphics.setColor(0, 0, 0, 1)
gui.drawBar(x - 14, y - 38, 26, 4) gui.drawBar(x - 14, y - 38, 26, 4)
love.graphics.setColor(248/255, 160/255, 0, 1) love.graphics.setColor(248/255, 160/255, 0, 1)
gui.drawBar(x - 14, y - 37, 24, 2) local bar = math.floor(24 * (self.hp / self.data.stats.hpmax))
gui.drawBar(x - 14, y - 37, bar, 2)
love.graphics.setColor(1, 1, 1, 1) love.graphics.setColor(1, 1, 1, 1)
end end
@ -33,11 +39,12 @@ function Ennemy:drawIcon(x, y)
love.graphics.setColor(1, 1, 1, 1) love.graphics.setColor(1, 1, 1, 1)
end end
function Ennemy:getStats() function Ennemy:receiveDatas()
local stats = {} self.data = game.ennemies:getEnnemyData(self.ennid)
stats.speed = 25 end
return stats function Ennemy:getStats()
return self.data.stats
end end
return Ennemy return Ennemy