更新
This commit is contained in:
parent
b319dfeb27
commit
e48107d424
Binary file not shown.
BIN
excel/item.xlsx
BIN
excel/item.xlsx
Binary file not shown.
Binary file not shown.
@ -40,6 +40,7 @@ function UIList:Init(Prefab: Instance)
|
||||
self.Data = {}
|
||||
self.Instances = {}
|
||||
self.Connections = {}
|
||||
self.LayoutOrderKey = nil
|
||||
self.Component = nil
|
||||
self.UIRoot = Prefab
|
||||
self.Org = Utils:FindInDescendantsUI(Prefab, "__org")
|
||||
@ -62,20 +63,45 @@ function UIList:AddData(data: table)
|
||||
self:SetSingleInstance(#self.Data, data)
|
||||
end
|
||||
|
||||
function UIList:SetLayoutOrder(keyName: string)
|
||||
self.LayoutOrderKey = keyName
|
||||
for _, ui in pairs(self.Instances) do
|
||||
ui.UIRoot.LayoutOrder = tonumber(ui.Data[keyName])
|
||||
end
|
||||
end
|
||||
|
||||
function UIList:SetSingleInstance(index: number, data: table)
|
||||
local child = self.Component:Init(data)
|
||||
child.TopUI = self.TopUI
|
||||
child.ListUI = self
|
||||
|
||||
local uiInstance = self.Org:Clone()
|
||||
child.UIRoot = uiInstance
|
||||
uiInstance.Name = index
|
||||
uiInstance.Parent = self.Org.Parent
|
||||
if self.LayoutOrderKey then
|
||||
uiInstance.LayoutOrder = tonumber(child.Data[self.LayoutOrderKey])
|
||||
end
|
||||
self.Instances[index] = child
|
||||
|
||||
AutoInjectVariables(child)
|
||||
if child.OnInitFinish then child:OnInitFinish() end
|
||||
child:Refresh()
|
||||
uiInstance.Visible = true
|
||||
end
|
||||
|
||||
function UIList:GetMinLayoutOrderInstance()
|
||||
local minOrder = math.huge
|
||||
local minInstance = nil
|
||||
for _, ui in pairs(self.Instances) do
|
||||
if ui.UIRoot.LayoutOrder < minOrder then
|
||||
minOrder = ui.UIRoot.LayoutOrder
|
||||
minInstance = ui
|
||||
end
|
||||
end
|
||||
return minInstance
|
||||
end
|
||||
|
||||
function UIList:Refresh()
|
||||
for _, ui in pairs(self.Instances) do ui:Destroy() end
|
||||
self.Instances = {}
|
||||
@ -90,6 +116,8 @@ function UIList:Refresh()
|
||||
end
|
||||
|
||||
function UIList:Clean()
|
||||
if self.TopUI then self.TopUI = nil end
|
||||
if self.ListUI then self.ListUI = nil end
|
||||
-- 清除自己的内容
|
||||
for _, connection in pairs(self.Connections) do
|
||||
connection:Disconnect()
|
||||
@ -108,6 +136,7 @@ function UIList:Clean()
|
||||
end
|
||||
self.Connections = nil
|
||||
|
||||
if ui.UIRoot then ui.UIRoot:Destroy() end
|
||||
ui:Destroy()
|
||||
end
|
||||
self.Instances = {}
|
||||
|
@ -19,7 +19,7 @@ local FolderPlayerGui = LocalPlayer:WaitForChild("PlayerGui")
|
||||
function UIWindow:Init(UIManager: table, Data: table?)
|
||||
local self = {}
|
||||
self.UIManager = UIManager
|
||||
self.Data = Data
|
||||
self.Data = Data or {}
|
||||
self.Variables = {}
|
||||
self.Connections = {}
|
||||
self.SignalConnections = {}
|
||||
@ -27,7 +27,6 @@ function UIWindow:Init(UIManager: table, Data: table?)
|
||||
self.UIParentName = nil
|
||||
self.CloseDestroy = true
|
||||
|
||||
|
||||
-- 运行时操作变量
|
||||
self.UIRoot = nil
|
||||
self.AutoInject = false
|
||||
@ -53,6 +52,7 @@ function UIWindow:AutoInjectVariables()
|
||||
if sixChar == "__list" then
|
||||
local prefab = Utils:FindInDescendantsUI(self.UIRoot, varName)
|
||||
target = UIList:Init(prefab)
|
||||
target.TopUI = self
|
||||
else
|
||||
-- _开头,递归查找
|
||||
target = Utils:FindInDescendantsUI(self.UIRoot, varName)
|
||||
@ -86,12 +86,27 @@ function UIWindow:OnOpenWindow()
|
||||
end
|
||||
|
||||
function UIWindow:OnCloseWindow()
|
||||
if self.SignalConnections then
|
||||
for _, connection in pairs(self.SignalConnections) do
|
||||
connection:DisconnectAll()
|
||||
end
|
||||
self.SignalConnections = nil
|
||||
end
|
||||
|
||||
if self.Connections then
|
||||
for _, connection in pairs(self.Connections) do
|
||||
connection:Disconnect()
|
||||
end
|
||||
self.Connections = nil
|
||||
end
|
||||
|
||||
if self.CloseDestroy then
|
||||
self.UIRoot:Destroy()
|
||||
self.UIRoot = nil
|
||||
else
|
||||
self.UIRoot.Visible = false
|
||||
end
|
||||
self:Destroy()
|
||||
end
|
||||
|
||||
--> 覆盖用
|
||||
@ -100,13 +115,21 @@ function UIWindow:OnDataChanged() end
|
||||
function UIWindow:Refresh() end
|
||||
|
||||
function UIWindow:Destroy()
|
||||
for _, connection in pairs(self.SignalConnections) do
|
||||
connection:DisconnectAll()
|
||||
if self.TopUI then self.TopUI = nil end
|
||||
|
||||
if self.SignalConnections then
|
||||
for _, connection in pairs(self.SignalConnections) do
|
||||
connection:DisconnectAll()
|
||||
end
|
||||
end
|
||||
self.SignalConnections = nil
|
||||
|
||||
for _, connection in pairs(self.Connections) do
|
||||
connection:Disconnect()
|
||||
if self.Connections then
|
||||
for _, connection in pairs(self.Connections) do
|
||||
print("进入断开连接")
|
||||
|
||||
connection:Disconnect()
|
||||
end
|
||||
end
|
||||
self.Connections = nil
|
||||
|
||||
|
@ -1,3 +1,18 @@
|
||||
[
|
||||
{"id":1,"type":1,"name":1,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10}
|
||||
{"id":40000,"type":1,"name":40000,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40001,"type":1,"name":40001,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40002,"type":1,"name":40002,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40003,"type":1,"name":40003,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40004,"type":1,"name":40004,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40005,"type":1,"name":40005,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40006,"type":1,"name":40006,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40007,"type":1,"name":40007,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40008,"type":1,"name":40008,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40009,"type":1,"name":40009,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40010,"type":1,"name":40010,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40011,"type":1,"name":40011,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40012,"type":1,"name":40012,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40013,"type":1,"name":40013,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40014,"type":1,"name":40014,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10},
|
||||
{"id":40015,"type":1,"name":40015,"attributes":[14,200,10,15,200,10,16,100,0],"recycle":10}
|
||||
]
|
@ -60,5 +60,37 @@
|
||||
{"id":13105,"type":4,"typeArgs":[],"quality":6,"iconId":66,"nameId":23105,"textId":33105,"buyPrice":[11,60],"sellPrice":[11,60],"use":[],"showPackage":null},
|
||||
{"id":13106,"type":4,"typeArgs":[],"quality":7,"iconId":67,"nameId":23106,"textId":33106,"buyPrice":[11,70],"sellPrice":[11,70],"use":[],"showPackage":null},
|
||||
{"id":20000,"type":5,"typeArgs":[],"quality":1,"iconId":1,"nameId":30000,"textId":40000,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":30000,"type":6,"typeArgs":[],"quality":1,"iconId":2,"nameId":40000,"textId":50000,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null}
|
||||
{"id":30000,"type":6,"typeArgs":[],"quality":1,"iconId":2,"nameId":40000,"textId":50000,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40000,"type":2,"typeArgs":[],"quality":1,"iconId":1,"nameId":40000,"textId":60000,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40001,"type":2,"typeArgs":[],"quality":2,"iconId":2,"nameId":40001,"textId":60001,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40002,"type":2,"typeArgs":[],"quality":3,"iconId":3,"nameId":40002,"textId":60002,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40003,"type":2,"typeArgs":[],"quality":4,"iconId":4,"nameId":40003,"textId":60003,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40004,"type":2,"typeArgs":[],"quality":5,"iconId":5,"nameId":40004,"textId":60004,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40005,"type":2,"typeArgs":[],"quality":6,"iconId":6,"nameId":40005,"textId":60005,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40006,"type":2,"typeArgs":[],"quality":7,"iconId":7,"nameId":40006,"textId":60006,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40007,"type":2,"typeArgs":[],"quality":8,"iconId":8,"nameId":40007,"textId":60007,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40008,"type":2,"typeArgs":[],"quality":9,"iconId":9,"nameId":40008,"textId":60008,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40009,"type":2,"typeArgs":[],"quality":10,"iconId":10,"nameId":40009,"textId":60009,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40010,"type":2,"typeArgs":[],"quality":11,"iconId":11,"nameId":40010,"textId":60010,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40011,"type":2,"typeArgs":[],"quality":12,"iconId":12,"nameId":40011,"textId":60011,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40012,"type":2,"typeArgs":[],"quality":13,"iconId":13,"nameId":40012,"textId":60012,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40013,"type":2,"typeArgs":[],"quality":14,"iconId":14,"nameId":40013,"textId":60013,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40014,"type":2,"typeArgs":[],"quality":15,"iconId":15,"nameId":40014,"textId":60014,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":40015,"type":2,"typeArgs":[],"quality":16,"iconId":16,"nameId":40015,"textId":60015,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50000,"type":3,"typeArgs":[],"quality":1,"iconId":1,"nameId":50000,"textId":70000,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50001,"type":3,"typeArgs":[],"quality":2,"iconId":2,"nameId":50001,"textId":70001,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50002,"type":3,"typeArgs":[],"quality":3,"iconId":3,"nameId":50002,"textId":70002,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50003,"type":3,"typeArgs":[],"quality":4,"iconId":4,"nameId":50003,"textId":70003,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50004,"type":3,"typeArgs":[],"quality":5,"iconId":5,"nameId":50004,"textId":70004,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50005,"type":3,"typeArgs":[],"quality":6,"iconId":6,"nameId":50005,"textId":70005,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50006,"type":3,"typeArgs":[],"quality":7,"iconId":7,"nameId":50006,"textId":70006,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50007,"type":3,"typeArgs":[],"quality":8,"iconId":8,"nameId":50007,"textId":70007,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50008,"type":3,"typeArgs":[],"quality":9,"iconId":9,"nameId":50008,"textId":70008,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50009,"type":3,"typeArgs":[],"quality":10,"iconId":10,"nameId":50009,"textId":70009,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50010,"type":3,"typeArgs":[],"quality":11,"iconId":11,"nameId":50010,"textId":70010,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50011,"type":3,"typeArgs":[],"quality":12,"iconId":12,"nameId":50011,"textId":70011,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50012,"type":3,"typeArgs":[],"quality":13,"iconId":13,"nameId":50012,"textId":70012,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50013,"type":3,"typeArgs":[],"quality":14,"iconId":14,"nameId":50013,"textId":70013,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50014,"type":3,"typeArgs":[],"quality":15,"iconId":15,"nameId":50014,"textId":70014,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null},
|
||||
{"id":50015,"type":3,"typeArgs":[],"quality":16,"iconId":16,"nameId":50015,"textId":70015,"buyPrice":[],"sellPrice":[],"use":[],"showPackage":null}
|
||||
]
|
@ -1,4 +1,20 @@
|
||||
[
|
||||
{"id":100006,"text":"Coin+{0}"},
|
||||
{"id":100007,"text":"Score+{0}"}
|
||||
{"id":100007,"text":"Score+{0}"},
|
||||
{"id":40000,"text":"测试装备1"},
|
||||
{"id":40001,"text":"测试装备2"},
|
||||
{"id":40002,"text":"测试装备3"},
|
||||
{"id":40003,"text":"测试装备4"},
|
||||
{"id":40004,"text":"测试装备5"},
|
||||
{"id":40005,"text":"测试装备6"},
|
||||
{"id":40006,"text":"测试装备7"},
|
||||
{"id":40007,"text":"测试装备8"},
|
||||
{"id":40008,"text":"测试装备9"},
|
||||
{"id":40009,"text":"测试装备10"},
|
||||
{"id":40010,"text":"测试装备11"},
|
||||
{"id":40011,"text":"测试装备12"},
|
||||
{"id":40012,"text":"测试装备13"},
|
||||
{"id":40013,"text":"测试装备14"},
|
||||
{"id":40014,"text":"测试装备15"},
|
||||
{"id":40015,"text":"测试装备16"}
|
||||
]
|
@ -32,13 +32,17 @@ local JsonLanguage, JsonImage = Localization:GetLocalizationJson()
|
||||
-- 获取文本Id数据
|
||||
function Localization:GetLanguageData(Id: number)
|
||||
if not Id then return end
|
||||
return Utils:GetIdDataFromJson(JsonLanguage, Id).text
|
||||
local data = Utils:GetIdDataFromJson(JsonLanguage, Id)
|
||||
if not data then return "" end
|
||||
return data.text
|
||||
end
|
||||
|
||||
-- 获取图片Id数据
|
||||
function Localization:GetImageData(Id: number)
|
||||
if not Id then return end
|
||||
return Utils:GetIdDataFromJson(JsonImage, Id).sourceId
|
||||
local data = Utils:GetIdDataFromJson(JsonImage, Id)
|
||||
if not data then return "" end
|
||||
return data.sourceId
|
||||
end
|
||||
|
||||
return Localization
|
@ -164,7 +164,7 @@ function Utils:GetFlatDirectionAndEndPos(startPos: Vector3, targetPos: Vector3,
|
||||
end
|
||||
|
||||
function Utils:CreateDataInstance(Player: Player, UniqueId: number, EquipmentData: table, Folder: Instance)
|
||||
if Player or UniqueId or EquipmentData or Folder then
|
||||
if not Player or not UniqueId or not EquipmentData or not Folder then
|
||||
warn('创建实例失败: ' , Player.Name, UniqueId, EquipmentData, Folder)
|
||||
return
|
||||
end
|
||||
|
@ -146,7 +146,7 @@ function DamageProxy:TakeDamage(Caster: TypeList.Character, Victim: TypeList.Cha
|
||||
-- 伤害计算
|
||||
local VictimHealth = Victim:GetAttributeValue("hp")
|
||||
local resultValue, isDied = Victim:ChangeAttributeValue("hp", math.max(0, VictimHealth - Damage))
|
||||
print("伤害数据打印", Damage, VictimHealth, resultValue, isDied)
|
||||
-- print("伤害数据打印", Damage, VictimHealth, resultValue, isDied)
|
||||
if isDied then break end
|
||||
end
|
||||
-- 实际发送数据
|
||||
|
@ -3,6 +3,12 @@ local HelpProxy = {}
|
||||
--> Server
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
--> Tools
|
||||
local Utils = require(ReplicatedStorage.Tools.Utils)
|
||||
|
||||
--> Json
|
||||
local JsonItemProp = require(ReplicatedStorage.Json.ItemProp)
|
||||
|
||||
--> Events
|
||||
local RE_PlayerHelper = ReplicatedStorage.Events.RE_PlayerHelper
|
||||
|
||||
@ -16,7 +22,13 @@ RE_PlayerHelper.OnServerEvent:Connect(function(Player: Player, EventName: string
|
||||
HelpProxy:CleanPlayerData(Player)
|
||||
elseif EventName == "AddItem" then
|
||||
local PlayerInfoProxy = require(script.Parent.PlayerInfoProxy)
|
||||
PlayerInfoProxy:ChangeItemCount(Player, EventData[1], EventData[2])
|
||||
local itemData = Utils:GetIdDataFromJson(JsonItemProp, EventData[1])
|
||||
if itemData.type == 3 then
|
||||
local BookProxy = require(script.Parent.BookProxy)
|
||||
BookProxy:UnlockBook(Player, EventData[1] - 10000)
|
||||
else
|
||||
PlayerInfoProxy:ChangeItemCount(Player, EventData[1], EventData[2])
|
||||
end
|
||||
print("添加物品成功", PlayerInfoProxy:GetItemCount(Player, EventData[1]))
|
||||
end
|
||||
end)
|
||||
|
@ -109,7 +109,6 @@ function PlayerFightProxy:GetPlayerRole(Player: Player)
|
||||
end
|
||||
|
||||
function PlayerFightProxy:GetPlayerAI(Player: Player)
|
||||
print(PlayerFightProxy.pData[Player.UserId])
|
||||
return PlayerFightProxy.pData[Player.UserId].PlayerAI
|
||||
end
|
||||
|
||||
|
@ -24,6 +24,8 @@ UserInputService.InputBegan:Connect(function(input, gameProcessed)
|
||||
RE_UpgradeAttributes:FireServer(3)
|
||||
elseif input.KeyCode == Enum.KeyCode.N then
|
||||
RE_UpgradeAttributes:FireServer(4)
|
||||
elseif input.KeyCode == Enum.KeyCode.KeypadOne then
|
||||
RE_PlayerHelper:FireServer("AddItem", {math.random(50000, 50015), 1})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -109,4 +109,7 @@ RE_CleanPlayerPerformance.OnClientEvent:Connect(function(CleanedPlayer: Player)
|
||||
PerformanceClient.pData[UserId] = nil
|
||||
end)
|
||||
|
||||
-- 打开默认界面
|
||||
UIManager:OpenWindow("MainWindow")
|
||||
|
||||
return PerformanceClient
|
@ -0,0 +1,61 @@
|
||||
local WeaponItem = {}
|
||||
WeaponItem.__index = WeaponItem
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Utils = require(ReplicatedStorage.Tools.Utils)
|
||||
local Localization = require(ReplicatedStorage.Tools.Localization)
|
||||
local Signal = require(ReplicatedStorage.Tools.Signal)
|
||||
|
||||
local JsonItemProp = require(ReplicatedStorage.Json.ItemProp)
|
||||
|
||||
function WeaponItem:Init(data: table)
|
||||
local self = {}
|
||||
self.Data = data
|
||||
self.Variables = {
|
||||
["_imgIcon"] = 0,
|
||||
["_tmpName"] = 0,
|
||||
["_tmpQuality"] = 0,
|
||||
["_btnClick"] = 0,
|
||||
["_imgSelected"] = 0,
|
||||
}
|
||||
self.SignalConnections = {}
|
||||
self.Connections = {}
|
||||
|
||||
setmetatable(self, WeaponItem)
|
||||
return self
|
||||
end
|
||||
|
||||
function WeaponItem:SetSelected(isSelected: boolean)
|
||||
self.Variables._imgSelected.Visible = isSelected
|
||||
end
|
||||
|
||||
function WeaponItem:Refresh()
|
||||
local itemData = Utils:GetIdDataFromJson(JsonItemProp, self.Data.OrgId)
|
||||
self.Variables._imgIcon.Image = Localization:GetImageData(itemData.iconId)
|
||||
self.Variables._tmpName.Text = Localization:GetLanguageData(itemData.nameId)
|
||||
self.Variables._tmpQuality.Text = self.Data.Quality
|
||||
end
|
||||
|
||||
function WeaponItem:OnInitFinish()
|
||||
-- 点击事件
|
||||
local con = self.Variables["_btnClick"].Activated:Connect(function()
|
||||
self.TopUI:ShowDetailInfo(self.Data)
|
||||
self:SetSelected(true)
|
||||
|
||||
if self.TopUI.LastActiveItem then
|
||||
self.TopUI.LastActiveItem:SetSelected(false)
|
||||
end
|
||||
self.TopUI.LastActiveItem = self
|
||||
end)
|
||||
table.insert(self.Connections, con)
|
||||
end
|
||||
|
||||
function WeaponItem:Destroy()
|
||||
for k, v in pairs(self) do
|
||||
self[k] = nil
|
||||
end
|
||||
self = nil
|
||||
end
|
||||
|
||||
return WeaponItem
|
160
src/StarterPlayerScripts/UI/Windows/CreateWindow/init.luau
Normal file
160
src/StarterPlayerScripts/UI/Windows/CreateWindow/init.luau
Normal file
@ -0,0 +1,160 @@
|
||||
--> Services
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
--> Dependencies
|
||||
local UIWindow = require(ReplicatedStorage.Base.UIWindow)
|
||||
local UIEnums = require(ReplicatedStorage.Base.UIEnums)
|
||||
|
||||
--> Components
|
||||
local WeaponItem = require(script.WeaponItem)
|
||||
|
||||
--> Variables
|
||||
local Utils = require(ReplicatedStorage.Tools.Utils)
|
||||
local Localization = require(ReplicatedStorage.Tools.Localization)
|
||||
local Signal = require(ReplicatedStorage.Tools.Signal)
|
||||
|
||||
--> Json
|
||||
local JsonItemProp = require(ReplicatedStorage.Json.ItemProp)
|
||||
|
||||
--> Events
|
||||
local RE_Forge = ReplicatedStorage.Events.RE_Forge
|
||||
|
||||
local LocalPlayer = game.Players.LocalPlayer
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local CreateWindow = {}
|
||||
CreateWindow.__index = CreateWindow
|
||||
setmetatable(CreateWindow, {__index = UIWindow})
|
||||
|
||||
function CreateWindow:Init(UIManager: table, Data: table?)
|
||||
local self = UIWindow:Init(UIManager, Data)
|
||||
setmetatable(self, CreateWindow)
|
||||
self.Variables = {
|
||||
["_btnBgClose"] = 0,
|
||||
|
||||
["_goWeaponPanel"] = 0,
|
||||
["_btnClose"] = 0,
|
||||
|
||||
["__listWeaponPackage"] = 0,
|
||||
-- 详情面板
|
||||
["_btnCreate"] = 0,
|
||||
["_btnMult"] = 0,
|
||||
["_imgIcon"] = 0,
|
||||
["_tmpName"] = 0,
|
||||
["_tmpQuality"] = 0,
|
||||
["_toggleAutoRecycle"] = 0,
|
||||
["_imgAutoRecycleActive"] = 0,
|
||||
}
|
||||
self.MultNumber = 1
|
||||
self.AutoRecycle = false
|
||||
self.UIRootName = "ui_w_create"
|
||||
self.UIParentName = UIEnums.UIParent.UIRoot
|
||||
|
||||
self.LastActiveItem = nil
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function CreateWindow:ShowDetailInfo(data: table?)
|
||||
if data then
|
||||
self.Variables["_imgIcon"].Image = Localization:GetImageData(Utils:GetIdDataFromJson(JsonItemProp, data.OrgId).iconId)
|
||||
self.Variables["_tmpName"].Text = Utils:GetIdDataFromJson(JsonItemProp, data.OrgId).nameId
|
||||
self.Variables["_tmpQuality"].Text = Utils:GetIdDataFromJson(JsonItemProp, data.OrgId).quality
|
||||
else
|
||||
self.Variables["_imgIcon"].Image = ""
|
||||
self.Variables["_tmpName"].Text = ""
|
||||
self.Variables["_tmpQuality"].Text = ""
|
||||
end
|
||||
end
|
||||
|
||||
function CreateWindow:OnClickMult()
|
||||
self.MultNumber += 1
|
||||
if self.MultNumber > 10 then self.MultNumber = 1 end
|
||||
self.Variables["_btnMult"].Text = "x" .. self.MultNumber
|
||||
end
|
||||
|
||||
function CreateWindow:OnToggleAutoRecycleClick()
|
||||
self.AutoRecycle = not self.AutoRecycle
|
||||
self.Variables["_imgAutoRecycleActive"].Visible = self.AutoRecycle
|
||||
end
|
||||
|
||||
function CreateWindow:OnClickCreate()
|
||||
if self.LastActiveItem then
|
||||
local data = self.LastActiveItem.Data
|
||||
RE_Forge:FireServer(data.OrgId, self.MultNumber)
|
||||
end
|
||||
end
|
||||
|
||||
function CreateWindow:OnOpenWindow()
|
||||
UIWindow.OnOpenWindow(self)
|
||||
|
||||
-- 自己进行数据处理
|
||||
local DataFolder = Utils:GetPlayerDataFolder(LocalPlayer):FindFirstChild("Book")
|
||||
local data = {}
|
||||
for _, child in DataFolder:GetChildren() do
|
||||
data[child.Name] = {
|
||||
OrgId = tonumber(child.Name),
|
||||
Quality = child:GetAttribute("quality"),
|
||||
Timestamp = child:GetAttribute("timestamp"),
|
||||
}
|
||||
end
|
||||
self:SetData(data)
|
||||
|
||||
-- 监听数据变化
|
||||
local childAddCon = DataFolder.ChildAdded:Connect(function(child)
|
||||
self.Data[child.Name] = {
|
||||
OrgId = tonumber(child.Name),
|
||||
Quality = child:GetAttribute("quality"),
|
||||
Timestamp = child:GetAttribute("timestamp"),
|
||||
}
|
||||
self.Variables["__listWeaponPackage"]:AddData(self.Data[child.Name])
|
||||
end)
|
||||
table.insert(self.Connections, childAddCon)
|
||||
|
||||
-- 点击事件
|
||||
local bgCloseCon = self.Variables["_btnBgClose"].Activated:Connect(function()
|
||||
self.UIManager:CloseWindow(script.Name)
|
||||
end)
|
||||
local closeCon = self.Variables["_btnClose"].Activated:Connect(function()
|
||||
self.UIManager:CloseWindow(script.Name)
|
||||
end)
|
||||
local multCon = self.Variables["_btnMult"].Activated:Connect(function()
|
||||
self:OnClickMult()
|
||||
end)
|
||||
local autoRecycleCon = self.Variables["_toggleAutoRecycle"].Activated:Connect(function()
|
||||
self:OnToggleAutoRecycleClick()
|
||||
end)
|
||||
local createCon = self.Variables["_btnCreate"].Activated:Connect(function()
|
||||
self:OnClickCreate()
|
||||
end)
|
||||
|
||||
table.insert(self.Connections, bgCloseCon)
|
||||
table.insert(self.Connections, closeCon)
|
||||
table.insert(self.Connections, multCon)
|
||||
table.insert(self.Connections, autoRecycleCon)
|
||||
table.insert(self.Connections, createCon)
|
||||
|
||||
self.Variables["__listWeaponPackage"]:AddComponent(WeaponItem)
|
||||
self.Variables["__listWeaponPackage"]:SetData(self.Data)
|
||||
self.Variables["__listWeaponPackage"]:SetLayoutOrder("OrgId")
|
||||
|
||||
if self.Data then
|
||||
local minInstance = self.Variables["__listWeaponPackage"]:GetMinLayoutOrderInstance()
|
||||
self:ShowDetailInfo(minInstance.Data)
|
||||
|
||||
self.LastActiveItem = minInstance
|
||||
minInstance:SetSelected(true)
|
||||
else
|
||||
self:ShowDetailInfo()
|
||||
end
|
||||
end
|
||||
|
||||
function CreateWindow:OnCloseWindow()
|
||||
UIWindow.OnCloseWindow(self)
|
||||
|
||||
self.Variables["__listWeaponPackage"]:Clean()
|
||||
end
|
||||
|
||||
|
||||
|
||||
return CreateWindow
|
37
src/StarterPlayerScripts/UI/Windows/MainWindow/init.luau
Normal file
37
src/StarterPlayerScripts/UI/Windows/MainWindow/init.luau
Normal file
@ -0,0 +1,37 @@
|
||||
--> Services
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
--> Dependencies
|
||||
local UIWindow = require(ReplicatedStorage.Base.UIWindow)
|
||||
local UIEnums = require(ReplicatedStorage.Base.UIEnums)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local MainWindow = {}
|
||||
MainWindow.__index = MainWindow
|
||||
setmetatable(MainWindow, {__index = UIWindow})
|
||||
|
||||
function MainWindow:Init(UIManager: table, Data: table?)
|
||||
local self = UIWindow:Init(UIManager, Data)
|
||||
setmetatable(self, MainWindow)
|
||||
self.Variables = {
|
||||
["_btnMainCreate"] = 0,
|
||||
}
|
||||
self.UIRootName = "ui_w_main"
|
||||
self.UIParentName = UIEnums.UIParent.UIRoot
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function MainWindow:OnOpenWindow()
|
||||
UIWindow.OnOpenWindow(self)
|
||||
|
||||
local createCon = self.Variables["_btnMainCreate"].Activated:Connect(function()
|
||||
self.UIManager:OpenWindow("CreateWindow")
|
||||
end)
|
||||
table.insert(self.Connections, createCon)
|
||||
end
|
||||
|
||||
|
||||
|
||||
return MainWindow
|
Loading…
x
Reference in New Issue
Block a user