2021-04-23 10:01:42 +08:00
|
|
|
|
starNumIamage = {
|
2020-05-09 13:31:21 +08:00
|
|
|
|
[1] = "x_xb_shuzi_01",
|
|
|
|
|
[2] = "x_xb_shuzi_02",
|
|
|
|
|
[3] = "x_xb_shuzi_03",
|
|
|
|
|
[4] = "x_xb_shuzi_04",
|
|
|
|
|
[5] = "x_xb_shuzi_05",
|
2020-07-31 18:40:22 +08:00
|
|
|
|
[6] = "x_xb_shuzi_06",
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
FindTreasureDispatchPanel = Inherit(BasePanel)
|
|
|
|
|
local curSelectHeroList={}
|
|
|
|
|
local tabs = {}
|
|
|
|
|
local selectHeroGrid = {}
|
|
|
|
|
local conditionGrid = {}
|
|
|
|
|
local proId = ProIdConst.All
|
|
|
|
|
local conFigData
|
|
|
|
|
local missionData
|
|
|
|
|
local allHeroData--显示英雄数据
|
|
|
|
|
local curSortHeroList--一键选择英雄数据
|
|
|
|
|
local needState
|
|
|
|
|
local conditionHeros = {}
|
|
|
|
|
local timer = Timer.New()
|
|
|
|
|
local curAllHeros = {}
|
|
|
|
|
local isMaterial = true
|
|
|
|
|
local curPanelHerosSortNum = 1
|
2021-04-22 21:34:11 +08:00
|
|
|
|
local tabsImg = {"z_icon_01_zh", "r_hero_huo 1_zh", "r_hero_feng 1_zh", "r_hero_shui 1_zh", "r_hero_dadi 1_zh"}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function FindTreasureDispatchPanel:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.spLoader = SpriteLoader.New()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
self.BtnBack = Util.GetGameObject(self.transform, "btnBack")
|
|
|
|
|
self.btnSure = Util.GetGameObject(self.transform, "btnSure")
|
|
|
|
|
self.btnAutoSure = Util.GetGameObject(self.transform, "btnAutoSure")
|
2021-02-24 14:45:09 +08:00
|
|
|
|
self.btnAutoSureText = Util.GetGameObject(self.transform, "btnAutoSure/Text"):GetComponent("Text")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
self.cardPre = Util.GetGameObject(self.gameObject, "item")
|
2022-03-25 14:12:19 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.Scrollbar = Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar")
|
|
|
|
|
local v = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect
|
|
|
|
|
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "scroll").transform,
|
2022-03-25 14:12:19 +08:00
|
|
|
|
self.cardPre, self.Scrollbar, Vector2.New(-v.x*2, -v.y), 1, 5, Vector2.New(25,32))
|
|
|
|
|
self.ScrollView.moveTween.MomentumAmount = 0
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.ScrollView.moveTween.Strength = 1
|
2022-03-25 14:12:19 +08:00
|
|
|
|
self.ScrollView.elastic = false
|
|
|
|
|
--self.ScrollView.itemCount = 15
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.selectBtn = Util.GetGameObject(self.gameObject, "Tabs/selectBtn")
|
|
|
|
|
for i = 0, 6 do
|
|
|
|
|
tabs[i] = Util.GetGameObject(self.transform, "Tabs/grid/Btn" .. i)
|
2021-04-22 21:34:11 +08:00
|
|
|
|
if tabsImg[i + 1] then
|
2021-04-23 10:01:42 +08:00
|
|
|
|
Util.GetGameObject(tabs[i], "Image"):GetComponent("Image").sprite = self.spLoader:LoadSprite(tabsImg[i + 1])
|
2021-04-22 21:34:11 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for i = 1, 5 do
|
|
|
|
|
selectHeroGrid[i] = Util.GetGameObject(self.transform, "selectHeroGrid/item (" .. i..")")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for i = 1, 5 do
|
|
|
|
|
conditionGrid[i] = Util.GetGameObject(self.transform, "conditionGrid/condition (" .. i..")")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.matreiaObj = Util.GetGameObject(self.gameObject, "matreialTimeInfoBg/matreiaObj")
|
|
|
|
|
self.matreiaImage = Util.GetGameObject(self.gameObject, "matreialTimeInfoBg/matreiaObj/matreiaImage"):GetComponent("Image")
|
|
|
|
|
self.matreiaText = Util.GetGameObject(self.gameObject, "matreialTimeInfoBg/matreiaObj/numText"):GetComponent("Text")
|
|
|
|
|
self.timeText = Util.GetGameObject(self.gameObject, "matreialTimeInfoBg/timeObj/numText"):GetComponent("Text")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function FindTreasureDispatchPanel:BindEvent()
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.BtnBack, function()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.matreiaObj, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, FindTreasureManager.materialItemId)
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.btnSure, function()
|
|
|
|
|
if not isMaterial then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,FindTreasureManager.materialItemId).Name)..Language[10657])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #needState do
|
|
|
|
|
if needState[i] < 1 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10658])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local curSelectHeroIdsTab = {}
|
|
|
|
|
for k, v in pairs(curSelectHeroList) do
|
|
|
|
|
table.insert(curSelectHeroIdsTab,k)
|
|
|
|
|
end
|
|
|
|
|
--Log("missionData.missionId "..missionData.missionId)
|
|
|
|
|
--for i = 1, #curSelectHeroIdsTab do
|
|
|
|
|
--Log("curSelectHeroIdsTab "..curSelectHeroIdsTab[i])
|
|
|
|
|
--end
|
|
|
|
|
NetManager.FindTreasureMissingRoomSendHeroRequest(missionData.missionId,curSelectHeroIdsTab,function()
|
|
|
|
|
TaskManager.RefreshFindTreasureHerosData(missionData.missionId,curSelectHeroIdsTab,conFigData.WasteTime)
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.FindTreasure.RefreshFindTreasure,false)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.btnAutoSure, function()
|
|
|
|
|
self:AutoSelectHero()
|
2021-02-26 14:52:59 +08:00
|
|
|
|
self:OnShowPanelData(curAllHeros,false,false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end)
|
|
|
|
|
for i = 0, 6 do
|
|
|
|
|
Util.AddClick(tabs[i], function()
|
|
|
|
|
if i == proId then
|
|
|
|
|
proId = ProIdConst.All
|
|
|
|
|
else
|
|
|
|
|
proId = i
|
|
|
|
|
end
|
|
|
|
|
self:GetCurSortHeroListData()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function FindTreasureDispatchPanel:AddListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function FindTreasureDispatchPanel:RemoveListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function FindTreasureDispatchPanel:OnOpen(_missionData)
|
|
|
|
|
|
|
|
|
|
missionData =_missionData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function FindTreasureDispatchPanel:OnShow()
|
|
|
|
|
|
|
|
|
|
curPanelHerosSortNum = 1
|
|
|
|
|
curSelectHeroList = {}
|
|
|
|
|
curAllHeros = {}
|
|
|
|
|
isMaterial = true
|
|
|
|
|
conFigData = ConfigManager.GetConfigData(ConfigName.MazeTreasure,math.floor(missionData.missionId%10000))
|
|
|
|
|
allHeroData = HeroManager.GetFingTreasureAllHeroDatas()
|
|
|
|
|
curSortHeroList = HeroManager.GetFingTreasureAllHeroDatas()
|
|
|
|
|
self:SortHeroDatas(allHeroData)
|
|
|
|
|
self:SortHeroDatas2(curSortHeroList)
|
2021-02-26 14:52:59 +08:00
|
|
|
|
self:OnShowPanelData(allHeroData,true,true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
proId = ProIdConst.All
|
|
|
|
|
self:SetSelectBtn()
|
|
|
|
|
--显示选择的英雄
|
|
|
|
|
self:ShowSelectHeroData()
|
|
|
|
|
--显示条件
|
|
|
|
|
self:ShowNeedConditionData()
|
|
|
|
|
--赋值所有符合条件的英雄
|
|
|
|
|
self:GetConditionHeros()
|
|
|
|
|
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.matreiaImage.sprite = self.spLoader:LoadSprite(GetResourcePath(ConfigManager.GetConfigData(ConfigName.ItemConfig,FindTreasureManager.materialItemId).ResourceID))
|
2020-09-23 14:51:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local isJian = PrivilegeManager.GetSerData(155) ~= nil--PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.FINDTREASURE_EXPERT) > 0
|
|
|
|
|
local privilegeTypeConfig = ConfigManager.GetConfigDataByKey(ConfigName.PrivilegeTypeConfig,"PrivilegeType",PRIVILEGE_TYPE.FINDTREASURE_EXPERT)
|
|
|
|
|
local jianNum = (privilegeTypeConfig and isJian) and (privilegeTypeConfig.Condition[1][2])/10000 or 1
|
|
|
|
|
local takeItemNum = isJian and (conFigData.TakeItem[2] + conFigData.TakeItem[2] * jianNum) or conFigData.TakeItem[2]
|
2021-04-21 16:36:12 +08:00
|
|
|
|
--LogGreen("isJian "..tostring(isJian).." jianNum "..jianNum.." takeItemNum "..takeItemNum)
|
2020-09-23 14:51:33 +08:00
|
|
|
|
self.matreiaText.text = BagManager.GetItemCountById(FindTreasureManager.materialItemId) .. "/"..takeItemNum
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self.timeText.text = self:TimeStampToDateString(conFigData.WasteTime)
|
2020-09-23 14:51:33 +08:00
|
|
|
|
if BagManager.GetItemCountById(FindTreasureManager.materialItemId) < takeItemNum then isMaterial = false end
|
2021-02-24 14:45:09 +08:00
|
|
|
|
|
|
|
|
|
self.btnAutoSureText.fontSize = GetCurLanguage() == 0 and 45 or 40
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-02-26 14:52:59 +08:00
|
|
|
|
function FindTreasureDispatchPanel:OnShowPanelData(_allHeroData,isTop,isAni)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
curAllHeros = _allHeroData
|
|
|
|
|
self.ScrollView:SetData(_allHeroData, function (index, go)
|
|
|
|
|
self:OnShowSingleCardData(go, _allHeroData[index])
|
2021-02-26 14:52:59 +08:00
|
|
|
|
end,not isTop,not isAni)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
function FindTreasureDispatchPanel:OnShowSingleCardData(go,heroData)--isSelect 1选择 2 没选择
|
|
|
|
|
local choosed = Util.GetGameObject(go.transform, "choosed")
|
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
if curSelectHeroList[heroData.dynamicId] then
|
|
|
|
|
heroData.sortId = curPanelHerosSortNum
|
|
|
|
|
curPanelHerosSortNum = curPanelHerosSortNum + 1
|
|
|
|
|
curSelectHeroList[heroData.dynamicId]=heroData
|
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
self:OnShowCardData(go,heroData,1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FindTreasureDispatchPanel:ShowNeedConditionData(type)
|
|
|
|
|
needState = self:DetectionSelectHeros()
|
|
|
|
|
for i = 1, #conditionGrid do--curSelectHeroList
|
|
|
|
|
if #conFigData.Condition >= i then
|
|
|
|
|
conditionGrid[i]:SetActive(true)
|
|
|
|
|
local starIcon = Util.GetGameObject(conditionGrid[i], "starIcon")
|
|
|
|
|
local proIcon = Util.GetGameObject(conditionGrid[i], "proIcon")
|
|
|
|
|
starIcon:SetActive(conFigData.Condition[i][1] == FindTreasureNeedType.Star)
|
|
|
|
|
proIcon:SetActive(conFigData.Condition[i][1] == FindTreasureNeedType.Pro)
|
|
|
|
|
proIcon.transform.localScale = Vector3.one
|
|
|
|
|
if conFigData.Condition[i][1] == FindTreasureNeedType.Pro then
|
|
|
|
|
proIcon.transform.localScale = Vector3.New(1.5, 1.5, 1)
|
|
|
|
|
end
|
|
|
|
|
Util.SetGray(conditionGrid[i], needState[i] < 1)
|
|
|
|
|
local tipsStr = ""
|
2020-06-18 20:39:29 +08:00
|
|
|
|
if conFigData.Condition[i][1] == FindTreasureNeedType.Star then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
tipsStr = Language[10659]..conFigData.Condition[i][2]..Language[10660]
|
2021-04-21 13:12:04 +08:00
|
|
|
|
Util.GetGameObject(conditionGrid[i], "starIcon/numImage"):GetComponent("Image").sprite = self.spLoader:LoadSprite(starNumIamage[self:GetHeroStarImage(conFigData.Condition[i][2],1)])
|
|
|
|
|
Util.GetGameObject(conditionGrid[i], "starIcon/starImage"):GetComponent("Image").sprite = self.spLoader:LoadSprite(self:GetHeroStarImage(conFigData.Condition[i][2],2))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif conFigData.Condition[i][1] == FindTreasureNeedType.Pro then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
tipsStr = Language[10659]..HeroElementDef[conFigData.Condition[i][2]]..Language[10661]
|
2021-04-21 13:12:04 +08:00
|
|
|
|
proIcon:GetComponent("Image").sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(conFigData.Condition[i][2]))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
Util.AddOnceClick(conditionGrid[i], function()
|
|
|
|
|
PopupTipPanel.ShowTip(tipsStr)
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
conditionGrid[i]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FindTreasureDispatchPanel:ShowSelectHeroData()
|
|
|
|
|
local curSelectHeroSortList = {}
|
|
|
|
|
for i, v in pairs(curSelectHeroList) do
|
|
|
|
|
table.insert(curSelectHeroSortList,v)
|
|
|
|
|
--Log("v.dynamicId "..v.dynamicId.." "..v.heroConfig.ReadingName)
|
|
|
|
|
end
|
|
|
|
|
table.sort(curSelectHeroSortList, function(a, b)
|
|
|
|
|
return a.sortId < b.sortId
|
|
|
|
|
end)
|
|
|
|
|
for i = 1, #selectHeroGrid do--curSelectHeroList
|
|
|
|
|
if conFigData.NeedCard >= i then
|
|
|
|
|
selectHeroGrid[i]:SetActive(true)
|
|
|
|
|
if LengthOfTable(curSelectHeroSortList) >= i then--conFigData.NeedCard
|
|
|
|
|
Util.GetGameObject(selectHeroGrid[i], "GameObject"):SetActive(true)
|
|
|
|
|
if curSelectHeroSortList[i] then
|
|
|
|
|
self:OnShowCardData(Util.GetGameObject(selectHeroGrid[i], "GameObject"),curSelectHeroSortList[i],2)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
Util.GetGameObject(selectHeroGrid[i], "GameObject"):SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
selectHeroGrid[i]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FindTreasureDispatchPanel:OnShowCardData(go,heroData,type)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
Util.GetGameObject(go.transform, "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Util.GetGameObject(go.transform, "lv/Text"):GetComponent("Text").text = heroData.lv
|
2021-04-21 13:12:04 +08:00
|
|
|
|
Util.GetGameObject(go.transform, "icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(heroData.icon)
|
|
|
|
|
-- Util.GetGameObject(go.transform, "posIcon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(heroData.professionIcon)
|
2022-03-31 09:51:10 +08:00
|
|
|
|
Util.GetGameObject(go.transform, "proIcon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.changeProId))
|
2021-04-21 13:12:04 +08:00
|
|
|
|
--Util.GetGameObject(go.transform, "heroStage"):GetComponent("Image").sprite = self.spLoader:LoadSprite(HeroStageSprite[heroData.heroConfig.HeroStage])
|
2020-06-08 13:57:30 +08:00
|
|
|
|
-- Util.GetGameObject(go.transform, "heroStage"):SetActive(false)
|
2020-06-19 16:18:05 +08:00
|
|
|
|
Util.GetGameObject(go.transform, "posIcon"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(go.transform, "heroStage"):SetActive(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local starGrid = Util.GetGameObject(go.transform, "star")
|
2021-10-26 16:00:31 +08:00
|
|
|
|
local star,starType = heroData.GetStar(1)
|
|
|
|
|
SetHeroStars(self.spLoader, starGrid, star,starType)
|
2022-03-25 14:12:19 +08:00
|
|
|
|
local effect=SetHeroFlyEffect(go,self.spLoader,heroData.star,self.sortingOrder + 1,1,3)
|
|
|
|
|
-- if effect then
|
|
|
|
|
-- local meshs2=effect:GetComponentsInChildren(typeof(UnityEngine.SkinnedMeshRenderer))
|
|
|
|
|
-- for key, value in pairs(meshs2:ToTable()) do
|
|
|
|
|
-- if value.material.shader.name=="YXZ/Effect/TransparentRim" then
|
|
|
|
|
-- value.material.shader=poolManager:LoadAsset("YXZ_Effect_TransparentRim_1",poolManager.AssetType.Other)
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- local meshs1=starGrid:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
|
|
|
|
|
-- for key, value in pairs(meshs1:ToTable()) do
|
|
|
|
|
-- local mat=value:GetComponent(typeof(UnityEngine.Renderer))
|
|
|
|
|
-- if mat.material.shader.name=="UI Particles/Additive" then
|
|
|
|
|
-- mat.material.shader=poolManager:LoadAsset("UI-Particle-Add_1",poolManager.AssetType.Other)
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
local particles=go:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
|
|
|
|
|
for key, value in pairs(particles:ToTable()) do
|
2022-01-12 16:41:51 +08:00
|
|
|
|
local mat=value:GetComponent(typeof(UnityEngine.Renderer))
|
2022-03-25 14:12:19 +08:00
|
|
|
|
if mat.material.shader.name=="CGwell FX/Additive Lv1" then
|
|
|
|
|
mat.material.shader=poolManager:LoadAsset("Add Lv1_1",poolManager.AssetType.Other)
|
|
|
|
|
elseif mat.material.shader.name=="UI Particles/Additive" then
|
2022-01-12 16:41:51 +08:00
|
|
|
|
mat.material.shader=poolManager:LoadAsset("UI-Particle-Add_1",poolManager.AssetType.Other)
|
2022-03-25 14:12:19 +08:00
|
|
|
|
elseif mat.material.shader.name=="YXZ/Effect/Mix Masking(Without Moving)_alphablend" then
|
|
|
|
|
mat.material.shader=poolManager:LoadAsset("YXZ_MixMaskingWithoutMoving_alphablend_1",poolManager.AssetType.Other)
|
2022-01-12 16:41:51 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2022-03-25 14:12:19 +08:00
|
|
|
|
local meshs=go:GetComponentsInChildren(typeof(UnityEngine.MeshRenderer))
|
|
|
|
|
for key, value in pairs(meshs:ToTable()) do
|
|
|
|
|
if value.material.shader.name=="Custom/S_03_UV_alpha_add" then
|
|
|
|
|
value.material.shader=poolManager:LoadAsset("S_03_uv_alpha_add_1",poolManager.AssetType.Other)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local meshs2=go:GetComponentsInChildren(typeof(UnityEngine.SkinnedMeshRenderer))
|
|
|
|
|
for key, value in pairs(meshs2:ToTable()) do
|
|
|
|
|
if value.material.shader.name=="YXZ/Effect/TransparentRim" then
|
|
|
|
|
value.material.shader=poolManager:LoadAsset("YXZ_Effect_TransparentRim_1",poolManager.AssetType.Other)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-11-05 13:18:55 +08:00
|
|
|
|
Util.SetParticleSortLayer(starGrid,self.sortingOrder + 1)
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local cardBtn = Util.GetGameObject(go.transform, "icon")
|
|
|
|
|
local choosed = Util.GetGameObject(go.transform, "choosed")
|
|
|
|
|
Util.AddOnceClick(cardBtn, function()
|
|
|
|
|
if curSelectHeroList[heroData.dynamicId] then
|
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
curSelectHeroList[heroData.dynamicId]=nil
|
|
|
|
|
--监测方法
|
|
|
|
|
if type == 2 then
|
2021-02-26 14:52:59 +08:00
|
|
|
|
self:OnShowPanelData(curAllHeros,false,false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
self:ShowNeedConditionData()
|
|
|
|
|
self:ShowSelectHeroData()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if LengthOfTable(curSelectHeroList)>=conFigData.NeedCard then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10403])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
heroData .sortId = curPanelHerosSortNum
|
|
|
|
|
curPanelHerosSortNum = curPanelHerosSortNum + 1
|
|
|
|
|
curSelectHeroList[heroData.dynamicId]=heroData
|
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
--监测方法
|
|
|
|
|
self:ShowNeedConditionData()
|
|
|
|
|
self:ShowSelectHeroData()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--组合当前选项数据
|
|
|
|
|
function FindTreasureDispatchPanel:GetCurSortHeroListData()
|
|
|
|
|
local heros = {}
|
|
|
|
|
self:SetSelectBtn()
|
|
|
|
|
if proId ~= ProIdConst.All then
|
|
|
|
|
heros = self:GetCurProHeros(proId)
|
|
|
|
|
curSortHeroList = self:GetCurProHeros(proId)
|
|
|
|
|
else
|
|
|
|
|
heros = allHeroData
|
|
|
|
|
curSortHeroList = HeroManager.GetFingTreasureAllHeroDatas()
|
|
|
|
|
end
|
2021-02-26 14:52:59 +08:00
|
|
|
|
self:OnShowPanelData(heros,false,false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
function FindTreasureDispatchPanel:HeroSortData(heroData)
|
|
|
|
|
table.sort(heroData, function(a, b)
|
|
|
|
|
if a.id == b.id then
|
|
|
|
|
if a.lv == b.lv then
|
|
|
|
|
return a.id > b.id
|
|
|
|
|
else
|
|
|
|
|
return a.lv < b.lv
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.id > b.id
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
function FindTreasureDispatchPanel:SetSelectBtn()
|
|
|
|
|
self.selectBtn:SetActive(proId ~= ProIdConst.All)
|
|
|
|
|
if proId ~= ProIdConst.All then
|
|
|
|
|
self.selectBtn.transform.localPosition = tabs[proId].transform.localPosition
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--一键派遣
|
|
|
|
|
function FindTreasureDispatchPanel:AutoSelectHero()
|
|
|
|
|
--思路 按条件顺序选择 没选择一个英雄检测其他条件是否有满足的 满足跳过 不管能不能派遣都显示
|
|
|
|
|
curSelectHeroList = {}
|
|
|
|
|
local conditionTabs = {}
|
|
|
|
|
for i = 1, #conFigData.Condition do
|
|
|
|
|
conditionTabs[i] = 0
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #conditionHeros do
|
|
|
|
|
if #conditionHeros[i] > 0 then
|
|
|
|
|
local jixu = self:AutoSelectState(conditionTabs)
|
|
|
|
|
if jixu <= 0 then needState = conditionTabs return end
|
|
|
|
|
if i > jixu then jixu = i end
|
|
|
|
|
if #conditionHeros[jixu] <= 0 then return end
|
2020-09-01 16:45:11 +08:00
|
|
|
|
local num = self:AutoSelectState2(conditionTabs) - 1
|
|
|
|
|
local curSelectSingleHero = self:AutoSelectHeroId(conditionHeros[jixu],num)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
curSelectSingleHero.sortId = curPanelHerosSortNum--排序
|
|
|
|
|
curPanelHerosSortNum = curPanelHerosSortNum + 1--排序
|
|
|
|
|
curSelectHeroList[curSelectSingleHero.dynamicId] = curSelectSingleHero
|
|
|
|
|
for k = 1, #conFigData.Condition do
|
|
|
|
|
if conFigData.Condition[k][1] == FindTreasureNeedType.Star then
|
|
|
|
|
for j, v in pairs(curSelectHeroList) do
|
|
|
|
|
if v.star >= conFigData.Condition[k][2] then
|
2020-09-01 16:45:11 +08:00
|
|
|
|
conditionTabs[k] = 1
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif conFigData.Condition[k][1] == FindTreasureNeedType.Pro then
|
|
|
|
|
for j, v in pairs(curSelectHeroList) do
|
2022-03-31 09:51:10 +08:00
|
|
|
|
if v.changeProId == conFigData.Condition[k][2] then
|
2020-09-01 16:45:11 +08:00
|
|
|
|
conditionTabs[k] = 1
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--监测方法
|
|
|
|
|
self:ShowNeedConditionData()
|
|
|
|
|
self:ShowSelectHeroData()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FindTreasureDispatchPanel:AutoSelectState(conditionTabs)
|
|
|
|
|
for i = 1, #conditionTabs do
|
|
|
|
|
if conditionTabs[i] < 1 then
|
|
|
|
|
Log("jixu "..i)
|
|
|
|
|
return i
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return 0
|
|
|
|
|
end
|
2020-09-01 16:45:11 +08:00
|
|
|
|
function FindTreasureDispatchPanel:AutoSelectState2(conditionTabs)
|
|
|
|
|
local needNum = 0
|
|
|
|
|
for i = 1, #conditionTabs do
|
|
|
|
|
if conditionTabs[i] < 1 then
|
|
|
|
|
needNum = needNum + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return needNum
|
|
|
|
|
end
|
|
|
|
|
function FindTreasureDispatchPanel:AutoSelectHeroId(conditionSingleHeros,num)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local heroData = conditionSingleHeros[1]
|
|
|
|
|
local endfeheNeedNum = 0
|
|
|
|
|
for i = 1, #conditionSingleHeros do
|
|
|
|
|
local feheNeedNum = 0
|
|
|
|
|
for j = 1, #conFigData.Condition do
|
|
|
|
|
if conFigData.Condition[j][1] == FindTreasureNeedType.Star then
|
|
|
|
|
if conditionSingleHeros[i].star >= conFigData.Condition[j][2] then
|
|
|
|
|
feheNeedNum = feheNeedNum + 1
|
|
|
|
|
end
|
|
|
|
|
elseif conFigData.Condition[j][1] == FindTreasureNeedType.Pro then
|
2022-03-31 09:51:10 +08:00
|
|
|
|
if conditionSingleHeros[i].changeProId == conFigData.Condition[j][2] then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
feheNeedNum = feheNeedNum + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-09-01 16:45:11 +08:00
|
|
|
|
if num <= 1 then
|
|
|
|
|
if endfeheNeedNum < feheNeedNum then
|
|
|
|
|
return conditionSingleHeros[i]
|
|
|
|
|
end
|
|
|
|
|
elseif num > 1 then
|
|
|
|
|
if endfeheNeedNum < feheNeedNum then
|
|
|
|
|
endfeheNeedNum = feheNeedNum
|
|
|
|
|
heroData = conditionSingleHeros[i]
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return heroData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FindTreasureDispatchPanel:GetCurProHeros(_property)
|
|
|
|
|
local heros = {}
|
|
|
|
|
local index = 1
|
|
|
|
|
for i, v in pairs(allHeroData) do
|
|
|
|
|
if v.property == _property then
|
|
|
|
|
heros[index] = v
|
|
|
|
|
index = index + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return heros
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测选择的英雄是否满足条件
|
|
|
|
|
function FindTreasureDispatchPanel:DetectionSelectHeros()
|
|
|
|
|
local conditionTabs = {}
|
|
|
|
|
for i = 1, #conFigData.Condition do
|
|
|
|
|
conditionTabs[i] = 0
|
|
|
|
|
if conFigData.Condition[i][1] == FindTreasureNeedType.Star then
|
|
|
|
|
for j, v in pairs(curSelectHeroList) do
|
|
|
|
|
if v.star >= conFigData.Condition[i][2] then
|
|
|
|
|
conditionTabs[i] = 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif conFigData.Condition[i][1] == FindTreasureNeedType.Pro then
|
|
|
|
|
for j, v in pairs(curSelectHeroList) do
|
2022-03-31 09:51:10 +08:00
|
|
|
|
if v.changeProId == conFigData.Condition[i][2] then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
conditionTabs[i] = 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return conditionTabs
|
|
|
|
|
end
|
|
|
|
|
--
|
|
|
|
|
function FindTreasureDispatchPanel:GetConditionHeros()
|
|
|
|
|
conditionHeros = {}
|
|
|
|
|
for i = 1, #conFigData.Condition do
|
|
|
|
|
local curConditionHeros = {}
|
|
|
|
|
for k, v in pairs(curSortHeroList) do
|
|
|
|
|
if conFigData.Condition[i][1] == FindTreasureNeedType.Star then
|
|
|
|
|
if v.star >= conFigData.Condition[i][2] then
|
|
|
|
|
table.insert(curConditionHeros,v)
|
|
|
|
|
end
|
|
|
|
|
elseif conFigData.Condition[i][1] == FindTreasureNeedType.Pro then
|
2022-03-31 09:51:10 +08:00
|
|
|
|
if v.changeProId == conFigData.Condition[i][2] then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
table.insert(curConditionHeros,v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
conditionHeros[i] = curConditionHeros
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--英雄排序
|
|
|
|
|
function FindTreasureDispatchPanel:SortHeroDatas(_heroDatas)
|
|
|
|
|
--上阵最优先,星级优先,同星级等级优先,同星级同等级按sortId排序。排序时降序排序。
|
|
|
|
|
table.sort(_heroDatas, function(a, b)
|
|
|
|
|
if a.star == b.star then
|
|
|
|
|
if a.heroConfig.Natural ==b.heroConfig.Natural then
|
|
|
|
|
if a.lv == b.lv then
|
|
|
|
|
return a.heroConfig.Id < b.heroConfig.Id
|
|
|
|
|
else
|
|
|
|
|
return a.lv > b.lv
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.heroConfig.Natural > b.heroConfig.Natural
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.star > b.star
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
function FindTreasureDispatchPanel:SortHeroDatas2(_heroDatas)
|
|
|
|
|
--上阵最优先,星级优先,同星级等级优先,同星级同等级按sortId排序。排序时降序排序。
|
|
|
|
|
table.sort(_heroDatas, function(a, b)
|
|
|
|
|
if a.star == b.star then
|
|
|
|
|
if a.heroConfig.Natural ==b.heroConfig.Natural then
|
|
|
|
|
if a.lv == b.lv then
|
|
|
|
|
return a.heroConfig.Id > b.heroConfig.Id
|
|
|
|
|
else
|
|
|
|
|
return a.lv < b.lv
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.heroConfig.Natural < b.heroConfig.Natural
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.star < b.star
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
function FindTreasureDispatchPanel:GetHeroStarImage(star,type)
|
|
|
|
|
if type == 1 then
|
2020-07-31 18:40:22 +08:00
|
|
|
|
-- if star < 6 then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return star
|
2020-07-31 18:40:22 +08:00
|
|
|
|
-- elseif star > 5 then
|
|
|
|
|
-- return star%5
|
|
|
|
|
-- end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-07-31 18:40:22 +08:00
|
|
|
|
-- if star < 6 then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return "ui_1xing"
|
2020-07-31 18:40:22 +08:00
|
|
|
|
-- elseif star > 5 and star < 11 then
|
|
|
|
|
-- return "ui_1yue"
|
|
|
|
|
-- elseif star > 10 then
|
|
|
|
|
-- return "ui_1un"
|
|
|
|
|
-- end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function FindTreasureDispatchPanel:TimeStampToDateString(second)
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
|
|
|
|
return string.format("%02d:%02d:%02d", hour, minute, sec)
|
|
|
|
|
end
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function FindTreasureDispatchPanel:OnClose()
|
2021-11-16 16:59:30 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.FindTreasure.RefreshFindTreasureRect)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if timer then
|
|
|
|
|
timer:Stop()
|
|
|
|
|
timer = nil
|
|
|
|
|
end
|
|
|
|
|
curAllHeros = {}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function FindTreasureDispatchPanel:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.spLoader:Destroy()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-21 13:12:04 +08:00
|
|
|
|
return FindTreasureDispatchPanel
|
|
|
|
|
|