mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2026-02-03 19:46:49 +00:00
big commit
This commit is contained in:
30
src/shared/AlgebraEasings.lua
Normal file
30
src/shared/AlgebraEasings.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
--My versions
|
||||
|
||||
type EaseFunction = (n: number) -> number
|
||||
|
||||
export type EasingStyles = {
|
||||
Linear: EaseFunction,
|
||||
InOutBack: EaseFunction,
|
||||
OutBounce: EaseFunction
|
||||
}
|
||||
|
||||
local Ease: EasingStyles = {}
|
||||
--Google straight up gives wrong/bad math
|
||||
|
||||
function Ease.Linear(a,b,t)
|
||||
return a-a*t+b*t
|
||||
end
|
||||
|
||||
local c = 2.59491
|
||||
function Ease.InOutBack(n)
|
||||
return n<.5 and 2*n*n*(-c+2*n+2*c*n) or 3*(-1+n)*(-1+n)*(-2-c+2*n+2*c*n)
|
||||
end
|
||||
|
||||
local n1, d1 = 7.5625, 2.75
|
||||
function Ease.OutBounce(n)
|
||||
return (n<0.363636 and n*n*n1 or
|
||||
n<0.727273 and (.75*(1.*d1-2.*n*n1)) or
|
||||
n<0.909091 and (.9375*(1.*d1-2.4*n*n1)/d1)) or (.984375*(1.*d1-2.66667*n*n1))/d1
|
||||
end
|
||||
|
||||
return Ease
|
||||
98
src/shared/Client/Camera.lua
Normal file
98
src/shared/Client/Camera.lua
Normal file
@@ -0,0 +1,98 @@
|
||||
local Camera = {}
|
||||
Camera.__index = Camera
|
||||
|
||||
Camera.FOV = {
|
||||
Default = 70,
|
||||
Zoomed = 30,
|
||||
}
|
||||
Camera.FOV.Speed = {
|
||||
In = 0.3,
|
||||
Out = 0.4
|
||||
}
|
||||
Camera.VignetteEnabled = true
|
||||
Camera.CrosshairEffect = true
|
||||
Camera.EffectsEase = Enum.EasingStyle.Quad
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
|
||||
local ZoomTween = Tween.constructor()
|
||||
local VignetteTween = Tween.constructor()
|
||||
|
||||
function Camera.constructor(CurrentCamera: Camera, Player: Player)
|
||||
return setmetatable({
|
||||
Camera = CurrentCamera,
|
||||
Player = Player,
|
||||
}, Camera)
|
||||
end
|
||||
|
||||
function Camera:FirstPerson()
|
||||
self.Player.CameraMode = Enum.CameraMode.LockFirstPerson
|
||||
end
|
||||
|
||||
function Camera:ThirdPerson()
|
||||
self.Player.CameraMode = Enum.CameraMode.Classic
|
||||
end
|
||||
|
||||
--damn...
|
||||
type Vignette = any
|
||||
type Crosshair = any
|
||||
|
||||
function Camera:ZoomIn(Vignette: Vignette?, Crosshair: Crosshair?)
|
||||
ZoomTween:Start(self.Camera, {
|
||||
FieldOfView = Camera.FOV.Zoomed
|
||||
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||
|
||||
if Camera.VignetteEnabled then
|
||||
if Vignette then
|
||||
Vignette.Screen.Enabled = true
|
||||
|
||||
VignetteTween:Start(Vignette.Icon, {
|
||||
ImageTransparency = 0
|
||||
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||
else
|
||||
warn("Camera: no Vignette object was provided for the camera", debug.traceback())
|
||||
end
|
||||
end
|
||||
|
||||
if Camera.CrosshairEffect then
|
||||
if Crosshair then
|
||||
VignetteTween:Start(Crosshair.Icon, {
|
||||
ImageTransparency = .9
|
||||
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||
else
|
||||
warn("Camera: no Crosshair object was provided for the camera", debug.traceback())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Camera:ZoomOut(Vignette: Vignette?, Crosshair: Crosshair?)
|
||||
ZoomTween:Start(self.Camera, {
|
||||
FieldOfView = Camera.FOV.Default
|
||||
}, TweenInfo.new(Camera.FOV.Speed.Out, Camera.EffectsEase))
|
||||
|
||||
if Camera.VignetteEnabled then
|
||||
if Vignette then
|
||||
Vignette.Screen.Enabled = true
|
||||
|
||||
VignetteTween:Start(Vignette.Icon, {
|
||||
ImageTransparency = 1
|
||||
}, TweenInfo.new(Camera.FOV.Speed.Out, Camera.EffectsEase))
|
||||
else
|
||||
warn("Camera: no Vignette object was provided for the camera", debug.traceback())
|
||||
end
|
||||
end
|
||||
|
||||
if Camera.CrosshairEffect then
|
||||
if Crosshair then
|
||||
VignetteTween:Start(Crosshair.Icon, {
|
||||
ImageTransparency = 0
|
||||
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
|
||||
else
|
||||
warn("Camera: no Crosshair object was provided for the camera", debug.traceback())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Camera
|
||||
82
src/shared/Client/KeyBinds.lua
Normal file
82
src/shared/Client/KeyBinds.lua
Normal file
@@ -0,0 +1,82 @@
|
||||
--I couldn't get ContextActionService to work how i wanted it to
|
||||
|
||||
local BindLink = {}
|
||||
BindLink.__index = BindLink
|
||||
|
||||
local UIS = game:GetService("UserInputService")
|
||||
|
||||
export type KeyBindMap = {
|
||||
[string]: {
|
||||
[Enum.KeyCode]: () -> ()
|
||||
}
|
||||
}
|
||||
export type InputBegan = RBXScriptConnection
|
||||
export type InputEnded = RBXScriptConnection
|
||||
|
||||
type CallbackFunction = () -> ()
|
||||
|
||||
function BindLink.constructor() --Allow multiple bindings of the same keys, no overwrites
|
||||
type BindConstructor = {
|
||||
BindMap: KeyBindMap,
|
||||
InputBegan: InputBegan,
|
||||
InputEnded: InputEnded
|
||||
}
|
||||
|
||||
local self: BindConstructor = {}
|
||||
self.BindMap = {
|
||||
Began = {},
|
||||
Ended = {}
|
||||
}
|
||||
|
||||
--Return these for convenience
|
||||
self.InputBegan = UIS.InputBegan:Connect(function(input, gameProcessedEvent)
|
||||
if not gameProcessedEvent then
|
||||
local switch = self.BindMap.Began[input.KeyCode]
|
||||
if switch then
|
||||
switch()
|
||||
else
|
||||
--switch.default()
|
||||
end
|
||||
end
|
||||
end)
|
||||
self.InputEnded = UIS.InputEnded:Connect(function(input, gameProcessedEvent)
|
||||
if not gameProcessedEvent then
|
||||
local switch = self.BindMap.Ended[input.KeyCode]
|
||||
if switch then
|
||||
switch()
|
||||
else
|
||||
--switch.default()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
return setmetatable(self, BindLink)
|
||||
end
|
||||
|
||||
function BindLink:AddInputBegan(Keys: {Enum.KeyCode}, Callback: CallbackFunction)
|
||||
for i = 1, #Keys do
|
||||
local Key = Keys[i]
|
||||
|
||||
if self.BindMap.Began[Key] then
|
||||
warn(`Key >began< "{Key.Name}" is already binded on this KeyBind map`, debug.traceback())
|
||||
end
|
||||
self.BindMap.Began[Key] = Callback
|
||||
end
|
||||
end
|
||||
|
||||
function BindLink:AddInputEnded(Keys: {Enum.KeyCode}, Callback: CallbackFunction)
|
||||
for i = 1, #Keys do
|
||||
local Key = Keys[i]
|
||||
|
||||
if self.BindMap.Ended[Key] then
|
||||
warn(`Key >ended< "{Key.Name}" is already binded on this KeyBind map`, debug.traceback())
|
||||
end
|
||||
self.BindMap.Ended[Key] = Callback
|
||||
end
|
||||
end
|
||||
|
||||
function BindLink:KeyHold(Key: Enum.KeyCode): boolean
|
||||
return UIS:IsKeyDown(Key)
|
||||
end
|
||||
|
||||
return BindLink
|
||||
17
src/shared/Delta.lua
Normal file
17
src/shared/Delta.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local Delta = {
|
||||
FPS = 60
|
||||
}
|
||||
Delta.__index = Delta
|
||||
|
||||
type dt = number
|
||||
|
||||
function Delta:time(): dt
|
||||
local Frame = os.clock()
|
||||
local function Frame_heap(): dt
|
||||
Frame = os.clock()-Frame
|
||||
return task.wait(Frame/Delta.FPS)
|
||||
end
|
||||
return Frame_heap()
|
||||
end
|
||||
|
||||
return Delta
|
||||
20
src/shared/String.lua
Normal file
20
src/shared/String.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
local StringModule = {}
|
||||
StringModule.__index = StringModule
|
||||
|
||||
function StringModule.new(String: string)
|
||||
return setmetatable({
|
||||
String = String
|
||||
}, StringModule)
|
||||
end
|
||||
|
||||
type ByteArray = {string}
|
||||
|
||||
function StringModule:bytes(): ByteArray
|
||||
local cbytes = {self.String:byte(1,-1)}
|
||||
for i = 1, #cbytes do
|
||||
cbytes[i] = tostring(cbytes[i]):char()
|
||||
end
|
||||
return cbytes
|
||||
end
|
||||
|
||||
return StringModule
|
||||
13
src/shared/Tags.lua
Normal file
13
src/shared/Tags.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
local CS = game:GetService("CollectionService")
|
||||
|
||||
local exports: {[string]: BasePart} = {}
|
||||
|
||||
local AllTags = CS:GetAllTags()
|
||||
for i = 1, #AllTags do
|
||||
local TagName = AllTags[i]
|
||||
if TagName ~= "RopeMasterObject" then
|
||||
exports[TagName] = CS:GetTagged(TagName)[1]
|
||||
end
|
||||
end
|
||||
|
||||
return exports
|
||||
50
src/shared/Tween.lua
Normal file
50
src/shared/Tween.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
local Tween = {}
|
||||
Tween.__index = Tween
|
||||
|
||||
local TS = game:GetService("TweenService")
|
||||
|
||||
type TweenAnimation = {[string]: any}
|
||||
|
||||
function Tween.constructor(TweenSettings: TweenInfo?, Object: Instance?, PreProperties: TweenAnimation?)
|
||||
return setmetatable({
|
||||
TweenInfo = TweenSettings,
|
||||
Instance = Object,
|
||||
PreProperties = PreProperties
|
||||
}, Tween)
|
||||
end
|
||||
|
||||
function Tween:Start(PostInstance: Instance?, PostProperties: TweenAnimation?, PostTweenSettings: TweenInfo?): Tween
|
||||
local Props = self.PreProperties
|
||||
local Object = self.Instance
|
||||
local TweenSettings = self.TweenInfo
|
||||
|
||||
if PostProperties then
|
||||
if self.PreProperties then
|
||||
for tween_prop, tween_value in PostProperties do
|
||||
Props[tween_prop] = tween_value
|
||||
end
|
||||
print("Tween library: Combining PostProperties and PreProperties together", debug.traceback())
|
||||
else
|
||||
Props = PostProperties
|
||||
end
|
||||
end
|
||||
if PostInstance then
|
||||
if Object then
|
||||
print("Tween library: Overwriting an already defined animating object old=", Object, "new=", PostInstance, debug.traceback())
|
||||
end
|
||||
Object = PostInstance
|
||||
end
|
||||
if PostTweenSettings then
|
||||
if TweenSettings then
|
||||
print("Tween library: Overwriting already defined Tween settings", debug.traceback())
|
||||
end
|
||||
TweenSettings = PostTweenSettings
|
||||
end
|
||||
|
||||
local Animation = TS:Create(Object, TweenSettings, Props)
|
||||
Animation:Play()
|
||||
|
||||
return Animation
|
||||
end
|
||||
|
||||
return Tween
|
||||
11
src/shared/types/class.lua
Normal file
11
src/shared/types/class.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
-- type AccountImpl = {
|
||||
-- __index: AccountImpl,
|
||||
-- new: (name: string, balance: number) -> Account,
|
||||
-- deposit: (self: Account, credit: number) -> (),
|
||||
-- withdraw: (self: Account, debit: number) -> (),
|
||||
-- }
|
||||
|
||||
-- type Account = typeof(setmetatable({} :: { name: string, balance: number }, {} :: AccountImpl))
|
||||
|
||||
type hself<T,U> = {__index: T} & U
|
||||
export type constructor<T,U> = typeof(setmetatable({} :: T & hself<T,U>, {} :: U))
|
||||
Reference in New Issue
Block a user