mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-15 21:31:54 +00:00
Giant refactoring of how the client and server character is handled
This commit is contained in:
@@ -30,6 +30,8 @@ type GuiDependencies = {
|
||||
FrameworkText: TextLabel,
|
||||
SandboxText: TextLabel,
|
||||
DeveloperText: TextLabel,
|
||||
Quaternions: ImageLabel,
|
||||
TaylorSeries: ImageLabel,
|
||||
Xframe: Frame,
|
||||
Yframe: Frame,
|
||||
Zframe: Frame,
|
||||
@@ -41,6 +43,7 @@ type GuiDependencies = {
|
||||
local RS = game:GetService("RunService")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local TS = game:GetService("TestService")
|
||||
local CoP = game:GetService("ContentProvider")
|
||||
|
||||
local LoadingFun = true
|
||||
|
||||
@@ -55,6 +58,8 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
||||
local SandboxText = Frame:WaitForChild("Sandbox") :: TextLabel
|
||||
local DeveloperText = Frame:WaitForChild("Developer") :: TextLabel
|
||||
local ShadowGradient = TextShadow:WaitForChild("UIGradient") :: UIGradient
|
||||
local Quaternions = Frame:WaitForChild("Quaternions") :: ImageLabel
|
||||
local TaylorSeries = Frame:WaitForChild("TaylorSeries") :: ImageLabel
|
||||
|
||||
local Xframe = Frame:WaitForChild("X") :: Frame
|
||||
local Yframe = Frame:WaitForChild("Y") :: Frame
|
||||
@@ -73,6 +78,8 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
||||
FrameworkText = FrameworkText,
|
||||
SandboxText = SandboxText,
|
||||
DeveloperText = DeveloperText,
|
||||
Quaternions = Quaternions,
|
||||
TaylorSeries = TaylorSeries,
|
||||
Xframe = Xframe,
|
||||
Yframe = Yframe,
|
||||
Zframe = Zframe,
|
||||
@@ -82,6 +89,9 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
||||
}
|
||||
end
|
||||
|
||||
local Size = 300
|
||||
local WorldSize = 3
|
||||
|
||||
local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can now access the framework
|
||||
--Image if we had HTML and CSS...
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
@@ -89,12 +99,28 @@ local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can n
|
||||
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Frame, {
|
||||
BackgroundTransparency = 1
|
||||
})
|
||||
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
|
||||
|
||||
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
|
||||
TextTransparency = 1
|
||||
})
|
||||
}):Start()
|
||||
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.TaylorSeries, {
|
||||
ImageTransparency = 1
|
||||
}):Start()
|
||||
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Quaternions, {
|
||||
ImageTransparency = 1
|
||||
}):Start()
|
||||
|
||||
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Xframe_text, {
|
||||
TextTransparency = 1
|
||||
}):Start()
|
||||
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Yframe_text, {
|
||||
TextTransparency = 1
|
||||
}):Start()
|
||||
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Zframe_text, {
|
||||
TextTransparency = 1
|
||||
}):Start()
|
||||
|
||||
local FrameTween = FrameTween_Constructor:Start()
|
||||
DeveloperTween_Constructor:Start()
|
||||
|
||||
--Text deleting effect
|
||||
task.spawn(function()
|
||||
@@ -108,9 +134,16 @@ local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can n
|
||||
end
|
||||
end)
|
||||
|
||||
task.spawn(function()
|
||||
while task.wait() do
|
||||
Size = math.max(0, Size-5)
|
||||
end
|
||||
end)
|
||||
|
||||
FrameTween.Completed:Wait()
|
||||
Stepped:Disconnect()
|
||||
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
|
||||
script.Parent:Destroy()
|
||||
end
|
||||
|
||||
local function RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
||||
@@ -132,61 +165,63 @@ local function Scalar(X1: number, Y1: number, X2: number, Y2: number): Scalar
|
||||
}
|
||||
end
|
||||
|
||||
local Size = 300
|
||||
local WorldSize = 3
|
||||
local function UI_3D_Rotation(Gui: GuiDependencies, Delta: number)
|
||||
local ScreenD = workspace.CurrentCamera.ViewportSize
|
||||
local CenterX = ScreenD.X/2
|
||||
local CenterY = ScreenD.Y/1.4
|
||||
local mX = Delta/1.5
|
||||
local mY = Delta/1.5
|
||||
local mZ = -7.65
|
||||
|
||||
local RMatrix = RotationMatrix(mX,mY,mZ)
|
||||
local X = {Size*RMatrix.Ixx, Size*RMatrix.Ixy}
|
||||
local Y = {Size*RMatrix.Iyx, Size*RMatrix.Iyy}
|
||||
local Z = {Size*RMatrix.Izx, Size*RMatrix.Izy}
|
||||
|
||||
local AXIS_R_3DScalar_X = Scalar(CenterX+X[1],CenterY+X[2],CenterX,CenterY)
|
||||
local AXIS_R_3DScalar_Y = Scalar(CenterX+Y[1],CenterY+Y[2],CenterX,CenterY)
|
||||
local AXIS_R_3DScalar_Z = Scalar(CenterX+Z[1],CenterY+Z[2],CenterX,CenterY)
|
||||
|
||||
Gui.Xframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
||||
Gui.Yframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
||||
Gui.Zframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
||||
|
||||
Gui.Xframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
||||
Gui.Yframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
||||
Gui.Zframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
||||
|
||||
Gui.Xframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_X.Distance, WorldSize)
|
||||
Gui.Yframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Y.Distance, WorldSize)
|
||||
Gui.Zframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Z.Distance, WorldSize)
|
||||
|
||||
Gui.Xframe.Rotation = AXIS_R_3DScalar_X.Rotation
|
||||
Gui.Yframe.Rotation = AXIS_R_3DScalar_Y.Rotation
|
||||
Gui.Zframe.Rotation = AXIS_R_3DScalar_Z.Rotation
|
||||
|
||||
Gui.Xframe_text.Rotation = Gui.Xframe.Rotation
|
||||
Gui.Yframe_text.Rotation = Gui.Yframe.Rotation
|
||||
Gui.Zframe_text.Rotation = Gui.Zframe.Rotation
|
||||
end
|
||||
|
||||
return function(IntroGui: ScreenGui, load_elapse_start: number)
|
||||
local Gui = GuiDependencies(IntroGui)
|
||||
|
||||
local Stepped = RS.Stepped:Connect(function(Delta: number, dt: number)
|
||||
local ScreenD = workspace.CurrentCamera.ViewportSize
|
||||
local CenterX = ScreenD.X/2
|
||||
local CenterY = ScreenD.Y/1.4
|
||||
|
||||
local mX = Delta/1.5
|
||||
local mY = Delta/1.5
|
||||
local mZ = -7.65
|
||||
|
||||
local RMatrix = RotationMatrix(mX,mY,mZ)
|
||||
local X = {Size*RMatrix.Ixx, Size*RMatrix.Ixy}
|
||||
local Y = {Size*RMatrix.Iyx, Size*RMatrix.Iyy}
|
||||
local Z = {Size*RMatrix.Izx, Size*RMatrix.Izy}
|
||||
|
||||
local AXIS_R_3DScalar_X = Scalar(CenterX+X[1],CenterY+X[2],CenterX,CenterY)
|
||||
local AXIS_R_3DScalar_Y = Scalar(CenterX+Y[1],CenterY+Y[2],CenterX,CenterY)
|
||||
local AXIS_R_3DScalar_Z = Scalar(CenterX+Z[1],CenterY+Z[2],CenterX,CenterY)
|
||||
|
||||
Gui.Xframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_X.Distance, WorldSize)
|
||||
Gui.Xframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
||||
Gui.Xframe.Rotation = AXIS_R_3DScalar_X.Rotation
|
||||
|
||||
Gui.Xframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
||||
Gui.Xframe_text.Rotation = Gui.Xframe.Rotation
|
||||
|
||||
Gui.Yframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Y.Distance, WorldSize)
|
||||
Gui.Yframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
||||
Gui.Yframe.Rotation = AXIS_R_3DScalar_Y.Rotation
|
||||
|
||||
Gui.Yframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
||||
Gui.Yframe_text.Rotation = Gui.Yframe.Rotation
|
||||
|
||||
Gui.Zframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Z.Distance, WorldSize)
|
||||
Gui.Zframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
||||
Gui.Zframe.Rotation = AXIS_R_3DScalar_Z.Rotation
|
||||
|
||||
Gui.Zframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
||||
Gui.Zframe_text.Rotation = Gui.Zframe.Rotation
|
||||
local Stepped = RS.Stepped:Connect(function(Delta: number, _dt: number)
|
||||
UI_3D_Rotation(Gui, Delta)
|
||||
end)
|
||||
|
||||
task.spawn(function()
|
||||
CoP:PreloadAsync({Gui.TaylorSeries, Gui.Quaternions}) --Try as early as possible
|
||||
|
||||
if not game:IsLoaded() then
|
||||
game.Loaded:Wait()
|
||||
end
|
||||
|
||||
local load_elapse = os.clock()-load_elapse_start
|
||||
if LoadingFun then
|
||||
task.wait(math.max(0, 3-load_elapse)) --Only if you take longer than or exactly 3 seconds to load
|
||||
task.wait(math.max(0, 4-load_elapse)) --Only if you take longer than or exactly 4 seconds to load
|
||||
end
|
||||
|
||||
TS:Message("Load elapse: "..tostring(load_elapse), game)
|
||||
|
||||
GUI_LoadFinish(Stepped, Gui)
|
||||
|
||||
Reference in New Issue
Block a user