mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 23:01:53 +00:00
TagService -> Tags and more refactoring, close to working again
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local ElevatorDir = script.Parent
|
||||
local MainDir = ElevatorDir.Parent
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Tags = require(Storage:WaitForChild("Tags"))
|
||||
local Tags = require(MainDir:WaitForChild("Tags"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
type rbxassetid = string
|
||||
@@ -14,7 +17,7 @@ type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :
|
||||
type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Lanterns,
|
||||
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Tags.Lanterns,
|
||||
--Class functions
|
||||
Activate: (self: ClassConstructor, EnabledState: boolean, IsDirectionLantern: boolean, Lantern: Lantern) -> (),
|
||||
DirectionUp: (self: ClassConstructor, Enabled: boolean) -> (),
|
||||
@@ -24,12 +27,13 @@ type Impl_Constructor = {
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
Volume: number
|
||||
Volume: number,
|
||||
LightTweenTime: number
|
||||
}
|
||||
|
||||
type Constructor_Fun = (MainDisplay: UnionOperation, ChimeDirectionID: rbxassetid, ChimeLandingID: rbxassetid, Lanterns: Lanterns, Colors: Colors) -> ClassConstructor
|
||||
type Constructor_Fun = (MainDisplay: UnionOperation, ChimeDirectionID: rbxassetid, ChimeLandingID: rbxassetid, Lanterns: Tags.Lanterns, Colors: Colors) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
LanternsMap: Lanterns,
|
||||
LanternsMap: Tags.Lanterns,
|
||||
AudioChimeDirection: Sound,
|
||||
AudioChimeLanding: Sound,
|
||||
Colors: Colors
|
||||
@@ -41,12 +45,6 @@ type Lantern = {
|
||||
Played: boolean
|
||||
}
|
||||
|
||||
type Lanterns = {
|
||||
[number]: Lantern,
|
||||
Up: Lantern,
|
||||
Down: Lantern
|
||||
}
|
||||
|
||||
export type Colors = {
|
||||
Active: Color3,
|
||||
Off: Color3
|
||||
@@ -57,7 +55,8 @@ export type LanternsConstructor = ClassConstructor
|
||||
local Lanterns = {} :: Impl_Constructor
|
||||
Lanterns.__index = Lanterns
|
||||
|
||||
Lanterns.Volume = .8
|
||||
Lanterns.Volume = .5
|
||||
Lanterns.LightTweenTime = 1
|
||||
|
||||
function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, LanternsMap, Colors)
|
||||
local AudioChimeDirection = Instance.new("Sound") :: Sound
|
||||
@@ -78,7 +77,7 @@ function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, Lan
|
||||
}, Lanterns)
|
||||
end
|
||||
|
||||
local LanternLight = Tween.constructor(TweenInfo.new(1))
|
||||
local LanternLight = Tween.constructor(TweenInfo.new(Lanterns.LightTweenTime))
|
||||
|
||||
function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
local Tween = LanternLight:Start(Lantern.Light, {
|
||||
@@ -97,10 +96,14 @@ function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
end
|
||||
|
||||
function Lanterns:Reset()
|
||||
self.LanternsMap.Up.Played = false
|
||||
self.LanternsMap.Down.Played = false
|
||||
self:Activate(false, true, self.LanternsMap.Up)
|
||||
self:Activate(false, true, self.LanternsMap.Down)
|
||||
if self.LanternsMap.Up then
|
||||
self.LanternsMap.Up.Played = false
|
||||
self:Activate(false, true, self.LanternsMap.Up)
|
||||
end
|
||||
if self.LanternsMap.Down then
|
||||
self.LanternsMap.Down.Played = false
|
||||
self:Activate(false, true, self.LanternsMap.Down)
|
||||
end
|
||||
|
||||
for n: number = 1, #self.LanternsMap do
|
||||
self:Activate(false, false, self.LanternsMap[n])
|
||||
@@ -109,14 +112,14 @@ function Lanterns:Reset()
|
||||
end
|
||||
|
||||
function Lanterns:DirectionUp(Enabled)
|
||||
if not self.LanternsMap.Up.Played then
|
||||
if self.LanternsMap.Up and not self.LanternsMap.Up.Played then
|
||||
self.LanternsMap.Up.Played = true
|
||||
self:Activate(Enabled, true, self.LanternsMap.Up)
|
||||
end
|
||||
end
|
||||
|
||||
function Lanterns:DirectionDown(Enabled)
|
||||
if not self.LanternsMap.Down.Played then
|
||||
if self.LanternsMap.Down and not self.LanternsMap.Down.Played then
|
||||
self.LanternsMap.Down.Played = true
|
||||
self:Activate(Enabled, true, self.LanternsMap.Down)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user