mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Rotation matrix UI and Interactions dir
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -4,7 +4,39 @@
|
||||
|
||||
--Not a good idea to call modules from other services here
|
||||
|
||||
--Who said UI on here cant look like a web design lole,
|
||||
type RotationMatrix = {
|
||||
Ixx: number,
|
||||
Ixy: number,
|
||||
Iyx: number,
|
||||
Iyy: number,
|
||||
Izx: number,
|
||||
Izy: number
|
||||
}
|
||||
|
||||
type Scalar = {
|
||||
Distance: number,
|
||||
Center: Vector2,
|
||||
Rotation: number
|
||||
}
|
||||
|
||||
type Stepped = RBXScriptConnection
|
||||
|
||||
type GuiDependencies = {
|
||||
IntroGui: ScreenGui,
|
||||
Frame: Frame,
|
||||
FrameGradient: UIGradient,
|
||||
TextShadow: TextLabel,
|
||||
ShadowGradient: UIGradient,
|
||||
FrameworkText: TextLabel,
|
||||
SandboxText: TextLabel,
|
||||
DeveloperText: TextLabel,
|
||||
Xframe: Frame,
|
||||
Yframe: Frame,
|
||||
Zframe: Frame,
|
||||
Xframe_text: TextLabel,
|
||||
Yframe_text: TextLabel,
|
||||
Zframe_text: TextLabel,
|
||||
}
|
||||
|
||||
local RS = game:GetService("RunService")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
@@ -12,101 +44,138 @@ local TS = game:GetService("TestService")
|
||||
|
||||
local LoadingFun = true
|
||||
|
||||
local function GuiDependencies(IntroGui: ScreenGui)
|
||||
local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
||||
IntroGui.Enabled = true
|
||||
|
||||
local Frame = IntroGui:WaitForChild("Frame")
|
||||
local Viewport = Frame:WaitForChild("ViewportFrame")
|
||||
local Frame = IntroGui:WaitForChild("Frame") :: Frame
|
||||
|
||||
local FrameGradient = Frame:WaitForChild("UIGradient")
|
||||
local TextShadow = Frame:WaitForChild("TextShadow")
|
||||
local FrameworkText = Frame:WaitForChild("Framework")
|
||||
local SandboxText = Frame:WaitForChild("Sandbox")
|
||||
local DeveloperText = Frame:WaitForChild("Developer")
|
||||
local ShadowGradient = TextShadow:WaitForChild("UIGradient")
|
||||
local FrameGradient = Frame:WaitForChild("UIGradient") :: UIGradient
|
||||
local TextShadow = Frame:WaitForChild("TextShadow") :: TextLabel
|
||||
local FrameworkText = Frame:WaitForChild("Framework") :: TextLabel
|
||||
local SandboxText = Frame:WaitForChild("Sandbox") :: TextLabel
|
||||
local DeveloperText = Frame:WaitForChild("Developer") :: TextLabel
|
||||
local ShadowGradient = TextShadow:WaitForChild("UIGradient") :: UIGradient
|
||||
|
||||
local ViewportCamera = Instance.new("Camera")
|
||||
ViewportCamera.FieldOfView = 50
|
||||
ViewportCamera.Parent = Viewport
|
||||
Viewport.CurrentCamera = ViewportCamera
|
||||
local Xframe = Frame:WaitForChild("X") :: Frame
|
||||
local Yframe = Frame:WaitForChild("Y") :: Frame
|
||||
local Zframe = Frame:WaitForChild("Z") :: Frame
|
||||
|
||||
local GL_Cube = Viewport:WaitForChild("GL_Cube")
|
||||
local Xframe_text = Frame:WaitForChild("X_text") :: TextLabel
|
||||
local Yframe_text = Frame:WaitForChild("Y_text") :: TextLabel
|
||||
local Zframe_text = Frame:WaitForChild("Z_text") :: TextLabel
|
||||
|
||||
return {
|
||||
IntroGui = IntroGui,
|
||||
Frame = Frame,
|
||||
Viewport = Viewport,
|
||||
ViewportCamera = ViewportCamera,
|
||||
GL_Cube = GL_Cube,
|
||||
FrameGradient = FrameGradient,
|
||||
TextShadow = TextShadow,
|
||||
ShadowGradient = ShadowGradient,
|
||||
FrameworkText = FrameworkText,
|
||||
SandboxText = SandboxText,
|
||||
DeveloperText = DeveloperText
|
||||
DeveloperText = DeveloperText,
|
||||
Xframe = Xframe,
|
||||
Yframe = Yframe,
|
||||
Zframe = Zframe,
|
||||
Xframe_text = Xframe_text,
|
||||
Yframe_text = Yframe_text,
|
||||
Zframe_text = Zframe_text,
|
||||
}
|
||||
end
|
||||
|
||||
type GUIs = typeof(GuiDependencies)
|
||||
type Stepped = RBXScriptConnection
|
||||
|
||||
local function GUI_LoadFinish(Stepped: Stepped, Gui: GUIs) --We can now access the framework
|
||||
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"))
|
||||
|
||||
local EaseStyle = Enum.EasingStyle.Linear
|
||||
|
||||
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.Frame, {
|
||||
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Frame, {
|
||||
BackgroundTransparency = 1
|
||||
})
|
||||
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.DeveloperText, {
|
||||
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
|
||||
TextTransparency = 1
|
||||
})
|
||||
local ViewportFrame_Constructor = Tween.constructor(TweenInfo.new(3, EaseStyle), Gui.Viewport, {
|
||||
Position = UDim2.fromScale(0.5, 2) --Guaranteed off screen
|
||||
})
|
||||
|
||||
FrameTween_Constructor:Start()
|
||||
local FrameTween = FrameTween_Constructor:Start()
|
||||
DeveloperTween_Constructor:Start()
|
||||
local ViewportTween = ViewportFrame_Constructor:Start() --The longest tween
|
||||
|
||||
--Text deleting effect
|
||||
task.spawn(function()
|
||||
local sandbox_text_len = #Gui.SandboxText.Text
|
||||
|
||||
for i = sandbox_text_len, 1, -1 do --"A sandbox experience" has the longest text
|
||||
local rhpid_text_len = #Gui.FrameworkText.Text
|
||||
|
||||
Gui.SandboxText.Text = Gui.SandboxText.Text:sub(1,i-1)
|
||||
if rhpid_text_len ~= 0 then
|
||||
Gui.FrameworkText.Text = Gui.FrameworkText.Text:sub(1,i-1)
|
||||
for n: number = #Gui.SandboxText.Text, 1, -1 do --"A sandbox experience" has the longest text
|
||||
Gui.SandboxText.Text = Gui.SandboxText.Text:sub(1,n-1)
|
||||
if #Gui.FrameworkText.Text ~= 0 then
|
||||
Gui.FrameworkText.Text = Gui.FrameworkText.Text:sub(1,n-1)
|
||||
Gui.TextShadow.Text = Gui.FrameworkText.Text --heh hack
|
||||
end
|
||||
task.wait(.05)
|
||||
end
|
||||
end)
|
||||
|
||||
ViewportTween.Completed:Wait()
|
||||
FrameTween.Completed:Wait()
|
||||
Stepped:Disconnect()
|
||||
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
|
||||
end
|
||||
|
||||
type GL_Cube = Instance
|
||||
type GL_Side = Instance
|
||||
local function RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
||||
return {
|
||||
Ixx = math.cos(Z)*math.cos(X)-math.sin(Z)*math.sin(X)*math.sin(Y);
|
||||
Ixy = math.cos(Z)*math.sin(X)*math.sin(Y)+math.sin(Z)*math.cos(X);
|
||||
Iyx = -math.cos(Z)*math.sin(X)-math.sin(Z)*math.cos(X)*math.sin(Y);
|
||||
Iyy = math.cos(Z)*math.cos(X)*math.sin(Y)-math.sin(Z)*math.sin(X);
|
||||
Izx = -math.sin(Z)*math.cos(Y);
|
||||
Izy = math.cos(Z)*math.sin(Y)
|
||||
}
|
||||
end
|
||||
|
||||
local function Scalar(X1: number, Y1: number, X2: number, Y2: number): Scalar
|
||||
return {
|
||||
Distance = math.sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
|
||||
Center = Vector2.new((X1+X2)/2,(Y1+Y2)/2);
|
||||
Rotation = math.deg(math.atan2(Y1-Y2,X1-X2))
|
||||
}
|
||||
end
|
||||
|
||||
local Size = 300
|
||||
local WorldSize = 3
|
||||
|
||||
return function(IntroGui: ScreenGui, load_elapse_start: number)
|
||||
local Gui = GuiDependencies(IntroGui)
|
||||
|
||||
Gui.ViewportCamera.CFrame = CFrame.lookAt(Gui.GL_Cube.Position-Vector3.new(3,-2.5,5), Gui.GL_Cube.Position)
|
||||
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 Cube_CF = Gui.GL_Cube.CFrame
|
||||
local Stepped = RS.Stepped:Connect(function(delta, dt)
|
||||
--Magic number heaven
|
||||
local d2 = delta*10
|
||||
Gui.FrameGradient.Rotation=d2
|
||||
Gui.ShadowGradient.Rotation=d2*4
|
||||
local mX = Delta/1.5
|
||||
local mY = Delta/1.5
|
||||
local mZ = -7.65
|
||||
|
||||
Gui.GL_Cube.CFrame = Cube_CF*CFrame.Angles(math.rad(100*math.cos(delta/8)), 0, delta/2)
|
||||
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
|
||||
end)
|
||||
|
||||
task.spawn(function()
|
||||
|
||||
@@ -8,7 +8,7 @@ local ReplicatedFirst = game:GetService("ReplicatedFirst")
|
||||
local Players = game:GetService("Players")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local DisabledInStudio = game:GetService("RunService"):IsStudio()
|
||||
local DisabledInStudio = false
|
||||
local IntroGui = nil
|
||||
|
||||
local function LoadedBind()
|
||||
@@ -21,6 +21,8 @@ local function LoadedBind()
|
||||
end
|
||||
|
||||
local function LoadingIntroGUI()
|
||||
ReplicatedFirst:RemoveDefaultLoadingScreen()
|
||||
|
||||
local RunIntroGui = require(script:WaitForChild("IntroGui"))
|
||||
|
||||
local Player = Players.LocalPlayer
|
||||
@@ -47,5 +49,3 @@ if not DisabledInStudio then
|
||||
end
|
||||
|
||||
LoadedBind()
|
||||
|
||||
ReplicatedFirst:RemoveDefaultLoadingScreen()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local MapDir = script.Parent
|
||||
local MapDir = script.Parent.Parent
|
||||
local MainDir = MapDir.Parent
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
@@ -19,7 +19,7 @@ type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
Create: (self: ClassConstructor) -> (),
|
||||
Init: (self: ClassConstructor) -> (),
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
@@ -38,8 +38,6 @@ Lights.__index = Lights
|
||||
|
||||
Lights.SwitchAnimationTime = .1
|
||||
|
||||
local LightSwitchTween = TweenModule.constructor(TweenInfo.new(Lights.SwitchAnimationTime, Enum.EasingStyle.Linear))
|
||||
|
||||
function Lights.constructor(LightSwitches)
|
||||
return setmetatable({
|
||||
LightSwitches = LightSwitches
|
||||
@@ -65,6 +63,8 @@ local function ToggleSwitchLight(EnabledState: boolean, LightObject: BasePart, L
|
||||
end
|
||||
end
|
||||
|
||||
local LightSwitchTween = TweenModule.constructor(TweenInfo.new(Lights.SwitchAnimationTime, Enum.EasingStyle.Linear))
|
||||
|
||||
local function SwitchAnimation(EnabledState: boolean, LightProperties: LightProperties)
|
||||
local Switch = LightProperties.Switch
|
||||
|
||||
@@ -85,7 +85,7 @@ end
|
||||
Guide for lights with toggable switches:
|
||||
TODO
|
||||
]]
|
||||
function Lights:Create()
|
||||
function Lights:Init()
|
||||
for _, LightProperties in self.LightSwitches do
|
||||
if LightProperties.Prompt and LightProperties.Switch then
|
||||
local Prompt = PromptsConstructor.constructor(LightProperties.Prompt, LightProperties.Switch)
|
||||
@@ -104,7 +104,7 @@ function Lights:Create()
|
||||
end
|
||||
end)
|
||||
else
|
||||
warn(`Prompt failed`)
|
||||
warn(`LightSwitch hook failed, a required field is missing:\n-----\nColorDeactivated = {LightProperties.ColorDeactivated}\nColorActivated = {LightProperties.ColorActivated}\nPrompt = {LightProperties.Prompt}\nLights = {LightProperties.Lights}\n-----`)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -77,7 +77,6 @@ export type InteractablesTree = {
|
||||
LightSwitches: LightSwitchTree
|
||||
}
|
||||
|
||||
|
||||
export type ButtonsTree = {
|
||||
Landing: ButtonProperties,
|
||||
Car: ButtonProperties,
|
||||
@@ -237,7 +236,7 @@ function Tags:__Interactables()
|
||||
if InteractType == Enums.Interactables.LightSwitch then
|
||||
local ptr = Interactables.LightSwitches[InteractObjectLocation]
|
||||
local itype = type(Inst) == "table"
|
||||
local Switch = itype and (Inst :: {Instance})[1] or Inst :: Instance
|
||||
local Switch = (itype and (Inst :: {Instance})[1] or Inst :: Instance) :: BasePart
|
||||
if itype then
|
||||
warn(`2 or more light switch tags were present under the same name, using the first index. "{TagName}". This feature is not implemented yet`)
|
||||
end
|
||||
@@ -249,6 +248,7 @@ function Tags:__Interactables()
|
||||
Prompt.HoldDuration = Tags.MaxLightSwitchHoldDuration
|
||||
Prompt.Parent = Attachment
|
||||
local ClickSound = Instance.new("Sound") :: Sound
|
||||
ClickSound.Volume = .1
|
||||
ClickSound.SoundId = Tags.LightSwitchActivateSoundId
|
||||
ClickSound.Parent = Switch
|
||||
|
||||
@@ -281,7 +281,7 @@ function Tags:__Interactables()
|
||||
ptr.Lights = Inst
|
||||
else
|
||||
ptr.Lights = {}
|
||||
table.insert(ptr.Lights :: {Instance}, Inst)
|
||||
table.insert(ptr.Lights :: {BasePart}, Inst :: BasePart)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,7 +7,12 @@ local ShowEditorEntities = game:GetService("RunService"):IsServer()
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
local Elevators = script:WaitForChild("Elevators")
|
||||
local Elevators = script:WaitForChild("Elevators")
|
||||
local Maps = script:WaitForChild("Map")
|
||||
|
||||
local Interactions = Maps:WaitForChild("Interactions")
|
||||
local LightSwitches = require(Interactions:WaitForChild("LightSwitches"))
|
||||
|
||||
local Otis1960_Module = require(Elevators:WaitForChild("Otis1960"))
|
||||
|
||||
local TagsModule = require(script:WaitForChild("Tags"))
|
||||
@@ -30,6 +35,10 @@ Workspace_Stuff()
|
||||
local Interactables = TagsConstructor:__Interactables()
|
||||
print("[DEBUG] Interactables=", Interactables)
|
||||
|
||||
--Interactables
|
||||
local LightSwitchesConstructor = LightSwitches.constructor(Interactables.LightSwitches)
|
||||
LightSwitchesConstructor:Init()
|
||||
|
||||
--Start the elevators
|
||||
local Buttons = TagsConstructor:__ElevatorButtons()
|
||||
print("[DEBUG] Buttons=", Buttons)
|
||||
|
||||
@@ -7,16 +7,52 @@
|
||||
type EaseFunction = (n: number) -> number
|
||||
type LinearFunction = (a: number, b: number, t: number) -> number
|
||||
|
||||
export type RotationMatrix = {
|
||||
Ixx: number,
|
||||
Ixy: number,
|
||||
Iyx: number,
|
||||
Iyy: number,
|
||||
Izx: number,
|
||||
Izy: number
|
||||
}
|
||||
|
||||
export type Scalar = {
|
||||
Distance: number,
|
||||
Center: Vector2,
|
||||
Rotation: number
|
||||
}
|
||||
|
||||
export type Math = {
|
||||
Linear: LinearFunction,
|
||||
InOutBack: EaseFunction,
|
||||
OutBounce: EaseFunction,
|
||||
InQuad: EaseFunction,
|
||||
RotationMatrix: (X: number, Y: number, Z: number) -> RotationMatrix,
|
||||
Scalar: (X1: number, Y1: number, X2: number, Y2: number) -> Scalar
|
||||
}
|
||||
|
||||
local Math = {} :: Math
|
||||
--Google straight up gives wrong/bad math
|
||||
|
||||
function Math.RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
||||
return {
|
||||
Ixx = math.cos(Z)*math.cos(X)-math.sin(Z)*math.sin(X)*math.sin(Y);
|
||||
Ixy = math.cos(Z)*math.sin(X)*math.sin(Y)+math.sin(Z)*math.cos(X);
|
||||
Iyx = -math.cos(Z)*math.sin(X)-math.sin(Z)*math.cos(X)*math.sin(Y);
|
||||
Iyy = math.cos(Z)*math.cos(X)*math.sin(Y)-math.sin(Z)*math.sin(X);
|
||||
Izx = -math.sin(Z)*math.cos(Y);
|
||||
Izy = math.cos(Z)*math.sin(Y)
|
||||
}
|
||||
end
|
||||
|
||||
function Math.Scalar(X1: number, Y1: number, X2: number, Y2: number): Scalar
|
||||
return {
|
||||
Distance = math.sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
|
||||
Center = Vector2.new((X1+X2)/2,(Y1+Y2)/2);
|
||||
Rotation = math.deg(math.atan2(Y1-Y2,X1-X2))
|
||||
}
|
||||
end
|
||||
|
||||
--My versions
|
||||
function Math.Linear(a,b,t)
|
||||
return a-a*t+b*t
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user