2021-01-04 11:39:58 +08:00
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
FourTrailSingleHelpHero = {}
|
|
|
|
|
|
|
|
|
|
function FourTrailSingleHelpHero:New(gameObject)
|
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
|
|
|
|
setmetatable(b, { __index = FourTrailSingleHelpHero })
|
|
|
|
|
self:InitComponent(b.gameObject)
|
|
|
|
|
return b
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function FourTrailSingleHelpHero:InitComponent(go)
|
|
|
|
|
self.hero = Util.GetGameObject(go, "HeroPre")
|
|
|
|
|
self.frame = Util.GetGameObject(self.hero, "frame"):GetComponent("Image")
|
|
|
|
|
self.icon = Util.GetGameObject(go, "icon"):GetComponent("Image")
|
|
|
|
|
self.lv = Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
|
|
|
|
|
self.proIcon = Util.GetGameObject(go, "proIcon"):GetComponent("Image")
|
|
|
|
|
self.starGrid = Util.GetGameObject(go, "star")
|
|
|
|
|
|
|
|
|
|
self.name = Util.GetGameObject(go,"name"):GetComponent("Text")
|
|
|
|
|
self.num = Util.GetGameObject(go,"power/Text"):GetComponent("Text")
|
|
|
|
|
self.tip = Util.GetGameObject(go,"tip"):GetComponent("Text")
|
|
|
|
|
self.select = Util.GetGameObject(go,"Button/tip"):GetComponent("Image")
|
2021-02-03 18:40:26 +08:00
|
|
|
|
self.selectText = Util.GetGameObject(go,"Button/Text"):GetComponent("Text")
|
2021-01-04 11:39:58 +08:00
|
|
|
|
self.btn = Util.GetGameObject(go,"Button")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FourTrailSingleHelpHero:OnOpen(curType,...)
|
|
|
|
|
local args = {...}
|
|
|
|
|
local player = {}
|
|
|
|
|
local heroData = {}
|
|
|
|
|
self.curType = args[2]
|
|
|
|
|
if curType == 1 then
|
|
|
|
|
heroData = args[1].hero
|
|
|
|
|
player = args[1].player
|
|
|
|
|
else
|
|
|
|
|
heroData = args[1]
|
|
|
|
|
end
|
|
|
|
|
self.frame.sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality, heroData.star))
|
|
|
|
|
self.icon:GetComponent("Image").sprite = Util.LoadSprite(heroData.icon)
|
|
|
|
|
self.lv:GetComponent("Text").text = heroData.lv
|
|
|
|
|
self.proIcon.sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
|
|
|
|
|
SetHeroStars(self.starGrid , heroData.star)
|
|
|
|
|
self.name.text = itemConfig[heroData.heroConfig.Id].Name
|
|
|
|
|
self.num.text = heroData.warPower
|
|
|
|
|
if curType == 1 then
|
|
|
|
|
local from = ""
|
|
|
|
|
if player.guildName == 0 then
|
|
|
|
|
from = "好友"
|
|
|
|
|
else
|
|
|
|
|
from = "公会成员"
|
|
|
|
|
end
|
|
|
|
|
self.tip.text = "来自"..from.."<color=#08EC03>"..player.userName.."</color>"
|
|
|
|
|
self.tip.gameObject:SetActive(true)
|
|
|
|
|
self:SetIcon1(heroData)
|
|
|
|
|
else
|
|
|
|
|
self.tip.gameObject:SetActive(false)
|
|
|
|
|
self:SetIcon2(heroData)
|
|
|
|
|
end
|
|
|
|
|
Util.AddOnceClick(self.hero, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FourTrailSingleHelpHero:SetIcon1(heroData)
|
|
|
|
|
local tempData = MonsterCampManager.GetFriendHelpHero(self.curType)
|
|
|
|
|
if tempData and heroData.dynamicId == tempData.hero.dynamicId then
|
|
|
|
|
if tempData.state == 1 then
|
|
|
|
|
self.select.sprite = Util.LoadSprite("r_hero_button_003")
|
|
|
|
|
self.selectText.text = "已使用"
|
|
|
|
|
end
|
|
|
|
|
self.select.sprite = Util.LoadSprite("r_hero_button_003")
|
|
|
|
|
self.selectText.text = "取消选择"
|
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
|
|
|
|
--发协议
|
|
|
|
|
MonsterCampManager.SetFriendHelpHero(nil,self.curType)
|
|
|
|
|
self:SetIcon1(heroData)
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
self.select.sprite = Util.LoadSprite("r_hero_button_001")
|
|
|
|
|
self.selectText.text = "选择神将"
|
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
|
|
|
|
if tempData and tempData.state == 0 then
|
|
|
|
|
PopupTipPanel.ShowTip("已选择其他神将!")
|
|
|
|
|
elseif tempData and tempData.state == 1 then
|
|
|
|
|
PopupTipPanel.ShowTip("今日已无使用助战次数!")
|
|
|
|
|
else
|
|
|
|
|
MonsterCampManager.SetFriendHelpHero(msg,self.curType)
|
|
|
|
|
self:SetIcon1(heroData)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FourTrailSingleHelpHero:SetIcon2(heroData)
|
|
|
|
|
local tempData = MonsterCampManager.GetFriendHelpHero(self.curType)
|
|
|
|
|
if tempData and heroData.dynamicId == tempData.dynamicId then
|
|
|
|
|
self.select.sprite = Util.LoadSprite("r_hero_button_003")
|
|
|
|
|
self.selectText.text = "支援中"
|
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
self.select.sprite = Util.LoadSprite("r_hero_button_001")
|
|
|
|
|
self.selectText.text = "选择神将"
|
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
|
|
|
|
if tempData then
|
|
|
|
|
PopupTipPanel.ShowTip("已选择支援神将!")
|
|
|
|
|
else
|
|
|
|
|
MonsterCampManager.SetMyHelpHeroData(self.curType,heroData)
|
|
|
|
|
PopupTipPanel.ShowTip("已选择神将,获得XX金币!")
|
|
|
|
|
self:SetIcon1(heroData)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function FourTrailSingleHelpHero:OnDestroy()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return FourTrailSingleHelpHero
|