Skip to content

Commit

Permalink
重构新增人物界面。 基本功能实现。
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwings committed Mar 27, 2018
1 parent e1aa7e7 commit 19e9781
Show file tree
Hide file tree
Showing 4 changed files with 4,650 additions and 27 deletions.
8 changes: 4 additions & 4 deletions Actor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Actor:readData(data)
for k, v in pairs( data ) do
self[k] = v
end
local actorImg = self["actorImg"] or "actor (1)"
local actorImg = self["actorImg"]
self:getAnims(actorImg)
end
--------------------------- 键盘控制 ------------------------
Expand Down Expand Up @@ -159,8 +159,8 @@ end
------------------ 行走图文件 --------------------

function Actor:getAnims(name)
self.actorImg = assets.graphics.Characters[name]
local image = self.actorImg
self.moveImg = assets.graphics.Characters[name]
local image = self.moveImg
local g = anim8.newGrid(32, 64, image:getWidth(), image:getHeight())
self.anim = {}
self["anim"]["S"] = anim8.newAnimation(g('1-4', 1), 0.5)
Expand All @@ -172,7 +172,7 @@ end

function Actor:drawAnim()
--love.graphics.print(self.name, self.x - 8, self.y - 24)
self.image:draw(self.actorImg, self.x, self.y)
self.image:draw(self.moveImg, self.x, self.y)
--love.graphics.draw(self.actorImg, self.x, self.y)
love.graphics.colorRectangle("fill", self.x, self.y + 50, self.hp, 2, { 255, 0, 0, 255 })
love.graphics.colorRectangle("fill", self.x, self.y + 52, self.mp, 2, { 0, 0, 255, 255 })
Expand Down
5 changes: 2 additions & 3 deletions GameScreen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local npcs = {}
local function loadData( )
-- actor class
---@param actor Actor
player=Actor:new(actorData["XuZhu"])
-- player=Actor:new(actorData["XuZhu"])
enemy=Actor:new(actorData["DuanYu"])
---
for k, v in pairs(actorData) do
Expand Down Expand Up @@ -165,8 +165,7 @@ function GameScreen.new( )
-- Update Moan
end
if gameTurn >= enemy.turn then
--Actions.moveW(enemy,dt)
--enemy.turn = gameTurn + math.random(1,6)
enemy.turn = gameTurn + math.random(1,6)
behaviorTree:tick(enemy.id, blackBoard)
end
player:update(dt)
Expand Down
69 changes: 49 additions & 20 deletions NewScreen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
--- DateTime: 18/3/26 下午8:39
---
local Screen = require("lib/Screen")
local ScreenManager = require("lib/ScreenManager")
local assets = require("lib.cargo").init("assets")
local actorData = assets.data.actorDataNew
local NewScreen = {}
local bg = love.graphics.newImage("bg.jpeg")
--local font = love.graphics.newFont("assets/font/myfont.ttf", 24)
Expand All @@ -14,39 +16,46 @@ local titlefont = assets.font.myfont(48)
local index = 1
local indexY = 1
local newActor = {}
newActor.gui = {
{ name = "姓名", prop = "name", guiType = "text", contant = "东方未明", select = { "东方未明", "无名" }, color = { 255, 255, 255 } },
{ name = "性别", prop = "gender", guiType = "text", contant = "男性", select = { "男性", "女性", "无性" }, color = { 255, 255, 255 } },
{ name = "年龄", prop = "age", guiType = "int", contant = "16", select = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25 }, color = { 255, 255, 255 } },
{ name = "臂力", prop = "Str", guiType = "int", contant = "20", select = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25 }, color = { 255, 255, 255 } },
{ name = "根骨", prop = "Con", guiType = "int", contant = "20", select = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25 }, color = { 255, 255, 255 } },
{ name = "身法", prop = "Dex", guiType = "int", contant = "20", select = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25 }, color = { 255, 255, 255 } },
{ name = "悟性", prop = "Int", guiType = "int", contant = "20", select = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25 }, color = { 255, 255, 255 } },
{ name = "五感", prop = "Cho", guiType = "int", contant = "20", select = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25 }, color = { 255, 255, 255 } },
{ name = "魅力", prop = "Chn", guiType = "int", contant = "20", select = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25 }, color = { 255, 255, 255 } },
{ name = "气血", prop = "HP", guiType = "int", contant = "120", color = { 255, 255, 255 } },
{ name = "真气", prop = "MP", guiType = "int", contant = "120", color = { 255, 255, 255 } },
{ name = "确定", guiType = "text", contant = "再想想", select = { "再想想", "确定了" }, color = { 255, 255, 255 } }
}
newActor["gui"] = assets.gui.newGameGUI
local face
local moveImg
local fname,lname
function NewScreen.new()
love.graphics.setFont(font)
local self = Screen.new()
local title = love.graphics.newText(titlefont, { { 0, 0, 0 }, "前世身份" })
local t = love.graphics.newText(font)
function self:draw()
love.graphics.draw(bg, 0, 0, 0)
local num = 1
love.graphics.setColor(0, 0, 0, 100)
love.graphics.rectangle("fill", 90, 90, 400, 600, 8)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.rectangle("line", 90, 90, 400, 600, 8)

for i, v in pairs(newActor.gui) do
if v.prop and v.prop == "faceImg" then
face = assets.graphics.Faces[v.contant]
end
if v.prop and v.prop == "actorImg" then
moveImg = assets.graphics.Characters[v.contant]
end
if i == index then
v.color = { 255, 0, 0 }
else
v.color = { 255, 255, 255 }
end
t:set({ v.color, v.name .. " " .. v.contant })
love.graphics.print(index, 200, 200)
love.graphics.draw(t, 100, 100 + 30 * num)
num = num + 1
love.graphics.draw(t, v.x,v.y)
end
--face = assets.graphics.Faces[1]
if face ~= nil then
--print(face)
love.graphics.draw(face,380,120)
end
if moveImg ~= nil then
love.graphics.draw(moveImg,260,240)
end

love.graphics.draw(title, 300, 40)
love.graphics.setColor(255, 255, 255, 255)
end
Expand All @@ -65,8 +74,28 @@ function NewScreen.new()
if v.select then
v.contant = v.select[math.random(#v.select)]
end
elseif key == "s" and indexY > 1 then
indexY = indexY - 1
elseif key == "j" and newActor.gui[#newActor.gui].contant == "" then
player = Actor:new(actorData["XuZhu"])
for i, v in pairs(newActor.gui) do
if player[v.prop] then
if v.type == "int" then
player[v.prop] = tonumber(v.contant)
else
player[v.prop] = v.contant
end
end

if v.prop == "fname" then
fname = v.contant
end
if v.prop == "lname" then
lname = v.contant
end

end

player["name"] = fname .. lname
ScreenManager.switch("game")
end
end
return self
Expand Down
Loading

0 comments on commit 19e9781

Please sign in to comment.