英雄列表

This commit is contained in:
chenxi 2023-04-08 17:52:36 +08:00
parent f2e69642a9
commit 96483f028c
13 changed files with 155 additions and 127 deletions

View File

@ -66,6 +66,7 @@ function DataManager:clear()
self.PlayerData:clear()
self.BattleData:clear()
self.ChapterData:clear()
self.HeroData:clear()
ModuleManager.TaskManager:clear()
end
@ -77,6 +78,7 @@ function DataManager:initWithServerData(data)
self.PlayerData:init(data.PlayerData)
self.ChapterData:init(data.ChapterData)
self.HeroData:init(data.HeroData)
self:scheduleGlobal()
self:checkDataBind()

View File

@ -158,7 +158,7 @@ GConst.TYPEOF_LUA_CLASS = {
-- 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",
}
@ -370,84 +370,8 @@ GConst.ENTITY_TYPE = {
}
GConst.ATTR_TYPE = {
-- 血量
hp = 1,
-- 生命恢复
-- recover = 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 = {

View File

@ -0,0 +1,3 @@
local ServerHeroData = class("ServerHeroData", ServerBaseData)
return ServerHeroData

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 56a4a8f5d6118d74b9bb6971db3d030a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -11,6 +11,7 @@ function ServerGameData:init()
self.isInit = true
self:initServerData("PlayerData", "app/server/data/server_player_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")
end

View File

@ -0,0 +1,6 @@
local HeroCell = class("HeroCell", BaseCell)
function HeroCell:refresh()
end
return HeroCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2908445d9bae05b4fad51ac5eca0730e
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d83268e262de62e478d7dd155698ccce
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 65cefb44eced49b4ab01c650f89e976b
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,6 +1,46 @@
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()
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
return HeroComp

View File

@ -3,7 +3,7 @@ local HeroData = class("HeroData", BaseData)
function HeroData:ctor()
self.heroes = {}
self.heroCount = 0
self.data.activeCount = 0
end
function HeroData:clear()
@ -12,20 +12,22 @@ end
function HeroData:init(data)
self.heroes = {}
self.heroCount = 0
data = data or {}
for id, info in pairs(data) do
self:_addHero(info)
self.heroCount = self.heroCount + 1
local heroCfg = ConfigManager:getConfig("hero")
for heroId, heroInfo in pairs(heroCfg) do
self:createHeroById(heroId, heroInfo)
end
end
function HeroData:_addHero(heroInfo)
self.heroes[heroInfo.cfg_id] = HeroEntity:create(heroInfo)
function HeroData:createHeroById(heroId, heroInfo)
self.heroes[heroId] = HeroEntity:create(heroId, heroInfo)
end
function HeroData:getHeroes()
function HeroData:getAllHeroes()
return self.heroes
end
function HeroData:getActiveHeroCount()
return self.data.activeCount
end
return HeroData

View File

@ -1,50 +1,21 @@
local HeroEntity = class("HeroEntity", BaseData)
function HeroEntity:ctor(heroInfo)
self.id = heroInfo.id or 1
self.cfgId = heroInfo.cfg_id or self.id
self.data.lv = heroInfo.lv or 1
function HeroEntity:ctor(cfgId, config)
self.id = cfgId
self.config = config
self.cfgId = cfgId
self.data.lv = 0
self.attrDirty = false
self.data.powerDirty = false
self:_loadConfig()
self.baseAttrOriginal = {}
self:initAttrTab()
self.allAttr = {}
self:initAttr()
self:updateAttr()
end
function HeroEntity:initAttrTab()
self.allAttr = {}
local cfg = ConfigManager:getConfig("attr")
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()
function HeroEntity:initAttr()
self.allAttr[GConst.ATTR_TYPE.hp] = 0
self.allAttr[GConst.ATTR_TYPE.atk] = 0
end
function HeroEntity:setLv(lv)
@ -74,8 +45,6 @@ end
function HeroEntity:updateAttr()
self:updateBaseAttr()
self:_updateAllAttr()
self:calculatePower()
end
function HeroEntity:updateBaseAttr()