From 8787eb99e6d3872ec714f89bd8f57fe74ca06c7f Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 15 Aug 2019 09:35:37 +0200 Subject: [PATCH] feat(cbs): initial ennemy implementation --- .../datas/gamedata/ennemies/motobug/init.lua | 9 +++++++++ .../gamedata/ennemies/motobug/skills.lua | 3 +++ .../datas/gamedata/ennemies/motobug/stats.lua | 12 ++++++++++++ sonic-radiance.love/game/ennemies.lua | 15 +++++++++++++++ sonic-radiance.love/game/init.lua | 2 ++ .../scenes/battlesystem/actors/ennemy.lua | 19 +++++++++++++------ 6 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 sonic-radiance.love/datas/gamedata/ennemies/motobug/init.lua create mode 100644 sonic-radiance.love/datas/gamedata/ennemies/motobug/skills.lua create mode 100644 sonic-radiance.love/datas/gamedata/ennemies/motobug/stats.lua create mode 100644 sonic-radiance.love/game/ennemies.lua diff --git a/sonic-radiance.love/datas/gamedata/ennemies/motobug/init.lua b/sonic-radiance.love/datas/gamedata/ennemies/motobug/init.lua new file mode 100644 index 0000000..354cb2e --- /dev/null +++ b/sonic-radiance.love/datas/gamedata/ennemies/motobug/init.lua @@ -0,0 +1,9 @@ +return { + name = "Motobug", + fullname = "E-03 Motobug", + type = "badnics", + isAerial = false, + distAttack = false, + turns = 2, + move = 3, +} diff --git a/sonic-radiance.love/datas/gamedata/ennemies/motobug/skills.lua b/sonic-radiance.love/datas/gamedata/ennemies/motobug/skills.lua new file mode 100644 index 0000000..849dc74 --- /dev/null +++ b/sonic-radiance.love/datas/gamedata/ennemies/motobug/skills.lua @@ -0,0 +1,3 @@ +return { +--{attack_name}, +} diff --git a/sonic-radiance.love/datas/gamedata/ennemies/motobug/stats.lua b/sonic-radiance.love/datas/gamedata/ennemies/motobug/stats.lua new file mode 100644 index 0000000..dccb3a6 --- /dev/null +++ b/sonic-radiance.love/datas/gamedata/ennemies/motobug/stats.lua @@ -0,0 +1,12 @@ +return { + hpmax = 200, -- + ppmax = 50, -- + + attack = 10, -- + power = 20, -- + defense = 10, -- + technic = 10, -- + mind = 10, -- + luck = 02, -- + speed = 25, -- +} diff --git a/sonic-radiance.love/game/ennemies.lua b/sonic-radiance.love/game/ennemies.lua new file mode 100644 index 0000000..60336f1 --- /dev/null +++ b/sonic-radiance.love/game/ennemies.lua @@ -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 diff --git a/sonic-radiance.love/game/init.lua b/sonic-radiance.love/game/init.lua index f595f53..ad712ff 100644 --- a/sonic-radiance.love/game/init.lua +++ b/sonic-radiance.love/game/init.lua @@ -25,6 +25,7 @@ local Game = Object:extend() local Characters = require "game.characters" +local Ennemies = require "game.ennemies" local binser = require "core.modules.gamesystem.libs.binser" @@ -36,6 +37,7 @@ function Game:new() self.gametime = 0 self.characters = Characters(self) + self.ennemies = Ennemies(self) end function Game:setData(data) diff --git a/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua b/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua index 9f5ca28..32d6a2e 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua @@ -3,11 +3,16 @@ local Ennemy = Battler:extend() 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) self.isEnnemy = true + self.ennid = id or "motobug" self.actionPerTurn = 2 + + self:receiveDatas() + self.hp = self.data.stats.hpmax + self.pp = self.data.stats.ppmax end function Ennemy:draw() @@ -22,7 +27,8 @@ function Ennemy:drawHUD() love.graphics.setColor(0, 0, 0, 1) gui.drawBar(x - 14, y - 38, 26, 4) 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) end @@ -33,11 +39,12 @@ function Ennemy:drawIcon(x, y) love.graphics.setColor(1, 1, 1, 1) end -function Ennemy:getStats() - local stats = {} - stats.speed = 25 +function Ennemy:receiveDatas() + self.data = game.ennemies:getEnnemyData(self.ennid) +end - return stats +function Ennemy:getStats() + return self.data.stats end return Ennemy