英雄列表
This commit is contained in:
parent
f2e69642a9
commit
96483f028c
@ -66,6 +66,7 @@ function DataManager:clear()
|
|||||||
self.PlayerData:clear()
|
self.PlayerData:clear()
|
||||||
self.BattleData:clear()
|
self.BattleData:clear()
|
||||||
self.ChapterData:clear()
|
self.ChapterData:clear()
|
||||||
|
self.HeroData:clear()
|
||||||
|
|
||||||
ModuleManager.TaskManager:clear()
|
ModuleManager.TaskManager:clear()
|
||||||
end
|
end
|
||||||
@ -77,6 +78,7 @@ function DataManager:initWithServerData(data)
|
|||||||
|
|
||||||
self.PlayerData:init(data.PlayerData)
|
self.PlayerData:init(data.PlayerData)
|
||||||
self.ChapterData:init(data.ChapterData)
|
self.ChapterData:init(data.ChapterData)
|
||||||
|
self.HeroData:init(data.HeroData)
|
||||||
|
|
||||||
self:scheduleGlobal()
|
self:scheduleGlobal()
|
||||||
self:checkDataBind()
|
self:checkDataBind()
|
||||||
|
|||||||
@ -158,7 +158,7 @@ GConst.TYPEOF_LUA_CLASS = {
|
|||||||
|
|
||||||
-- cell
|
-- cell
|
||||||
ITEM_CELL = "app/ui/common/cell/item_cell",
|
ITEM_CELL = "app/ui/common/cell/item_cell",
|
||||||
EQUIP_CELL = "app/ui/common/cell/equip_cell",
|
HERO_CELL = "app/ui/common/cell/hero_cell",
|
||||||
REWARD_CELL = "app/ui/common/cell/reward_cell",
|
REWARD_CELL = "app/ui/common/cell/reward_cell",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,84 +370,8 @@ GConst.ENTITY_TYPE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GConst.ATTR_TYPE = {
|
GConst.ATTR_TYPE = {
|
||||||
-- 血量
|
|
||||||
hp = 1,
|
hp = 1,
|
||||||
-- 生命恢复
|
|
||||||
-- recover = 2,
|
|
||||||
-- 攻击
|
|
||||||
atk = 2,
|
atk = 2,
|
||||||
-- 速度
|
|
||||||
-- spd = 4,
|
|
||||||
-- 暴击
|
|
||||||
crit = 3,
|
|
||||||
-- 暴击伤害
|
|
||||||
crit_time = 4,
|
|
||||||
-- 技能范围增加(百分比)
|
|
||||||
-- atk_range = 7,
|
|
||||||
-- 伤害减免,在伤害计算的最后按百分比减少
|
|
||||||
dmg_dec_all = 5,
|
|
||||||
-- 对boss的伤害提升
|
|
||||||
-- hurt_boss_time = 9,
|
|
||||||
-- 攻击力百分比
|
|
||||||
atkp_1 = 6,
|
|
||||||
atkp_2 = 7,
|
|
||||||
atkp_3 = 8,
|
|
||||||
atkp_4 = 9,
|
|
||||||
atkp_5 = 10,
|
|
||||||
atkp_6 = 11,
|
|
||||||
atkp_7 = 12,
|
|
||||||
atkp_8 = 13,
|
|
||||||
atkp_9 = 14,
|
|
||||||
-- 生命百分比
|
|
||||||
hpp_1 = 15,
|
|
||||||
hpp_2 = 16,
|
|
||||||
hpp_3 = 17,
|
|
||||||
hpp_4 = 18,
|
|
||||||
hpp_5 = 19,
|
|
||||||
hpp_6 = 20,
|
|
||||||
hpp_7 = 21,
|
|
||||||
-- 移动速度百分比
|
|
||||||
-- spdp = 25,
|
|
||||||
-- 增加自身的伤害
|
|
||||||
dmg_addition = 22,
|
|
||||||
-- 中毒伤害提高(比例)
|
|
||||||
-- hurt_poisonP = 27,
|
|
||||||
-- 对中毒单位伤害提高(比例)
|
|
||||||
-- dmg_addition_poicon = 28,
|
|
||||||
-- 闪避几率(受伤时有几率不掉血)
|
|
||||||
miss = 23,
|
|
||||||
-- 金币获取(百分比)
|
|
||||||
gold_gain = 24,
|
|
||||||
-- 技能伤害(百分比)
|
|
||||||
dmg_addition_skill = 25,
|
|
||||||
-- 普攻伤害(百分比)
|
|
||||||
dmg_addition_normal = 26,
|
|
||||||
-- 放置奖励(百分比)
|
|
||||||
idle_income = 27,
|
|
||||||
-- 矿镐回复速度(百分比)
|
|
||||||
pickaxe_recover_spd = 28,
|
|
||||||
-- 矿镐持有上限(固定值)
|
|
||||||
pickaxe_own_limit = 29,
|
|
||||||
-- 研究用矿石获取(百分比)
|
|
||||||
mineral_gain = 30,
|
|
||||||
-- 研究速度(百分比)
|
|
||||||
research_spd = 31,
|
|
||||||
-- 所有战斗中的攻击力百分比加成
|
|
||||||
-- atkp_0 = 38,
|
|
||||||
-- 击飞伤害
|
|
||||||
airborne_damage = 32,
|
|
||||||
-- 击飞数量
|
|
||||||
airborne_num = 33,
|
|
||||||
-- 所有技能的伤害提升
|
|
||||||
-- skill_all_damage = 41,
|
|
||||||
-- 武器技能1的伤害提升
|
|
||||||
-- skill_1_damage = 42,
|
|
||||||
-- -- 武器技能2的伤害提升
|
|
||||||
-- skill_2_damage = 43,
|
|
||||||
-- -- 武器技能3的伤害提升
|
|
||||||
-- skill_3_damage = 44,
|
|
||||||
-- -- 普攻伤害提升
|
|
||||||
-- attack_damage = 45,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GConst.GAMEOBJECT_LAYER = {
|
GConst.GAMEOBJECT_LAYER = {
|
||||||
|
|||||||
3
lua/app/server/data/server_hero_data.lua
Normal file
3
lua/app/server/data/server_hero_data.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
local ServerHeroData = class("ServerHeroData", ServerBaseData)
|
||||||
|
|
||||||
|
return ServerHeroData
|
||||||
10
lua/app/server/data/server_hero_data.lua.meta
Normal file
10
lua/app/server/data/server_hero_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 56a4a8f5d6118d74b9bb6971db3d030a
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -11,6 +11,7 @@ function ServerGameData:init()
|
|||||||
self.isInit = true
|
self.isInit = true
|
||||||
self:initServerData("PlayerData", "app/server/data/server_player_data")
|
self:initServerData("PlayerData", "app/server/data/server_player_data")
|
||||||
self:initServerData("BagData", "app/server/data/server_bag_data")
|
self:initServerData("BagData", "app/server/data/server_bag_data")
|
||||||
|
self:initServerData("HeroData", "app/server/data/server_hero_data")
|
||||||
self:initServerData("ChapterData", "app/server/data/server_chapter_data")
|
self:initServerData("ChapterData", "app/server/data/server_chapter_data")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
6
lua/app/ui/common/cell/hero_cell.lua
Normal file
6
lua/app/ui/common/cell/hero_cell.lua
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
local HeroCell = class("HeroCell", BaseCell)
|
||||||
|
|
||||||
|
function HeroCell:refresh()
|
||||||
|
end
|
||||||
|
|
||||||
|
return HeroCell
|
||||||
10
lua/app/ui/common/cell/hero_cell.lua.meta
Normal file
10
lua/app/ui/common/cell/hero_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2908445d9bae05b4fad51ac5eca0730e
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
8
lua/app/ui/hero/cell.meta
Normal file
8
lua/app/ui/hero/cell.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d83268e262de62e478d7dd155698ccce
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
43
lua/app/ui/hero/cell/hero_list_cell.lua
Normal file
43
lua/app/ui/hero/cell/hero_list_cell.lua
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
local HeroListCell = class("HeroListCell", BaseCell)
|
||||||
|
|
||||||
|
local H = {
|
||||||
|
NORMAL = 112,
|
||||||
|
HAS_TITLE = 216
|
||||||
|
}
|
||||||
|
|
||||||
|
function HeroListCell:init()
|
||||||
|
self.uiMap = self:getUIMap()
|
||||||
|
self.heroCells = {
|
||||||
|
self.uiMap["hero_list_cell.prop_node.hero_cell_1"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
|
||||||
|
self.uiMap["hero_list_cell.prop_node.hero_cell_2"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
|
||||||
|
self.uiMap["hero_list_cell.prop_node.hero_cell_3"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
|
||||||
|
self.uiMap["hero_list_cell.prop_node.hero_cell_4"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
|
||||||
|
self.uiMap["hero_list_cell.prop_node.hero_cell_5"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
|
||||||
|
}
|
||||||
|
self.title = self.uiMap["hero_list_cell.title"]
|
||||||
|
self.titleTx = self.uiMap["hero_list_cell.title.title_desc"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroListCell:refresh(list)
|
||||||
|
-- for i, cell in ipairs(self.heroCells) do
|
||||||
|
-- local info = list.unitList and list.unitList[i]
|
||||||
|
-- cell:getBaseObject():setActive(info ~= nil)
|
||||||
|
-- if info and info.entity then
|
||||||
|
-- cell:refresh(info.entity)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- self.title:setActive(list.showTitle ~= nil)
|
||||||
|
-- if list.showTitle ~= nil then
|
||||||
|
-- self.titleTx:setText(list.showTitle)
|
||||||
|
-- self:getBaseObject():setSizeDeltaY(H.HAS_TITLE)
|
||||||
|
-- else
|
||||||
|
-- local h = H.NORMAL
|
||||||
|
-- if list.isFirstLine then
|
||||||
|
-- h = h + 30
|
||||||
|
-- end
|
||||||
|
-- self:getBaseObject():setSizeDeltaY(h)
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
|
||||||
|
return HeroListCell
|
||||||
10
lua/app/ui/hero/cell/hero_list_cell.lua.meta
Normal file
10
lua/app/ui/hero/cell/hero_list_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65cefb44eced49b4ab01c650f89e976b
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -1,6 +1,46 @@
|
|||||||
local HeroComp = class("HeroComp", LuaComponent)
|
local HeroComp = class("HeroComp", LuaComponent)
|
||||||
|
|
||||||
|
local HERO_LIST_CELL = "app/ui/hero/cell/hero_list_cell"
|
||||||
|
|
||||||
|
function HeroComp:init()
|
||||||
|
self.uiMap = self:getBaseObject():genAllChildren()
|
||||||
|
self.scrollRect = self.uiMap["hero_ui.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||||
|
self.scrollRect:addInitCallback(function()
|
||||||
|
return HERO_LIST_CELL
|
||||||
|
end)
|
||||||
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||||
|
cell:refresh()
|
||||||
|
end)
|
||||||
|
self.heroList = {}
|
||||||
|
end
|
||||||
|
|
||||||
function HeroComp:refresh()
|
function HeroComp:refresh()
|
||||||
|
if #self.heroList <= 0 then
|
||||||
|
local heroes = DataManager.HeroData:getAllHeroes()
|
||||||
|
for k, v in pairs(heroes) do
|
||||||
|
table.insert(self.heroList, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:refreshScrollRect()
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroComp:refreshScrollRect()
|
||||||
|
local activeCount = DataManager.HeroData:getActiveHeroCount()
|
||||||
|
local lockCount = #self.heroList - activeCount
|
||||||
|
local cellCount = 0
|
||||||
|
if activeCount > 0 then
|
||||||
|
cellCount = cellCount + math.ceil(activeCount / 5)
|
||||||
|
end
|
||||||
|
if lockCount > 0 then
|
||||||
|
cellCount = cellCount + math.ceil(lockCount / 5)
|
||||||
|
end
|
||||||
|
local currCount = self.scrollRect:getTotalCount()
|
||||||
|
if cellCount == currCount then
|
||||||
|
self.scrollRect:updateAllCell()
|
||||||
|
else
|
||||||
|
self.scrollRect:clearCells()
|
||||||
|
self.scrollRect:refillCells(cellCount)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return HeroComp
|
return HeroComp
|
||||||
@ -3,7 +3,7 @@ local HeroData = class("HeroData", BaseData)
|
|||||||
|
|
||||||
function HeroData:ctor()
|
function HeroData:ctor()
|
||||||
self.heroes = {}
|
self.heroes = {}
|
||||||
self.heroCount = 0
|
self.data.activeCount = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroData:clear()
|
function HeroData:clear()
|
||||||
@ -12,20 +12,22 @@ end
|
|||||||
|
|
||||||
function HeroData:init(data)
|
function HeroData:init(data)
|
||||||
self.heroes = {}
|
self.heroes = {}
|
||||||
self.heroCount = 0
|
local heroCfg = ConfigManager:getConfig("hero")
|
||||||
data = data or {}
|
for heroId, heroInfo in pairs(heroCfg) do
|
||||||
for id, info in pairs(data) do
|
self:createHeroById(heroId, heroInfo)
|
||||||
self:_addHero(info)
|
|
||||||
self.heroCount = self.heroCount + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroData:_addHero(heroInfo)
|
function HeroData:createHeroById(heroId, heroInfo)
|
||||||
self.heroes[heroInfo.cfg_id] = HeroEntity:create(heroInfo)
|
self.heroes[heroId] = HeroEntity:create(heroId, heroInfo)
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroData:getHeroes()
|
function HeroData:getAllHeroes()
|
||||||
return self.heroes
|
return self.heroes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroData:getActiveHeroCount()
|
||||||
|
return self.data.activeCount
|
||||||
|
end
|
||||||
|
|
||||||
return HeroData
|
return HeroData
|
||||||
@ -1,50 +1,21 @@
|
|||||||
local HeroEntity = class("HeroEntity", BaseData)
|
local HeroEntity = class("HeroEntity", BaseData)
|
||||||
|
|
||||||
function HeroEntity:ctor(heroInfo)
|
function HeroEntity:ctor(cfgId, config)
|
||||||
self.id = heroInfo.id or 1
|
self.id = cfgId
|
||||||
self.cfgId = heroInfo.cfg_id or self.id
|
self.config = config
|
||||||
self.data.lv = heroInfo.lv or 1
|
self.cfgId = cfgId
|
||||||
|
self.data.lv = 0
|
||||||
self.attrDirty = false
|
self.attrDirty = false
|
||||||
self.data.powerDirty = false
|
|
||||||
|
|
||||||
self:_loadConfig()
|
|
||||||
|
|
||||||
self.baseAttrOriginal = {}
|
self.baseAttrOriginal = {}
|
||||||
self:initAttrTab()
|
self.allAttr = {}
|
||||||
|
self:initAttr()
|
||||||
self:updateAttr()
|
self:updateAttr()
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:initAttrTab()
|
function HeroEntity:initAttr()
|
||||||
self.allAttr = {}
|
self.allAttr[GConst.ATTR_TYPE.hp] = 0
|
||||||
local cfg = ConfigManager:getConfig("attr")
|
self.allAttr[GConst.ATTR_TYPE.atk] = 0
|
||||||
for i = 1, #cfg do
|
|
||||||
self.allAttr[i] = {unit = 0, value = 0}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:_loadConfig()
|
|
||||||
self.config = ConfigManager:getConfig("hero")[self.cfgId]
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:setHid(id)
|
|
||||||
self.id = id
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getHid()
|
|
||||||
return self.id
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getId()
|
|
||||||
return self.cfgId
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:setId(id)
|
|
||||||
if not id then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self.cfgId = id
|
|
||||||
self:_loadConfig()
|
|
||||||
self:setDirty()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:setLv(lv)
|
function HeroEntity:setLv(lv)
|
||||||
@ -74,8 +45,6 @@ end
|
|||||||
|
|
||||||
function HeroEntity:updateAttr()
|
function HeroEntity:updateAttr()
|
||||||
self:updateBaseAttr()
|
self:updateBaseAttr()
|
||||||
self:_updateAllAttr()
|
|
||||||
self:calculatePower()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:updateBaseAttr()
|
function HeroEntity:updateBaseAttr()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user