miduo_client/Assets/ManagedResources/~Lua/Modules/Setting/SettingPlayerRide.lua

288 lines
13 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
--坐骑
local SettingPlayerRide = quick_class("SettingPlayerRide")
2020-05-09 13:31:21 +08:00
local this = SettingPlayerRide
2021-03-27 20:01:39 +08:00
local live2dRoot
local live2dRoot2
local curPlayerHeadIconConfig
local curItemConfig
2021-03-30 10:28:03 +08:00
local curUserRideConFig
2020-05-09 13:31:21 +08:00
function SettingPlayerRide:ctor(mainPanel, gameObject)
self.mainPanel = mainPanel
self.gameObject = gameObject
self:InitComponent(gameObject)
self:BindEvent()
end
2021-03-29 16:45:04 +08:00
local curUserRideId
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function SettingPlayerRide:InitComponent(gameObject)
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
this.smallShow = Util.GetGameObject(gameObject, "Image")
this.jingqingqidai = Util.GetGameObject(gameObject, "notOpen")
2021-03-27 20:01:39 +08:00
this.live2dRootParent = Util.GetGameObject(gameObject, "live2dRootParent")
this.live2dRootParent2 = Util.GetGameObject(gameObject, "live2dRootParent2")
this.name = Util.GetGameObject(gameObject, "name/Text"):GetComponent("Text")
2021-04-08 18:01:29 +08:00
SetTextVerTial(this.name,Vector3.New(120,10,0),nil,nil,5)
2021-04-09 12:26:35 +08:00
Util.GetGameObject(gameObject, "skinProInfo/getInfoImage/Text"):GetComponent("Text").text = Language[11829]
2021-03-27 20:01:39 +08:00
this.getInfo = Util.GetGameObject(gameObject, "skinProInfo/getInfo"):GetComponent("Text")
2021-04-09 12:26:35 +08:00
Util.GetGameObject(gameObject, "skinProInfo/proImage/Text"):GetComponent("Text").text = Language[11965]
2021-03-26 20:06:08 +08:00
this.goToBtn = Util.GetGameObject(gameObject, "goToBtn")
2021-03-27 20:01:39 +08:00
this.goToBtnText = Util.GetGameObject(gameObject, "goToBtn/Text"):GetComponent("Text")
this.stateImg = Util.GetGameObject(gameObject, "stateImg"):GetComponent("Image")
2021-03-30 11:38:20 +08:00
this.stateImgGo = Util.GetGameObject(gameObject, "stateImg")
2021-03-27 20:01:39 +08:00
this.lefeTime = Util.GetGameObject(gameObject, "lefeTime"):GetComponent("Text")
2021-03-30 10:28:03 +08:00
this.setImage = Util.GetGameObject(gameObject, "setImage")
2021-03-27 20:01:39 +08:00
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(458.2,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.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.skillDesIcon = Util.GetGameObject(this.skillDes, "Content/IconBG/Icon"):GetComponent("Image")
this.skillDesTitle = Util.GetGameObject(this.skillDes, "Content/Title")
this.skillDesTitleText = Util.GetGameObject(this.skillDesTitle,"Text"):GetComponent("Text")
this.skillDesText = Util.GetGameObject(this.skillDes, "Content/curinfo"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
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
2020-05-09 13:31:21 +08:00
end
--添加事件监听(用于子类重写)
function SettingPlayerRide:AddListener()
end
--移除事件监听(用于子类重写)
function SettingPlayerRide:RemoveListener()
end
--界面打开时调用(用于子类重写)
function SettingPlayerRide:OnOpen()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function SettingPlayerRide:OnShow()
2021-03-30 11:38:20 +08:00
PlayerManager.SetPlayerRideRedPoint(PlayerTitleRideSkinRedPointTypeStr.Ride,0)
2021-03-27 20:01:39 +08:00
this.ShowPanelData()
end
--显示信息
function this.ShowPanelData()
local rideList = ConfigManager.GetAllConfigsDataByKey(ConfigName.PlayerHeadIcon,"Type",PlayerHeadIconType.Ride)
LogGreen("rideList:"..#rideList)
2021-03-27 20:01:39 +08:00
--设置滚动区信息
2021-03-29 16:45:04 +08:00
curUserRideId = PlayerManager.GetPlayerRide()
2021-03-30 10:28:03 +08:00
curUserRideConFig = rideList[1]
2021-03-27 20:01:39 +08:00
this.scrollView:SetData(rideList,function(index,root)
this.ShowRideInfo(root,rideList[index])
end, not false, not false)
if curUserRideId > 0 then
2021-03-30 10:28:03 +08:00
curUserRideConFig = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,curUserRideId)
this.SingleRideClickShowInfo(curUserRideConFig)
2021-03-27 20:01:39 +08:00
else
2021-03-29 16:45:04 +08:00
this.SingleRideClickShowInfo(curUserRideConFig)
2021-03-27 20:01:39 +08:00
end
end
function this.ShowRideInfo(go,data)
local PlayerHeadIconConfig = data
2021-07-01 21:07:53 +08:00
-- LogBlue("PlayerHeadIconConfig "..PlayerHeadIconConfig.Id)
2021-03-27 20:01:39 +08:00
local itemConFig = ConfigManager.GetConfigData(ConfigName.ItemConfig,PlayerHeadIconConfig.ItemId)
2021-03-31 15:39:40 +08:00
local PlayerRoleConFig = ConfigManager.GetConfigData(ConfigName.PlayerRole,PlayerHeadIconConfig.ItemId)
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go, "iconMask/icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(PlayerRoleConFig.LargeIcon))
2021-04-09 12:26:35 +08:00
Util.GetGameObject(go, "noGetImage/noGetImage/Text"):GetComponent("Text").text = Language[12268]
Util.GetGameObject(go, "GetImage/GetImage/Text"):GetComponent("Text").text = Language[12269]
2021-03-27 20:01:39 +08:00
local noGetImage = Util.GetGameObject(go, "noGetImage")
local GetImage = Util.GetGameObject(go, "GetImage")
2021-03-30 10:28:03 +08:00
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
2021-03-27 20:01:39 +08:00
local isGet = false
if PlayerManager.userMountList[PlayerHeadIconConfig.Id] then
isGet = true
end
local isUser = false
if PlayerManager.GetPlayerRide() == PlayerHeadIconConfig.Id then
isUser = true
end
noGetImage:SetActive(not isGet)
GetImage:SetActive(isUser)
Util.AddOnceClick(go, function()
2021-03-30 10:28:03 +08:00
this.SingleRideClickShowInfo(data,go)
2021-03-27 20:01:39 +08:00
end)
end
2021-03-30 10:28:03 +08:00
function this.SingleRideClickShowInfo(data,go)
2021-03-27 20:01:39 +08:00
curPlayerHeadIconConfig = data
2021-03-30 10:28:03 +08:00
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
2021-03-29 16:45:04 +08:00
local isGet,isUser = PlayerManager.userMountList[curPlayerHeadIconConfig.Id],curUserRideId == curPlayerHeadIconConfig.Id
2021-03-27 20:01:39 +08:00
curItemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig,curPlayerHeadIconConfig.ItemId)
2021-03-29 16:45:04 +08:00
local rideData = PlayerManager.userMountList[curPlayerHeadIconConfig.Id]
2021-04-07 16:59:47 +08:00
this.name.text = GetLanguageStrById(curItemConfig.Name)
this.getInfo.text = GetLanguageStrById(curPlayerHeadIconConfig.ItemDescribe)
2021-03-27 20:01:39 +08:00
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)
2021-03-30 11:38:20 +08:00
this.stateImgGo:SetActive(true)
2021-03-27 20:01:39 +08:00
if not isGet and not isUser then
2021-04-09 12:26:35 +08:00
this.goToBtnText.text = Language[11829]
2021-03-30 11:38:20 +08:00
this.stateImgGo:SetActive(false)
2021-03-27 20:01:39 +08:00
elseif isGet and not isUser then
2021-04-09 12:26:35 +08:00
this.goToBtnText.text = Language[12270]
2021-03-27 20:01:39 +08:00
elseif isGet and isUser then
2021-04-09 12:26:35 +08:00
this.goToBtnText.text =Language[12271]
2021-03-27 20:01:39 +08:00
end
local setateImageStr = curPlayerHeadIconConfig.Time == 0 and "c_zuoqi_yongjiu_zh" or "c_zuoqi_xianshi_zh"
2021-04-21 13:12:04 +08:00
this.stateImg.sprite = this.spLoader:LoadSprite(setateImageStr)
2021-04-09 12:26:35 +08:00
this.lefeTime.text = curPlayerHeadIconConfig.Time == 0 and "" or Language[12173]..TimeStampToDateStr(rideData.overTime)
2021-03-27 20:01:39 +08:00
if live2dRoot then
live2dRoot:OnClose()
end
if live2dRoot2 then
live2dRoot2:OnClose()
end
if curPlayerHeadIconConfig.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,
2021-03-27 20:01:39 +08:00
ride = curPlayerHeadIconConfig.Id,
}
live2dRoot = PlayerLiveView:New(this.live2dRootParent,2, curPlayerLiveViewData)
live2dRoot:OnOpen(GetPlayerRoleSingleConFig().Scale7,nil,WALK_DIR.IDLE_LEFT)
local ridePlayerLiveViewData = {
ride = curPlayerHeadIconConfig.Id,
}
live2dRoot2 = PlayerLiveView:New(this.live2dRootParent2,2, ridePlayerLiveViewData)
live2dRoot2:OnOpen(GetPlayerRoleSingleConFig().Scale8,nil,WALK_DIR.IDLE_LEFT)
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 curPlayerHeadIconConfig.Icon then
this.skillGrid.gameObject:SetActive(true)
this.skillImage.gameObject:SetActive(true)
for i = 1,math.max(#this.skillList,#curPlayerHeadIconConfig.Icon) do
if not curPlayerHeadIconConfig.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(curPlayerHeadIconConfig.Icon[i]))
Util.AddOnceClick(this.skillList[i].btn,function()
this.skillDes.gameObject:SetActive(true)
local data = {}
data.icon = GetResourcePath(curPlayerHeadIconConfig.Icon[i])
local strs = string.split(curPlayerHeadIconConfig.SkillEffect,"|")
local strDes = string.split(strs[i],"#")
data.title = strDes[1]
data.des = strDes[2]
this.SetSkillDes(data)
end)
end
end
else
this.skillGrid.gameObject:SetActive(false)
this.skillImage.gameObject:SetActive(false)
end
2020-05-09 13:31:21 +08:00
2021-03-27 20:01:39 +08:00
Util.AddOnceClick(this.goToBtn, function()
if not isGet and not isUser then
PopupTipPanel.ShowTip(curPlayerHeadIconConfig.ItemDescribe)
2021-03-27 20:01:39 +08:00
elseif isGet and not isUser then
NetManager.RequestChangeModifyDecoration(3,curPlayerHeadIconConfig.Id,function(msg)
2021-03-27 20:01:39 +08:00
PlayerManager.SetPlayerRide(curPlayerHeadIconConfig.Id)
this.ShowPanelData()
PlayerManager.SetisRefreshMainPanelNpc(true)
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12272])
2021-03-27 20:01:39 +08:00
end)
elseif isGet and isUser then
NetManager.RequestChangeModifyDecoration(3,0,function()
2021-03-27 20:01:39 +08:00
PlayerManager.SetPlayerRide(0)
this.ShowPanelData()
PlayerManager.SetisRefreshMainPanelNpc(true)
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12273])
2021-03-27 20:01:39 +08:00
end)
end
end)
2020-05-09 13:31:21 +08:00
end
--界面关闭时调用(用于子类重写)
function SettingPlayerRide:OnClose()
2021-03-27 20:01:39 +08:00
if live2dRoot then
live2dRoot:OnClose()
end
if live2dRoot2 then
live2dRoot2:OnClose()
end
2020-05-09 13:31:21 +08:00
end
--界面销毁时调用(用于子类重写)
function SettingPlayerRide:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
this.skillList = {}
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return SettingPlayerRide