Menu
CoddyTech

탑 안으로

Coddy의 Roblox 게임: 끝없는 타워 코스 레슨. 21개 중 13번째.

카운트다운이 끝나면 라운드가 시작됩니다. 타워를 만들고, 용암을 시작하고, 모든 플레이어를 첫 번째 스테이지로 이동시키세요. 스테이지를 만들 때 테이블에 저장하면 towerStages[1]이 가장 아래 스테이지가 됩니다.

towerStages[i] = stage

캐릭터는 Model이므로 PivotTo를 사용하면 캐릭터 전체를 이동시킵니다. Start 패드 안이 아니라 그 위쪽으로 몇 스터드 떨어진 곳에 배치하면, 캐릭터가 패드 위에 착지합니다.

player.Character:PivotTo(towerStages[1].Start.CFrame + Vector3.new(0, 4, 0))

그런 다음 보드에서 로비와 같은 방식으로 라운드 카운트다운을 진행합니다.

challenge icon

챌린지

중급

라운드가 타워에서 시작됩니다.

  1. local towerStages = {}: buildTower에서 이를 비우고 towerStages[i] = stage를 저장합니다.
  2. startRound()를 작성합니다. 타워와 용암을 만들고 각 캐릭터를 towerStages[1].Start보다 4스터드 위로 이동시킵니다.
  3. 카운트다운이 끝난 후 이를 호출하고, Settings.RoundLength부터 i를 카운트다운합니다: setBoard("Climb! " .. i .. " seconds left").

‘플레이’를 누르면 타워에 착지하고, 보드에 Climb! 120 seconds left가 표시됩니다. 그런 다음 ‘확인’을 누릅니다.

직접 해보기

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local CollectionService = game:GetService("CollectionService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Settings = require(game.ReplicatedStorage.Settings)

local stages = ServerStorage.Stages
local tower = nil
local lava = nil

print("Each tower has " .. Settings.StageCount .. " stages")

-- 모든 플레이어에게 리더보드의 Wins가 주어집니다
Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local wins = Instance.new("IntValue")
	wins.Name = "Wins"
	wins.Parent = leaderstats
end)

-- 로비에 있는 게시판
local gui = Instance.new("SurfaceGui")
gui.Parent = workspace.Lobby.Board

local boardLabel = Instance.new("TextLabel")
boardLabel.Name = "Status"
boardLabel.Size = UDim2.fromScale(1, 1)
boardLabel.BackgroundColor3 = Color3.fromRGB(25, 25, 35)
boardLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
boardLabel.TextScaled = true
boardLabel.Text = "Endless Tower"
boardLabel.Parent = gui

local function setBoard(text)
	boardLabel.Text = text
end

-- Kill 태그가 붙은 모든 것은 닿으면 목숨을 잃게 합니다
local function killOnTouch(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end

-- 사라지는 발판은 누군가 밟은 직후 희미해졌다가 다시 나타납니다
local function makeVanish(part)
	part.Touched:Connect(function(hit)
		if part:GetAttribute("Gone") or not hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		part:SetAttribute("Gone", true)
		task.wait(Settings.VanishDelay)
		part.Transparency = 0.8
		part.CanCollide = false
		task.wait(Settings.VanishTime)
		part.Transparency = 0
		part.CanCollide = true
		part:SetAttribute("Gone", nil)
	end)
end

-- 레이저는 Slide 오프셋까지 미끄러져 갔다가 돌아오기를 계속 반복합니다
local function makeSlide(part)
	local info = TweenInfo.new(Settings.SlideTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)
	local goal = { Position = part.Position + part:GetAttribute("Slide") }
	TweenService:Create(part, info, goal):Play()
end

-- 점프 발판은 밟은 사람을 공중으로 튀어 올립니다
local function bounce(hit)
	local root = hit.Parent:FindFirstChild("HumanoidRootPart")
	if root then
		root.AssemblyLinearVelocity = Vector3.new(0, Settings.BouncePower, 0)
	end
end

-- 회전 장애물은 매 프레임 조금씩 회전합니다
RunService.Heartbeat:Connect(function(dt)
	for _, spinner in CollectionService:GetTagged("Spinner") do
		if spinner:IsDescendantOf(workspace) then
			spinner:PivotTo(spinner:GetPivot() * CFrame.Angles(0, math.rad(Settings.SpinSpeed) * dt, 0))
		end
	end
end)

-- 태그에 따라 스테이지의 모든 장애물을 활성화합니다
local function setupStage(stage)
	for _, part in stage:GetDescendants() do
		if part:HasTag("Kill") then
			part.Touched:Connect(killOnTouch)
		end
		if part:HasTag("Vanish") then
			makeVanish(part)
		end
		if part:HasTag("Conveyor") then
			part.AssemblyLinearVelocity = part.CFrame.LookVector * Settings.BeltSpeed
		end
		if part:HasTag("Slider") then
			makeSlide(part)
		end
		if part:HasTag("Bounce") then
			part.Touched:Connect(bounce)
		end
	end
end

-- 스테이지를 무작위로 하나 선택합니다
local function pickStage()
	local all = stages:GetChildren()
	return all[math.random(1, #all)]
end

-- 모델의 복사본을 타워 맨 위에 놓고, 복사본과 새 꼭대기 높이를 반환합니다
local function stack(template, bottom)
	local copy = template:Clone()
	local box, size = copy:GetBoundingBox()
	local lift = bottom - (box.Position.Y - size.Y / 2)
	copy:PivotTo(copy:GetPivot() + Vector3.new(0, lift, 0))
	copy.Parent = tower
	return copy, bottom + size.Y
end

-- 새로운 무작위 타워를 아래에서 위로 만듭니다
local function buildTower()
	tower = Instance.new("Model")
	tower.Name = "Tower"
	tower.Parent = workspace
	local top = 0
	for i = 1, Settings.StageCount do
		local stage, newTop = stack(pickStage(), top)
		top = newTop
		setupStage(stage)
	end
	stack(ServerStorage.Finish, top)
	return top
end

-- 용암이 바닥에서 타워 꼭대기 바로 아래까지 차오릅니다
local function startLava(top)
	lava = Instance.new("Part")
	lava.Name = "Lava"
	lava.Anchored = true
	lava.CanCollide = false
	lava.Size = Vector3.new(30, 2, 30)
	lava.Position = Vector3.new(0, -2, 0)
	lava.Color = Color3.fromRGB(255, 90, 20)
	lava.Material = Enum.Material.Neon
	lava.Parent = workspace
	lava.Touched:Connect(killOnTouch)
	local info = TweenInfo.new(top / Settings.LavaSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, Settings.LavaDelay)
	TweenService:Create(lava, info, { Position = Vector3.new(0, top - 2, 0) }):Play()
end

-- 레슨 13: Into the Tower가 여기에 들어갑니다

-- 카운트다운을 한 다음 타워를 만듭니다
for i = Settings.Intermission, 1, -1 do
	setBoard("Next tower in " .. i)
	task.wait(1)
end
local top = buildTower()
startLava(top)

Roblox 게임: 끝없는 타워의 모든 레슨

직접 연습해 보세요: Roblox 플레이그라운드