--跨服副本喇叭 SceneItemUse ={} local ItemID1 = -1; local ItemID2 = -1; local _UIImgTextScript1; local _UIImgTextScript2; local Btn1 local Btn2 local TimeSweep = 20 local SceneIDs = {602,603,604,605,606,608,609,610,611,641,642,643,644} local OPenUI = true local CurritemID = -1 function SceneItemUse:Awake( ) _UIImgTextScript1 = _UIImgText1:GetComponent('UIImgText') _UIImgTextScript2 = _UIImgText2:GetComponent('UIImgText') _UIImgTextScript1._TextAnchor = CS.UnityEngine.TextAnchor.MiddleCenter _UIImgTextScript2._TextAnchor = CS.UnityEngine.TextAnchor.MiddleCenter ItemID1 = CS.GCGame.Table.SystemParam.GetSystemParam_INT(60) ItemID2 = CS.GCGame.Table.SystemParam.GetSystemParam_INT(61) Btn1 = UseBtn1:GetComponent("Button") Btn2 = UseBtn2:GetComponent("Button") Btn1.onClick:RemoveAllListeners() Btn1.onClick:AddListener(function() SceneItemUse.Click_Item1() end) Btn2.onClick:RemoveAllListeners() Btn2.onClick:AddListener(function() SceneItemUse.Click_Item2() end) end function SceneItemUse:Update() if(CurritemID~=-1 and OPenUI==false and CS.HornInputPanelCtr.Instance~=nul) then OPenUI = true local line = CS.GCGame.Table.TableManager.GetCommonItemByID(CurritemID, 0); CS.HornInputPanelCtr.Instance:RecordHornType(line.SubClassID) CurritemID = -1 end TimeSweep = TimeSweep-1 if(TimeSweep<=0) then SceneItemUse.ItemCountShow() TimeSweep = 20 for i=0, #SceneIDs,1 do if(SceneIDs[i] == CS.GameManager.gameManager.RunningScene) then ChildRoot:SetActive(false) return end end ChildRoot:SetActive(true) end end function SceneItemUse.ItemCountShow() Count = CS.GameManager.gameManager.PlayerDataPool.BackPack:GetItemCountByDataId(ItemID1) if (Count > 0) then _UIImgTextScript1.text = string.format("X%d",Count) else _UIImgTextScript1.text = "dZ" end Count = CS.GameManager.gameManager.PlayerDataPool.BackPack:GetItemCountByDataId(ItemID2) if (Count > 0) then _UIImgTextScript2.text = string.format("X%d",Count) else _UIImgTextScript2.text = "dZ" end end function SceneItemUse:OnEnable() if(ItemID1==-1) then _UIImgText1.transform.parent.gameObject:SetActive(false) else _UIImgText1.transform.parent.gameObject:SetActive(true) end if(ItemID2==-1) then _UIImgText2.transform.parent.gameObject:SetActive(false) else _UIImgText2.transform.parent.gameObject:SetActive(true) end print(string.format("SceneItemUse.OnEnable : %s %s",ItemID1,ItemID2)) SceneItemUse.ItemCountShow() end function SceneItemUse.Click_Item1() SceneItemUse.UseItem(ItemID1) end function SceneItemUse.Click_Item2() SceneItemUse.UseItem(ItemID2) end function SceneItemUse.UseItem(ItemID) print(string.format("SceneItemUse.UseItem : %s",ItemID)) local gameItem = CS.GameManager.gameManager.PlayerDataPool.BackPack:GetItemByDataID(ItemID) if (gameItem == nil) then tab_CommonItem = CS.GCGame.Table.TableManager.GetCommonItemByID(ItemID, 0) if (tab_CommonItem == nil) then return end CS.MessageBoxLogic.OpenOKCancelBox( CS.GCGame.Table.StrDictionary.GetClientDictionaryString("#{4961}", tab_CommonItem.Name), nil, function() tab_ItemGetPath = CS.GCGame.Table.TableManager.GetItemGetPathByID(ItemID, 0) if (tab_ItemGetPath == nil) then return end Count = tab_ItemGetPath:getItemPathCount() for i=0, Count,1 do pathInfo = tab_ItemGetPath:GetItemPathbyIndex(k) if (pathInfo ~= nil and pathInfo ~= "-1") then local getPathData = CS.ItemGetPathPopRoot.GetPathData() getPathData.pathType = i getPathData.info = pathInfo getPathData.itemID = itemID CS.ItemGetPathPopRoot.GoGetPath(getPathData) return end end end,nil) else local commonItem = CS.GCGame.Table.TableManager.GetCommonItemByID(ItemID, 0); local nPlayerLevel = CS.GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level; if (nPlayerLevel < commonItem.MinLevelRequire or nPlayerLevel > commonItem.MaxLevelRequire) then CS.GUIData.AddNotifyData("#{1254}") return end CurritemID = ItemID OPenUI = false CS.UIManager.ShowUI(CS.UIInfo.HornInputPanel) end end