328 lines
14 KiB
Lua
328 lines
14 KiB
Lua
--坐骑
|
|
local SettingPlayerRide = quick_class("SettingPlayerRide")
|
|
local this = SettingPlayerRide
|
|
local live2dRoot
|
|
local live2dRoot2
|
|
local curUserRideConFig
|
|
function SettingPlayerRide:ctor(mainPanel, gameObject)
|
|
self.mainPanel = mainPanel
|
|
self.gameObject = gameObject
|
|
self:InitComponent(gameObject)
|
|
self:BindEvent()
|
|
end
|
|
--初始化组件(用于子类重写)
|
|
function SettingPlayerRide:InitComponent(gameObject)
|
|
this.spLoader = SpriteLoader.New()
|
|
this.smallShow = Util.GetGameObject(gameObject, "Image")
|
|
this.jingqingqidai = Util.GetGameObject(gameObject, "notOpen")
|
|
this.live2dRootParent = Util.GetGameObject(gameObject, "live2dRootParent")
|
|
this.live2dRootParent2 = Util.GetGameObject(gameObject, "live2dRootParent2")
|
|
this.name = Util.GetGameObject(gameObject, "name/Text"):GetComponent("Text")
|
|
SetTextVerTial(this.name,Vector3.New(120,10,0),nil,nil,5)
|
|
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")
|
|
local rootHight = this.proGrid.transform.rect.height
|
|
local width = this.proGrid.transform.rect.width
|
|
this.scrollViewPro=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.proGrid.transform,this.proPre,
|
|
nil,Vector2.New(width,rootHight),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.skillPre = Util.GetGameObject(gameObject, "skinProInfo/skillPre")
|
|
this.skillImage = Util.GetGameObject(gameObject, "skinProInfo/skillImage")
|
|
this.skillGrid = Util.GetGameObject(gameObject, "skinProInfo/skillGrid")
|
|
this.skillList = {}
|
|
|
|
this.skillDes = Util.GetGameObject(gameObject, "PokemonSkillInfoPopup")
|
|
this.skillDesClose = Util.GetGameObject(this.skillDes, "Button")
|
|
this.skillDesContent = Util.GetGameObject(this.skillDes, "Content")
|
|
this.skillDesIcon = Util.GetGameObject(this.skillDesContent,"bottom/IconBG/Icon"):GetComponent("Image")
|
|
this.skillDesTitle = Util.GetGameObject(this.skillDesContent,"Title")
|
|
this.skillDesTitleText = Util.GetGameObject(this.skillDesTitle,"Text"):GetComponent("Text")
|
|
this.skillDesText = Util.GetGameObject(this.skillDesContent,"bottom/curinfo"):GetComponent("Text")
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function SettingPlayerRide:BindEvent()
|
|
Util.AddClick(this.skillDesClose,function()
|
|
this.skillDes.gameObject:SetActive(false)
|
|
end)
|
|
end
|
|
|
|
function this.SetSkillDes(data)
|
|
this.skillDesIcon.sprite = this.spLoader:LoadSprite(data.icon)
|
|
this.skillDesTitleText.text = data.title
|
|
this.skillDesText.text = data.des
|
|
ForceRebuildLayout(this.skillDesContent.transform)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function SettingPlayerRide:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function SettingPlayerRide:RemoveListener()
|
|
|
|
end
|
|
--界面打开时调用(用于子类重写)
|
|
function SettingPlayerRide:OnOpen()
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function SettingPlayerRide:OnShow()
|
|
PlayerManager.SetPlayerRideRedPoint(PlayerTitleRideSkinRedPointTypeStr.Ride,0)
|
|
this.ShowPanelData()
|
|
end
|
|
--显示信息
|
|
function this.ShowPanelData()
|
|
local rideList = ConfigManager.GetAllConfigsDataByKey(ConfigName.PlayerHeadIcon,"Type",PlayerHeadIconType.Ride)
|
|
-- 排序,已解锁的放前面
|
|
table.sort(rideList, function(a, b)
|
|
if PlayerManager.userMountList[a.Id] and not PlayerManager.userMountList[b.Id] then
|
|
return true
|
|
elseif not PlayerManager.userMountList[a.Id] and PlayerManager.userMountList[b.Id] then
|
|
return false
|
|
else
|
|
return a.Id < b.Id
|
|
end
|
|
end)
|
|
--设置选中
|
|
local newRideId = PlayerSetTitleRideSkinManager.GetNewRide()
|
|
local curUserRideId = PlayerManager.GetPlayerRide()
|
|
if newRideId and newRideId > 0 then
|
|
curUserRideConFig = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,newRideId)
|
|
-- 所有坐骑设置为旧的
|
|
PlayerSetTitleRideSkinManager.SetAllOldRide()
|
|
elseif curUserRideId and curUserRideId > 0 then
|
|
curUserRideConFig = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,curUserRideId)
|
|
else
|
|
curUserRideConFig = rideList[1]
|
|
end
|
|
|
|
-- 设置数据显示
|
|
this.scrollView:SetData(rideList,function(index,root)
|
|
this.ShowRideInfo(root,rideList[index])
|
|
end, false, not false)
|
|
|
|
end
|
|
|
|
function this.ShowRideInfo(go,data)
|
|
-- LogBlue("data "..data.Id)
|
|
local itemConFig = ConfigManager.GetConfigData(ConfigName.ItemConfig,data.ItemId)
|
|
local PlayerRoleConFig = ConfigManager.GetConfigData(ConfigName.PlayerRole,data.ItemId)
|
|
Util.GetGameObject(go, "iconMask/icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(PlayerRoleConFig.LargeIcon))
|
|
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 data.Id == curUserRideConFig.Id then
|
|
this.SingleRideClickShowInfo(data, go)
|
|
else
|
|
local selectObj=Util.GetGameObject(go, "setImage")
|
|
if selectObj then
|
|
selectObj.gameObject:SetActive(false)
|
|
end
|
|
end
|
|
local isGet = false
|
|
if PlayerManager.userMountList[data.Id] then
|
|
isGet = true
|
|
end
|
|
local isUser = false
|
|
if PlayerManager.GetPlayerRide() == data.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)
|
|
-- 当前选中数据
|
|
curUserRideConFig = 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 curItemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig, data.ItemId)
|
|
this.name.text = GetLanguageStrById(curItemConfig.Name)
|
|
this.getInfo.text = GetLanguageStrById(data.ItemDescribe)
|
|
this.scrollViewPro:SetData(data.UnlockProperty,function(index,root)
|
|
local propertyConfig = ConfigManager.GetConfigData(ConfigName.PropertyConfig, data.UnlockProperty[index][1])
|
|
Util.GetGameObject(root, "proValue"):GetComponent("Text").text = GetLanguageStrById(propertyConfig.Info)..GetPropertyFormatStr(propertyConfig.Style, data.UnlockProperty[index][2])
|
|
end, not false, not false)
|
|
|
|
-- 限时和永久显示设置
|
|
local setateImageStr = data.Time == 0 and "c_zuoqi_yongjiu_zh" or "c_zuoqi_xianshi_zh"
|
|
this.stateImg.sprite = this.spLoader:LoadSprite(setateImageStr)
|
|
local rideData = PlayerManager.userMountList[data.Id]
|
|
this.lefeTime.text = data.Time == 0 and "" or Language[12173]..TimeStampToDateStr(rideData.overTime)
|
|
|
|
-- 判断是否展示坐骑
|
|
if live2dRoot then
|
|
live2dRoot:OnClose()
|
|
end
|
|
if live2dRoot2 then
|
|
live2dRoot2:OnClose()
|
|
end
|
|
if data.Hide == 0 then
|
|
this.jingqingqidai.gameObject:SetActive(false)
|
|
this.smallShow.gameObject:SetActive(true)
|
|
this.live2dRootParent2.gameObject:SetActive(true)
|
|
this.live2dRootParent.gameObject:SetActive(true)
|
|
local curPlayerLiveViewData = {
|
|
skin = PlayerManager.GetPlayerSkin(),
|
|
sex = NameManager.roleSex,
|
|
ride = data.Id,
|
|
}
|
|
live2dRoot = PlayerLiveView:New(this.live2dRootParent,2, curPlayerLiveViewData)
|
|
live2dRoot:OnOpen(GetPlayerRoleSingleConFig().Scale7,nil,WALK_DIR.IDLE_LEFT)
|
|
local ridePlayerLiveViewData = {
|
|
ride = data.Id,
|
|
}
|
|
live2dRoot2 = PlayerLiveView:New(this.live2dRootParent2,2, ridePlayerLiveViewData)
|
|
live2dRoot2:OnOpen(GetPlayerRoleSingleConFig().Scale8,nil,WALK_DIR.IDLE_LEFT)
|
|
|
|
|
|
local PlayerRoleConFig = ConfigManager.GetConfigData(ConfigName.PlayerRole,data.ItemId)
|
|
local offset = Vector3.New(0, 0, 0)
|
|
-- 获取向左时的偏移值
|
|
if PlayerRoleConFig and PlayerRoleConFig.RideOffset and PlayerRoleConFig.RideOffset[3] then
|
|
offset.x = PlayerRoleConFig.RideOffset[3][1]
|
|
offset.y = PlayerRoleConFig.RideOffset[3][2]
|
|
end
|
|
live2dRoot.transform.localPosition = Vector3.New(281, 682, 0) - offset * GetPlayerRoleSingleConFig().Scale7
|
|
live2dRoot2.transform.localPosition = Vector3.New(6, 180, 0) - offset * GetPlayerRoleSingleConFig().Scale8
|
|
|
|
else
|
|
this.jingqingqidai.gameObject:SetActive(true)
|
|
this.smallShow.gameObject:SetActive(false)
|
|
this.live2dRootParent2.gameObject:SetActive(false)
|
|
this.live2dRootParent.gameObject:SetActive(false)
|
|
end
|
|
|
|
-- 技能显示
|
|
if not this.skillList then
|
|
this.skillList = {}
|
|
end
|
|
for k,v in ipairs(this.skillList) do
|
|
v.go.gameObject:SetActive(false)
|
|
end
|
|
if data.Icon then
|
|
this.skillGrid.gameObject:SetActive(true)
|
|
this.skillImage.gameObject:SetActive(true)
|
|
for i = 1,math.max(#this.skillList,#data.Icon) do
|
|
if not data.Icon[i] then
|
|
this.skillList[i].go.gameObject:SetActive(false)
|
|
else
|
|
if not this.skillList[i] then
|
|
this.skillList[i] = {}
|
|
this.skillList[i].go = newObjToParent(this.skillPre,this.skillGrid)
|
|
this.skillList[i].btn = Util.GetGameObject(this.skillList[i].go, "icon")
|
|
this.skillList[i].icon = this.skillList[i].btn:GetComponent("Image")
|
|
this.skillList[i].index = i
|
|
end
|
|
this.skillList[i].go.gameObject:SetActive(true)
|
|
this.skillList[i].icon.sprite = this.spLoader:LoadSprite(GetResourcePath(data.Icon[i]))
|
|
Util.AddOnceClick(this.skillList[i].btn,function()
|
|
this.skillDes.gameObject:SetActive(true)
|
|
local data1 = {}
|
|
data1.icon = GetResourcePath(data.Icon[i])
|
|
local strs = string.split(data.SkillEffect,"|")
|
|
local strDes = string.split(strs[i],"#")
|
|
data1.title = strDes[1]
|
|
data1.des = strDes[2]
|
|
this.SetSkillDes(data1)
|
|
end)
|
|
end
|
|
end
|
|
else
|
|
this.skillGrid.gameObject:SetActive(false)
|
|
this.skillImage.gameObject:SetActive(false)
|
|
end
|
|
|
|
-- 设置按钮状态
|
|
local isGet = PlayerManager.userMountList[data.Id]
|
|
local curUserRideId = PlayerManager.GetPlayerRide()
|
|
local isUser = curUserRideId == data.Id
|
|
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[12270]
|
|
this.stateImgGo:SetActive(true)
|
|
elseif isGet and isUser then
|
|
this.goToBtnText.text =Language[12271]
|
|
this.stateImgGo:SetActive(true)
|
|
end
|
|
-- 按钮监听事件
|
|
Util.AddOnceClick(this.goToBtn, function()
|
|
if not isGet and not isUser then
|
|
PopupTipPanel.ShowTip(data.ItemDescribe)
|
|
elseif isGet and not isUser then
|
|
NetManager.RequestChangeModifyDecoration(3,data.Id,function(msg)
|
|
PlayerManager.SetPlayerRide(data.Id)
|
|
this.ShowPanelData()
|
|
PlayerManager.SetisRefreshMainPanelNpc(true)
|
|
PopupTipPanel.ShowTip(Language[12272])
|
|
end)
|
|
elseif isGet and isUser then
|
|
NetManager.RequestChangeModifyDecoration(3,0,function()
|
|
PlayerManager.SetPlayerRide(0)
|
|
this.ShowPanelData()
|
|
PlayerManager.SetisRefreshMainPanelNpc(true)
|
|
PopupTipPanel.ShowTip(Language[12273])
|
|
end)
|
|
end
|
|
end)
|
|
end
|
|
--界面关闭时调用(用于子类重写)
|
|
function SettingPlayerRide:OnClose()
|
|
|
|
if live2dRoot then
|
|
live2dRoot:OnClose()
|
|
end
|
|
if live2dRoot2 then
|
|
live2dRoot2:OnClose()
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function SettingPlayerRide:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
this.skillList = {}
|
|
end
|
|
|
|
return SettingPlayerRide |