207 lines
9.2 KiB
Lua
207 lines
9.2 KiB
Lua
|
|
FourTrailSingleHelpHero = {}
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local redTrailType = {
|
|
[1] = RedPointType.PersonTrailHelp,
|
|
[2] = RedPointType.BuddishTrailHelp,
|
|
[3] = RedPointType.DemonTrailHelp,
|
|
[4] = RedPointType.TaoistTrailHelp,
|
|
}
|
|
local redTrailType1 = {
|
|
[1] = RedPointType.PersonTrail,
|
|
[2] = RedPointType.BuddishTrail,
|
|
[3] = RedPointType.DemonTrail,
|
|
[4] = RedPointType.TaoistTrail,
|
|
}
|
|
function FourTrailSingleHelpHero:New(gameObject)
|
|
local b = {}
|
|
b.gameObject = gameObject
|
|
b.transform = gameObject.transform
|
|
setmetatable(b, { __index = FourTrailSingleHelpHero })
|
|
return b
|
|
end
|
|
|
|
--初始化组件(用于子类重写)
|
|
function FourTrailSingleHelpHero:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
local go = Util.GetGameObject(self.gameObject, "GameObject")
|
|
self.hero = Util.GetGameObject(go, "HeroPre")
|
|
self.frame = Util.GetGameObject(self.hero, "frame"):GetComponent("Image")
|
|
self.icon = Util.GetGameObject(self.hero, "icon"):GetComponent("Image")
|
|
self.lv = Util.GetGameObject(self.hero, "lv/Text"):GetComponent("Text")
|
|
self.proIcon = Util.GetGameObject(self.hero, "proIcon"):GetComponent("Image")
|
|
self.starGrid = Util.GetGameObject(self.hero, "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")
|
|
self.selectText = Util.GetGameObject(go,"Button/Text"):GetComponent("Text")
|
|
self.btn = Util.GetGameObject(go,"Button")
|
|
end
|
|
--绑定事件(用于子类重写)
|
|
function FourTrailSingleHelpHero:BindEvent()
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function FourTrailSingleHelpHero:AddListener()
|
|
end
|
|
|
|
function FourTrailSingleHelpHero:OnOpen(_sortingOrder)
|
|
self.sortingOrder = _sortingOrder
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function FourTrailSingleHelpHero:RemoveListener()
|
|
end
|
|
function FourTrailSingleHelpHero:OnShow(curType,...)
|
|
local args = {...}
|
|
local player = {}
|
|
local heroData = {}
|
|
self.curType = args[2]
|
|
self.heifhtPower = args[3]
|
|
if curType == 1 then
|
|
heroData = args[1].hero
|
|
player = args[1].player
|
|
heroData.changeProId = player.hero.propertyId
|
|
self.proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(player.hero.propertyId))
|
|
else
|
|
heroData = args[1]
|
|
self.proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.changeProId))
|
|
end
|
|
self.frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality, heroData.star))
|
|
self.icon:GetComponent("Image").sprite = self.spLoader:LoadSprite(heroData.icon)
|
|
self.lv:GetComponent("Text").text = heroData.lv
|
|
|
|
local star,starType = heroData.GetStar(1)
|
|
SetHeroStars(self.spLoader,self.starGrid , star,starType)
|
|
SetHeroFlyEffect(self.hero,self.spLoader,heroData.star,self.sortingOrder+1,1 )
|
|
Util.SetParticleSortLayer(self.starGrid,self.sortingOrder + 1)
|
|
self.name.text = itemConfig[heroData.heroConfig.Id].Name
|
|
-- local allAddProVal = HeroManager.CalculateHeroAllProValList(1, heroData, false)
|
|
--LogGreen(heroData.dynamicId.." allAddProVal[HeroProType.WarPower]:"..allAddProVal[HeroProType.WarPower])
|
|
self.num.text = HeroPowerManager.GetHeroPower(heroData.dynamicId)--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,player)
|
|
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,player)
|
|
local tempData = MonsterCampManager.GetFriendHelpHero(self.curType)
|
|
self.btn:GetComponent("Button").enabled = true
|
|
if tempData and heroData.dynamicId == tempData.hero.dynamicId then
|
|
if tempData.player and tempData.player.state == 1 then
|
|
self.select.sprite = self.spLoader:LoadSprite("Btn_hz_lan_01")
|
|
--self.select:SetNativeSize()
|
|
self.selectText.text = "已使用"
|
|
self.btn:GetComponent("Button").enabled = false
|
|
else
|
|
self.select.sprite = self.spLoader:LoadSprite("Btn_hz_cheng_01")
|
|
self.select:SetNativeSize()
|
|
self.selectText.text = "取消选择"
|
|
Util.AddOnceClick(self.btn, function()
|
|
NetManager.UseHelpHeroRequest(heroData.dynamicId,self.curType,0,function()
|
|
local curFormation = FormationManager.GetFormationByID(1700 + self.curType)
|
|
--上阵列表赋值
|
|
local choosedList ={}
|
|
for j = 1, #curFormation.teamHeroInfos do
|
|
local teamInfo = curFormation.teamHeroInfos[j]
|
|
-- 加空判断避免不知名错误
|
|
if teamInfo and teamInfo.heroId ~= heroData.dynamicId then
|
|
table.insert(choosedList, {heroId = teamInfo.heroId,position=teamInfo.position})
|
|
end
|
|
end
|
|
FormationManager.SaveFormation(
|
|
(1700 + self.curType),
|
|
choosedList,
|
|
FormationManager.formationList[(1700 + self.curType)].teamPokemonInfos
|
|
)
|
|
MonsterCampManager.SetFriendHelpHero(nil,self.curType)
|
|
self:SetIcon1(heroData,player)
|
|
return
|
|
end)
|
|
end)
|
|
end
|
|
elseif self.heifhtPower < heroData.warPower then
|
|
self.select.sprite = self.spLoader:LoadSprite("Btn_hz_lan_01")
|
|
--self.select:SetNativeSize()
|
|
self.selectText.text = "战力过高"
|
|
self.btn:GetComponent("Button").enabled = false
|
|
else
|
|
self.select.sprite = self.spLoader:LoadSprite("Btn_hz_cheng_01")
|
|
self.select:SetNativeSize()
|
|
self.selectText.text = "选择英雄"
|
|
Util.AddOnceClick(self.btn, function()
|
|
local tempData1 = MonsterCampManager.GetFriendHelpHero(self.curType)
|
|
if tempData1 and tempData1.player and tempData1.player.state == 0 then
|
|
PopupTipPanel.ShowTip("已选择其他英雄!")
|
|
elseif tempData1 and tempData1.player and tempData1.player.state == 1 then
|
|
LogGreen(tempData1.player.state)
|
|
PopupTipPanel.ShowTip("今日已无使用助战次数!")
|
|
else
|
|
NetManager.UseHelpHeroRequest(heroData.dynamicId,self.curType,1,function()
|
|
MonsterCampManager.SetFriendHelpHero(player,self.curType)
|
|
self:SetIcon1(heroData,player)
|
|
return
|
|
end)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
function FourTrailSingleHelpHero:SetIcon2(heroData)
|
|
local tempData = MonsterCampManager.GetMyHelpHero(self.curType)
|
|
self.btn:GetComponent("Button").enabled = true
|
|
if tempData and heroData.dynamicId == tempData.dynamicId then
|
|
self.btn:GetComponent("Button").enabled = false
|
|
self.select.sprite = self.spLoader:LoadSprite("Btn_hz_lan_01")
|
|
--self.select:SetNativeSize()
|
|
self.selectText.text = "支援中"
|
|
Util.AddOnceClick(self.btn, function()
|
|
end)
|
|
else
|
|
self.select.sprite = self.spLoader:LoadSprite("Btn_hz_cheng_01")
|
|
self.select:SetNativeSize()
|
|
self.selectText.text = "选择英雄"
|
|
Util.AddOnceClick(self.btn, function()
|
|
local tempData1 = MonsterCampManager.GetMyHelpHero(self.curType)
|
|
if tempData1 then
|
|
PopupTipPanel.ShowTip("已选择支援英雄!")
|
|
else
|
|
NetManager.SetHelpHeroRequest(heroData.dynamicId,function(msg)
|
|
MonsterCampManager.SetMyHelpHeroData(self.curType,heroData,nil)
|
|
if msg.drop and msg.drop.itemlist and #msg.drop.itemlist > 0 then
|
|
local item = msg.drop.itemlist[1]
|
|
PopupTipPanel.ShowTip(string.format("已选择英雄,获得%s%s",item.itemNum,ConfigManager.GetConfigData(ConfigName.ItemConfig,item.itemId).Name))
|
|
end
|
|
CheckRedPointStatus(redTrailType[self.curType])
|
|
CheckRedPointStatus(redTrailType1[self.curType])
|
|
self:SetIcon2(heroData)
|
|
end)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
function FourTrailSingleHelpHero:OnClose()
|
|
end
|
|
|
|
function FourTrailSingleHelpHero:OnDestroy()
|
|
self.spLoader:OnDestroy()
|
|
end
|
|
|
|
|
|
return FourTrailSingleHelpHero |