276 lines
11 KiB
Lua
276 lines
11 KiB
Lua
--坐骑
|
|
local SettingPlayerTitle = quick_class("SettingPlayerTitle")
|
|
local this = SettingPlayerTitle
|
|
local live2dRoot
|
|
local live2dRoot2
|
|
local curPlayerHeadIconConfig
|
|
local curItemConfig
|
|
local curUserRideConFig
|
|
function SettingPlayerTitle:ctor(mainPanel, gameObject)
|
|
self.mainPanel = mainPanel
|
|
self.gameObject = gameObject
|
|
self:InitComponent(gameObject)
|
|
self:BindEvent()
|
|
end
|
|
|
|
local _sortingorder = 0
|
|
local curUserRideId
|
|
--初始化组件(用于子类重写)
|
|
function SettingPlayerTitle:InitComponent(gameObject,rootPanel)
|
|
this.spLoader = SpriteLoader.New()
|
|
this.rootPanel = rootPanel
|
|
this.live2dRootParent = Util.GetGameObject(gameObject, "live2dRootParent")
|
|
this.live2dRootParent2 = Util.GetGameObject(gameObject, "live2dRootParent2")
|
|
this.name = Util.GetGameObject(gameObject, "name/Text"):GetComponent("Text")
|
|
Util.GetGameObject(gameObject, "skinProInfo/getInfoImage/Text"):GetComponent("Text").text = Language[11829]
|
|
this.getInfo = Util.GetGameObject(gameObject, "skinProInfo/getInfo"):GetComponent("Text")
|
|
Util.GetGameObject(gameObject, "skinProInfo/proImage/Text"):GetComponent("Text").text = Language[11965]
|
|
this.goToBtn = Util.GetGameObject(gameObject, "goToBtn")
|
|
this.goToBtnText = Util.GetGameObject(gameObject, "goToBtn/Text"):GetComponent("Text")
|
|
this.stateImg = Util.GetGameObject(gameObject, "stateImg"):GetComponent("Image")
|
|
this.stateImgGo = Util.GetGameObject(gameObject, "stateImg")
|
|
this.lefeTime = Util.GetGameObject(gameObject, "lefeTime"):GetComponent("Text")
|
|
this.setImage = Util.GetGameObject(gameObject, "setImage")
|
|
|
|
this.itemPre = Util.GetGameObject(gameObject, "itemPre")
|
|
this.itemGrid = Util.GetGameObject(gameObject, "rect/grid")
|
|
this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.itemGrid.transform,this.itemPre,
|
|
nil,Vector2.New(494.3,525.5),1,1,Vector2.New(0,0))
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
this.scrollView.moveTween.MomentumAmount = 1
|
|
this.scrollView.moveTween.Strength = 2
|
|
|
|
this.proPre = Util.GetGameObject(gameObject, "skinProInfo/proPre")
|
|
this.proGrid = Util.GetGameObject(gameObject, "skinProInfo/proGrid")
|
|
this.scrollViewPro=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.proGrid.transform,this.proPre,
|
|
nil,Vector2.New(540,159.6),1,2,Vector2.New(0,0))
|
|
this.scrollViewPro.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
|
|
this.scrollViewPro.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
this.scrollViewPro.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
this.scrollViewPro.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
this.scrollViewPro.moveTween.MomentumAmount = 1
|
|
this.scrollViewPro.moveTween.Strength = 2
|
|
|
|
|
|
this.titleLive = SubUIManager.Open(SubUIConfig.PlayerTitle, this.live2dRootParent.transform)
|
|
this.titleLive2 = SubUIManager.Open(SubUIConfig.PlayerTitle, this.live2dRootParent2.transform)
|
|
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function SettingPlayerTitle:BindEvent()
|
|
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function SettingPlayerTitle:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function SettingPlayerTitle:RemoveListener()
|
|
|
|
end
|
|
--界面打开时调用(用于子类重写)
|
|
function SettingPlayerTitle:OnOpen()
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function SettingPlayerTitle:OnShow()
|
|
PlayerManager.SetPlayerTitleRedPoint(PlayerTitleRideSkinRedPointTypeStr.Title,0)
|
|
this.ShowPanelData()
|
|
end
|
|
--显示信息
|
|
function this.ShowPanelData()
|
|
|
|
local rideList = ConfigManager.GetAllConfigsDataByKey(ConfigName.PlayerHeadIcon,"Type",PlayerHeadIconType.Designation)
|
|
local one={}
|
|
local two={}
|
|
local three={}
|
|
for key, value in pairs(rideList) do
|
|
local id=value.Id
|
|
if id==PlayerManager.GetPlayerDesignation() then
|
|
table.insert(one,value)
|
|
elseif PlayerManager.userTitleList[id] then
|
|
table.insert(two,value)
|
|
else
|
|
table.insert(three,value)
|
|
end
|
|
end
|
|
table.sort(two,function(a,b)
|
|
return a.Id<b.Id
|
|
end)
|
|
table.sort(three,function(a,b)
|
|
return a.Id<b.Id
|
|
end)
|
|
local list={}
|
|
for key, value in pairs(one) do
|
|
table.insert(list,value)
|
|
end
|
|
for key, value in pairs(two) do
|
|
table.insert(list,value)
|
|
end
|
|
for key, value in pairs(three) do
|
|
table.insert(list,value)
|
|
end
|
|
--设置滚动区信息
|
|
curUserRideId = PlayerManager.GetPlayerDesignation()
|
|
-- LogError(" "..curUserRideId)
|
|
curUserRideConFig = list[1]
|
|
this.scrollView:SetData(list,function(index,root)
|
|
this.ShowRideInfo(root,list[index])
|
|
end, not false, not false)
|
|
if curUserRideId > 0 then
|
|
curUserRideConFig = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,curUserRideId)
|
|
this.SingleRideClickShowInfo(curUserRideConFig,this.setImage)
|
|
else
|
|
this.SingleRideClickShowInfo(curUserRideConFig,this.setImage)
|
|
end
|
|
end
|
|
|
|
function this.ShowRideInfo(go,data)
|
|
local PlayerHeadIconConfig = data
|
|
local PlayerRoleConFig = ConfigManager.GetConfigData(ConfigName.PlayerRole,PlayerHeadIconConfig.ItemId)
|
|
local ArtResourcesConfig=ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig,PlayerRoleConFig.LargeIcon)
|
|
Util.GetGameObject(go, "iconMask/icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(ArtResourcesConfig.Name)
|
|
Util.GetGameObject(go, "noGetImage/noGetImage/Text"):GetComponent("Text").text = Language[12268]
|
|
Util.GetGameObject(go, "GetImage/GetImage/Text"):GetComponent("Text").text = Language[12269]
|
|
local noGetImage = Util.GetGameObject(go, "noGetImage")
|
|
local GetImage = Util.GetGameObject(go, "GetImage")
|
|
this.setImage:SetActive(false)
|
|
if PlayerHeadIconConfig.Id == curUserRideConFig.Id then
|
|
this.setImage:SetActive(true)
|
|
this.setImage.transform:SetParent(go.transform)
|
|
this.setImage.transform.localPosition = Vector3.zero
|
|
this.setImage.transform.localScale = Vector3.one
|
|
end
|
|
local isGet = false
|
|
if PlayerManager.userTitleList[PlayerHeadIconConfig.Id] then
|
|
isGet = true
|
|
end
|
|
local isUser = false
|
|
if PlayerManager.GetPlayerDesignation() == PlayerHeadIconConfig.Id then
|
|
isUser = true
|
|
end
|
|
noGetImage:SetActive(not isGet)
|
|
GetImage:SetActive(isUser)
|
|
Util.AddOnceClick(go, function()
|
|
this.SingleRideClickShowInfo(data,go)
|
|
end)
|
|
|
|
end
|
|
function this.SingleRideClickShowInfo(data,go)
|
|
curPlayerHeadIconConfig = data
|
|
if go then
|
|
this.setImage:SetActive(true)
|
|
this.setImage.transform:SetParent(go.transform)
|
|
this.setImage.transform.localPosition = Vector3.zero
|
|
this.setImage.transform.localScale = Vector3.one
|
|
end
|
|
local isGet,isUser = PlayerManager.userTitleList[curPlayerHeadIconConfig.Id],curUserRideId == curPlayerHeadIconConfig.Id
|
|
curItemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig,curPlayerHeadIconConfig.ItemId)
|
|
local rideData = PlayerManager.userTitleList[curPlayerHeadIconConfig.Id]
|
|
this.getInfo.text = curPlayerHeadIconConfig.ItemDescribe
|
|
if curPlayerHeadIconConfig.UnlockProperty then
|
|
this.proGrid.gameObject:SetActive(true)
|
|
this.scrollViewPro:SetData(curPlayerHeadIconConfig.UnlockProperty,function(index,root)
|
|
local propertyConfig = ConfigManager.GetConfigData(ConfigName.PropertyConfig, curPlayerHeadIconConfig.UnlockProperty[index][1])
|
|
Util.GetGameObject(root, "proValue"):GetComponent("Text").text = GetLanguageStrById(propertyConfig.Info).." ".. GetPropertyFormatStr(propertyConfig.Style, curPlayerHeadIconConfig.UnlockProperty[index][2])
|
|
end, not false, not false)
|
|
else
|
|
this.proGrid.gameObject:SetActive(false)
|
|
end
|
|
|
|
this.stateImgGo:SetActive(true)
|
|
if not isGet and not isUser then
|
|
this.goToBtnText.text = Language[11829]
|
|
this.stateImgGo:SetActive(false)
|
|
elseif isGet and not isUser then
|
|
this.goToBtnText.text = Language[12315]
|
|
elseif isGet and isUser then
|
|
this.goToBtnText.text = Language[12316]
|
|
end
|
|
local setateImageStr = curPlayerHeadIconConfig.Time == 0 and "c_zuoqi_yongjiu_zh" or "c_zuoqi_xianshi_zh"
|
|
this.stateImg.sprite = this.spLoader:LoadSprite(setateImageStr)
|
|
|
|
if rideData then
|
|
this.lefeTime.text = curPlayerHeadIconConfig.Time == 0 and "" or Language[12173]..TimeStampToDateStr(rideData.overTime)
|
|
else
|
|
this.lefeTime.text=""
|
|
end
|
|
|
|
if live2dRoot then
|
|
live2dRoot:OnClose()
|
|
end
|
|
if live2dRoot2 then
|
|
live2dRoot2:OnClose()
|
|
end
|
|
local curPlayerLiveViewData = {
|
|
skin = PlayerManager.GetPlayerSkin(),
|
|
sex = NameManager.roleSex,
|
|
ride =0,
|
|
}
|
|
live2dRoot = PlayerLiveView:New(this.live2dRootParent,2, curPlayerLiveViewData)
|
|
live2dRoot:OnOpen(GetPlayerRoleSingleConFig().Scale7,nil,WALK_DIR.IDLE_LEFT)
|
|
|
|
local curPlayerRole = ConfigManager.GetConfigData(ConfigName.PlayerRole,data.ItemId)
|
|
local curArtResourcesConfig = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig,curPlayerRole.LiveAnimName)
|
|
this.name.text = curArtResourcesConfig.Desc
|
|
-- 设置称号显示
|
|
this.titleLive:SetShow(data.ItemId, Vector3.New(0,150,0), 0.5, 0.5, _sortingorder)
|
|
this.titleLive2:SetShow(data.ItemId, Vector3.New(0,0,0), 1, 1, _sortingorder)
|
|
|
|
Util.AddOnceClick(this.goToBtn, function()
|
|
if not isGet and not isUser then
|
|
PopupTipPanel.ShowTip( curPlayerHeadIconConfig.ItemDescribe)
|
|
elseif isGet and not isUser then
|
|
NetManager.RequestChangeModifyDecoration(2,curPlayerHeadIconConfig.Id,function(msg)
|
|
PlayerManager.SetPlayerDesignation(curPlayerHeadIconConfig.Id)
|
|
this.ShowPanelData()
|
|
PlayerManager.SetisRefreshMainPanelNpc(true)
|
|
PopupTipPanel.ShowTip(Language[12317])
|
|
end)
|
|
elseif isGet and isUser then
|
|
NetManager.RequestChangeModifyDecoration(2,0,function()
|
|
PlayerManager.SetPlayerDesignation(0)
|
|
this.ShowPanelData()
|
|
PlayerManager.SetisRefreshMainPanelNpc(true)
|
|
PopupTipPanel.ShowTip(Language[12318])
|
|
end)
|
|
end
|
|
end)
|
|
end
|
|
|
|
-- 界面层级变动
|
|
function SettingPlayerTitle:OnSortingOrderChange(sortingOrder)
|
|
if this.titleLive then
|
|
this.titleLive:SetLayer(sortingOrder)
|
|
end
|
|
if this.titleLive2 then
|
|
this.titleLive2:SetLayer(sortingOrder)
|
|
end
|
|
_sortingorder = sortingOrder
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function SettingPlayerTitle:OnClose()
|
|
if live2dRoot then
|
|
live2dRoot:OnClose()
|
|
end
|
|
if live2dRoot2 then
|
|
live2dRoot2:OnClose()
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function SettingPlayerTitle:OnDestroy()
|
|
_sortingorder = 0
|
|
this.spLoader:Destroy()
|
|
SubUIManager.Close(this.titleLive)
|
|
SubUIManager.Close(this.titleLive2)
|
|
end
|
|
|
|
return SettingPlayerTitle |