源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

175 lines
4.6 KiB

CheatPropertyView = CheatPropertyView or BaseClass(BaseView)
local CheatPropertyView = CheatPropertyView
CheatPropertyView.Properties = {
{1001, "fighting"},
{1, "att"},
{4, "def"},
{5, "hit"},
{6, "dodge"},
{7, "crit"},
{8, "ten"},
{9, "hurt_add_ratio"},
{10, "hurt_del_ratio"},
{11, "hit_ratio"},
{12, "dodge_ratio"},
{13, "crit_ratio"},
{14, "uncrit_ratio"},
{15, "abs_att"},
{16, "abs_def"},
{27, "skill_hurt_add_ratio"},
{28, "skill_hurt_del_ratio"},
{29, "final_hurt_add_ratio"},
{30, "final_hurt_del_ratio"},
{51, "pvp_hurt_add_ratio"},
{52, "crit_hurt_add_ratio"},
{53, "crit_hurt_del_ratio"},
{203, "boss_hurt_add_ratio"},
{19, "att_add_ratio"},
{20, "hp_add_ratio"},
{54, "heart_ratio"},
{56, "heart_resist_ratio"},
{58, "att_speed_add_ratio"},
{59, "speed_add_ratio"},
{201, "hp_resume"},
{77, "ice_hurt"},
{78, "ice_def"},
{79, "thunder_hurt"},
{80, "thunder_def"},
{81, "fire_hurt"},
{82, "fire_def"},
{83, "wind_hurt"},
{84, "wind_def"},
{21, "exp_add_ratio"},
{48, "parry_ratio"},
{49, "stab_ratio"},
{50, "pvp_hurt_del_ratio"},
{55, "heart_add_hurt"},
{57, "heart_del_hurt"},
}
function CheatPropertyView:__init()
self.base_file = "cheat"
self.layout_file = "CheatPropertyView"
self.layer_name = "Top"
self.destroy_imm = true
self.use_background = false
self.change_scene_close = true
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
end
self.open_callback = function ( )
self:OpenSuccess()
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function CheatPropertyView:Open( )
--self.data = data
BaseView.Open(self)
end
function CheatPropertyView:LoadSuccess()
self.nodes = {
"bg/scroll_view","bg/close_btn:obj","bg/scroll_view/Viewport/Content",
"bg/hp:txt",
}
self:GetChildren(self.nodes)
SetAnchoredPosition(self.transform, 0, 0)
end
function CheatPropertyView:AddEvent()
local function onBtnClickHandler( target )
self:Close()
end
AddClickEvent(self.close_btn_obj, onBtnClickHandler)
local function on_hp_change( )
self:UpdateHp()
end
self.bind_hp_id = RoleManager.Instance.mainRoleInfo:BindOne("hp",on_hp_change)
self.bind_maxHp_id = RoleManager.Instance.mainRoleInfo:BindOne("maxHp",on_hp_change)
local function on_all_change( )
self:UpdateProperties()
self:UpdateHp()
end
self.bind_property_id = RoleManager.Instance.mainRoleInfo:Bind(EventName.UPDATE_MAIN_ROLE_INFO_VIEW, on_all_change)
self.bind_fighting_id = RoleManager.Instance.mainRoleInfo:BindOne("fighting", on_all_change)
self.bind_level_id = RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, on_all_change)
end
function CheatPropertyView:OpenSuccess()
self:UpdateProperties()
self:UpdateHp()
end
function CheatPropertyView:UpdateProperties()
local attr_list = CheatPropertyView.Properties
self.attr_list_con = self.attr_list_con or self:AddUIComponent(UI.ItemListCreator)
local info = {
data_list = attr_list,
item_con = self.Content,
scroll_view = self.scroll_view,
prefab_ab_name = "cheat",
prefab_res_name = "CheatPropertyItem",
item_height = 30,
space_y = 2,
child_names = {"text:txt",},
on_update_item = function(item, i, v)
local index = tonumber(v[1])
if index > 1000 then --自定义属性
local str = ""
if index == 1001 then
str = string.format("等级:%d 战力:%d", RoleManager.Instance.mainRoleInfo.level, RoleManager.Instance.mainRoleInfo[v[2]] or 99999999)
end
item.text_txt.text = str
else
local name = WordManager:GetProperties(tonumber(v[1]))
local role_value = RoleManager.Instance.mainRoleInfo[v[2]] or 99999999
local value = WordManager:GetPropertyValue(tonumber(v[1]), role_value)
item.text_txt.text = "(" .. tonumber(v[1]) .. ")" .. name .. ": " .. value
end
end,
}
self.attr_list_con:UpdateItems(info)
end
function CheatPropertyView:UpdateHp( )
local hp_str = string.format("血量:%d/%d", RoleManager.Instance.mainRoleInfo.hp, RoleManager.Instance.mainRoleInfo.maxHp)
self.hp_txt.text = hp_str
end
function CheatPropertyView:DestroySuccess( )
if self.bind_hp_id then
RoleManager.Instance.mainRoleInfo:UnBind(self.bind_hp_id)
self.bind_hp_id = nil
end
if self.bind_maxHp_id then
RoleManager.Instance.mainRoleInfo:UnBind(self.bind_maxHp_id)
self.bind_maxHp_id = nil
end
if self.bind_property_id then
RoleManager.Instance.mainRoleInfo:UnBind(self.bind_property_id)
self.bind_property_id = nil
end
if self.bind_fighting_id then
RoleManager.Instance.mainRoleInfo:UnBind(self.bind_fighting_id)
self.bind_fighting_id = nil
end
if self.bind_level_id then
RoleManager.Instance.mainRoleInfo:UnBind(self.bind_level_id)
self.bind_level_id = nil
end
end