|
|
--自动挂机时间,经验状态tips
|
|
AutoFightTips = AutoFightTips or BaseClass(BaseView)
|
|
function AutoFightTips:__init()
|
|
self.base_file = "autoFight"
|
|
self.layout_file = "AutoFightTips"
|
|
self.layer_name = "Activity"
|
|
self.open_wnd_anim = 0
|
|
-- self.use_local_view = true
|
|
self.change_scene_close = true
|
|
self.close_mode = CloseMode.CloseDestroy
|
|
self.destroy_imm = true
|
|
self.hide_maincancas = false
|
|
self.background_alpha = 0
|
|
self.use_background = true --任务栏特效遮罩影响了这里,加上透明背景
|
|
self.click_bg_toClose = true
|
|
|
|
self.model = AutoFightManager:getInstance()
|
|
self.item_list = {}
|
|
self.load_callback = function()
|
|
self:LoadSuccess()
|
|
self:InitEvent()
|
|
end
|
|
|
|
self.open_callback = function()
|
|
GoodsModel:getInstance():Fire(GoodsModel.GET_GOODS_BUFF_LIST) --发15055更新物品buff
|
|
self:SetData()
|
|
end
|
|
|
|
self.destroy_callback = function()
|
|
self:Remove()
|
|
end
|
|
end
|
|
function AutoFightTips:Remove()
|
|
if self.orientation_change_id then
|
|
GlobalEventSystem:UnBind(self.orientation_change_id)
|
|
self.orientation_change_id = nil
|
|
end
|
|
if self.event_id then
|
|
AutoFightManager:getInstance():UnBind(self.event_id)
|
|
self.event_id = nil
|
|
end
|
|
if self.event_id2 then
|
|
GoodsModel:getInstance():UnBind(self.event_id2)
|
|
self.event_id2 = nil
|
|
end
|
|
if self.event_id3 then
|
|
AutoFightManager:getInstance():UnBind(self.event_id3)
|
|
self.event_id3 = nil
|
|
end
|
|
if self.event_id4 then
|
|
GlobalEventSystem:UnBind(self.event_id4)
|
|
self.event_id4 = nil
|
|
end
|
|
if self.event_id5 then
|
|
GlobalEventSystem:UnBind(self.event_id5)
|
|
self.event_id5 = nil
|
|
end
|
|
|
|
for i,v in ipairs(self.item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.item_list = {}
|
|
end
|
|
|
|
function AutoFightTips:Open()
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function AutoFightTips:LoadSuccess()
|
|
self.raycast = self:GetChild("raycast")
|
|
self.raycast.transform.sizeDelta = Vector2(ScreenWidth,ScreenHeight)
|
|
self.raycast.localPosition = Vector3(-ScreenWidth/2+ClientConfig.iphone_x_offset_left, ScreenHeight/2, 0)
|
|
|
|
self.layout = self:GetChild("layout")
|
|
self.layout.localPosition = Vector3(-ScreenWidth/2 + 172 + ClientConfig.iphone_x_offset_left, ScreenHeight / 2 - 90, 0)
|
|
|
|
self.ScrollView = self:GetChild("layout/ScrollView")
|
|
self.ScrollViewViewport = self:GetChild("layout/ScrollView/Viewport")
|
|
self.ScrollViewCon = self:GetChild("layout/ScrollView/Viewport/Content")
|
|
self.bg = self:GetChild("layout/bg")
|
|
|
|
self.scroll_comp = self.ScrollView:GetComponent("ScrollRect")
|
|
end
|
|
|
|
function AutoFightTips:InitEvent()
|
|
|
|
local function onOrientationChange()
|
|
self.layout.localPosition = Vector2(ClientConfig.iphone_x_offset_left, 0)
|
|
end
|
|
self.orientation_change_id = GlobalEventSystem:Bind(EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
|
|
|
|
AddClickEvent(self.raycast.gameObject,function ()
|
|
self:Close()
|
|
end)
|
|
local update_fun = function ()
|
|
-- local function on_delay( )
|
|
self:SetData()
|
|
-- end
|
|
-- setTimeout(on_delay, 0.1)
|
|
end
|
|
-- self.event_id = AutoFightManager:getInstance():Bind(AutoFightManager.UPDATE_EXPERIENCE_DATA, update_fun)
|
|
-- self.event_id2 = GoodsModel:getInstance():Bind(GoodsModel.UPDATE_GOODS_BUFF_DATA, update_fun)
|
|
self.event_id4 = GlobalEventSystem:Bind(EventName.UPDATE_BUFF_VIEW, update_fun)
|
|
|
|
local close_fun = function ()
|
|
self:Close()
|
|
end
|
|
self.event_id3 = AutoFightManager:getInstance():Bind(AutoFightManager.CLOSE_AUTO_FIGHT_TIP, close_fun)
|
|
|
|
local function onSceneChangeHandler()
|
|
self:Close()
|
|
end
|
|
self.event_id5 = GlobalEventSystem:Bind(SceneEventType.SCENE_CHANGED, onSceneChangeHandler)
|
|
|
|
self:SetData()
|
|
end
|
|
|
|
function AutoFightTips:SetData()
|
|
if IsNull(self.gameObject) then
|
|
return
|
|
end
|
|
for k,v in pairs(self.item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
|
|
local mvo = RoleManager.Instance.mainRoleInfo
|
|
local scroll_height = 0
|
|
local count = 0
|
|
local height = 0
|
|
local buff_list = MainUIModel:getInstance():GetAllBuff()
|
|
if buff_list then
|
|
for i,v in ipairs(buff_list) do
|
|
if Config.ConfigBuffIcon[v.id] then
|
|
local item = self.item_list[count + 1]
|
|
if item == nil then
|
|
item = BufferTipsItem.New(self.ScrollViewCon)
|
|
self.item_list[count + 1] = item
|
|
end
|
|
local is_end = i == #buff_list
|
|
item:SetData(v, is_end)
|
|
item:SetVisible(true)
|
|
local x = 6
|
|
item:SetAnchoredPosition(x, -height)
|
|
count = count + 1
|
|
height = item:GetAllHeight() + height
|
|
end
|
|
end
|
|
end
|
|
|
|
scroll_height = height
|
|
|
|
self.scroll_comp.enabled = false
|
|
if count >= 4 then
|
|
height = 418
|
|
self.scroll_comp.enabled = true
|
|
elseif count > 0 then
|
|
height = height + 31
|
|
else
|
|
height = 0
|
|
end
|
|
self.gameObject:SetActive(height > 0)
|
|
self.bg.sizeDelta = Vector2(311, height)
|
|
self.ScrollView.sizeDelta = Vector2(311, height-31)
|
|
self.ScrollViewCon.sizeDelta = Vector2(311, scroll_height)
|
|
end
|