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

196 lines
8.5 KiB
Lua
Raw Normal View History

--坐骑
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
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-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")
Util.GetGameObject(gameObject, "skinProInfo/getInfoImage/Text"):GetComponent("Text").text = "获取途径"
this.getInfo = Util.GetGameObject(gameObject, "skinProInfo/getInfo"):GetComponent("Text")
Util.GetGameObject(gameObject, "skinProInfo/proImage/Text"):GetComponent("Text").text = "属性加成"
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")
this.lefeTime = Util.GetGameObject(gameObject, "lefeTime"):GetComponent("Text")
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
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function SettingPlayerRide:BindEvent()
2021-03-27 20:01:39 +08:00
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-27 20:01:39 +08:00
this.ShowPanelData()
end
--显示信息
function this.ShowPanelData()
local rideList = ConfigManager.GetAllConfigsDataByKey(ConfigName.PlayerHeadIcon,"Type",PlayerHeadIconType.Ride)
--设置滚动区信息
2021-03-29 16:45:04 +08:00
curUserRideId = PlayerManager.GetPlayerRide()
local curUserRideConFig
2021-03-27 20:01:39 +08:00
this.scrollView:SetData(rideList,function(index,root)
if curUserRideId <= 0 and index == 1 then
2021-03-29 16:45:04 +08:00
curUserRideConFig = rideList[index]
2021-03-27 20:01:39 +08:00
end
this.ShowRideInfo(root,rideList[index])
end, not false, not false)
if curUserRideId > 0 then
local data = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,curUserRideId)
2021-03-29 16:45:04 +08:00
this.SingleRideClickShowInfo(data)
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
LogBlue("PlayerHeadIconConfig "..PlayerHeadIconConfig.Id)
local itemConFig = ConfigManager.GetConfigData(ConfigName.ItemConfig,PlayerHeadIconConfig.ItemId)
Util.GetGameObject(go, "iconMask/icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(itemConFig.ResourceID))
Util.GetGameObject(go, "noGetImage/noGetImage/Text"):GetComponent("Text").text = "暂未解锁"
Util.GetGameObject(go, "GetImage/GetImage/Text"):GetComponent("Text").text = "使用中"
local noGetImage = Util.GetGameObject(go, "noGetImage")
local GetImage = Util.GetGameObject(go, "GetImage")
local setImage = Util.GetGameObject(go, "GetImage")
setImage:SetActive(false)
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-29 16:45:04 +08:00
this.SingleRideClickShowInfo(data)
2021-03-27 20:01:39 +08:00
end)
end
2021-03-29 16:45:04 +08:00
function this.SingleRideClickShowInfo(data)
2021-03-27 20:01:39 +08:00
curPlayerHeadIconConfig = data
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-03-27 20:01:39 +08:00
this.name.text = curItemConfig.Name
this.getInfo.text = curItemConfig.ItemDescribe
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)
if not isGet and not isUser then
this.goToBtnText.text = "获取途径"
elseif isGet and not isUser then
this.goToBtnText.text = "骑乘"
elseif isGet and isUser then
this.goToBtnText.text ="取消骑乘"
end
local setateImageStr = curPlayerHeadIconConfig.Time == 0 and "c_zuoqi_yongjiu_zh" or "c_zuoqi_xianshi_zh"
this.stateImg.sprite = Util.LoadSprite(setateImageStr)
2021-03-29 16:45:04 +08:00
this.lefeTime.text = curPlayerHeadIconConfig.Time == 0 and "" or "到期时间:"..TimeStampToDateStr(rideData.overTime)
2021-03-27 20:01:39 +08:00
if live2dRoot then
live2dRoot:OnClose()
end
if live2dRoot2 then
live2dRoot2:OnClose()
end
local curPlayerLiveViewData = {
skin = PlayerManager.GetPlayerSkin(),
sex = NameManager.roleSex,
ride = curPlayerHeadIconConfig.Id,
}
live2dRoot = PlayerLiveView:New(this.live2dRootParent,2, curPlayerLiveViewData)
2021-03-29 17:53:40 +08:00
live2dRoot:OnOpen(15,nil,WALK_DIR.IDLE_LEFT)
2021-03-27 20:01:39 +08:00
local ridePlayerLiveViewData = {
ride = curPlayerHeadIconConfig.Id,
}
live2dRoot2 = PlayerLiveView:New(this.live2dRootParent2,2, ridePlayerLiveViewData)
2021-03-29 17:53:40 +08:00
live2dRoot2:OnOpen(50,nil,WALK_DIR.IDLE_LEFT)
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( curItemConfig.ItemDescribe)
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-03-29 16:45:04 +08:00
PopupTipPanel.ShowTip("已骑乘坐骑!")
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-03-29 16:45:04 +08:00
PopupTipPanel.ShowTip("已取消骑乘!")
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()
end
2020-06-23 18:36:24 +08:00
return SettingPlayerRide