parent
15bc5ae874
commit
e50c9f6e54
8 changed files with 28 additions and 4 deletions
|
@ -12,6 +12,7 @@ function Gizmo:new(world, x, y, w, h, overrides)
|
||||||
self.overrides = overrides
|
self.overrides = overrides
|
||||||
self.drawDebugBox = false
|
self.drawDebugBox = false
|
||||||
self.event = defaultEvent
|
self.event = defaultEvent
|
||||||
|
self.interactionName = "Talk"
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gizmo:getUniqueId()
|
function Gizmo:getUniqueId()
|
||||||
|
@ -48,6 +49,7 @@ function Gizmo:applyProperties()
|
||||||
if (game.destroyedGizmo[self.uniqueId] == true) then
|
if (game.destroyedGizmo[self.uniqueId] == true) then
|
||||||
self:destroy()
|
self:destroy()
|
||||||
end
|
end
|
||||||
|
self.interactionName = self.properties.interactionName or self.interactionName
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gizmo:setDefaultProperties()
|
function Gizmo:setDefaultProperties()
|
||||||
|
|
|
@ -8,6 +8,7 @@ local overrides = {
|
||||||
["charDir"] = "right",
|
["charDir"] = "right",
|
||||||
["destroy"] = "forever",
|
["destroy"] = "forever",
|
||||||
["needButton"] = true,
|
["needButton"] = true,
|
||||||
|
["interactionName"] = "Take",
|
||||||
}
|
}
|
||||||
|
|
||||||
function ItemBox:new(world, x, y)
|
function ItemBox:new(world, x, y)
|
||||||
|
|
|
@ -8,6 +8,7 @@ local overrides = {
|
||||||
["charDir"] = "down",
|
["charDir"] = "down",
|
||||||
["destroy"] = "forever",
|
["destroy"] = "forever",
|
||||||
["needButton"] = true,
|
["needButton"] = true,
|
||||||
|
["interactionName"] = "Take",
|
||||||
}
|
}
|
||||||
|
|
||||||
function RingBox:new(world, x, y)
|
function RingBox:new(world, x, y)
|
||||||
|
|
|
@ -42,6 +42,7 @@ function Player:new(world, x, y, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:updateStart(dt)
|
function Player:updateStart(dt)
|
||||||
|
self.interactionName = ""
|
||||||
self.tweens:update(dt)
|
self.tweens:update(dt)
|
||||||
self:updateTerrain()
|
self:updateTerrain()
|
||||||
self:updateActiveCharacter()
|
self:updateActiveCharacter()
|
||||||
|
@ -122,6 +123,14 @@ end
|
||||||
function Player:drawHUD(id)
|
function Player:drawHUD(id)
|
||||||
self:drawHealth((424 - self.scene:getEmblemsPosition()) - 48, 168)
|
self:drawHealth((424 - self.scene:getEmblemsPosition()) - 48, 168)
|
||||||
self:drawEmblems(self.scene:getEmblemsPosition(), 24)
|
self:drawEmblems(self.scene:getEmblemsPosition(), 24)
|
||||||
|
if (not utils.string.isEmpty(self.interactionName)) then
|
||||||
|
local w = self.assets.fonts["small"]:getWidth(self.interactionName) + 16
|
||||||
|
love.graphics.setColor(0,0,0,0.5)
|
||||||
|
local x, y = 424 - w + 4, 240 - 24
|
||||||
|
love.graphics.rectangle("fill", x - w/2, y + 1, w, 15, 8, 8)
|
||||||
|
utils.graphics.resetColor()
|
||||||
|
self.assets.fonts["small"]:draw(self.interactionName, x, y, -1, "center")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:draw()
|
function Player:draw()
|
||||||
|
|
|
@ -24,6 +24,7 @@ function PlayerInteractions:initInteractions()
|
||||||
self.lastPos = {}
|
self.lastPos = {}
|
||||||
self.lastPos.x = self.x
|
self.lastPos.x = self.x
|
||||||
self.lastPos.y = self.y
|
self.lastPos.y = self.y
|
||||||
|
self.interactionName = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
function PlayerInteractions:updateInteraction()
|
function PlayerInteractions:updateInteraction()
|
||||||
|
@ -35,10 +36,12 @@ end
|
||||||
|
|
||||||
function PlayerInteractions:collideWithGizmo(other)
|
function PlayerInteractions:collideWithGizmo(other)
|
||||||
if (other.needButton) then
|
if (other.needButton) then
|
||||||
|
self.interactionName = other.interactionName
|
||||||
if (self.keys["A"].isPressed) then
|
if (self.keys["A"].isPressed) then
|
||||||
other:doAction()
|
other:doAction()
|
||||||
self.haveCollided = true
|
self.haveCollided = true
|
||||||
self.lastCollision = other.creationID
|
self.lastCollision = other.creationID
|
||||||
|
self.interactionName = ""
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (self.lastCollision ~= other.creationID) then
|
if (self.lastCollision ~= other.creationID) then
|
||||||
|
@ -50,10 +53,14 @@ function PlayerInteractions:collideWithGizmo(other)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PlayerInteractions:talkToGizmo(other)
|
function PlayerInteractions:talkToGizmo(other)
|
||||||
if (self.keys["A"].isPressed and (self:faceRightDirection(other))) then
|
if (self:faceRightDirection(other)) then
|
||||||
|
self.interactionName = other.interactionName
|
||||||
|
if (self.keys["A"].isPressed) then
|
||||||
other:doAction()
|
other:doAction()
|
||||||
self.haveCollided = true
|
self.haveCollided = true
|
||||||
self.lastCollision = other.creationID
|
self.lastCollision = other.creationID
|
||||||
|
self.interactionName = ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ local overrides = {
|
||||||
["isSolid"] = true,
|
["isSolid"] = true,
|
||||||
["destroy"] = "nope",
|
["destroy"] = "nope",
|
||||||
["needButton"] = true,
|
["needButton"] = true,
|
||||||
|
["interactionName"] = "Talk",
|
||||||
}
|
}
|
||||||
|
|
||||||
function PNJ:new(world, x, y)
|
function PNJ:new(world, x, y)
|
||||||
|
|
|
@ -3,6 +3,7 @@ local Teleporter = Gizmo:extend()
|
||||||
|
|
||||||
function Teleporter:new(world, x, y, w, h)
|
function Teleporter:new(world, x, y, w, h)
|
||||||
Teleporter.super.new(self, world, x, y, w, h, nil)
|
Teleporter.super.new(self, world, x, y, w, h, nil)
|
||||||
|
self.interactionName = "Enter"
|
||||||
end
|
end
|
||||||
|
|
||||||
function Teleporter:applyProperties()
|
function Teleporter:applyProperties()
|
||||||
|
|
|
@ -40,6 +40,8 @@ function OverWorld:new(area, playerx, playery)
|
||||||
self.charsetManager = CharsetManager(self)
|
self.charsetManager = CharsetManager(self)
|
||||||
self.assets:batchImport("game.modules.gui.assets")
|
self.assets:batchImport("game.modules.gui.assets")
|
||||||
self.assets:batchImport("scenes.overworld.assets")
|
self.assets:batchImport("scenes.overworld.assets")
|
||||||
|
self.assets.fonts["small"]:setLineHeight(16/18)
|
||||||
|
self.assets.fonts["small"]:setFilter("shadow")
|
||||||
|
|
||||||
self.tweens = TweenManager(self)
|
self.tweens = TweenManager(self)
|
||||||
self.screens = screens
|
self.screens = screens
|
||||||
|
|
Loading…
Reference in a new issue