装备系统

This commit is contained in:
Fang 2023-07-12 17:09:52 +08:00
parent 8dddb194f8
commit 28bf5ab6ad
37 changed files with 37556 additions and 35421 deletions

View File

@ -125,6 +125,7 @@ BIReport.ITEM_GET_TYPE = {
DUNGEON_WEAPON_CHALLENGE = "DungeonWeaponChallenge", DUNGEON_WEAPON_CHALLENGE = "DungeonWeaponChallenge",
DUNGEON_WEAPON_END = "DungeonWeaponEnd", DUNGEON_WEAPON_END = "DungeonWeaponEnd",
DUNGEON_WEAPON_SWEEP = "DungeonWeaponSweep", DUNGEON_WEAPON_SWEEP = "DungeonWeaponSweep",
EQUIP_UPGRADE = "EquipUpgrade",
} }
BIReport.ADS_CLICK_TYPE = { BIReport.ADS_CLICK_TYPE = {

View File

@ -14,6 +14,7 @@ function DataManager:init()
self:initManager("CollectionData", "app/userdata/collection/collection_data") self:initManager("CollectionData", "app/userdata/collection/collection_data")
self:initManager("HeroData", "app/userdata/hero/hero_data") self:initManager("HeroData", "app/userdata/hero/hero_data")
self:initManager("BagData", "app/userdata/bag/bag_data") self:initManager("BagData", "app/userdata/bag/bag_data")
self:initManager("EquipData", "app/userdata/equip/equip_data")
self:initManager("BattleData", "app/userdata/battle/battle_data") self:initManager("BattleData", "app/userdata/battle/battle_data")
self:initManager("BattlePVPData", "app/userdata/battle/battle_pvp_data") self:initManager("BattlePVPData", "app/userdata/battle/battle_pvp_data")
self:initManager("FormationData", "app/userdata/formation/formation_data") self:initManager("FormationData", "app/userdata/formation/formation_data")
@ -98,6 +99,7 @@ function DataManager:clear()
self.CollectionData:clear() self.CollectionData:clear()
self.HeroData:clear() self.HeroData:clear()
self.BagData:clear() self.BagData:clear()
self.EquipData:clear()
self.FormationData:clear() self.FormationData:clear()
self.ActivityData:clear() self.ActivityData:clear()
self.MailData:clear() self.MailData:clear()
@ -137,6 +139,7 @@ function DataManager:initWithServerData(data)
self.DungeonData:initDungeonShards(data.chapter_shards_challenge) self.DungeonData:initDungeonShards(data.chapter_shards_challenge)
self.HeroData:init(data.bag.heroes) self.HeroData:init(data.bag.heroes)
self.BagData:init(data.bag) self.BagData:init(data.bag)
self.EquipData:init(data.heroes_equips)
self.FormationData:init(data.fight_info) self.FormationData:init(data.fight_info)
self.DungeonData:initDungeonWeapon(data.chapter_weapon_challenge) self.DungeonData:initDungeonWeapon(data.chapter_weapon_challenge)
self.DungeonData:initDungeonArmor(data.chapter_armor_challenge) self.DungeonData:initDungeonArmor(data.chapter_armor_challenge)

View File

@ -48,6 +48,7 @@ EventManager.CUSTOM_EVENT = {
ARENA_RANK_SUCCESS = "ARENA_RANK_SUCCESS",-- 排行榜获取成功 ARENA_RANK_SUCCESS = "ARENA_RANK_SUCCESS",-- 排行榜获取成功
ARENA_AD_BOX_SUCCESS = "ARENA_AD_BOX_SUCCESS",-- ad宝箱获取成功 ARENA_AD_BOX_SUCCESS = "ARENA_AD_BOX_SUCCESS",-- ad宝箱获取成功
COLLECTION_CLICK_GET_POINT = "COLLECTION_CLICK_GET_POINT", COLLECTION_CLICK_GET_POINT = "COLLECTION_CLICK_GET_POINT",
EQUIP_UPGRADE_SUCCESS = "EQUIP_UPGRADE_SUCCESS",
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN", -- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER" -- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
} }

View File

@ -63,6 +63,8 @@ local MODULE_PATHS = {
CommonManager = "app/module/common/common_manager", CommonManager = "app/module/common/common_manager",
-- 武器副本 -- 武器副本
DungeonWeaponManager = "app/module/dungeon_weapon/dungeon_weapon_manager", DungeonWeaponManager = "app/module/dungeon_weapon/dungeon_weapon_manager",
-- 装备
EquipManager = "app/module/equip/equip_manager",
} }
-- 这里的key对应func_open里的id -- 这里的key对应func_open里的id
@ -90,6 +92,8 @@ ModuleManager.MODULE_KEY = {
COLLECT = "collection_open", -- 收集 COLLECT = "collection_open", -- 收集
DUNGEON_ARMOR = "dungeon_armor_open", -- 支线副本 DUNGEON_ARMOR = "dungeon_armor_open", -- 支线副本
DUNGEON_WEAPON = "dungeon_weapon_open", -- 装备副本 DUNGEON_WEAPON = "dungeon_weapon_open", -- 装备副本
EQUIP_WEAPON = "equip_weapon_open", -- 武器
EQUIP_ARMOR = "equip_armor_open", -- 防具
} }
local _moduleMgrs = {} local _moduleMgrs = {}

File diff suppressed because it is too large Load Diff

View File

@ -459,152 +459,616 @@ local item = {
[1001]={ [1001]={
["type"]=2, ["type"]=2,
["qlt"]=1, ["qlt"]=1,
["icon"]="1001" ["icon"]="1001",
["get_way_type"]=1,
["get_way"]={
1,
2,
3,
4,
5,
6,
7,
8
}
}, },
[1002]={ [1002]={
["type"]=2, ["type"]=2,
["qlt"]=2, ["qlt"]=2,
["icon"]="1002" ["icon"]="1002",
["get_way_type"]=1,
["get_way"]={
3,
4,
5,
6,
7,
8
}
}, },
[1003]={ [1003]={
["type"]=2, ["type"]=2,
["qlt"]=3, ["qlt"]=3,
["icon"]="1003" ["icon"]="1003",
["get_way_type"]=1,
["get_way"]={
6,
7,
8,
9,
10,
11,
12,
13,
14
}
}, },
[1004]={ [1004]={
["type"]=2, ["type"]=2,
["qlt"]=4, ["qlt"]=4,
["icon"]="1004" ["icon"]="1004",
["get_way_type"]=1,
["get_way"]={
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
}
}, },
[1005]={ [1005]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1005" ["icon"]="1005",
["get_way_type"]=1,
["get_way"]={
12,
13,
14,
15,
16,
17,
18,
19,
20
}
}, },
[1006]={ [1006]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1006" ["icon"]="1006",
["get_way_type"]=1,
["get_way"]={
15,
16,
17,
18,
19,
20
}
}, },
[1007]={ [1007]={
["type"]=2, ["type"]=2,
["qlt"]=1, ["qlt"]=1,
["icon"]="1007" ["icon"]="1007",
["get_way_type"]=2,
["get_way"]={
1,
5,
6,
7,
11,
12,
13,
17,
18,
19,
23,
24
}
}, },
[1008]={ [1008]={
["type"]=2, ["type"]=2,
["qlt"]=2, ["qlt"]=2,
["icon"]="1008" ["icon"]="1008",
["get_way_type"]=2,
["get_way"]={
7,
11,
12,
13,
17,
18,
19,
23,
24,
25,
29,
30,
31,
35,
36
}
}, },
[1009]={ [1009]={
["type"]=2, ["type"]=2,
["qlt"]=3, ["qlt"]=3,
["icon"]="1009" ["icon"]="1009",
["get_way_type"]=2,
["get_way"]={
13,
17,
18,
19,
23,
24,
25,
29,
30,
31,
35,
36,
37,
41,
42,
43,
47,
48
}
}, },
[1010]={ [1010]={
["type"]=2, ["type"]=2,
["qlt"]=4, ["qlt"]=4,
["icon"]="1010" ["icon"]="1010",
["get_way_type"]=2,
["get_way"]={
25,
29,
30,
31,
35,
36,
37,
41,
42,
43,
47,
48,
49,
53,
54,
55,
59,
60
}
}, },
[1011]={ [1011]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1011" ["icon"]="1011",
["get_way_type"]=2,
["get_way"]={
37,
41,
42,
43,
47,
48,
49,
53,
54,
55,
59,
60
}
}, },
[1012]={ [1012]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1012" ["icon"]="1012",
["get_way_type"]=2,
["get_way"]={
49,
53,
54,
55,
59,
60
}
}, },
[1013]={ [1013]={
["type"]=2, ["type"]=2,
["qlt"]=1, ["qlt"]=1,
["icon"]="1013" ["icon"]="1013",
["get_way_type"]=2,
["get_way"]={
2,
5,
6,
8,
11,
12,
14,
17,
18,
20,
23,
24
}
}, },
[1014]={ [1014]={
["type"]=2, ["type"]=2,
["qlt"]=2, ["qlt"]=2,
["icon"]="1014" ["icon"]="1014",
["get_way_type"]=2,
["get_way"]={
8,
11,
12,
14,
17,
18,
20,
23,
24,
26,
29,
30,
32,
35,
36
}
}, },
[1015]={ [1015]={
["type"]=2, ["type"]=2,
["qlt"]=3, ["qlt"]=3,
["icon"]="1015" ["icon"]="1015",
["get_way_type"]=2,
["get_way"]={
14,
17,
18,
20,
23,
24,
26,
29,
30,
32,
35,
36,
38,
41,
42,
44,
47,
48
}
}, },
[1016]={ [1016]={
["type"]=2, ["type"]=2,
["qlt"]=4, ["qlt"]=4,
["icon"]="1016" ["icon"]="1016",
["get_way_type"]=2,
["get_way"]={
26,
29,
30,
32,
35,
36,
38,
41,
42,
44,
47,
48,
50,
53,
54,
56,
59,
60
}
}, },
[1017]={ [1017]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1017" ["icon"]="1017",
["get_way_type"]=2,
["get_way"]={
38,
41,
42,
44,
47,
48,
50,
53,
54,
56,
59,
60
}
}, },
[1018]={ [1018]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1018" ["icon"]="1018",
["get_way_type"]=2,
["get_way"]={
50,
53,
54,
56,
59,
60
}
}, },
[1019]={ [1019]={
["type"]=2, ["type"]=2,
["qlt"]=1, ["qlt"]=1,
["icon"]="1019" ["icon"]="1019",
["get_way_type"]=2,
["get_way"]={
3,
5,
6,
9,
11,
12,
15,
17,
18,
21,
23,
24
}
}, },
[1020]={ [1020]={
["type"]=2, ["type"]=2,
["qlt"]=2, ["qlt"]=2,
["icon"]="1020" ["icon"]="1020",
["get_way_type"]=2,
["get_way"]={
9,
11,
12,
15,
17,
18,
21,
23,
24,
27,
29,
30,
33,
35,
36
}
}, },
[1021]={ [1021]={
["type"]=2, ["type"]=2,
["qlt"]=3, ["qlt"]=3,
["icon"]="1021" ["icon"]="1021",
["get_way_type"]=2,
["get_way"]={
15,
17,
18,
21,
23,
24,
27,
29,
30,
33,
35,
36,
39,
41,
42,
45,
47,
48
}
}, },
[1022]={ [1022]={
["type"]=2, ["type"]=2,
["qlt"]=4, ["qlt"]=4,
["icon"]="1022" ["icon"]="1022",
["get_way_type"]=2,
["get_way"]={
27,
29,
30,
33,
35,
36,
39,
41,
42,
45,
47,
48,
51,
53,
54,
57,
59,
60
}
}, },
[1023]={ [1023]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1023" ["icon"]="1023",
["get_way_type"]=2,
["get_way"]={
39,
41,
42,
45,
47,
48,
51,
53,
54,
57,
59,
60
}
}, },
[1024]={ [1024]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1024" ["icon"]="1024",
["get_way_type"]=2,
["get_way"]={
51,
53,
54,
57,
59,
60
}
}, },
[1025]={ [1025]={
["type"]=2, ["type"]=2,
["qlt"]=1, ["qlt"]=1,
["icon"]="1025" ["icon"]="1025",
["get_way_type"]=2,
["get_way"]={
4,
5,
6,
10,
11,
12,
16,
17,
18,
22,
23,
24
}
}, },
[1026]={ [1026]={
["type"]=2, ["type"]=2,
["qlt"]=2, ["qlt"]=2,
["icon"]="1026" ["icon"]="1026",
["get_way_type"]=2,
["get_way"]={
10,
11,
12,
16,
17,
18,
22,
23,
24,
28,
29,
30,
34,
35,
36
}
}, },
[1027]={ [1027]={
["type"]=2, ["type"]=2,
["qlt"]=3, ["qlt"]=3,
["icon"]="1027" ["icon"]="1027",
["get_way_type"]=2,
["get_way"]={
16,
17,
18,
22,
23,
24,
28,
29,
30,
34,
35,
36,
40,
41,
42,
46,
47,
48
}
}, },
[1028]={ [1028]={
["type"]=2, ["type"]=2,
["qlt"]=4, ["qlt"]=4,
["icon"]="1028" ["icon"]="1028",
["get_way_type"]=2,
["get_way"]={
28,
29,
30,
34,
35,
36,
40,
41,
42,
46,
47,
48,
52,
53,
54,
58,
59,
60
}
}, },
[1029]={ [1029]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1029" ["icon"]="1029",
["get_way_type"]=2,
["get_way"]={
40,
41,
42,
46,
47,
48,
52,
53,
54,
58,
59,
60
}
}, },
[1030]={ [1030]={
["type"]=2, ["type"]=2,
["qlt"]=5, ["qlt"]=5,
["icon"]="1030" ["icon"]="1030",
["get_way_type"]=2,
["get_way"]={
52,
53,
54,
58,
59,
60
}
}, },
[12001]={ [12001]={
["type"]=5, ["type"]=5,

View File

@ -396,6 +396,9 @@ local LocalizationGlobalConst =
DUNGEON_WEAPON_DESC_14 = "DUNGEON_WEAPON_DESC_14", DUNGEON_WEAPON_DESC_14 = "DUNGEON_WEAPON_DESC_14",
MOP_UP_DESC_1 = "MOP_UP_DESC_1", MOP_UP_DESC_1 = "MOP_UP_DESC_1",
MOP_UP_DESC_2 = "MOP_UP_DESC_2", MOP_UP_DESC_2 = "MOP_UP_DESC_2",
DUNGEON_WEAPON_DESC_15 = "DUNGEON_WEAPON_DESC_15",
EQUIP_DESC_19 = "EQUIP_DESC_19",
EQUIP_DESC_20 = "EQUIP_DESC_20",
} }
return LocalizationGlobalConst return LocalizationGlobalConst

View File

@ -396,6 +396,9 @@ local localization_global =
["DUNGEON_WEAPON_DESC_14"] = "查看", ["DUNGEON_WEAPON_DESC_14"] = "查看",
["MOP_UP_DESC_1"] = "扫荡完成", ["MOP_UP_DESC_1"] = "扫荡完成",
["MOP_UP_DESC_2"] = "再次扫荡", ["MOP_UP_DESC_2"] = "再次扫荡",
["DUNGEON_WEAPON_DESC_15"] = "灯神阵容",
["EQUIP_DESC_19"] = "最强灯神第{0}层获得",
["EQUIP_DESC_20"] = "时空裂隙{0}-{1}获得",
} }
return localization_global return localization_global

View File

@ -12,6 +12,7 @@ local CONST_PATHS = {
BattleConst = "app/module/battle/battle_const", BattleConst = "app/module/battle/battle_const",
HeroConst = "app/module/hero/hero_const", HeroConst = "app/module/hero/hero_const",
FormationConst = "app/module/formation/formation_const", FormationConst = "app/module/formation/formation_const",
EquipConst = "app/module/equip/equip_const",
ShopConst = "app/module/shop/shop_const", ShopConst = "app/module/shop/shop_const",
SummonConst = "app/module/summon/summon_const", SummonConst = "app/module/summon/summon_const",
MailConst = "app/module/mail/mail_const", MailConst = "app/module/mail/mail_const",
@ -204,6 +205,7 @@ GConst.ATLAS_PATH = {
ICON_HERO_2 = "assets/arts/atlas/icon/hero_2.asset", ICON_HERO_2 = "assets/arts/atlas/icon/hero_2.asset",
ICON_SKILL_ROGUE = "assets/arts/atlas/icon/skill_rogue.asset", ICON_SKILL_ROGUE = "assets/arts/atlas/icon/skill_rogue.asset",
ICON_BUFF = "assets/arts/atlas/icon/buff.asset", ICON_BUFF = "assets/arts/atlas/icon/buff.asset",
ICON_EQUIP = "assets/arts/atlas/icon/equip.asset",
BOUNTY = "assets/arts/atlas/ui/bounty.asset", BOUNTY = "assets/arts/atlas/ui/bounty.asset",
UI_SETTING = "assets/arts/atlas/ui/setting.asset", UI_SETTING = "assets/arts/atlas/ui/setting.asset",
ICON_TASK = "assets/arts/atlas/icon/task.asset", ICON_TASK = "assets/arts/atlas/icon/task.asset",
@ -481,6 +483,14 @@ GConst.ENTITY_TYPE = {
JEWELRY_ENTITY = 3, JEWELRY_ENTITY = 3,
} }
GConst.MATCH_HP_NAME = {
[1] = "hp",
[2] = "hp",
[3] = "hp",
[4] = "hp",
[5] = "hp",
}
GConst.MATCH_ATTACK_NAME = { GConst.MATCH_ATTACK_NAME = {
[0] = "atk", [0] = "atk",
[1] = "atk_red", [1] = "atk_red",

View File

@ -428,6 +428,11 @@ function GFunc.getBuffDesc(buffName, effectNum)
return I18N:getTextWithOtherKey("buff", "name", buffName, "desc", effectNum) return I18N:getTextWithOtherKey("buff", "name", buffName, "desc", effectNum)
end end
function GFunc.getAttrDesc(attrName, attrNum)
attrNum = attrNum // 100 .. "%"
return I18N:getTextWithOtherKey("attr", "name", attrName, "desc", attrNum)
end
function GFunc.getAttrName(key) function GFunc.getAttrName(key)
return I18N:getText("attr", key, "name") return I18N:getText("attr", key, "name")
end end

View File

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

View File

@ -0,0 +1,27 @@
local EquipConst = {}
-- 部位类型
EquipConst.PART_TYPE = {
WEAPON = 1,
HAT = 2,
CLOTHES = 3,
BELT = 4,
HANDGUARD = 5
}
-- 界面类型
EquipConst.PANEL_TYPE = {
HERO = 1,
WEAPON = 2,
ARMOR = 3,
}
-- 加成属性类型
EquipConst.ATTR_TYPE = {
HP = 1,
ATK = 2,
NORMAL_HURT = 3,
SKILL_HURT = 4,
}
return EquipConst

View File

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

View File

@ -0,0 +1,40 @@
local EquipManager = class("EquipManager", BaseModule)
-- 升级装备
function EquipManager:reqUpgrade(id, part)
local entity = DataManager.EquipData:getEquip(id, part)
if not entity then
return
end
if not entity:isEnoughMaterial() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_8))
-- 打开副本界面
return
end
if not entity:isEnoughGold() then
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_GOLD)
ModuleManager.ShopManager:tryTriggerCoinGift()
return
end
if entity:isMaxLevel() then
if entity:getPart() == GConst.EquipConst.PART_TYPE.WEAPON then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_7, DataManager.PlayerData:getLv() + 1))
else
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_9, entity:getLevel() + 1))
end
return
end
self:sendMessage(ProtoMsgType.FromMsgEnum.EquipUpgradeReq, {hero_id = id, position = part}, {}, self.rspUpgrade, BIReport.ITEM_GET_TYPE.EQUIP_UPGRADE)
end
function EquipManager:rspUpgrade(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.EquipData:onUpgradeEquip(result.reqData.hero_id, result.reqData.position)
end
end
return EquipManager

View File

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

View File

@ -16,6 +16,55 @@ HeroConst.CHECK_LV_UP_STATE = {
COIN_NOT_ENOUGH = 5 COIN_NOT_ENOUGH = 5
} }
-- 总计
HeroConst.ATTR_SHOW_TOTAL = {
GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
GConst.MATCH_NORMAL_HURT_NAME, -- 普攻增伤
GConst.MATCH_SKILL_HURT_NAME, -- 技能增伤
GConst.MATCH_CRIT_NAME, -- 暴击率百分比
GConst.MATCH_CRIT_TIME_NAME, -- 暴击伤害百分比
GConst.MATCH_NORMAL_HURTP_NAME, -- 普攻增伤百分比
GConst.MATCH_SKILL_HURTP_NAME, -- 技能增伤百分比
GConst.MATCH_CURED_NAME, -- 治疗效果提升百分比
}
-- 基础
HeroConst.ATTR_SHOW_BASE = {
GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
}
-- 武器
HeroConst.ATTR_SHOW_WEAPON = {
GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
GConst.MATCH_CRIT_NAME, -- 暴击率百分比
GConst.MATCH_CRIT_TIME_NAME, -- 暴击伤害百分比
GConst.MATCH_CURED_NAME, -- 治疗效果提升百分比
}
-- 防具
HeroConst.ATTR_SHOW_ARMOR = {
GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
GConst.MATCH_NORMAL_HURT_NAME, -- 普攻增伤
GConst.MATCH_SKILL_HURT_NAME, -- 技能增伤
GConst.MATCH_NORMAL_HURTP_NAME, -- 普攻增伤百分比
GConst.MATCH_SKILL_HURTP_NAME, -- 技能增伤百分比
}
-- 皮肤
HeroConst.ATTR_SHOW_SKIN = {
GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
}
-- 需要显示属性的模块
HeroConst.SHOW_NODE =
{
HeroConst.ATTR_SHOW_TOTAL,
HeroConst.ATTR_SHOW_BASE,
HeroConst.ATTR_SHOW_WEAPON,
HeroConst.ATTR_SHOW_ARMOR,
}
HeroConst.TRIAL_HERO_ID = 34001 -- 花木兰 HeroConst.TRIAL_HERO_ID = 34001 -- 花木兰
HeroConst.TRIAL_HERO_MIN_CHAPTER = 2 HeroConst.TRIAL_HERO_MIN_CHAPTER = 2
HeroConst.TRIAL_HERO_MAX_CHAPTER = 4 HeroConst.TRIAL_HERO_MAX_CHAPTER = 4

View File

@ -0,0 +1,194 @@
local ArmorInfoComp = class("ArmorInfoComp", LuaComponent)
local BTN_ICON = {"common_btn_green_2", "common_btn_grey_2"}
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
local ARMOR_PART_INDEX = {
[1] = GConst.EquipConst.PART_TYPE.HAT,
[2] = GConst.EquipConst.PART_TYPE.CLOTHES,
[3] = GConst.EquipConst.PART_TYPE.HANDGUARD,
[4] = GConst.EquipConst.PART_TYPE.BELT,
}
function ArmorInfoComp:init()
local uiMap = self:getUIMap()
self.txAttr = uiMap["armor_info.attr.tx_attr"]
self.txDesc = uiMap["armor_info.tx_desc"]
self.btnUp = uiMap["armor_info.upgrade.btn_up"]
self.txUp = uiMap["armor_info.upgrade.btn_up.tx_desc"]
self.txNum = uiMap["armor_info.upgrade.btn_up.tx_num"]
self.btnAttr = uiMap["armor_info.attr.btn_attr"]
self.imgCurBg = uiMap["armor_info.current.cur_armor.bg"]
self.txCurName = uiMap["armor_info.current.cur_armor.name.tx_name"]
self.imgCurIcon = uiMap["armor_info.current.cur_armor.img_icon"]
self.txCurLevel = uiMap["armor_info.current.cur_armor.tx_num"]
self.imgNextBg = uiMap["armor_info.current.next_armor.bg"]
self.txNextName = uiMap["armor_info.current.next_armor.name.tx_name"]
self.imgNextIcon = uiMap["armor_info.current.next_armor.img_icon"]
self.txNextLevel = uiMap["armor_info.current.next_armor.tx_num"]
self.attr = {}
for i = 1, 2 do
self.attr[i] = uiMap["armor_info.attr_" .. i]
end
self.armor = {}
for i = 1, 4 do
self.armor[i] = uiMap["armor_info.other.armor_" .. i]
self.armor[i]:addClickListener(function()
self:onSelectIdx(i)
end)
end
self.txAttr:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_6))
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16))
self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3))
self.btnUp:addClickListener(function()
ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), self.selectPart)
end)
self.btnAttr:addClickListener(function()
ModuleManager.TipsManager:showDescTips(DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), self.selectPart):getAttrDesc(), self.btnAttr)
end)
end
function ArmorInfoComp:setHeroData(heroEntity)
self.heroEntity = heroEntity
self.selectPart = self.selectPart or GConst.EquipConst.PART_TYPE.HAT
end
function ArmorInfoComp:refresh()
self:onSelectIdx(self:getIndexByPart(self.selectPart))
end
function ArmorInfoComp:onSelectIdx(index)
self.selectPart = ARMOR_PART_INDEX[index]
self:refreshSelectArmor()
for index, value in ipairs(self.armor) do
self:refreshPart(index)
end
end
function ArmorInfoComp:refreshSelectArmor()
-- current
local armorEntity = DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), self.selectPart)
self.txCurName:setText(armorEntity:getName())
self.imgCurBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. armorEntity:getStage())
-- self.imgCurIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorEntity:getIconId())
self.txCurLevel:setText("+".. armorEntity:getLevel())
-- next
local armorNextEntity = armorEntity:getNextLevelEntity()
self.txNextName:setText(armorNextEntity:getName())
self.imgNextBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. armorNextEntity:getStage())
-- self.imgNextIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorNextEntity:getIconId())
self.txNextLevel:setText("+".. armorNextEntity:getLevel())
-- 基础属性
local diffAtk = (armorNextEntity:getAttack() - armorEntity:getAttack()) // DEFAULT_FACTOR
local diffNormalHurt = (armorNextEntity:getNormalHurt() - armorEntity:getNormalHurt()) // DEFAULT_FACTOR
local diffSkillHurt = (armorNextEntity:getSkillHurt() - armorEntity:getSkillHurt()) // DEFAULT_FACTOR
local diffHp = (armorNextEntity:getHp() - armorEntity:getHp()) // DEFAULT_FACTOR
local showAttrType = {}
for index, obj in ipairs(self.attr) do
local map = obj:genAllChildren()
local imgIcon = map["img_icon"]
local txTitle = map["tx_title"]
local txNum = map["tx_num"]
obj:setVisible(true)
if not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK) and diffAtk > 0 then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_5")
txTitle:setText("<color=#FCB501>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3).."</color>")
txNum:setText(armorEntity:getAttack() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffAtk .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT) and diffNormalHurt > 0 then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_20")
txTitle:setText("<color=#4CCFFA>"..I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURT).."</color>")
txNum:setText(armorEntity:getNormalHurt() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffNormalHurt .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT) and diffSkillHurt > 0 then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_21")
txTitle:setText("<color=#EC80FF>"..I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURT).."</color>")
txNum:setText(armorEntity:getSkillHurt() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffSkillHurt .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.HP) and diffHp > 0 then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.HP)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_4")
txTitle:setText("<color=#FB6895>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2).."</color>")
txNum:setText(armorEntity:getHp() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffHp .. "</color>")
else
obj:setVisible(false)
end
end
-- 消耗材料
local cost = armorEntity:getUpgradeMaterials()
for i = 1, 3 do
local uiMap = self:getUIMap()
local costNode = uiMap["armor_info.upgrade.cost.cost_" .. i]
if cost[i] then
costNode:setActive(true)
local icon = uiMap["armor_info.upgrade.cost.cost_" .. i .. ".img_icon"]
local num = uiMap["armor_info.upgrade.cost.cost_" .. i .. ".tx_num"]
local costId = GFunc.getRewardId(cost[i])
local costNum = GFunc.getRewardNum(cost[i])
local haveNum = DataManager.BagData.ItemData:getItemNumById(costId)
if haveNum < costNum then
num:setText("<color=#FF5252>" .. haveNum .. "</color>/" .. costNum)
else
num:setText(haveNum .. "/" .. costNum)
end
-- icon:setSprite(GFunc.getIconRes(costId))
else
costNode:setActive(false)
end
end
self.txNum:setText(armorEntity:getUpgradeGoldNum())
local canLvUp = armorEntity:canLevelUp()
if canLvUp then
self.btnUp:addRedPoint(120, 50, 0.6)
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
else
self.btnUp:removeRedPoint()
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end
end
function ArmorInfoComp:refreshPart(index)
local part = ARMOR_PART_INDEX[index]
local armorObj = self.armor[index]
-- Logger.logHighlight("index:"..index)
-- Logger.logHighlight("part:"..part)
if not armorObj then
Logger.logHighlight("不存在部位:"..part)
return
end
local armorEntity = DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), part)
local map = armorObj:genAllChildren()
local imgSelect = map["img_select"]
local imgBg = map["img_bg"]
local imgIcon = map["img_icon"]
local imgType = map["img_type"]
local txLevel = map["tx_num"]
local stage = armorEntity:getStage()
imgSelect:setActive(part == self.selectPart)
imgSelect:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_select_" .. math.floor(stage / 2) + stage % 2)
imgBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. stage)
-- imgIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorEntity:getIconId())
imgType:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, stage <= 1 and "frame_dec_1" or "frame_dec_2")
txLevel:setText("+".. armorEntity:getLevel())
end
function ArmorInfoComp:getIndexByPart(part)
for i, p in ipairs(ARMOR_PART_INDEX) do
if p == part then
return i
end
end
return nil
end
return ArmorInfoComp

View File

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

View File

@ -0,0 +1,236 @@
local AttrCell = class("AttrCell", BaseCell)
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
function AttrCell:init()
local uiMap = self:getUIMap()
self.imgIcon = uiMap["attr_cell.img_icon"]
self.txDesc = uiMap["attr_cell.tx_desc"]
self.txValue = uiMap["attr_cell.tx_value"]
end
function AttrCell:refresh(heroId, nodeType, attrType)
self.heroEntity = DataManager.HeroData:getHeroById(heroId)
self.weaponEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.WEAPON)
self.hatEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.HAT)
self.clothesEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.CLOTHES)
self.beltEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.BELT)
self.handguardEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.HANDGUARD)
self.nodeType = nodeType
self.attrName = attrType[self.heroEntity:getMatchType()]
if attrType == GConst.MATCH_HP_NAME then
self:showHp()
elseif attrType == GConst.MATCH_ATTACK_NAME then
self:showAtk()
elseif attrType == GConst.MATCH_NORMAL_HURT_NAME then
self:showNormalHurt()
elseif attrType == GConst.MATCH_SKILL_HURT_NAME then
self:showSkillHurt()
elseif attrType == GConst.MATCH_CRIT_NAME then
self:showCrit()
elseif attrType == GConst.MATCH_CRIT_TIME_NAME then
self:showCritAtk()
elseif attrType == GConst.MATCH_NORMAL_HURTP_NAME then
self:showNormalHurtp()
elseif attrType == GConst.MATCH_SKILL_HURTP_NAME then
self:showSkillHurtp()
elseif attrType == GConst.MATCH_CURED_NAME then
self:showCured()
end
end
-- 显示生命
function AttrCell:showHp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_2")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_HP))
local totalBaseValue = 0
totalBaseValue = totalBaseValue + self.heroEntity:getAttrValue(self.attrName)
totalBaseValue = totalBaseValue + self.weaponEntity:getHp()
totalBaseValue = totalBaseValue + DataManager.EquipData:getTotalArmorHp(self.heroEntity:getCfgId())
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
value = self.heroEntity:getCfgHp(self.heroEntity:getLv())
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getHp()
value = value + totalBaseValue * self.weaponEntity:getHpPercent() // DEFAULT_FACTOR
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = DataManager.EquipData:getTotalArmorHp(self.heroEntity:getCfgId())
value = value + totalBaseValue * DataManager.EquipData:getTotalArmorHpPercent(self.heroEntity:getCfgId()) // DEFAULT_FACTOR
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示攻击力
function AttrCell:showAtk()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_1")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_ATK))
local totalBaseValue = 0
totalBaseValue = totalBaseValue + self.heroEntity:getAttrValue(self.attrName)
totalBaseValue = totalBaseValue + self.weaponEntity:getHp()
totalBaseValue = totalBaseValue + DataManager.EquipData:getTotalArmorAttack(self.heroEntity:getCfgId())
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
value = self.heroEntity:getCfgAtk(self.heroEntity:getLv())
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getAttack()
value = value + totalBaseValue * self.weaponEntity:getAtkPercent() // DEFAULT_FACTOR
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = DataManager.EquipData:getTotalArmorAttack(self.heroEntity:getCfgId())
value = value + totalBaseValue * DataManager.EquipData:getTotalArmorAttackPercent(self.heroEntity:getCfgId()) // DEFAULT_FACTOR
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示普攻增伤
function AttrCell:showNormalHurt()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_3")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURTP))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = value + self.hatEntity:getNormalHurt()
value = value + self.clothesEntity:getNormalHurt()
value = value + self.beltEntity:getNormalHurt()
value = value + self.handguardEntity:getNormalHurt()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示技能增伤
function AttrCell:showSkillHurt()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_4")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURTP))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = value + self.hatEntity:getSkillHurt()
value = value + self.clothesEntity:getSkillHurt()
value = value + self.beltEntity:getSkillHurt()
value = value + self.handguardEntity:getSkillHurt()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示暴击率
function AttrCell:showCrit()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_5")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getCritPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value)
end
-- 显示暴击伤害
function AttrCell:showCritAtk()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_6")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT_TIME))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getCritHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value)
end
-- 显示普攻增伤百分比
function AttrCell:showNormalHurtp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_3")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURT))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = value + self.hatEntity:getNormalHurtPercent()
value = value + self.clothesEntity:getNormalHurtPercent()
value = value + self.beltEntity:getNormalHurtPercent()
value = value + self.handguardEntity:getNormalHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示技能增伤百分比
function AttrCell:showSkillHurtp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_4")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURT))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = value + self.hatEntity:getSkillHurtPercent()
value = value + self.clothesEntity:getSkillHurtPercent()
value = value + self.beltEntity:getSkillHurtPercent()
value = value + self.handguardEntity:getSkillHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示治疗效果提升百分比
function AttrCell:showCured()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_7")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CURED))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getHealPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value)
end
return AttrCell

View File

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

View File

@ -0,0 +1,32 @@
local AttrNodeCell = class("AttrNodeCell", BaseCell)
local ATTR_CELL = "app/ui/hero/cell/attr_cell"
local ATTR_CELL_PATH = "assets/prefabs/ui/hero/cell/attr_cell.prefab"
function AttrNodeCell:init()
local uiMap = self:getUIMap()
self.txTitle = uiMap["total_node.tx_title"]
self.itemsRoot = uiMap["total_node.items"]
end
function AttrNodeCell:refresh(heroId, node)
if node == GConst.HeroConst.ATTR_SHOW_TOTAL then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_13))
elseif node == GConst.HeroConst.ATTR_SHOW_BASE then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_14))
elseif node == GConst.HeroConst.ATTR_SHOW_WEAPON then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_15))
elseif node == GConst.HeroConst.ATTR_SHOW_ARMOR then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16))
elseif node == GConst.HeroConst.ATTR_SHOW_SKIN then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_17))
end
for index, attr in ipairs(node) do
CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell)
cell:refresh(heroId, node, attr)
end)
end
end
return AttrNodeCell

View File

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

View File

@ -0,0 +1,57 @@
local HeroAttrUI = class("HeroAttrUI", BaseUI)
local ATTR_NODE_CELL = "app/ui/hero/cell/attr_node_cell"
local ATTR_NODE_CELL_PATH = "assets/prefabs/ui/hero/cell/attr_node_cell.prefab"
local ATTR_CELLS_PADDING = 60
local ATTR_CELL_HEIGHT = 80
local ATTR_CELL_SPACING_Y = 8
function HeroAttrUI:isFullScreen()
return false
end
function HeroAttrUI:getPrefabPath()
return "assets/prefabs/ui/hero/hero_attr_ui.prefab"
end
function HeroAttrUI:onPressBackspace()
self:closeUI()
end
function HeroAttrUI:onClose()
self.rootNodes:removeAllChildren()
end
function HeroAttrUI:ctor(parmas)
self.heroId = parmas
end
function HeroAttrUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.txTitle = uiMap["hero_attr_ui.content.tx_title"]
self.btnClose = uiMap["hero_attr_ui.content.btn_close"]
self.rootNodes = uiMap["hero_attr_ui.content.ScrollView.Viewport.Content"]
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_18))
self.btnClose:addClickListener(function()
self:closeUI()
end)
end
function HeroAttrUI:onRefresh()
local totalHeight = 0
for index, node in ipairs(GConst.HeroConst.SHOW_NODE) do
CellManager:loadCellAsync(ATTR_NODE_CELL_PATH, ATTR_NODE_CELL, self.rootNodes, function(cell)
local nodeHeight = math.ceil(#node / 2) * ATTR_CELL_HEIGHT + (math.ceil(#node / 2) - 1) * ATTR_CELL_SPACING_Y + ATTR_CELLS_PADDING
cell.baseObject:setLocalPositionY(-totalHeight)
cell.baseObject:setSizeDeltaY(nodeHeight)
cell:refresh(self.heroId, node)
totalHeight = totalHeight + nodeHeight
self.rootNodes:setSizeDeltaY(totalHeight)
end)
end
end
return HeroAttrUI

View File

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

View File

@ -14,11 +14,7 @@ function HeroComp:init()
self:onClickHero(cell, heroId) self:onClickHero(cell, heroId)
end) end)
end) end)
self.heroList = {} self.heroList = DataManager.HeroData:getAllHeroesSort()
local heroCfg = ConfigManager:getConfig("hero")
for id, v in pairs(heroCfg) do
table.insert(self.heroList, {cfgId = id, sort = id, elementType = v.position})
end
self.heroNodeList = { self.heroNodeList = {
self.uiMap["hero_ui.formation.hero_1"], self.uiMap["hero_ui.formation.hero_1"],
self.uiMap["hero_ui.formation.hero_2"], self.uiMap["hero_ui.formation.hero_2"],
@ -182,7 +178,6 @@ function HeroComp:refreshScrollRect()
end end
end end
self:sortHeroList()
self.allHeroCount = #self.heroList self.allHeroCount = #self.heroList
self.unlockCount = DataManager.HeroData:getUnlockHeroCount() self.unlockCount = DataManager.HeroData:getUnlockHeroCount()
local lockCount = self.allHeroCount - self.unlockCount local lockCount = self.allHeroCount - self.unlockCount
@ -202,35 +197,6 @@ function HeroComp:refreshScrollRect()
end end
end end
-- 等级>品质>id
function HeroComp:sortHeroList()
local HeroData = DataManager.HeroData
for _, info in ipairs(self.heroList) do
local heroEntity = HeroData:getHeroById(info.cfgId)
local sort = info.cfgId -- id 预留6位
sort = sort + (10 - info.elementType) * 1000000 -- 位置预留1位
sort = sort + 10000000 * heroEntity:getQlt() -- 品质1位
sort = sort + 100000000 * heroEntity:getLv() -- 预留3位
if heroEntity:isUnlock() then
sort = sort + 300000000000
if heroEntity:isActived() then
sort = sort + 400000000000
else
sort = sort + 300000000000
end
elseif DataManager.BagData.ItemData:getItemNumById(heroEntity:getFragmentId()) > 0 then
sort = sort + 200000000000
else
sort = sort + 100000000000
end
info.sort = sort
end
table.sort(self.heroList, function(a, b)
return a.sort > b.sort
end)
end
function HeroComp:onClickHero(cell, heroId) function HeroComp:onClickHero(cell, heroId)
if not cell or not heroId then if not cell or not heroId then
self.largeHeroCell:getBaseObject():setAnchoredPositionX(OUT_SCREEN_X) self.largeHeroCell:getBaseObject():setAnchoredPositionX(OUT_SCREEN_X)

View File

@ -1,9 +1,7 @@
local HeroDetailUI = class("HeroDetailUI", BaseUI) local HeroDetailUI = class("HeroDetailUI", BaseUI)
local COMP_HERO = "app/ui/hero/hero_info_comp"
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR local COMP_WEAPON = "app/ui/hero/weapon_info_comp"
local COMP_ARMOR = "app/ui/hero/armor_info_comp"
local BTN_ICON = {"common_btn_green_2", "common_btn_grey_2"}
local SIZE_DELTA_Y_HERO = 942 local SIZE_DELTA_Y_HERO = 942
local SIZE_DELTA_Y_LOOK = 802 local SIZE_DELTA_Y_LOOK = 802
@ -20,6 +18,7 @@ function HeroDetailUI:onPressBackspace()
end end
function HeroDetailUI:ctor(parmas) function HeroDetailUI:ctor(parmas)
self.panelType = parmas.panelType or GConst.EquipConst.PANEL_TYPE.HERO
self.onlyLook = parmas.onlyLook self.onlyLook = parmas.onlyLook
if parmas.heroEntity then if parmas.heroEntity then
self.heroEntity = parmas.heroEntity self.heroEntity = parmas.heroEntity
@ -30,175 +29,197 @@ function HeroDetailUI:ctor(parmas)
end end
function HeroDetailUI:onLoadRootComplete() function HeroDetailUI:onLoadRootComplete()
self:_initSpineObjs()
self:_display()
self:_addListeners()
self:_bind()
end
function HeroDetailUI:_display(lvChange)
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["hero_detail_ui.bg.title_desc"]:setText(self.heroEntity:getName())
uiMap["hero_detail_ui.bg.lv_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.heroEntity:getLv()))
local elementBg = uiMap["hero_detail_ui.bg.element_bg"] self.commonInfo = uiMap["hero_detail_ui.common"]
local elementTx = uiMap["hero_detail_ui.bg.element_desc"] self.heroInfo = uiMap["hero_detail_ui.hero_info"]
elementTx:setText(ModuleManager.HeroManager:getMatchTypeName(self.heroEntity:getMatchType())) self.weaponInfo = uiMap["hero_detail_ui.weapon_info"]
local elementTxRectWidth = elementTx:getRectWidth() self.armorInfo = uiMap["hero_detail_ui.armor_info"]
local elementTxWidth = elementTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth self.txTitle = uiMap["hero_detail_ui.common.img_title.tx_title"]
if elementTxWidth > elementTxRectWidth then self.btnClose = uiMap["hero_detail_ui.common.btn_close"]
elementBg:setSizeDeltaX(52 + elementTxWidth) self.btnHero = uiMap["hero_detail_ui.common.btns.btn_hero"]
self.txHero1 = uiMap["hero_detail_ui.common.btns.btn_hero.tx_btn"]
self.selectHero = uiMap["hero_detail_ui.common.btns.btn_hero.select"]
self.txHero2 = uiMap["hero_detail_ui.common.btns.btn_hero.select.tx_select"]
self.btnWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon"]
self.lockWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon.img_lock"]
self.txWeapon1 = uiMap["hero_detail_ui.common.btns.btn_weapon.tx_btn"]
self.selectWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon.select"]
self.txWeapon2 = uiMap["hero_detail_ui.common.btns.btn_weapon.select.tx_select"]
self.btnArmor = uiMap["hero_detail_ui.common.btns.btn_armor"]
self.lockArmor = uiMap["hero_detail_ui.common.btns.btn_armor.img_lock"]
self.txArmor1 = uiMap["hero_detail_ui.common.btns.btn_armor.tx_btn"]
self.selectArmor = uiMap["hero_detail_ui.common.btns.btn_armor.select"]
self.txArmor2 = uiMap["hero_detail_ui.common.btns.btn_armor.select.tx_select"]
self.btnLeft = uiMap["hero_detail_ui.common.btn_left"]
self.btnRight = uiMap["hero_detail_ui.common.btn_right"]
self.txHero1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
self.txHero2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
self.txWeapon1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
self.txWeapon2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
self.txArmor1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
self.txArmor2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
if not DataManager.EquipData:isWeaponOpen() then
self.lockWeapon:setVisible(true)
GFunc.centerImgAndTx(self.lockWeapon, self.txWeapon1, 5)
else else
elementBg:setSizeDeltaX(52 + elementTxRectWidth) self.lockWeapon:setVisible(false)
end
if not DataManager.EquipData:isArmorOpen() then
self.lockArmor:setVisible(true)
GFunc.centerImgAndTx(self.lockArmor, self.txArmor1, 5)
else
self.lockArmor:setVisible(false)
end end
uiMap["hero_detail_ui.bg.skill_desc"]:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getBaseSkill()))
uiMap["hero_detail_ui.bg.hp_name"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2))
uiMap["hero_detail_ui.bg.atk_name"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3))
uiMap["hero_detail_ui.bg.skill_node.skill_icon"]:setSprite(GConst.ATLAS_PATH.ICON_SKILL_BIG, ModuleManager.HeroManager:getSkillIcon(self.heroEntity:getBaseSkill()))
uiMap["hero_detail_ui.bg.hero_element"]:setSprite(GConst.ATLAS_PATH.HERO, ModuleManager.HeroManager:getMatchTypeIcon(self.heroEntity:getMatchType()))
local materials = self.heroEntity:getLvUpMaterials() or {} self.heroList = DataManager.HeroData:getAllHeroesSort()
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFragmentId()) self:updateSide()
local needFragmentCount = materials[1] or 1 self:refreshShow()
uiMap["hero_detail_ui.bg.fragment_bg.fragment_num"]:setText(fragmentCount .. "/" .. needFragmentCount)
local slider = uiMap["hero_detail_ui.bg.fragment_bg.slider"] self.btnHero:addClickListener(function()
if fragmentCount >= needFragmentCount then self.panelType = GConst.EquipConst.PANEL_TYPE.HERO
slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_1", nil, slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)) self:refreshShow()
else end)
slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_2", nil, slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)) self.btnWeapon:addClickListener(function()
end if not DataManager.EquipData:isWeaponOpen(true) then
slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount return
local activeCount = self.heroEntity:getActiveRogueCount()
local skillList = self.heroEntity:getRogueSkillList()
local skillLvs = ModuleManager.HeroManager:getActiveRogueLvs()
for i = 1, 7 do
local skillId = skillList[i]
if skillId then
local skillIcon = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".icon"]
local skillBg = uiMap["hero_detail_ui.bg.skill_up_" .. i]
local skillLv = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".desc"]
skillBg:addClickListener(function()
ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId), skillIcon)
end)
skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueIcon(skillId))
skillBg:setTouchEnable(true)
if i > activeCount then
skillLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, skillLvs[i] or 0))
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, "frame_0")
else
skillLv:setText(GConst.EMPTY_STRING)
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueBg(skillId, true))
if i == activeCount and lvChange and self.heroEntity:getLv() == skillLvs[i] then
local x, y = skillBg:fastGetAnchoredPosition()
self.spineObjSkill:setAnchoredPosition(x, y)
self.spineObjSkill:setVisible(true)
self.spineObjSkill:playAnim("idle", false, true)
end
end
end end
end self.panelType = GConst.EquipConst.PANEL_TYPE.WEAPON
self:refreshShow()
uiMap["hero_detail_ui.bg.fragment_bg"]:setVisible(not self.heroEntity:isMaxLv()) end)
self.btnArmor:addClickListener(function()
local canLvUp = self.heroEntity:canLvUp() if not DataManager.EquipData:isArmorOpen(true) then
uiMap["hero_detail_ui.bg.fragment_bg.fragment_icon"]:setVisible(not canLvUp) return
local lv = self.heroEntity:getLv()
local str
local hpStr
local atkStr
if self.heroEntity:isActived() then
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)
local curHp = self.heroEntity:getCfgHp() // DEFAULT_FACTOR
local curAtk = self.heroEntity:getCfgAtk() // DEFAULT_FACTOR
local addHp = self.heroEntity:getCfgHp(lv + 1) // DEFAULT_FACTOR - curHp
local addAtk = self.heroEntity:getCfgAtk(lv + 1) // DEFAULT_FACTOR - curAtk
if addHp <= 0 then
hpStr = curHp
else
hpStr = curHp .. "<color=#82FF82>+" .. addHp .. "</color>"
end end
if addAtk <= 0 then self.panelType = GConst.EquipConst.PANEL_TYPE.ARMOR
atkStr = curAtk self:refreshShow()
else end)
atkStr = curAtk .. "<color=#82FF82>+" .. addAtk .. "</color>" self.btnClose:addClickListener(function()
end
else
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_5)
hpStr = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
atkStr = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
end
uiMap["hero_detail_ui.bg.up_btn.desc"]:setText(str)
uiMap["hero_detail_ui.bg.up_btn.num"]:setText(materials[2])
uiMap["hero_detail_ui.bg.up_btn.rp"]:setVisible(self.heroEntity:canLvUp())
uiMap["hero_detail_ui.bg.hp"]:setText(hpStr)
uiMap["hero_detail_ui.bg.atk"]:setText(atkStr)
local btn = uiMap["hero_detail_ui.bg.up_btn"]
self.spineObjLv:setVisible(canLvUp)
if canLvUp then
btn:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
self.spineObjLv:playAnim("animation", true, false)
else
btn:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end
btn:setTouchEnable(true)
btn:setActive(not self.heroEntity:isMaxLv())
if lvChange then
self.spineObj:setVisible(true)
self.spineObj:playAnim("idle", false, true)
end
if self.onlyLook then -- 仅查看的不显示升级和激活按钮
uiMap["hero_detail_ui.bg.down"]:setVisible(false)
uiMap["hero_detail_ui.bg.up_btn"]:setVisible(false)
uiMap["hero_detail_ui.bg"]:setSizeDeltaY(SIZE_DELTA_Y_LOOK)
else
uiMap["hero_detail_ui.bg.down"]:setVisible(true)
uiMap["hero_detail_ui.bg.up_btn"]:setVisible(true)
uiMap["hero_detail_ui.bg"]:setSizeDeltaY(SIZE_DELTA_Y_HERO)
end
end
function HeroDetailUI:_addListeners()
local uiMap = self.root:genAllChildren()
uiMap["hero_detail_ui.bg.back_btn"]:addClickListener(function()
self:closeUI() self:closeUI()
end) end)
self.btnLeft:addClickListener(function()
uiMap["hero_detail_ui.bg.up_btn"]:addClickListener(function() if not self:isExistLeftHero() then
ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity) return
end
self.heroEntity = DataManager.HeroData:getHeroById(self.heroList[self.idxLast].cfgId)
self:updateSide()
self:refreshShow()
end) end)
end self.btnRight:addClickListener(function()
if not self:isExistRightHero() then
function HeroDetailUI:_bind() return
self:bind(self.heroEntity, "lv", function() end
self:_display(true) self.heroEntity = DataManager.HeroData:getHeroById(self.heroList[self.idxNext].cfgId)
self:updateSide()
self:refreshShow()
end)
self:addEventListener(EventManager.CUSTOM_EVENT.EQUIP_UPGRADE_SUCCESS, function()
self:refreshShow()
end) end)
self:bind(DataManager.BagData.ItemData:getItemById(GConst.ItemConst.ITEM_ID_GOLD), "isDirty", function() self:bind(DataManager.BagData.ItemData:getItemById(GConst.ItemConst.ITEM_ID_GOLD), "isDirty", function()
self:_display() self:refreshShow()
end) end)
end end
function HeroDetailUI:_initSpineObjs() function HeroDetailUI:updateSide()
local uiMap = self.root:genAllChildren() for index, data in ipairs(self.heroList) do
self.spineObjSkill = uiMap["hero_detail_ui.bg.ui_spine_obj_skill"] if data.cfgId == self.heroEntity.id then
self.spineObjLv = uiMap["hero_detail_ui.bg.ui_spine_obj_lv"] self.idxLast = index - 1
self.spineObj = uiMap["hero_detail_ui.bg.ui_spine_obj"] self.idxNext = index + 1
self.spineObjAvatar = uiMap["hero_detail_ui.bg.ui_spine_obj_avatar"] end
end
end
self.spineObjAvatar:getSkeletonGraphic().enabled = false function HeroDetailUI:refreshShow()
self.spineObjAvatar:loadAssetAsync(self.heroEntity:getModelId(), function() self.txTitle:setText(self.heroEntity:getName())
self.spineObjAvatar:getSkeletonGraphic().enabled = true
self.spineObjAvatar:playAnim("idle", true, true, true)
end, true)
self.spineObjSkill:setVisible(false) if self.panelType == GConst.EquipConst.PANEL_TYPE.HERO then
self.spineObjLv:setVisible(false) self:showHeroInfo()
self.spineObj:setVisible(false) elseif self.panelType == GConst.EquipConst.PANEL_TYPE.WEAPON then
self:showWeaponInfo()
elseif self.panelType == GConst.EquipConst.PANEL_TYPE.ARMOR then
self:showArmorInfo()
end
if self.onlyLook then -- 仅查看的不显示升级和激活按钮
self.btnHero:setVisible(false)
self.btnWeapon:setVisible(false)
self.btnArmor:setVisible(false)
self.btnLeft:setVisible(false)
self.btnRight:setVisible(false)
self.commonInfo:setSizeDeltaY(SIZE_DELTA_Y_LOOK)
else
self.btnHero:setVisible(true)
self.btnWeapon:setVisible(true)
self.btnArmor:setVisible(true)
self.btnLeft:setVisible(self:isExistLeftHero())
self.btnRight:setVisible(self:isExistRightHero())
self.commonInfo:setSizeDeltaY(SIZE_DELTA_Y_HERO)
end
end
function HeroDetailUI:showHeroInfo()
self.heroInfo:setActive(true)
self.selectHero:setActive(true)
self.weaponInfo:setActive(false)
self.selectWeapon:setActive(false)
self.armorInfo:setActive(false)
self.selectArmor:setActive(false)
if not self.compHero then
self.heroInfo:initPrefabHelper()
self.heroInfo:genAllChildren()
self.compHero = self.heroInfo:addLuaComponent(COMP_HERO)
end
self.compHero:setHeroData(self.heroEntity, self.onlyLook)
self.compHero:refresh()
end
function HeroDetailUI:showWeaponInfo()
self.heroInfo:setActive(false)
self.selectHero:setActive(false)
self.weaponInfo:setActive(true)
self.selectWeapon:setActive(true)
self.armorInfo:setActive(false)
self.selectArmor:setActive(false)
if not self.compWeapon then
self.weaponInfo:initPrefabHelper()
self.weaponInfo:genAllChildren()
self.compWeapon = self.weaponInfo:addLuaComponent(COMP_WEAPON)
end
self.compWeapon:setHeroData(self.heroEntity)
self.compWeapon:refresh()
end
function HeroDetailUI:showArmorInfo()
self.heroInfo:setActive(false)
self.selectHero:setActive(false)
self.weaponInfo:setActive(false)
self.selectWeapon:setActive(false)
self.armorInfo:setActive(true)
self.selectArmor:setActive(true)
if not self.compArmor then
self.armorInfo:initPrefabHelper()
self.armorInfo:genAllChildren()
self.compArmor = self.armorInfo:addLuaComponent(COMP_ARMOR)
end
self.compArmor:setHeroData(self.heroEntity)
self.compArmor:refresh()
end
-- 是否存在左侧英雄
function HeroDetailUI:isExistLeftHero()
return self.idxLast and self.idxLast > 0
end
-- 是否存在右侧英雄
function HeroDetailUI:isExistRightHero()
return self.idxNext and self.idxNext <= #self.heroList
end end
return HeroDetailUI return HeroDetailUI

View File

@ -0,0 +1,194 @@
local HeroInfoComp = class("HeroInfoComp", LuaComponent)
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
local BTN_ICON = {"common_btn_green_2", "common_btn_grey_2"}
local SIZE_DELTA_Y_HERO = 942
local SIZE_DELTA_Y_LOOK = 802
function HeroInfoComp:init()
local uiMap = self:getUIMap()
self.slider = uiMap["hero_detail_ui.bg.fragment_bg.slider"]
self.imgElement = uiMap["hero_detail_ui.bg.hero_element"]
self.imgSkill = uiMap["hero_detail_ui.bg.skill_node.skill_icon"]
self.imgFragment = uiMap["hero_detail_ui.bg.fragment_bg.fragment_icon"]
self.btnUp = uiMap["hero_detail_ui.bg.up_btn"]
self.imgUpIcon = uiMap["hero_detail_ui.bg.up_btn.icon"]
self.txUpdesc = uiMap["hero_detail_ui.bg.up_btn.desc"]
self.txUpNum = uiMap["hero_detail_ui.bg.up_btn.num"]
self.txLv = uiMap["hero_detail_ui.bg.lv_desc"]
self.txElement = uiMap["hero_detail_ui.bg.element_desc"]
self.txSkill = uiMap["hero_detail_ui.bg.skill_desc"]
self.txFragmentNum = uiMap["hero_detail_ui.bg.fragment_bg.fragment_num"]
self.txHpName = uiMap["hero_detail_ui.bg.hp_name"]
self.txAtkName = uiMap["hero_detail_ui.bg.atk_name"]
self.txHp = uiMap["hero_detail_ui.bg.hp"]
self.txAtk = uiMap["hero_detail_ui.bg.atk"]
self.bgFragment = uiMap["hero_detail_ui.bg.fragment_bg"]
self.spineObjSkill = uiMap["hero_detail_ui.bg.ui_spine_obj_skill"]
self.spineObjLv = uiMap["hero_detail_ui.bg.ui_spine_obj_lv"]
self.spineObj = uiMap["hero_detail_ui.bg.ui_spine_obj"]
self.spineObjAvatar = uiMap["hero_detail_ui.bg.ui_spine_obj_avatar"]
self.upgrade = uiMap["hero_info.up"]
self.bgElement = uiMap["hero_detail_ui.bg.element_bg"]
self.btnAttr = uiMap["hero_info.bg_6.btn_attr"]
self.skill = {}
self.skillIcon = {}
self.skillDesc = {}
for i = 1, 7 do
self.skill[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i]
self.skillIcon[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".icon"]
self.skillDesc[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".desc"]
end
self.spineObjSkill:setVisible(false)
self.spineObjLv:setVisible(false)
self.spineObj:setVisible(false)
self.btnUp:addClickListener(function()
ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity)
end)
self.btnAttr:addClickListener(function()
UIManager:showUI("app/ui/hero/hero_attr_ui", self.heroEntity:getCfgId())
end)
end
function HeroInfoComp:setHeroData(heroEntity, onlyLook)
self.heroEntity = heroEntity
self.onlyLook = onlyLook
self:bind(self.heroEntity, "lv", function()
self:refresh(true)
end)
end
function HeroInfoComp:refresh(lvChange)
self.txLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.heroEntity:getLv()))
self.spineObjAvatar:getSkeletonGraphic().enabled = false
self.spineObjAvatar:loadAssetAsync(self.heroEntity:getModelId(), function()
self.spineObjAvatar:getSkeletonGraphic().enabled = true
self.spineObjAvatar:playAnim("idle", true, true, true)
end, true)
self.txElement:setText(ModuleManager.HeroManager:getMatchTypeName(self.heroEntity:getMatchType()))
local elementTxRectWidth = self.txElement:getRectWidth()
local elementTxWidth = self.txElement:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
if elementTxWidth > elementTxRectWidth then
self.bgElement:setSizeDeltaX(52 + elementTxWidth)
else
self.bgElement:setSizeDeltaX(52 + elementTxRectWidth)
end
self.txSkill:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getBaseSkill()))
self.txHpName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2))
self.txAtkName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3))
self.imgSkill:setSprite(GConst.ATLAS_PATH.ICON_SKILL_BIG, ModuleManager.HeroManager:getSkillIcon(self.heroEntity:getBaseSkill()))
self.imgElement:setSprite(GConst.ATLAS_PATH.HERO, ModuleManager.HeroManager:getMatchTypeIcon(self.heroEntity:getMatchType()))
local materials = self.heroEntity:getLvUpMaterials() or {}
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFragmentId())
local needFragmentCount = materials[1] or 1
self.txFragmentNum:setText(fragmentCount .. "/" .. needFragmentCount)
if fragmentCount >= needFragmentCount then
self.slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_1", nil, self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER))
else
self.slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_2", nil, self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER))
end
self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
local activeCount = self.heroEntity:getActiveRogueCount()
local skillList = self.heroEntity:getRogueSkillList()
local skillLvs = ModuleManager.HeroManager:getActiveRogueLvs()
for i = 1, 7 do
local skillId = skillList[i]
if skillId then
local skillBg = self.skill[i]
local skillIcon = self.skillIcon[i]
local skillLv = self.skillDesc[i]
skillBg:addClickListener(function()
ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId), skillIcon)
end)
skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueIcon(skillId))
skillBg:setTouchEnable(true)
if i > activeCount then
skillLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, skillLvs[i] or 0))
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, "frame_0")
else
skillLv:setText(GConst.EMPTY_STRING)
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueBg(skillId, true))
if i == activeCount and lvChange and self.heroEntity:getLv() == skillLvs[i] then
local x, y = skillBg:fastGetAnchoredPosition()
self.spineObjSkill:setAnchoredPosition(x, y)
self.spineObjSkill:setVisible(true)
self.spineObjSkill:playAnim("idle", false, true)
end
end
end
end
self.bgFragment:setVisible(not self.heroEntity:isMaxLv())
local canLvUp = self.heroEntity:canLvUp()
self.imgFragment:setVisible(not canLvUp)
local lv = self.heroEntity:getLv()
local str
local hpStr
local atkStr
if self.heroEntity:isActived() then
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)
local curHp = self.heroEntity:getHp() // DEFAULT_FACTOR
local curAtk = self.heroEntity:getAtk() // DEFAULT_FACTOR
local addHp = self.heroEntity:getCfgHp(lv + 1) // DEFAULT_FACTOR - curHp
local addAtk = self.heroEntity:getCfgAtk(lv + 1) // DEFAULT_FACTOR - curAtk
if addHp <= 0 then
hpStr = curHp
else
hpStr = curHp .. "<color=#A2FF29>+" .. addHp .. "</color>"
end
if addAtk <= 0 then
atkStr = curAtk
else
atkStr = curAtk .. "<color=#A2FF29>+" .. addAtk .. "</color>"
end
else
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_5)
hpStr = self.heroEntity:getHp(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
atkStr = self.heroEntity:getAtk(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
end
self.txUpdesc:setText(str)
self.txUpNum:setText(materials[2])
self.txHp:setText(hpStr)
self.txAtk:setText(atkStr)
if canLvUp then
self.btnUp:addRedPoint(120, 50, 0.6)
else
self.btnUp:removeRedPoint()
end
self.spineObjLv:setVisible(canLvUp)
if canLvUp then
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
self.spineObjLv:playAnim("animation", true, false)
else
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end
self.btnUp:setTouchEnable(true)
self.btnUp:setActive(not self.heroEntity:isMaxLv())
if lvChange then
self.spineObj:setVisible(true)
self.spineObj:playAnim("idle", false, true)
end
if self.onlyLook then -- 仅查看的不显示升级和激活按钮
self.upgrade:setVisible(false)
self.baseObject:setSizeDeltaY(SIZE_DELTA_Y_LOOK)
else
self.upgrade:setVisible(true)
self.baseObject:setSizeDeltaY(SIZE_DELTA_Y_HERO)
end
end
return HeroInfoComp

View File

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

View File

@ -0,0 +1,121 @@
local WeaponInfoComp = class("WeaponInfoComp", LuaComponent)
local BTN_ICON = {"common_btn_green_2", "common_btn_grey_2"}
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
function WeaponInfoComp:init()
local uiMap = self:getUIMap()
self.txName = uiMap["weapon_info.name.tx_name"]
self.imgWeapon = uiMap["weapon_info.img_weapon"]
self.txLevel = uiMap["weapon_info.level.tx_level"]
self.txDesc1 = uiMap["weapon_info.tx_desc_1"]
self.txDesc2 = uiMap["weapon_info.tx_desc_2"]
self.txAttr = uiMap["weapon_info.ScrollView.Viewport.Content.tx_attr"]
self.btnUp = uiMap["weapon_info.upgrade.btn_up"]
self.txUp = uiMap["weapon_info.upgrade.btn_up.tx_desc"]
self.txNum = uiMap["weapon_info.upgrade.btn_up.tx_num"]
self.attr = {}
for i = 1, 2 do
self.attr[i] = uiMap["weapon_info.attr_" .. i]
end
self.txDesc1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_4))
self.txDesc2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_5))
self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3))
self.btnUp:addClickListener(function()
ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON)
end)
end
function WeaponInfoComp:setHeroData(heroEntity)
self.heroEntity = heroEntity
self.weaponEntity = DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON)
end
function WeaponInfoComp:refresh()
local nextWeaponEntity = self.weaponEntity:getNextLevelEntity()
self.txName:setText(self.weaponEntity:getName())
-- self.imgWeapon:setSprite(GConst.ATLAS_PATH.COMMON, self.weaponEntity:getIcon())
self.txLevel:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3) .. self.weaponEntity:getLevel().."/"..self.weaponEntity:getMaxLevel())
self.txAttr:setText(self.weaponEntity:getAttrDesc())
-- 基础属性
local diffAtk = (nextWeaponEntity:getAttack() - self.weaponEntity:getAttack()) // DEFAULT_FACTOR
local diffNormalHurt = (nextWeaponEntity:getNormalHurt() - self.weaponEntity:getNormalHurt()) // DEFAULT_FACTOR
local diffSkillHurt = (nextWeaponEntity:getSkillHurt() - self.weaponEntity:getSkillHurt()) // DEFAULT_FACTOR
local diffHp = (nextWeaponEntity:getHp() - self.weaponEntity:getHp()) // DEFAULT_FACTOR
local showAttrType = {}
for index, obj in ipairs(self.attr) do
local map = obj:genAllChildren()
local imgIcon = map["img_icon"]
local txTitle = map["tx_title"]
local txNum = map["tx_num"]
obj:setVisible(true)
if not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK) and diffAtk > 0 then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_5")
txTitle:setText("<color=#FCB501>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3).."</color>")
txNum:setText(self.weaponEntity:getAttack() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffAtk .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT) and diffNormalHurt > 0 then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_20")
txTitle:setText("<color=#4CCFFA>"..I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURT).."</color>")
txNum:setText(self.weaponEntity:getNormalHurt() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffNormalHurt .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT) and diffSkillHurt > 0 then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_21")
txTitle:setText("<color=#EC80FF>"..I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURT).."</color>")
txNum:setText(self.weaponEntity:getSkillHurt() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffSkillHurt .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.HP) and diffHp > 0 then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.HP)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_4")
txTitle:setText("<color=#FB6895>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2).."</color>")
txNum:setText(self.weaponEntity:getHp() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffHp .. "</color>")
else
obj:setVisible(false)
end
end
-- 消耗材料
local cost = self.weaponEntity:getUpgradeMaterials()
for i = 1, 3 do
local uiMap = self:getUIMap()
local costNode = uiMap["weapon_info.upgrade.cost.cost_" .. i]
if cost[i] then
costNode:setActive(true)
local icon = uiMap["weapon_info.upgrade.cost.cost_" .. i .. ".img_icon"]
local num = uiMap["weapon_info.upgrade.cost.cost_" .. i .. ".tx_num"]
local costId = GFunc.getRewardId(cost[i])
local costNum = GFunc.getRewardNum(cost[i])
local haveNum = DataManager.BagData.ItemData:getItemNumById(costId)
if haveNum < costNum then
num:setText("<color=#FF5252>" .. haveNum .. "</color>/" .. costNum)
else
num:setText(haveNum .. "/" .. costNum)
end
-- icon:setSprite(GFunc.getIconRes(costId))
else
costNode:setActive(false)
end
end
if self.weaponEntity:isEnoughGold() then
self.txNum:setText(self.weaponEntity:getUpgradeGoldNum())
else
self.txNum:setText("<color=#FF5252>" .. self.weaponEntity:getUpgradeGoldNum() .. "</color>")
end
local canLvUp = self.weaponEntity:canLevelUp()
if canLvUp then
self.btnUp:addRedPoint(120, 50, 0.6)
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
else
self.btnUp:removeRedPoint()
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end
end
return WeaponInfoComp

View File

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

View File

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

View File

@ -0,0 +1,208 @@
local EquipData = class("EquipData", BaseData)
local EquipEntity = require "app/userdata/equip/equip_entity"
function EquipData:ctor()
self.data.isDirty = false
end
function EquipData:clear()
end
function EquipData:init(data)
data = data or GConst.EMPTY_TABLE
Logger.logHighlight("装备数据")
Logger.printTable(data)
self.equips = {}
if not data.HeroesEquips then
return
end
for heroId, equip in pairs(data.HeroesEquips) do
for part, level in pairs(equip.Equips) do
self:addEquip(heroId, part, level)
end
end
self:updateHeroValue()
end
-- 更新英雄数值
function EquipData:updateHeroValue()
if not self.equips then
return
end
for heroId, equip in pairs(self.equips) do
local heroEntity = DataManager.HeroData:getHeroById(heroId)
for part, level in pairs(equip) do
self:addAttrValue(heroEntity, part)
end
end
end
function EquipData:addAttrValue(heroEntity, part, isDeduct)
local equipEntity = self:getEquip(heroEntity:getCfgId(), part)
local hp = equipEntity:getHp()
local atk = equipEntity:getAttack()
local normalHurt = equipEntity:getNormalHurt()
local skillHurt = equipEntity:getSkillHurt()
local critPer = equipEntity:getCritPercent()
local critHurtPer = equipEntity:getCritHurtPercent()
local normalHurtPer = equipEntity:getNormalHurtPercent()
local skillHurtPer = equipEntity:getSkillHurtPercent()
local healPer = equipEntity:getHealPercent()
heroEntity:addAttrValue(GConst.MATCH_HP_NAME[heroEntity:getMatchType()], isDeduct and -hp or hp)
heroEntity:addAttrValue(GConst.MATCH_ATTACK_NAME[heroEntity:getMatchType()], isDeduct and -atk or atk)
heroEntity:addAttrValue(GConst.MATCH_NORMAL_HURT_NAME[heroEntity:getMatchType()], isDeduct and -normalHurt or normalHurt)
heroEntity:addAttrValue(GConst.MATCH_SKILL_HURT_NAME[heroEntity:getMatchType()], isDeduct and -skillHurt or skillHurt)
heroEntity:addAttrValue(GConst.MATCH_CRIT_NAME[heroEntity:getMatchType()], isDeduct and -critPer or critPer)
heroEntity:addAttrValue(GConst.MATCH_CRIT_TIME_NAME[heroEntity:getMatchType()], isDeduct and -critHurtPer or critHurtPer)
heroEntity:addAttrValue(GConst.MATCH_NORMAL_HURTP_NAME[heroEntity:getMatchType()], isDeduct and -normalHurtPer or normalHurtPer)
heroEntity:addAttrValue(GConst.MATCH_SKILL_HURTP_NAME[heroEntity:getMatchType()], isDeduct and -skillHurtPer or skillHurtPer)
heroEntity:addAttrValue(GConst.MATCH_CURED_NAME[heroEntity:getMatchType()], isDeduct and -healPer or healPer)
local printStr = ""
if not isDeduct then
printStr = printStr .. "增加装备数值:"..heroEntity:getCfgId().."-"..part .. "\n"
else
printStr = printStr .. "减去装备数值:"..heroEntity:getCfgId().."-"..part .. "\n"
end
printStr = printStr .. "生命:".. hp .. "\n"
printStr = printStr .. "攻击力:".. atk .. "\n"
printStr = printStr .. "普攻增伤:".. normalHurt .. "\n"
printStr = printStr .. "技能增伤:".. skillHurt .. "\n"
printStr = printStr .. "暴击率:".. critPer .. "\n"
printStr = printStr .. "暴击伤害百分比:".. critHurtPer .. "\n"
printStr = printStr .. "普攻增伤百分比:".. normalHurtPer .. "\n"
printStr = printStr .. "技能增伤百分比:".. skillHurtPer .. "\n"
printStr = printStr .. "治疗加成百分比:".. healPer .. "\n"
Logger.logHighlight(printStr)
end
function EquipData:setDirty()
self.data.isDirty = not self.data.isDirty
end
-- 武器功能是否开启
function EquipData:isWeaponOpen(showToast)
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.EQUIP_WEAPON, not showToast) then
return false
end
return true
end
-- 防具功能是否开启
function EquipData:isArmorOpen(showToast)
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.EQUIP_ARMOR, not showToast) then
return false
end
return true
end
function EquipData:addEquip(heroId, part, level)
if not self.equips[heroId] then
self.equips[heroId] = {}
end
if self.equips[heroId][part] then
return
end
self.equips[heroId][part] = self:createEntity(heroId, part, level)
end
function EquipData:createEntity(heroId, part, level)
return EquipEntity:create(heroId, part, level)
end
function EquipData:getEquip(id, part)
if not self.equips[id] then
self.equips[id] = {}
end
if not self.equips[id][part] then
self.equips[id][part] = self:createEntity(id, part)
end
return self.equips[id][part]
end
-- 获取英雄所有防具(不包含武器)生命固定值
function EquipData:getTotalArmorHp(heroId)
local hatEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.HAT)
local clothesEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.CLOTHES)
local beltEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.BELT)
local handguardEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.HANDGUARD)
local result = 0
result = result + hatEntity:getHp()
result = result + clothesEntity:getHp()
result = result + beltEntity:getHp()
result = result + handguardEntity:getHp()
return result
end
-- 获取英雄所有防具(不包含武器)攻击力固定值
function EquipData:getTotalArmorAttack(heroId)
local hatEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.HAT)
local clothesEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.CLOTHES)
local beltEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.BELT)
local handguardEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.HANDGUARD)
local result = 0
result = result + hatEntity:getAttack()
result = result + clothesEntity:getAttack()
result = result + beltEntity:getAttack()
result = result + handguardEntity:getAttack()
return result
end
-- 获取英雄所有防具(不包含武器)生命加成
function EquipData:getTotalArmorHpPercent(heroId)
local hatEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.HAT)
local clothesEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.CLOTHES)
local beltEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.BELT)
local handguardEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.HANDGUARD)
local result = 0
result = result + hatEntity:getHpPercent()
result = result + clothesEntity:getHpPercent()
result = result + beltEntity:getHpPercent()
result = result + handguardEntity:getHpPercent()
return result
end
-- 获取英雄所有防具(不包含武器)攻击力固定值
function EquipData:getTotalArmorAttackPercent(heroId)
local hatEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.HAT)
local clothesEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.CLOTHES)
local beltEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.BELT)
local handguardEntity = self:getEquip(heroId, GConst.EquipConst.PART_TYPE.HANDGUARD)
local result = 0
result = result + hatEntity:getAtkPercent()
result = result + clothesEntity:getAtkPercent()
result = result + beltEntity:getAtkPercent()
result = result + handguardEntity:getAtkPercent()
return result
end
-- 装备升级
function EquipData:onUpgradeEquip(heroId, part)
local entity = self:getEquip(heroId, part)
if not entity then
return
end
local last = entity:getLastLevelEntity()
if last then
self:addAttrValue(DataManager.HeroData:getHeroById(heroId), part, true)
end
entity:onLevelUp()
self:addAttrValue(DataManager.HeroData:getHeroById(heroId), part)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.EQUIP_UPGRADE_SUCCESS)
end
return EquipData

View File

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

View File

@ -0,0 +1,337 @@
local EquipEntity = class("EquipEntity", BaseData)
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
function EquipEntity:ctor(heroId, part, level)
self.level = level or 0
self.cfg, self.cfgId = table.find(ConfigManager:getConfig("equip"), function(value)
return value.hero == heroId and value.part == part
end)
end
function EquipEntity:setDirty()
self.data.isDirty = not self.data.isDirty
end
-- 获取部位id
function EquipEntity:getId()
return self.cfgId
end
-- 获取部位所属英雄
function EquipEntity:getHeroId()
return self.cfg.hero
end
-- 获取部位类型
function EquipEntity:getPart()
return self.cfg.part
end
-- 获取部位生命值
function EquipEntity:getHp()
if self.cfg.armor_hp and self.cfg.armor_hp[self.level] then
return self.cfg.armor_hp[self.level]
end
return 0
end
-- 获取部位攻击力
function EquipEntity:getAttack()
if self.cfg.armor_atk and self.cfg.armor_atk[self.level] then
return self.cfg.armor_atk[self.level]
end
return 0
end
-- 获取部位普攻伤害
function EquipEntity:getNormalHurt()
if self.cfg.normal_hurt_add and self.cfg.normal_hurt_add[self.level] then
return self.cfg.normal_hurt_add[self.level]
end
return 0
end
-- 获取部位技能伤害
function EquipEntity:getSkillHurt()
if self.cfg.skill_hurt_add and self.cfg.skill_hurt_add[self.level] then
return self.cfg.skill_hurt_add[self.level]
end
return 0
end
-- 获取攻击加成百分比
function EquipEntity:getAtkPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_ATTACK_ADD_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取生命值加成百分比
function EquipEntity:getHpPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_HP_ADD_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取暴击率百分比
function EquipEntity:getCritPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CRIT_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
--获取暴击伤害百分比
function EquipEntity:getCritHurtPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CRIT_TIME_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取治疗百分比
function EquipEntity:getHealPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CURED_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取普攻增伤百分比
function EquipEntity:getNormalHurtPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_NORMAL_HURTP_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取技能增伤百分比
function EquipEntity:getSkillHurtPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_SKILL_HURTP_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取部位阶段等级
function EquipEntity:getStage()
for idx, level in pairs(self.cfg.features_level) do
if self.level < level then
return idx
end
end
return nil-- 超过最大阶段等级
end
-- 获取属性描述
function EquipEntity:getAttrDesc()
local strAttr = ""
local stage = self:getStage()
for i = 1, stage + 1 do
local level = self.cfg.features_level[i]
local attr = self.cfg.features_attr[i]
local str = I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3) .. level .. ":".. GFunc.getAttrDesc(attr.type, attr.num)
if i < stage + 1 then
strAttr = "<color=#EEDFFF>" .. strAttr.. str .. "\n</color>"
else
strAttr = "<color=#9C94BE>" .. strAttr.. str .. "(" .. I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_12) .. ")</color>"
end
end
return strAttr
end
-- 获取部位已获得属性
function EquipEntity:getStageAttr()
local stage = self:getStage()
if stage then
return self.cfg.features_attr[stage]
end
return nil
end
-- 获取部位图标id
function EquipEntity:getIconId()
local stage = self:getStage()
if stage then
return self.cfg.weapon_icon[stage]
end
return nil
end
-- 获取部位名称
function EquipEntity:getName()
local names = I18N:getText("equip", self:getId(), "name")
names = string.split(names, ",")
return names[self:getStage()] or ""
end
-- 获取部位当前等级
function EquipEntity:getLevel()
return self.level
end
-- 获取部位等级上限
function EquipEntity:getMaxLevel()
if self:getPart() == GConst.EquipConst.PART_TYPE.WEAPON then
-- 武器等级上限是玩家等级*2
return DataManager.PlayerData:getLv() * 2
else
-- 防具等级上限是当前英雄武器等级
return DataManager.EquipData:getEquip(self:getHeroId(), GConst.EquipConst.PART_TYPE.WEAPON):getLevel()
end
end
-- 部位是否可升级
function EquipEntity:canLevelUp()
--判断材料
if not self:isEnoughMaterial() then
return false
end
-- 判断金币
if not self:isEnoughGold() then
return false
end
-- 判断等级
if self:isMaxLevel() then
return false
end
return true
end
-- 升级材料是否满足
function EquipEntity:isEnoughMaterial()
for index, cost in ipairs(self:getUpgradeMaterials()) do
if cost.num > DataManager.BagData.ItemData:getItemNumById(cost.id) then
return false
end
end
return true
end
-- 升级金币是否满足
function EquipEntity:isEnoughGold()
return DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD) >= self:getUpgradeGoldNum()
end
-- 部位是否是最大等级
function EquipEntity:isMaxLevel()
return self:getLevel() >= self:getMaxLevel()
end
-- 获取部位上一等级实例
function EquipEntity:getLastLevelEntity()
if self:getLevel() == 0 then
return nil
end
return DataManager.EquipData:createEntity(self:getHeroId(), self:getPart(), self:getLevel() - 1)
end
-- 获取部位下一等级实例
function EquipEntity:getNextLevelEntity()
return DataManager.EquipData:createEntity(self:getHeroId(), self:getPart(), self:getLevel() + 1)
end
-- 获取部位升级所需材料和金币
function EquipEntity:getUpgradeCost()
local nextCost = ConfigManager:getConfig("equip_level")[self:getLevel() + 1]
if not nextCost then
return
end
local part = self:getPart()
if part == GConst.EquipConst.PART_TYPE.WEAPON then
return nextCost.weapon_cost
elseif part == GConst.EquipConst.PART_TYPE.HAT then
return nextCost.hat_cost
elseif part == GConst.EquipConst.PART_TYPE.CLOTHES then
return nextCost.clothes_cost
elseif part == GConst.EquipConst.PART_TYPE.BELT then
return nextCost.belt_cost
elseif part == GConst.EquipConst.PART_TYPE.HANDGUARD then
return nextCost.handguard_cost
end
end
-- 获取部位升级所需金币数
function EquipEntity:getUpgradeGoldNum()
local cost = self:getUpgradeCost()
if cost then
for key, value in pairs(cost) do
if GFunc.getRewardId(value) == GConst.ItemConst.ITEM_ID_GOLD then
return GFunc.getRewardNum(value)
end
end
end
return 0
end
-- 获取部位升级所需材料
function EquipEntity:getUpgradeMaterials()
local cost = self:getUpgradeCost()
local materials = {}
if cost then
for key, value in pairs(cost) do
if GFunc.getRewardId(value) ~= GConst.ItemConst.ITEM_ID_GOLD then
table.insert(materials, value)
end
end
end
return materials
end
-- 升级
function EquipEntity:onLevelUp()
self.level = self.level + 1
self:setDirty()
end
return EquipEntity

View File

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

View File

@ -235,4 +235,40 @@ function HeroData:getAllHeroesBIStr()
return str return str
end end
-- 获取所有英雄列表(等级>品质>id
function HeroData:getAllHeroesSort()
local result = {}
local heroCfg = ConfigManager:getConfig("hero")
for id, v in pairs(heroCfg) do
table.insert(result, {cfgId = id, sort = id, elementType = v.position})
end
for _, info in ipairs(result) do
local heroEntity = self:getHeroById(info.cfgId)
local sort = info.cfgId -- id 预留6位
sort = sort + (10 - info.elementType) * 1000000 -- 位置预留1位
sort = sort + 10000000 * heroEntity:getQlt() -- 品质1位
sort = sort + 100000000 * heroEntity:getLv() -- 预留3位
if heroEntity:isUnlock() then
sort = sort + 300000000000
if heroEntity:isActived() then
sort = sort + 400000000000
else
sort = sort + 300000000000
end
elseif DataManager.BagData.ItemData:getItemNumById(heroEntity:getFragmentId()) > 0 then
sort = sort + 200000000000
else
sort = sort + 100000000000
end
info.sort = sort
end
table.sort(result, function(a, b)
return a.sort > b.sort
end)
return result
end
return HeroData return HeroData

View File

@ -142,10 +142,17 @@ function HeroEntity:setAttrValue(name, value)
self.allAttr[name] = GFunc.encryptNumber(value or 0) self.allAttr[name] = GFunc.encryptNumber(value or 0)
end end
function HeroEntity:addAttrValue(name, add)
-- Logger.logHighlight("add "..name..":"..add)
local before = self:getAttrValue(name)
self.allAttr[name] = GFunc.encryptNumber(before + add or 0)
end
function HeroEntity:getAttrValue(name) function HeroEntity:getAttrValue(name)
if not self.allAttr[name] then if not self.allAttr[name] then
return 0 return 0
end end
-- Logger.logHighlight("get "..name..":"..GFunc.decryptNumber(self.allAttr[name]))
return GFunc.decryptNumber(self.allAttr[name]) return GFunc.decryptNumber(self.allAttr[name])
end end