188 lines
6.6 KiB
Lua
188 lines
6.6 KiB
Lua
----- 元素共鸣 -----
|
|
ElementalResonanceView = {}
|
|
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
local monsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
local elementalResonanceConfig = ConfigManager.GetConfig(ConfigName.ElementalResonanceConfig)
|
|
local elementPropertyList = {}
|
|
local ImageList = { "r_zhandou_yuansu_02", "r_zhandou_yuansu_06", "r_zhandou_yuansu_03", "r_zhandou_yuansu_04","r_zhandou_yuansu_05","r_zhandou_yuansu_07" }
|
|
|
|
function ElementalResonanceView:New(gameObject)
|
|
local b = {}
|
|
b.gameObject = gameObject
|
|
b.transform = gameObject.transform
|
|
setmetatable(b, { __index = ElementalResonanceView })
|
|
return b
|
|
end
|
|
|
|
function ElementalResonanceView:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
self.elementalResonanceBtn = Util.GetGameObject(self.gameObject, "elementalResonanceBtn")
|
|
self.orginLayer = 0
|
|
self.effect = Util.GetGameObject(self.elementalResonanceBtn, "effect")
|
|
self.elementalResonanceImage = Util.GetGameObject(self.gameObject, "elementalResonanceBtn/bgImage/Image"):GetComponent("Image")
|
|
end
|
|
|
|
function ElementalResonanceView:BindEvent()
|
|
-- 功能开启列表
|
|
Util.AddClick(self.elementalResonanceBtn, function()
|
|
UIManager.OpenPanel(UIName.ElementPopup, self.dataTable,self.thisPanelOrder)
|
|
end)
|
|
end
|
|
|
|
function ElementalResonanceView:AddListener()
|
|
end
|
|
|
|
function ElementalResonanceView:RemoveListener()
|
|
end
|
|
|
|
|
|
function ElementalResonanceView:OnOpen(context)
|
|
if context then
|
|
self:SetOrderStatus(context)
|
|
end
|
|
end
|
|
|
|
function ElementalResonanceView:OnClose()
|
|
UIManager.ClosePanel(UIName.ElementPopup)
|
|
self.spLoader:Destroy()
|
|
end
|
|
|
|
--设定层级
|
|
function ElementalResonanceView:SetOrderStatus(context)
|
|
if not context then
|
|
return
|
|
end
|
|
|
|
local sortingOrder = context.sortOrder + 90
|
|
-- Log("<color=yellow>"..sortOrder.."</color>")
|
|
self.thisPanelOrder = context.sortOrder
|
|
--self.transform:GetComponent("Canvas").sortingOrder = sortingOrder
|
|
Util.AddParticleSortLayer(self.effect, sortingOrder - self.orginLayer)
|
|
self.orginLayer = sortingOrder
|
|
end
|
|
|
|
--得到元素共鸣类型
|
|
-- 1.火 2.风 3.水 4.大地
|
|
function ElementalResonanceView:GetElementalType(curFormation, type)
|
|
elementPropertyList = {}
|
|
local fireElementNum = 0
|
|
local windyElementNum = 0
|
|
local waterElementNum = 0
|
|
local groundElementNum = 0
|
|
self.dataTable = {}
|
|
|
|
if (type == 1) then
|
|
for i, v in pairs(curFormation) do
|
|
|
|
local data = HeroManager.GetSingleHeroData(v.heroId)
|
|
self.heroPropertyType = data.changeProId
|
|
LogGreen("data.changeProId:"..tostring(data.changeProId))
|
|
table.insert(elementPropertyList, self.heroPropertyType)
|
|
end
|
|
self.dataTable.title = Language[12021]
|
|
end
|
|
if (type == 2) then
|
|
for i, v in ipairs(curFormation) do
|
|
self.heroPropertyType =heroConfig[v.roleId].PropertyName
|
|
table.insert(elementPropertyList, self.heroPropertyType)
|
|
end
|
|
self.dataTable.title = Language[12022]
|
|
end
|
|
|
|
for i, v in pairs(elementPropertyList) do--遍历该列表拿筛选出各元素
|
|
if (v == 1) then
|
|
fireElementNum = fireElementNum + 1
|
|
elseif (v == 2) then
|
|
windyElementNum = windyElementNum + 1
|
|
elseif (v == 3) then
|
|
waterElementNum = waterElementNum + 1
|
|
elseif (v == 4) then
|
|
groundElementNum = groundElementNum + 1
|
|
end
|
|
end
|
|
|
|
local list = {}
|
|
list[1] = fireElementNum
|
|
list[2] = windyElementNum
|
|
list[3] = waterElementNum
|
|
list[4] = groundElementNum
|
|
|
|
local indexChoose = 0
|
|
for i = 1, #list do
|
|
local v=list[i]
|
|
if v==4 then
|
|
indexChoose=4
|
|
end
|
|
if v==5 then
|
|
indexChoose=5
|
|
end
|
|
if v==6 then
|
|
indexChoose=6
|
|
end
|
|
end
|
|
|
|
local count=0
|
|
for i = 1, #list do
|
|
local v=list[i]
|
|
if v==3 then
|
|
count=count+1 --你有几组3
|
|
end
|
|
end
|
|
if count==1 then --当你有1组3时 返回2
|
|
indexChoose=2
|
|
elseif count==2 then
|
|
indexChoose=3 --当你有2组3时 返回3
|
|
end
|
|
|
|
local index=0
|
|
for i = 1, #list do
|
|
local v=list[i]
|
|
if v==2 then
|
|
index=index+1
|
|
end
|
|
end
|
|
if index==3 then
|
|
indexChoose=1 --当你有3组2时 返回1
|
|
end
|
|
|
|
-- LogRed("元素共鸣 "..indexChoose)
|
|
self.dataTable.activeIndex = indexChoose
|
|
|
|
local isShow = false
|
|
isShow = indexChoose > 0
|
|
if (isShow == false) then
|
|
self.elementalResonanceImage.sprite = self.spLoader:LoadSprite("r_zhandou_yuansu_01")
|
|
else
|
|
if indexChoose > 0 then
|
|
self.elementalResonanceImage.sprite = self.spLoader:LoadSprite(ImageList[indexChoose])
|
|
end
|
|
end
|
|
self.effect:SetActive(isShow)
|
|
end
|
|
|
|
function ElementalResonanceView:SetPosition(type)
|
|
if (type == 1) then
|
|
-- self.elementalResonanceBtn.transform.localPosition = Vector3.New(455, 783, 0)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(1, 1)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(1, 1)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
self.elementalResonanceBtn.transform.localPosition = Vector3.New(400, 800, 0)
|
|
elseif(type==2) then
|
|
--self.elementalResonanceBtn.transform.localPosition = Vector3.New(-484, 876, 1)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(58, 13)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0, 0)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0, 0)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
elseif(type==3) then
|
|
--self.elementalResonanceBtn.transform.localPosition = Vector3.New(500, 876, 1)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(-68, -89)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(1, 1)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(1, 1)
|
|
self.elementalResonanceBtn.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
end
|
|
end
|
|
|
|
function ElementalResonanceView:SetElementalPropertyTextColor()
|
|
end
|
|
return ElementalResonanceView |