WIP: new-cbs #117

Closed
kazhnuz wants to merge 23 commits from new-cbs into master
7 changed files with 105 additions and 1 deletions
Showing only changes of commit 0710086b25 - Show all commits

View file

@ -0,0 +1,52 @@
local EnnemyController = Object:extend()
local Villain = require "scenes.battlesystem.fighters.ennemy"
local STATS = require "datas.consts.stats"
function EnnemyController:new(scene)
self.super.new(self)
self.scene = scene
self.list = {}
end
function EnnemyController:addAll(ennemies)
local count = self:countList(ennemies)
for i, ennemyBaseData in ipairs(ennemies) do
local ennData = core.datas:parse("ennemytype", ennemyBaseData)
local nbr = ennData.number or 1
for i=1, nbr do
self:add(ennData, count)
end
end
end
function EnnemyController:countList(ennemies)
local count = 0
for i, ennemyBaseData in ipairs(ennemies) do
local ennData = core.datas:parse("ennemytype", ennemyBaseData)
local nbr = ennData.number or 1
count = count + nbr
end
return count
end
function EnnemyController:getEnnemyArchetype(ennData)
if (ennData.archetype ~= nil) then
return ennData.archetype
end
return ennData.name
end
function EnnemyController:add(ennData, count)
local ennemy = {}
ennemy.type = ennData.type
ennemy.name = ennData.name
ennemy.category = ennData.category
ennemy.actor = nil
ennemy.isAlive = true
ennemy.data = ennData
table.insert(self.list, ennemy)
self.scene.world:spawnEnnemy(self:getEnnemyArchetype(ennData), ennemy, count)
end
return EnnemyController

View file

@ -6,6 +6,8 @@ local PauseScreen = require("game.modules.subgames.pause")
local HUD = require("game.modules.subgames.hud")
local TestWorld = require("game.modules.subgames.world.parent")
local EnnemyController = require "game.modules.subgames.ennemies"
function PlayStyle:new(supportedLevels, missionfile)
PlayStyle.super.new(self, false, false)
self.timer = 0
@ -22,6 +24,7 @@ function PlayStyle:new(supportedLevels, missionfile)
self.haveStarted = false
self.canPause = true
self.ennemies = EnnemyController(self)
end
function PlayStyle:loadMissionFile(supportedLevels, missionfile)

View file

@ -0,0 +1,33 @@
local Parent = require("game.modules.subgames.world.actors.fighters.parent")
local Ennemy = Parent:extend()
function Ennemy:new(world, x, y, owner)
self.defaultDir = -1
self.owner = owner
self.data = self.owner.data
Ennemy.super.new(self, world, x, y, self.owner.name)
self:changeSprite(self.owner.name)
end
function Ennemy:getAbstract()
return game.ennemies:getEnnemyData(self.owner.category, self.owner.name)
end
function Ennemy:getFighterHitbox()
return 16, 12, self.abstract.data.hudHeight
end
function Ennemy:isAerial()
return self.abstract.data.isAerial
end
function Ennemy:getCustomSpeed()
return 16
end
function Ennemy:getSpritePath()
return "datas/gamedata/ennemies/" .. self.owner.category .. "/" .. self.owner.name .. "/sprites"
end
return Ennemy

View file

@ -39,7 +39,7 @@ function FighterParent:updateEnd(dt)
end
function FighterParent:animationEnded(name)
self:playStateFunc("animationEnded", name)
end
return FighterParent

View file

@ -19,4 +19,7 @@ Obj.index = {}
Obj.index[01] = Obj.Ring
Obj.index[02] = Obj.Ring
Obj.ennemies = {}
Obj.ennemies["basic"] = require "game.modules.subgames.world.actors.fighters.ennemies"
return Obj

View file

@ -11,6 +11,7 @@ function ParentWorld:new(scene, maptype, mapname)
self.mapname = mapname
self.autorun = false
self.i = 0
end
function ParentWorld:createMapController()
@ -22,6 +23,17 @@ function ParentWorld:loadMapObjects()
self:addInvisibleWalls()
end
function ParentWorld:spawnEnnemy(name, owner, count)
local EnnemyObj = self.obj.ennemies[name]
if (EnnemyObj == nil) then
EnnemyObj = self.obj.ennemies["basic"]
end
local x = math.random(240, 424)
local y = (120 / count) * (self.i)
self.i = self.i + 1
EnnemyObj(self, 240, y, owner)
end
function ParentWorld:newObjFromIndex(id, x, y, z)
self.obj.index[id](self, x, y, z)
end

View file

@ -30,6 +30,7 @@ function CBS:new(battleData)
CBS.super.new(self, {"shoot", "test", "battle"}, "testmissions", {"sonic"})
self.assets:batchImport("assets.battle")
self:playMusic(battleData.music)
self.ennemies:addAll(battleData.ennemies)
end
function CBS:playMusic(music)