2021-04-21 13:12:04 +08:00
|
|
|
|
EnvoyItem={}
|
2020-12-17 10:41:00 +08:00
|
|
|
|
-- 鸿蒙守卫脚本
|
|
|
|
|
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)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.spLoader = SpriteLoader.New()
|
2020-12-17 10:41:00 +08:00
|
|
|
|
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")
|
2021-01-07 21:45:22 +08:00
|
|
|
|
self.timer_text = Util.GetGameObject(self.gameObject,"Box/Empty/frame/Text"):GetComponent("Text")
|
|
|
|
|
self.AddImage = Util.GetGameObject(self.gameObject,"Box/Empty/frame/AddImage")
|
2020-12-18 13:39:35 +08:00
|
|
|
|
self.RedPoint = Util.GetGameObject(self.gameObject,"Box/Empty/redPoint")
|
2021-11-05 10:18:10 +08:00
|
|
|
|
self.heroGo = Util.GetGameObject(self.gameObject, "GameObject")
|
|
|
|
|
self.proIcon = Util.GetGameObject(self.gameObject, "GameObject/proIcon"):GetComponent("Image")
|
|
|
|
|
self.frame = Util.GetGameObject(self.gameObject, "GameObject/frame"):GetComponent("Image")
|
|
|
|
|
self.lv = Util.GetGameObject(self.gameObject, "GameObject/lv/Text"):GetComponent("Text")
|
|
|
|
|
self.icon = Util.GetGameObject(self.gameObject, "GameObject/icon"):GetComponent("Image")
|
|
|
|
|
self.starGrid = Util.GetGameObject(self.gameObject, "GameObject/star")
|
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 = ""
|
2022-01-18 10:53:25 +08:00
|
|
|
|
local str = ConfigManager.GetConfigData(ConfigName.SpecialConfig,100).Value
|
|
|
|
|
local num = tonumber(string.split(str,"#")[1])
|
2022-01-18 11:20:55 +08:00
|
|
|
|
local money = math.ceil((self.data.time - GetTimeStamp()) / num)*tonumber(string.split(str,"#")[3])
|
2021-03-04 15:16:23 +08:00
|
|
|
|
content =string.format(Language[12189],money)
|
2020-12-17 10:41:00 +08:00
|
|
|
|
MsgPanel.ShowTwo(content,function ()
|
|
|
|
|
MsgPanel.Hide()
|
|
|
|
|
end,function ()
|
|
|
|
|
if BagManager.GetTotalItemNum(UpViewRechargeType.DemonCrystal) < money then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10846])
|
2020-12-17 10:41:00 +08:00
|
|
|
|
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
|
2021-01-08 17:29:54 +08:00
|
|
|
|
self.AddImage:SetActive(true)
|
2021-03-02 16:53:12 +08:00
|
|
|
|
end,Language[10731],Language[11934])
|
2020-12-17 10:41:00 +08:00
|
|
|
|
end)
|
|
|
|
|
-- body
|
|
|
|
|
else
|
|
|
|
|
UIManager.OpenPanel(UIName.HongMengChooseHeroPanel,true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EnvoyItem:UpdateFun()
|
|
|
|
|
-- body
|
|
|
|
|
self:SetItem(self.gameObject,self.data)
|
|
|
|
|
end
|
2022-01-05 18:17:44 +08:00
|
|
|
|
local sortingOrder=0
|
2020-12-17 10:41:00 +08:00
|
|
|
|
function EnvoyItem:SetItem(go,data)
|
2021-04-21 16:36:12 +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
|
2021-11-05 10:18:10 +08:00
|
|
|
|
self.heroGo:SetActive(true)
|
2020-12-17 10:41:00 +08:00
|
|
|
|
-- body
|
|
|
|
|
local heroSingleData = HeroManager.GetSingleHeroData(data.heroId)
|
|
|
|
|
self.Empty:SetActive(false)
|
2020-12-18 13:39:35 +08:00
|
|
|
|
self.RedPoint:SetActive(false)
|
2021-11-05 10:18:10 +08:00
|
|
|
|
self.frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroSingleData.heroConfig.Quality,heroSingleData.star))
|
2021-01-18 17:43:11 +08:00
|
|
|
|
local data = HarmonyManager.GetSingleAdditions(HarmonyAddType.AddLv)
|
|
|
|
|
if heroSingleData.lv == data then
|
2021-01-04 16:31:46 +08:00
|
|
|
|
-- body
|
2021-11-05 10:18:10 +08:00
|
|
|
|
self.lv.text = string.format("<color=#ffbe22>%d</color>",heroSingleData.lv)
|
2021-01-04 16:31:46 +08:00
|
|
|
|
else
|
2021-11-05 10:18:10 +08:00
|
|
|
|
self.lv.text = string.format("<color=red>%d</color>",heroSingleData.lv)
|
2021-01-04 16:31:46 +08:00
|
|
|
|
end
|
2021-11-05 10:18:10 +08:00
|
|
|
|
self.icon:GetComponent("Image").sprite = self.spLoader:LoadSprite(heroSingleData.icon)
|
2020-12-17 10:41:00 +08:00
|
|
|
|
|
2022-03-28 18:18:19 +08:00
|
|
|
|
self.proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroSingleData.changeProId))
|
2021-11-05 10:18:10 +08:00
|
|
|
|
|
2021-10-26 16:00:31 +08:00
|
|
|
|
local star,starType = heroSingleData.GetStar(1)
|
2021-11-05 10:18:10 +08:00
|
|
|
|
SetHeroStars(self.spLoader, self.starGrid, star,starType,nil,nil,Vector2.New(0,1))
|
2022-01-20 15:06:04 +08:00
|
|
|
|
SetHeroFlyEffect(self.heroGo,self.spLoader,heroSingleData.star,sortingOrder+1,1,2,20)
|
2021-11-05 10:18:10 +08:00
|
|
|
|
ForceRebuildLayout(self.starGrid.transform)
|
2020-12-17 10:41:00 +08:00
|
|
|
|
else
|
|
|
|
|
self.Empty:SetActive(true)
|
2021-11-05 10:18:10 +08:00
|
|
|
|
self.heroGo:SetActive(false)
|
2020-12-21 10:08:30 +08:00
|
|
|
|
if self.data.time-GetTimeStamp() > 0 then
|
|
|
|
|
-- body
|
2021-03-04 15:16:23 +08:00
|
|
|
|
print(Language[12190]..self.data.time-GetTimeStamp())
|
2021-01-07 21:45:22 +08:00
|
|
|
|
self.AddImage:SetActive(false)
|
2020-12-21 10:08:30 +08:00
|
|
|
|
self.RedPoint:SetActive(false)
|
|
|
|
|
else
|
2021-03-04 15:16:23 +08:00
|
|
|
|
print(Language[12191])
|
2021-01-07 21:45:22 +08:00
|
|
|
|
self.AddImage:SetActive(true)
|
2020-12-21 10:08:30 +08:00
|
|
|
|
self.RedPoint:SetActive(true)
|
|
|
|
|
end
|
2020-12-17 10:41:00 +08:00
|
|
|
|
end
|
2021-11-05 10:18:10 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EnvoyItem:SetEffectLayer(sort)
|
2022-01-05 18:17:44 +08:00
|
|
|
|
sortingOrder=sort
|
2021-11-05 10:18:10 +08:00
|
|
|
|
Util.SetParticleSortLayer(self.starGrid,sort + 1)
|
2020-12-17 10:41:00 +08:00
|
|
|
|
end
|
2021-04-21 13:12:04 +08:00
|
|
|
|
return EnvoyItem
|
|
|
|
|
|