feat : add equip dialogs
This commit is contained in:
parent
0d4fe92a90
commit
6c451e7aee
13 changed files with 214 additions and 29 deletions
|
@ -23,7 +23,7 @@ function TransitionParent:loadResources()
|
|||
end
|
||||
|
||||
function TransitionParent:update(dt)
|
||||
self.tween:update(dt)
|
||||
self.tween:update(dt * 1.5)
|
||||
end
|
||||
|
||||
function TransitionParent:timerResponse(timer)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
name = "darkgloves",
|
||||
fullname = "Dark Gloves",
|
||||
description = "Gloves engluffed with darkness",
|
||||
conditions = {},
|
||||
effects = {},
|
||||
statsBoost = {
|
||||
attack = 5,
|
||||
hpmax = -10
|
||||
},
|
||||
isEquipement = true,
|
||||
usableInBattle = false,
|
||||
usableOnMap = false,
|
||||
affectEverybody = false,
|
||||
duration = 0
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
name = "slowmoshoes",
|
||||
fullname = "SlowMo Shoes",
|
||||
description = "Shoes that make you slower",
|
||||
conditions = {},
|
||||
effects = {},
|
||||
statsBoost = {
|
||||
speed = -5,
|
||||
mind = 6
|
||||
},
|
||||
isEquipement = true,
|
||||
usableInBattle = false,
|
||||
usableOnMap = false,
|
||||
affectEverybody = false,
|
||||
duration = 0
|
||||
}
|
|
@ -8,4 +8,16 @@ CONST.RANK_A = 80
|
|||
CONST.RANK_S = 100
|
||||
CONST.MULT_HP = 4.5
|
||||
|
||||
CONST.LIST = {"hpmax", "ppmax", "attack", "power", "defense", "mind", "technic", "speed"}
|
||||
|
||||
CONST.SIMPLENAME = {}
|
||||
CONST.SIMPLENAME["hpmax"] = "HP"
|
||||
CONST.SIMPLENAME["ppmax"] = "PP"
|
||||
CONST.SIMPLENAME["attack"] = "ATK"
|
||||
CONST.SIMPLENAME["power"] = "POW"
|
||||
CONST.SIMPLENAME["defense"] = "DEF"
|
||||
CONST.SIMPLENAME["mind"] = "MND"
|
||||
CONST.SIMPLENAME["technic"] = "TEK"
|
||||
CONST.SIMPLENAME["speed"] = "SPD"
|
||||
|
||||
return CONST
|
||||
|
|
|
@ -29,13 +29,13 @@ function CharacterData:setData(data)
|
|||
self.level = data.level
|
||||
self.exp = data.exp
|
||||
self.exp_next = data.exp_next
|
||||
self:createStats()
|
||||
|
||||
self.hp = data.hp
|
||||
self.pp = data.pp
|
||||
self.statuts = data.statuts
|
||||
|
||||
self.equip = data.equip or {}
|
||||
self.equip = data.equip
|
||||
self:createStats()
|
||||
end
|
||||
|
||||
return CharacterData
|
||||
|
|
|
@ -19,14 +19,17 @@ end
|
|||
|
||||
function CharacterEquip:setEquip(category, name)
|
||||
if (not utils.string.isEmpty(self.equip[category])) then
|
||||
game.loot:addItem(category, self.equip[category])
|
||||
game.loot:addItem(category, self.equip[category], 1)
|
||||
end
|
||||
self.equip[category] = name
|
||||
game.loot:removeItem(category, name)
|
||||
game.loot:removeItem(category, name, 1)
|
||||
self.stats = self:createStats()
|
||||
end
|
||||
|
||||
function CharacterEquip:predictStat(category, name)
|
||||
|
||||
function CharacterEquip:predictStat(statName, category, name)
|
||||
local data = itemutils.getItemData(category, name)
|
||||
local boost = data.statsBoost[statName] or 0
|
||||
return self:getStat(statName, category) + boost
|
||||
end
|
||||
|
||||
function CharacterEquip:getEquipStats(stat, ignore)
|
||||
|
|
|
@ -27,6 +27,12 @@ function AbstractCharacter:createStats()
|
|||
for _, name in ipairs(statNames) do
|
||||
stats[name] = self:getStat(name)
|
||||
end
|
||||
if (self.hp ~= nil) then
|
||||
self.hp = math.min(self.hp, stats.hpmax)
|
||||
end
|
||||
if (self.pp ~= nil) then
|
||||
self.pp = math.min(self.pp, stats.ppmax)
|
||||
end
|
||||
|
||||
return stats
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local CharacterLevel = Object:extend()
|
||||
|
||||
local charutils = require "game.utils.characters"
|
||||
local statList = {"hpmax", "ppmax", "attack", "power", "defense", "mind", "technic", "speed"}
|
||||
local STATS = require "datas.stats"
|
||||
|
||||
function CharacterLevel:initLevel()
|
||||
self.level = self.data.startlevel
|
||||
|
@ -49,7 +49,7 @@ function CharacterLevel:getComputedStat(statname)
|
|||
end
|
||||
|
||||
function CharacterLevel:getStatList()
|
||||
return statList
|
||||
return STATS.LIST
|
||||
end
|
||||
|
||||
return CharacterLevel
|
||||
|
|
|
@ -3,8 +3,8 @@ local CharacterMenu = baseMenu:extend()
|
|||
|
||||
local const = require "scenes.overworld.screens.mainmenu.const"
|
||||
|
||||
function CharacterMenu:new(scene)
|
||||
local x = const.X + 136
|
||||
function CharacterMenu:new(scene, x)
|
||||
local x = x or const.X + 136
|
||||
local w = const.WIDTH - x + 28
|
||||
CharacterMenu.super.new(self, scene, "character", x, const.Y, w, const.HEIGHT, 4)
|
||||
end
|
||||
|
|
|
@ -3,13 +3,15 @@ local CharacterWidget = baseWidget:extend()
|
|||
|
||||
local ComplexHPBar = require "game.modules.gui.complexhpbar"
|
||||
local Emblem = require "game.modules.gui.emblem"
|
||||
local itemutils = require "game.utils.items"
|
||||
|
||||
-- Hero custom widget
|
||||
--
|
||||
function CharacterWidget:new(scene, name)
|
||||
function CharacterWidget:new(scene, name, showEquip)
|
||||
self.charName = name
|
||||
self.emblem = Emblem(game.characters.list[name], scene)
|
||||
self.font2 = scene.assets.fonts["hudnbrs_small"]
|
||||
self.showEquip = showEquip
|
||||
CharacterWidget.super.new(self, scene, "character")
|
||||
|
||||
self.hpbar = ComplexHPBar(88)
|
||||
|
@ -26,6 +28,7 @@ function CharacterWidget:drawCanvas()
|
|||
local debut = 0
|
||||
local xDebut = 32
|
||||
self.font:draw(character.fullname, xDebut, debut, -1, "left")
|
||||
if (self.showEquip == nil) then
|
||||
local yLvl = debut + 16
|
||||
local xLvl = xDebut
|
||||
self.scene.assets.images["lvl"]:draw(xLvl, yLvl)
|
||||
|
@ -33,18 +36,27 @@ function CharacterWidget:drawCanvas()
|
|||
self.font2:print(character.level, xLvl + 19, yLvl, "left")
|
||||
local expString = character.exp .. "/" .. character.exp_next
|
||||
self.font2:print(expString, xLvl + 19, yLvl + 10, "left")
|
||||
else
|
||||
local charEquip = character.equip[self.showEquip]
|
||||
local equipString = "None"
|
||||
if (not utils.string.isEmpty(charEquip)) then
|
||||
local data = itemutils.getItemData(self.showEquip, charEquip)
|
||||
equipString = data.fullname
|
||||
end
|
||||
self.font:draw(equipString, xDebut, debut + 16, -1, "left")
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterWidget:draw(x, y)
|
||||
local character = game.characters.list[self.charName]
|
||||
self.emblem:draw(x, y + 6)
|
||||
|
||||
if (self.showEquip == nil) then
|
||||
local xDebut = x + 52
|
||||
local yDebut = y + 15
|
||||
self.scene.assets.fonts["hudnbrs_small"]:set()
|
||||
self.hpbar:drawWithLabels(xDebut + 53, yDebut, character.hp, character.stats.hpmax)
|
||||
self.ppbar:drawWithLabels(xDebut + 64, yDebut + 11, character.pp, character.stats.ppmax)
|
||||
|
||||
end
|
||||
if self.canvas.texture ~= nil then
|
||||
love.graphics.draw(self.canvas.texture, x - self.ox, y - self.oy)
|
||||
end
|
||||
|
|
115
sonic-radiance.love/scenes/overworld/screens/mainmenu/equip.lua
Normal file
115
sonic-radiance.love/scenes/overworld/screens/mainmenu/equip.lua
Normal file
|
@ -0,0 +1,115 @@
|
|||
local ParentScreen = require "scenes.overworld.screens.parent"
|
||||
local EquipScreen = ParentScreen:extend()
|
||||
|
||||
local menu = require "game.modules.menus.list"
|
||||
local const = require "scenes.overworld.screens.mainmenu.const"
|
||||
local gui = require "game.modules.gui"
|
||||
|
||||
local baseCharacterMenu = require "scenes.overworld.screens.mainmenu.common.charmenu"
|
||||
local baseCharacterWidget = require "scenes.overworld.screens.mainmenu.common.charwidget"
|
||||
local CharacterMenu = baseCharacterMenu:extend()
|
||||
local CharacterWidget = baseCharacterWidget:extend()
|
||||
|
||||
local STATS = require "datas.stats"
|
||||
|
||||
local DESC_SIZE = 32 * 6
|
||||
|
||||
function EquipScreen:new(scene, category, item, widgetId)
|
||||
self.category = category
|
||||
self.item = item
|
||||
self.itemData = game.loot:getItemData(category, self.item.name)
|
||||
self.widgetId = widgetId
|
||||
|
||||
self.choiceBack = gui.newChoiceBack(48 + 16)
|
||||
self.descBox = gui.newTextBox("assets/gui/dialogbox.png", DESC_SIZE, 40 + 48+16)
|
||||
|
||||
self.desc = self.itemData.description
|
||||
self.charName = ""
|
||||
EquipScreen.super.new(self, scene, "Equipement")
|
||||
end
|
||||
|
||||
function EquipScreen:setMenu()
|
||||
CharacterMenu(self.scene, 224)
|
||||
for i, name in ipairs(game.characters.team) do
|
||||
CharacterWidget(self.scene, name, self.category)
|
||||
end
|
||||
self.scene.menusystem:switchMenu("character")
|
||||
end
|
||||
|
||||
function EquipScreen:draw()
|
||||
self.scene.assets.fonts["small"]:setLineHeight(16 / 18)
|
||||
self:drawPocket()
|
||||
self:drawDescription(const.X, const.Y)
|
||||
end
|
||||
|
||||
function EquipScreen:drawDescription(x, y)
|
||||
love.graphics.draw(self.descBox, x, y)
|
||||
local xx, yy, ww = x + 6, y + 4, DESC_SIZE - 12
|
||||
self.scene.assets.fonts["small"]:draw(self.itemData.fullname, xx, yy, ww, "left")
|
||||
if (self.charName ~= "") then
|
||||
local char = game.characters.list[self.charName]
|
||||
for i, statName in ipairs(STATS.LIST) do
|
||||
local xStat = xx + (((i - 1) % 2) * (ww/2))
|
||||
local yStat = yy + (math.floor((i-1)/2) * 16) + 24
|
||||
local middle = xStat + 10 + ww/4
|
||||
local stat = char.stats[statName]
|
||||
local newStat = char:predictStat(statName, self.category, self.item.name)
|
||||
self.scene.assets.fonts["small"]:draw(STATS.SIMPLENAME[statName], xStat, yStat, ww, "left")
|
||||
self.scene.assets.fonts["small"]:setColor(1, 1, 1, 0.9)
|
||||
self.scene.assets.fonts["small"]:draw(stat .. " ", middle, yStat, -1, "right")
|
||||
self.scene.assets.fonts["small"]:draw(">", middle, yStat, -1, "center")
|
||||
if (newStat > stat) then
|
||||
self.scene.assets.fonts["small"]:setColor(0.3, 1, 0.3, 0.9)
|
||||
elseif (newStat < stat) then
|
||||
self.scene.assets.fonts["small"]:setColor(1, 0.3, 0.3, 0.9)
|
||||
end
|
||||
|
||||
self.scene.assets.fonts["small"]:draw(" " .. newStat, middle, yStat, -1, "left")
|
||||
self.scene.assets.fonts["small"]:setColor(1, 1, 1, 1)
|
||||
utils.graphics.resetColor()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function EquipScreen:drawPocket()
|
||||
local x = const.X + DESC_SIZE - 48
|
||||
local y = const.Y2 - 24
|
||||
love.graphics.draw(self.choiceBack, x, y)
|
||||
|
||||
self.scene.assets.fonts["small"]:draw("x" .. self.item.number, x + 16, y - 2, -1, "left")
|
||||
end
|
||||
|
||||
function EquipScreen:goBack()
|
||||
self.scene.screens.mainmenu["items"](self.scene, game.loot:getPocketIdByName(self.category), self.widgetId)
|
||||
end
|
||||
|
||||
function EquipScreen:useItem(charName)
|
||||
local character = game.characters.list[charName]
|
||||
if (self.item.number <= 1) then
|
||||
character:setEquip(self.category, self.item.name)
|
||||
self:goBack()
|
||||
else
|
||||
character:setEquip(self.category, self.item.name)
|
||||
end
|
||||
end
|
||||
|
||||
-- Character menu
|
||||
function CharacterMenu:cancelAction()
|
||||
-- Switch à l'écran précédant
|
||||
self.scene.assets:playSFX("mBack")
|
||||
self.scene.currentScreen:goBack()
|
||||
end
|
||||
|
||||
-- Hero custom widget
|
||||
--
|
||||
function CharacterWidget:selectAction()
|
||||
self.scene.currentScreen.charName = self.charName
|
||||
end
|
||||
|
||||
function CharacterWidget:action()
|
||||
self.scene.assets:playSFX("mSelect")
|
||||
self.scene.currentScreen:useItem(self.charName)
|
||||
self:redrawCanvas()
|
||||
end
|
||||
|
||||
return EquipScreen
|
|
@ -2,5 +2,6 @@ return {
|
|||
pause = require "scenes.overworld.screens.mainmenu.pause",
|
||||
character = require "scenes.overworld.screens.mainmenu.character",
|
||||
items = require "scenes.overworld.screens.mainmenu.items",
|
||||
useItems = require "scenes.overworld.screens.mainmenu.useitems"
|
||||
useItems = require "scenes.overworld.screens.mainmenu.useitems",
|
||||
equip = require "scenes.overworld.screens.mainmenu.equip"
|
||||
}
|
||||
|
|
|
@ -178,15 +178,19 @@ function UseWidget:new(scene, pocket, item, widgetId)
|
|||
self.item = item
|
||||
self.itemData = game.loot:getItemData(pocket, self.item.name)
|
||||
self.pocket = pocket
|
||||
self.pocketData = game.loot:getPocketByName(self.pocket)
|
||||
self.widgetId = widgetId
|
||||
UseWidget.super.new(self, scene, "useMenu", "Use", "")
|
||||
if (not self.itemData.usableOnMap) then
|
||||
if (not (self.itemData.usableOnMap or self.pocketData.isEquipement)) then
|
||||
self.color = {0.6, 0.6, 0.6}
|
||||
end
|
||||
end
|
||||
|
||||
function UseWidget:action()
|
||||
if (self.itemData.usableOnMap) then
|
||||
if (self.pocketData.isEquipement) then
|
||||
self.scene.screens.mainmenu["equip"](self.scene, self.pocket, self.item, self.widgetId)
|
||||
self.scene.assets:playSFX("mSelect")
|
||||
elseif (self.itemData.usableOnMap) then
|
||||
self.scene.screens.mainmenu["useItems"](self.scene, self.pocket, self.item, self.widgetId)
|
||||
self.scene.assets:playSFX("mSelect")
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue