mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
work on door floors
This commit is contained in:
@@ -1,36 +0,0 @@
|
|||||||
--!optimize 2
|
|
||||||
--!native
|
|
||||||
--!strict
|
|
||||||
|
|
||||||
local Floors = {}
|
|
||||||
Floors.__index = Floors
|
|
||||||
|
|
||||||
local Storage = game:GetService("ReplicatedStorage")
|
|
||||||
local CS = game:GetService("CollectionService")
|
|
||||||
|
|
||||||
local Tags = require(Storage:WaitForChild("Tags"))
|
|
||||||
|
|
||||||
function Floors.constructor(NumberOfFloors: number, Year: string)
|
|
||||||
local Floors = {}
|
|
||||||
for i: number = 1, NumberOfFloors do
|
|
||||||
local FloorTag_1 = CS:GetTagged(`ElevatorDoor_{Year}_Floor{tostring(i)}_1`)
|
|
||||||
local FloorTag_2 = CS:GetTagged(`ElevatorDoor_{Year}_Floor{tostring(i)}_2`)
|
|
||||||
if FloorTag_1 then
|
|
||||||
table.insert(Floors, FloorTag_1)
|
|
||||||
end
|
|
||||||
if FloorTag_2 then
|
|
||||||
table.insert(Floors, FloorTag_2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return setmetatable({
|
|
||||||
NumberOfFloors = NumberOfFloors,
|
|
||||||
Floors = Floors
|
|
||||||
}, Floors)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Floors:GetFloor(Floor: number): Instance?
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
return Floors
|
|
||||||
@@ -92,12 +92,12 @@ local function DoorsAnimationFloor(floor: number, opening: boolean?, activated_v
|
|||||||
local DoorTween1 = Tween.constructor(TweenInfo.new(
|
local DoorTween1 = Tween.constructor(TweenInfo.new(
|
||||||
TweenTime,
|
TweenTime,
|
||||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||||
Enum.EasingDirection.InOut
|
Enum.EasingDirection.Out
|
||||||
), Floor10_Door1)
|
), Floor10_Door1)
|
||||||
local DoorTween2 = Tween.constructor(TweenInfo.new(
|
local DoorTween2 = Tween.constructor(TweenInfo.new(
|
||||||
TweenTime,
|
TweenTime,
|
||||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||||
Enum.EasingDirection.InOut
|
Enum.EasingDirection.Out
|
||||||
), Floor10_Door2)
|
), Floor10_Door2)
|
||||||
local Door1Tween_Floor: Tween = DoorTween1:Start(nil, {
|
local Door1Tween_Floor: Tween = DoorTween1:Start(nil, {
|
||||||
Position = opening and init_closed_door1 or init_opened_door1
|
Position = opening and init_closed_door1 or init_opened_door1
|
||||||
@@ -134,14 +134,14 @@ local function DoorsAnimation(self: ClassConstructor, opening: boolean?, activat
|
|||||||
}, TweenInfo.new(
|
}, TweenInfo.new(
|
||||||
TweenTime,
|
TweenTime,
|
||||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||||
Enum.EasingDirection.InOut
|
Enum.EasingDirection.Out
|
||||||
))
|
))
|
||||||
local Door2Tween = self.DoorTween2:Start(nil, {
|
local Door2Tween = self.DoorTween2:Start(nil, {
|
||||||
Position = opening and init_closed_door2 or init_opened_door2
|
Position = opening and init_closed_door2 or init_opened_door2
|
||||||
}, TweenInfo.new(
|
}, TweenInfo.new(
|
||||||
TweenTime,
|
TweenTime,
|
||||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||||
Enum.EasingDirection.InOut
|
Enum.EasingDirection.Out
|
||||||
))
|
))
|
||||||
|
|
||||||
if not opening then
|
if not opening then
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ type Impl_Static_Props = {
|
|||||||
LanternDisplayColorOff: Color3,
|
LanternDisplayColorOff: Color3,
|
||||||
LanternChimeDirection: rbxassetid,
|
LanternChimeDirection: rbxassetid,
|
||||||
LanternChimeLanding: rbxassetid,
|
LanternChimeLanding: rbxassetid,
|
||||||
|
FloorLevelingDistance: number,
|
||||||
|
LeveledDistance: number,
|
||||||
__Moving: boolean,
|
__Moving: boolean,
|
||||||
__CurrentFloor: number
|
__CurrentFloor: number
|
||||||
}
|
}
|
||||||
@@ -81,6 +83,8 @@ type ButtonFunctions = {
|
|||||||
local Otis1960 = {} :: Impl_Constructor
|
local Otis1960 = {} :: Impl_Constructor
|
||||||
Otis1960.__index = Otis1960
|
Otis1960.__index = Otis1960
|
||||||
|
|
||||||
|
Otis1960.FloorLevelingDistance = 2.5
|
||||||
|
Otis1960.LeveledDistance = 0.5
|
||||||
Otis1960.Responsiveness = 50
|
Otis1960.Responsiveness = 50
|
||||||
Otis1960.MaxVelocity = 10
|
Otis1960.MaxVelocity = 10
|
||||||
Otis1960.ButtonActivatedColor = Color3.fromRGB(180,0,0)
|
Otis1960.ButtonActivatedColor = Color3.fromRGB(180,0,0)
|
||||||
@@ -185,6 +189,21 @@ function Otis1960.constructor(TagsConstructor, ButtonsTags, LanternsTags)
|
|||||||
return ClassConstructor
|
return ClassConstructor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function FloorLeveling(self: ClassConstructor, RequestedLevel: number)
|
||||||
|
self.BoxAlignPosition.MaxVelocity = 1
|
||||||
|
self.LanternsConstructor:Toggle(true, RequestedLevel)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function FloorLeveled(self: ClassConstructor, RequestedLevel: number)
|
||||||
|
(self.__MovingConnection :: RBXScriptConnection):Disconnect()
|
||||||
|
|
||||||
|
Otis1960.__Moving = false
|
||||||
|
Otis1960.__CurrentFloor = RequestedLevel
|
||||||
|
self.BoxAlignPosition.MaxVelocity = Otis1960.MaxVelocity
|
||||||
|
|
||||||
|
self.LanternsConstructor:Reset()
|
||||||
|
end
|
||||||
|
|
||||||
function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
|
function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
|
||||||
local RotationDelta = 0
|
local RotationDelta = 0
|
||||||
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position
|
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position
|
||||||
@@ -214,34 +233,20 @@ function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
|
|||||||
|
|
||||||
--Kill the connection
|
--Kill the connection
|
||||||
if GoingUp then
|
if GoingUp then
|
||||||
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y-1 then
|
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y-Otis1960.FloorLevelingDistance then
|
||||||
self.BoxAlignPosition.MaxVelocity = .35
|
FloorLeveling(self, RequestedLevel)
|
||||||
self.LanternsConstructor:Toggle(true, RequestedLevel)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y-.5 then
|
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y-Otis1960.LeveledDistance then
|
||||||
(self.__MovingConnection :: RBXScriptConnection):Disconnect()
|
FloorLeveled(self, RequestedLevel)
|
||||||
|
|
||||||
Otis1960.__Moving = false
|
|
||||||
Otis1960.__CurrentFloor = RequestedLevel
|
|
||||||
self.BoxAlignPosition.MaxVelocity = Otis1960.MaxVelocity
|
|
||||||
|
|
||||||
self.LanternsConstructor:Reset()
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if ElevatorPosition.Y<=self.BoxAlignPosition.Position.Y+1 then
|
if ElevatorPosition.Y<=self.BoxAlignPosition.Position.Y+Otis1960.FloorLevelingDistance then
|
||||||
self.BoxAlignPosition.MaxVelocity = .35
|
FloorLeveling(self, RequestedLevel)
|
||||||
self.LanternsConstructor:Toggle(true, RequestedLevel)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ElevatorPosition.Y<=self.BoxAlignPosition.Position.Y+.5 then
|
if ElevatorPosition.Y<=self.BoxAlignPosition.Position.Y+Otis1960.LeveledDistance then
|
||||||
(self.__MovingConnection :: RBXScriptConnection):Disconnect()
|
FloorLeveled(self, RequestedLevel)
|
||||||
|
|
||||||
Otis1960.__Moving = false
|
|
||||||
Otis1960.__CurrentFloor = RequestedLevel
|
|
||||||
self.BoxAlignPosition.MaxVelocity = Otis1960.MaxVelocity
|
|
||||||
|
|
||||||
self.LanternsConstructor:Reset()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ type Impl_Constructor = {
|
|||||||
Request: (self: ClassConstructor, Name: string) -> TagProduct | Error,
|
Request: (self: ClassConstructor, Name: string) -> TagProduct | Error,
|
||||||
__ElevatorLanterns: (self: ClassConstructor) -> LanternsTree,
|
__ElevatorLanterns: (self: ClassConstructor) -> LanternsTree,
|
||||||
__ElevatorButtons: (self: ClassConstructor) -> ElevatorModelButtons,
|
__ElevatorButtons: (self: ClassConstructor) -> ElevatorModelButtons,
|
||||||
|
__ElevatorDoors: (self: ClassConstructor) -> any,
|
||||||
__Interactables: (self: ClassConstructor) -> InteractablesTree
|
__Interactables: (self: ClassConstructor) -> InteractablesTree
|
||||||
} & Impl_Static_Props
|
} & Impl_Static_Props
|
||||||
|
|
||||||
type Impl_Static_Props = {
|
type Impl_Static_Props = {
|
||||||
Decoders: {
|
Decoders: {
|
||||||
CarTag: (FloorTag: string) -> number?
|
CarTag: (FloorTag: string) -> number?,
|
||||||
|
FloorTag: (FloorTag: string) -> string?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,8 +118,12 @@ Tags.__index = Tags
|
|||||||
|
|
||||||
Tags.Decoders = {
|
Tags.Decoders = {
|
||||||
CarTag = function(FloorTag)
|
CarTag = function(FloorTag)
|
||||||
local Match = FloorTag:match('%d+$')
|
local Match = FloorTag:match('^%d+$')
|
||||||
return Match and tonumber(Match)
|
return Match and tonumber(Match)
|
||||||
|
end,
|
||||||
|
|
||||||
|
FloorTag = function(FloorTag)
|
||||||
|
return FloorTag:match('^Floor%d+$')
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +236,24 @@ function Tags:__ElevatorButtons()
|
|||||||
return Buttons
|
return Buttons
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Tags:__ElevatorDoors()
|
||||||
|
local Doors = {}
|
||||||
|
|
||||||
|
for _, EnumValue in Enums.Elevator do
|
||||||
|
Doors[EnumValue :: Enums.ElevatorValues] = {}
|
||||||
|
|
||||||
|
for TagName: string, Inst: TagProduct in self.__export do
|
||||||
|
local Split = TagName:split('_')
|
||||||
|
local ModelHint = Split[1]
|
||||||
|
local FloorHint = Split[2]
|
||||||
|
|
||||||
|
if ModelHint == (EnumValue :: Enums.ElevatorValues) and Tags.Decoders.FloorTag(ModelHint) then
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Tags:__Interactables()
|
function Tags:__Interactables()
|
||||||
local Interactables: InteractablesTree = {
|
local Interactables: InteractablesTree = {
|
||||||
LightSwitches = {}
|
LightSwitches = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user