miduo_client/Assets/ManagedResources/~Lua/Modules/Harmony/EnvoyItem/EnvoyItem.lua

135 lines
4.7 KiB
Lua
Raw Normal View History

2020-12-17 10:41:00 +08:00
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")
2020-12-18 13:39:35 +08:00
self.RedPoint = Util.GetGameObject(self.gameObject,"Box/Empty/redPoint")
2020-12-17 10:41:00 +08:00
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
2020-12-18 13:39:35 +08:00
if self.data.time - GetTimeStamp() > 0 then
2020-12-17 10:41:00 +08:00
local content = ""
2020-12-28 14:33:30 +08:00
local money = math.ceil(self.data.time - GetTimeStamp()) / 432
2020-12-17 10:41:00 +08:00
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
--向服务器 发消息
2020-12-18 13:39:35 +08:00
NetManager.UnlockGrid(self.data.gridId,2,function (msg)
2020-12-17 10:41:00 +08:00
-- body
for i = 1, #HarmonyManager.hongmengGuards do
-- body
2020-12-18 13:39:35 +08:00
if HarmonyManager.hongmengGuards[i].gridId ==self.data.gridId then
2020-12-17 10:41:00 +08:00
HarmonyManager.hongmengGuards[i].time = 0
end
end
2020-12-18 13:39:35 +08:00
self.timer_text.text = ""
self.data.time = 0
2020-12-17 10:41:00 +08:00
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
2020-12-29 20:36:37 +08:00
-- LogGreen("HeroId",data.heroId)
2020-12-18 13:39:35 +08:00
CheckRedPointStatus(RedPointType.HongMeng_Evory)
2020-12-17 10:41:00 +08:00
if data.heroId ~= "" then
-- body
local heroSingleData = HeroManager.GetSingleHeroData(data.heroId)
self.Empty:SetActive(false)
2020-12-18 13:39:35 +08:00
self.RedPoint:SetActive(false)
2020-12-17 10:41:00 +08:00
Util.GetGameObject(go.transform, "GameObject/frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroSingleData.heroConfig.Quality,heroSingleData.star))
2021-01-04 16:31:46 +08:00
if heroSingleData.lv == HarmonyManager.hongmengAdditions[1].value then
-- body
Util.GetGameObject(go.transform, "GameObject/lv/Text"):GetComponent("Text").text = string.format("<color=#0f0>%d</color>",heroSingleData.lv)
else
Util.GetGameObject(go.transform, "GameObject/lv/Text"):GetComponent("Text").text = string.format("<color=red>%d</color>",heroSingleData.lv)
end
2020-12-30 14:50:38 +08:00
2020-12-18 13:39:35 +08:00
2020-12-29 20:36:37 +08:00
--Util.GetGameObject(go.transform, "GameObject/lv/Text"):GetComponent("Text").text = string.format("<color=#0f0>%d</color>",HarmonyManager.hongmengAdditions[1].value)
2020-12-17 10:41:00 +08:00
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)
2020-12-21 10:08:30 +08:00
if self.data.time-GetTimeStamp() > 0 then
-- body
self.RedPoint:SetActive(false)
else
self.RedPoint:SetActive(true)
end
2020-12-18 13:39:35 +08:00
2020-12-17 10:41:00 +08:00
end
2020-12-18 13:39:35 +08:00
2020-12-17 10:41:00 +08:00
end
return EnvoyItem