diff --git a/Assets/ManagedResources/~Lua/Modules/Setting/SettingPlayerRide.lua b/Assets/ManagedResources/~Lua/Modules/Setting/SettingPlayerRide.lua index e269b44908..2762db131b 100644 --- a/Assets/ManagedResources/~Lua/Modules/Setting/SettingPlayerRide.lua +++ b/Assets/ManagedResources/~Lua/Modules/Setting/SettingPlayerRide.lua @@ -3,16 +3,13 @@ local SettingPlayerRide = quick_class("SettingPlayerRide") local this = SettingPlayerRide local live2dRoot local live2dRoot2 -local curPlayerHeadIconConfig -local curItemConfig -local curUserRideConFig +local curUserRideConFig function SettingPlayerRide:ctor(mainPanel, gameObject) self.mainPanel = mainPanel self.gameObject = gameObject self:InitComponent(gameObject) self:BindEvent() end -local curUserRideId --初始化组件(用于子类重写) function SettingPlayerRide:InitComponent(gameObject) this.spLoader = SpriteLoader.New() @@ -105,43 +102,54 @@ end --显示信息 function this.ShowPanelData() local rideList = ConfigManager.GetAllConfigsDataByKey(ConfigName.PlayerHeadIcon,"Type",PlayerHeadIconType.Ride) - --设置滚动区信息 - curUserRideId = PlayerManager.GetPlayerRide() - curUserRideConFig = rideList[1] - this.scrollView:SetData(rideList,function(index,root) - this.ShowRideInfo(root,rideList[index]) - end, not false, not false) + -- 排序 + table.sort(rideList, function(a, b) + Log(a.Id.."|"..b.Id) + if PlayerManager.userMountList[a.Id] and not PlayerManager.userMountList[b.Id] then + Log("true") + return true + elseif not PlayerManager.userMountList[a.Id] and PlayerManager.userMountList[b.Id] then + Log("false") + return false + else + Log("ID:"..tostring(a.Id < b.Id)) + return a.Id < b.Id + end + end) + --设置选中 + local curUserRideId = PlayerManager.GetPlayerRide() if curUserRideId > 0 then curUserRideConFig = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,curUserRideId) - this.SingleRideClickShowInfo(curUserRideConFig) else - this.SingleRideClickShowInfo(curUserRideConFig) + curUserRideConFig = rideList[1] end + + -- 设置数据显示 + this.scrollView:SetData(rideList,function(index,root) + this.ShowRideInfo(root,rideList[index]) + end, not false, not false) + end function this.ShowRideInfo(go,data) - local PlayerHeadIconConfig = data - -- LogBlue("PlayerHeadIconConfig "..PlayerHeadIconConfig.Id) - local itemConFig = ConfigManager.GetConfigData(ConfigName.ItemConfig,PlayerHeadIconConfig.ItemId) - local PlayerRoleConFig = ConfigManager.GetConfigData(ConfigName.PlayerRole,PlayerHeadIconConfig.ItemId) + -- 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 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 + -- this.setImage:SetActive(false) + if data.Id == curUserRideConFig.Id then + this.SingleRideClickShowInfo(data, go) end local isGet = false - if PlayerManager.userMountList[PlayerHeadIconConfig.Id] then + if PlayerManager.userMountList[data.Id] then isGet = true end local isUser = false - if PlayerManager.GetPlayerRide() == PlayerHeadIconConfig.Id then + if PlayerManager.GetPlayerRide() == data.Id then isUser = true end noGetImage:SetActive(not isGet) @@ -152,41 +160,38 @@ function this.ShowRideInfo(go,data) end function this.SingleRideClickShowInfo(data,go) - curPlayerHeadIconConfig = data + -- 当前选中数据 + 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 isGet,isUser = PlayerManager.userMountList[curPlayerHeadIconConfig.Id],curUserRideId == curPlayerHeadIconConfig.Id - curItemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig,curPlayerHeadIconConfig.ItemId) - local rideData = PlayerManager.userMountList[curPlayerHeadIconConfig.Id] + -- 基础信息显示 + local curItemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig, data.ItemId) this.name.text = GetLanguageStrById(curItemConfig.Name) - this.getInfo.text = GetLanguageStrById(curPlayerHeadIconConfig.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]) + 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) - 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[12270] - elseif isGet and isUser then - this.goToBtnText.text =Language[12271] - end - local setateImageStr = curPlayerHeadIconConfig.Time == 0 and "c_zuoqi_yongjiu_zh" or "c_zuoqi_xianshi_zh" + + -- 限时和永久显示设置 + local setateImageStr = data.Time == 0 and "c_zuoqi_yongjiu_zh" or "c_zuoqi_xianshi_zh" this.stateImg.sprite = this.spLoader:LoadSprite(setateImageStr) - this.lefeTime.text = curPlayerHeadIconConfig.Time == 0 and "" or Language[12173]..TimeStampToDateStr(rideData.overTime) + 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 curPlayerHeadIconConfig.Hide == 0 then + if data.Hide == 0 then this.jingqingqidai.gameObject:SetActive(false) this.smallShow.gameObject:SetActive(true) this.live2dRootParent2.gameObject:SetActive(true) @@ -194,18 +199,18 @@ function this.SingleRideClickShowInfo(data,go) local curPlayerLiveViewData = { skin = PlayerManager.GetPlayerSkin(), sex = NameManager.roleSex, - ride = curPlayerHeadIconConfig.Id, + ride = data.Id, } live2dRoot = PlayerLiveView:New(this.live2dRootParent,2, curPlayerLiveViewData) live2dRoot:OnOpen(GetPlayerRoleSingleConFig().Scale7,nil,WALK_DIR.IDLE_LEFT) local ridePlayerLiveViewData = { - ride = curPlayerHeadIconConfig.Id, + 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,curPlayerHeadIconConfig.ItemId) + 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 @@ -222,17 +227,18 @@ function this.SingleRideClickShowInfo(data,go) 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 + if data.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 + 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 @@ -243,12 +249,12 @@ function this.SingleRideClickShowInfo(data,go) 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])) + 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 data = {} - data.icon = GetResourcePath(curPlayerHeadIconConfig.Icon[i]) - local strs = string.split(curPlayerHeadIconConfig.SkillEffect,"|") + data.icon = GetResourcePath(data.Icon[i]) + local strs = string.split(data.SkillEffect,"|") local strDes = string.split(strs[i],"#") data.title = strDes[1] data.des = strDes[2] @@ -261,13 +267,27 @@ function this.SingleRideClickShowInfo(data,go) 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(curPlayerHeadIconConfig.ItemDescribe) + PopupTipPanel.ShowTip(data.ItemDescribe) elseif isGet and not isUser then - NetManager.RequestChangeModifyDecoration(3,curPlayerHeadIconConfig.Id,function(msg) - PlayerManager.SetPlayerRide(curPlayerHeadIconConfig.Id) + NetManager.RequestChangeModifyDecoration(3,data.Id,function(msg) + PlayerManager.SetPlayerRide(data.Id) this.ShowPanelData() PlayerManager.SetisRefreshMainPanelNpc(true) PopupTipPanel.ShowTip(Language[12272])