117 lines
3.9 KiB
Lua
117 lines
3.9 KiB
Lua
|
EnvoyItem={}
|
||
|
-- 鸿蒙守卫脚本
|
||
|
function EnvoyItem:New(gameObject)
|
||
|
local b = {}
|
||
|
b.gameObject = gameObject
|
||
|
b.transform = gameObject.transform
|
||
|
setmetatable(b, { __index = EnvoyItem })
|
||
|
return b
|
||
|
end
|
||
|
EnvoyItem.GongMingTable = {}
|
||
|
EnvoyItem.HongMengData = {}
|
||
|
EnvoyItem.data = nil
|
||
|
function EnvoyItem:InitComponent(parent,data)
|
||
|
self.data = data
|
||
|
self.gameObject.transform:SetParent(parent.transform,false)
|
||
|
|
||
|
self.lock = Util.GetGameObject(self.gameObject,"Box/Empty/lock")
|
||
|
self.Empty = Util.GetGameObject(self.gameObject,"Box/Empty")
|
||
|
self.timer_text = Util.GetGameObject(self.gameObject,"Box/Empty/Image/Text"):GetComponent("Text")
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
function EnvoyItem:BindEvent()
|
||
|
|
||
|
end
|
||
|
|
||
|
function EnvoyItem:AddListener()
|
||
|
|
||
|
end
|
||
|
|
||
|
function EnvoyItem:RemoveListener()
|
||
|
|
||
|
end
|
||
|
|
||
|
function EnvoyItem:SetItemData(data)
|
||
|
-- body
|
||
|
self.data = data
|
||
|
end
|
||
|
|
||
|
function EnvoyItem:OnOpen()
|
||
|
|
||
|
|
||
|
self.lock:SetActive(false)
|
||
|
self:SetItem(self.gameObject,self.data)
|
||
|
Util.AddOnceClick(self.gameObject,function ()
|
||
|
-- body
|
||
|
HarmonyManager.GongMingBox = self.data.gridId
|
||
|
if self.data.heroId~="" then
|
||
|
-- body
|
||
|
UIManager.OpenPanel(UIName.HongMengEnvoyUnloadPanel,self.data)
|
||
|
else
|
||
|
if self.data.time > 0 then
|
||
|
local content = ""
|
||
|
local money = (self.data.time - GetTimeStamp()) * 432
|
||
|
content =string.format("是否花费%d妖晶直接恢复",money)
|
||
|
|
||
|
MsgPanel.ShowTwo(content,function ()
|
||
|
MsgPanel.Hide()
|
||
|
end,function ()
|
||
|
if BagManager.GetTotalItemNum(UpViewRechargeType.DemonCrystal) < money then
|
||
|
PopupTipPanel.ShowTip("妖晶不足")
|
||
|
MsgPanel.Hide()
|
||
|
return
|
||
|
end
|
||
|
--向服务器 发消息
|
||
|
NetManager.UnlockGrid(self.data.Id,function (msg)
|
||
|
-- body
|
||
|
for i = 1, #HarmonyManager.hongmengGuards do
|
||
|
-- body
|
||
|
if HarmonyManager.hongmengGuards[i].gridId ==msg.gridId then
|
||
|
HarmonyManager.hongmengGuards[i].time = 0
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
if msg.gridId == boxData.Id then
|
||
|
self.timer_text.text = ""
|
||
|
end
|
||
|
end,"取消","确认")
|
||
|
end)
|
||
|
-- body
|
||
|
else
|
||
|
UIManager.OpenPanel(UIName.HongMengChooseHeroPanel,true)
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
function EnvoyItem:UpdateFun()
|
||
|
-- body
|
||
|
self:SetItem(self.gameObject,self.data)
|
||
|
end
|
||
|
|
||
|
function EnvoyItem:SetItem(go,data)
|
||
|
self.data = data
|
||
|
if data.heroId ~= "" then
|
||
|
-- body
|
||
|
local heroSingleData = HeroManager.GetSingleHeroData(data.heroId)
|
||
|
self.Empty:SetActive(false)
|
||
|
Util.GetGameObject(go.transform, "GameObject/frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroSingleData.heroConfig.Quality,heroSingleData.star))
|
||
|
|
||
|
Util.GetGameObject(go.transform, "GameObject/lv/Text"):GetComponent("Text").text = string.format("<color=#0f0>%d</color>",HarmonyManager.hongmengTablet)
|
||
|
|
||
|
Util.GetGameObject(go.transform, "GameObject/icon"):GetComponent("Image").sprite = Util.LoadSprite(heroSingleData.icon)
|
||
|
|
||
|
Util.GetGameObject(go.transform, "GameObject/proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroSingleData.heroConfig.PropertyName))
|
||
|
local starGrid = Util.GetGameObject(go.transform, "GameObject/star")
|
||
|
SetHeroStars(starGrid, heroSingleData.star,1,nil,nil,Vector2.New(0,1))
|
||
|
else
|
||
|
self.Empty:SetActive(true)
|
||
|
end
|
||
|
|
||
|
end
|
||
|
return EnvoyItem
|