sonic-bluestreak/sonic-bluestreak.love/game/modules/world/actors/player/weapons.lua

26 lines
632 B
Lua
Raw Permalink Normal View History

2020-04-25 12:29:07 +02:00
local WeaponManager = Object:extend()
local weaponList = require("datas.gamedata.weapons")
function WeaponManager:new(player)
self.player = player
self:switch(1)
end
function WeaponManager:switch(newWeapon)
if (weaponList[newWeapon] ~= nil) then
self.currentWeapon = newWeapon;
self.player.statusbar:setWeapon(self.currentWeapon);
end
end
function WeaponManager:shoot(x, y, z, dir)
weaponData = weaponList[self.currentWeapon]
for i,coord in ipairs(weaponData.launch) do
self.player.obj.Weapon(self.player.world, x + coord[1], y + coord[2], z + coord[3], dir, weaponData)
end
end
return WeaponManager