2021-02-04 17:41:44 +08:00
|
|
|
|
|
2021-01-04 11:39:58 +08:00
|
|
|
|
FourTrailSingleHelpHero = {}
|
2021-02-04 17:41:44 +08:00
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
2021-01-04 11:39:58 +08:00
|
|
|
|
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]
|
2021-02-04 15:12:37 +08:00
|
|
|
|
self.heifhtPower = args[3]
|
2021-01-04 11:39:58 +08:00
|
|
|
|
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)
|
2021-02-04 17:03:14 +08:00
|
|
|
|
self:SetIcon1(heroData,player)
|
2021-01-04 11:39:58 +08:00
|
|
|
|
else
|
|
|
|
|
self.tip.gameObject:SetActive(false)
|
|
|
|
|
self:SetIcon2(heroData)
|
|
|
|
|
end
|
|
|
|
|
Util.AddOnceClick(self.hero, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2021-02-04 17:03:14 +08:00
|
|
|
|
function FourTrailSingleHelpHero:SetIcon1(heroData,player)
|
2021-01-04 11:39:58 +08:00
|
|
|
|
local tempData = MonsterCampManager.GetFriendHelpHero(self.curType)
|
|
|
|
|
if tempData and heroData.dynamicId == tempData.hero.dynamicId then
|
|
|
|
|
if tempData.state == 1 then
|
2021-02-04 15:12:37 +08:00
|
|
|
|
self.select.sprite = Util.LoadSprite("s_silingshilian_yishiyong")
|
|
|
|
|
self.selectText.text = ""
|
2021-02-04 17:03:14 +08:00
|
|
|
|
self.btn:GetComponent("Button").enabled = false
|
|
|
|
|
else
|
|
|
|
|
self.select.sprite = Util.LoadSprite("r_hero_button_001")
|
|
|
|
|
self.selectText.text = "取消选择"
|
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
|
|
|
|
NetManager.UseHelpHeroRequest(heroData.dynamicId,self.curType,0,function()
|
|
|
|
|
MonsterCampManager.SetFriendHelpHero(nil,self.curType)
|
|
|
|
|
self:SetIcon1(heroData)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
2021-01-04 11:39:58 +08:00
|
|
|
|
end
|
2021-02-04 15:12:37 +08:00
|
|
|
|
elseif self.heifhtPower < heroData.warPower then
|
|
|
|
|
self.select.sprite = Util.LoadSprite("s_silingshilian_zhanliguogao")
|
|
|
|
|
self.selectText.text = ""
|
2021-02-04 17:03:14 +08:00
|
|
|
|
self.btn:GetComponent("Button").enabled = false
|
2021-01-04 11:39:58 +08:00
|
|
|
|
else
|
|
|
|
|
self.select.sprite = Util.LoadSprite("r_hero_button_001")
|
|
|
|
|
self.selectText.text = "选择神将"
|
2021-02-04 17:03:14 +08:00
|
|
|
|
self.btn:GetComponent("Button").enabled = true
|
2021-01-04 11:39:58 +08:00
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
|
|
|
|
if tempData and tempData.state == 0 then
|
|
|
|
|
PopupTipPanel.ShowTip("已选择其他神将!")
|
|
|
|
|
elseif tempData and tempData.state == 1 then
|
2021-02-04 15:12:37 +08:00
|
|
|
|
PopupTipPanel.ShowTip("今日已无使用助战次数!")
|
2021-01-04 11:39:58 +08:00
|
|
|
|
else
|
2021-02-04 17:03:14 +08:00
|
|
|
|
NetManager.UseHelpHeroRequest(heroData.dynamicId,self.curType,1,function()
|
|
|
|
|
MonsterCampManager.SetFriendHelpHero(player,self.curType)
|
|
|
|
|
self:SetIcon1(heroData)
|
|
|
|
|
end)
|
2021-01-04 11:39:58 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FourTrailSingleHelpHero:SetIcon2(heroData)
|
2021-02-04 17:03:14 +08:00
|
|
|
|
LogGreen(heroData.dynamicId)
|
2021-01-04 11:39:58 +08:00
|
|
|
|
local tempData = MonsterCampManager.GetFriendHelpHero(self.curType)
|
2021-02-04 17:03:14 +08:00
|
|
|
|
LogGreen(heroData.dynamicId)
|
2021-01-04 11:39:58 +08:00
|
|
|
|
if tempData and heroData.dynamicId == tempData.dynamicId then
|
2021-02-04 15:12:37 +08:00
|
|
|
|
self.select.sprite = Util.LoadSprite("s_silingshilian_zhiyuanzhong")
|
2021-02-04 17:03:14 +08:00
|
|
|
|
self.select:SetNativeSize()
|
2021-02-04 15:12:37 +08:00
|
|
|
|
self.selectText.text = ""
|
2021-01-04 11:39:58 +08:00
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
self.select.sprite = Util.LoadSprite("r_hero_button_001")
|
2021-02-04 17:03:14 +08:00
|
|
|
|
self.select:SetNativeSize()
|
2021-01-04 11:39:58 +08:00
|
|
|
|
self.selectText.text = "选择神将"
|
|
|
|
|
Util.AddOnceClick(self.btn, function()
|
|
|
|
|
if tempData then
|
|
|
|
|
PopupTipPanel.ShowTip("已选择支援神将!")
|
|
|
|
|
else
|
2021-02-04 15:12:37 +08:00
|
|
|
|
NetManager.SetHelpHeroRequest(heroData.dynamicId,function(msg)
|
2021-02-04 17:03:14 +08:00
|
|
|
|
MonsterCampManager.SetMyHelpHeroData(self.curType,heroData,nil)
|
2021-02-04 15:12:37 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1)
|
|
|
|
|
self:SetIcon2(heroData)
|
|
|
|
|
end)
|
2021-01-04 11:39:58 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function FourTrailSingleHelpHero:OnDestroy()
|
2021-02-04 17:41:44 +08:00
|
|
|
|
self = nil
|
2021-01-04 11:39:58 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return FourTrailSingleHelpHero
|