점점 작아지는 섬
Coddy의 Roblox 게임: 재난 생존 코스 레슨. 20개 중 13번째.
세 번째 재난에는 새 파트가 필요하지 않습니다. 섬 자체가 줄어들고, 가장자리 근처에 서 있는 사람은 누구든 허공으로 떨어집니다. 트윈은 Position만큼 쉽게 Size를 변경할 수 있습니다. 파트는 크기를 조절해도 중심을 유지하므로 가운데를 향해 줄어듭니다.
local shrink = TweenInfo.new(10, Enum.EasingStyle.Linear)
TweenService:Create(base, shrink, { Size = Vector3.new(6, base.Size.Y, 6) }):Play()Enum.EasingStyle.Linear는 일정한 속도로 크기를 줄입니다. 기본 설정은 서서히 감속하여 처음에는 빠르고 끝에는 느립니다. 맵의 복사본만 줄어듭니다. ServerStorage의 Island는 크기를 유지하므로 다음 라운드는 온전한 크기의 섬에서 시작합니다.
챌린지
중급세 번째 재난을 추가하세요. 플레이어가 있는 섬이 줄어듭니다.
Disasters.Shrink(map)을 작성하세요.map.Base의 Size를Vector3.new(6, base.Size.Y, 6)로 트윈하세요. 시간은Settings.RoundLength * 0.7초이며,Enum.EasingStyle.Linear를 사용하세요.Disasters.Meteors(map)대신 이 함수를 호출하세요.
‘플레이’를 누르세요. 섬이 스폰 지점 주변의 작은 정사각형으로 줄어들고, 그곳에서는 안전합니다. 그런 다음 ‘확인’을 누르세요.
직접 해보기
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Settings = require(game.ReplicatedStorage.Settings)
local lobbySpawn = workspace.LobbySpawn
print("Rounds last " .. Settings.RoundLength .. " seconds")
-- 모든 플레이어의 리더보드에 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.StatusBoard
local status = Instance.new("TextLabel")
status.Name = "Status"
status.Size = UDim2.fromScale(1, 1)
status.BackgroundColor3 = Color3.fromRGB(25, 25, 35)
status.TextColor3 = Color3.fromRGB(255, 255, 255)
status.TextScaled = true
status.Text = "Welcome to Disaster Survival!"
status.Parent = gui
local function setStatus(text)
status.Text = text
end
local function teleport(player, target)
local character = player.Character
if character then
character:PivotTo(target.CFrame + Vector3.new(0, 4, 0))
end
end
local function defeat(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end
-- 이름별 재난 목록
local Disasters = {}
function Disasters.Flood(map)
local base = map.Base
local water = Instance.new("Part")
water.Name = "Water"
water.Anchored = true
water.CanCollide = false
water.Transparency = 0.3
water.Color = Color3.fromRGB(40, 120, 255)
water.Size = Vector3.new(base.Size.X + 10, 1, base.Size.Z + 10)
water.Position = base.Position - Vector3.new(0, 2, 0)
water.Parent = map
water.Touched:Connect(defeat)
local rise = TweenInfo.new(Settings.RoundLength * 0.8, Enum.EasingStyle.Linear)
TweenService:Create(water, rise, { Position = water.Position + Vector3.new(0, 8, 0) }):Play()
end
function Disasters.Meteors(map)
local base = map.Base
task.spawn(function()
while map.Parent do
local meteor = Instance.new("Part")
meteor.Name = "Meteor"
meteor.Shape = Enum.PartType.Ball
meteor.Size = Vector3.new(3, 3, 3)
meteor.Color = Color3.fromRGB(255, 120, 30)
meteor.Material = Enum.Material.Neon
local x = base.Position.X + math.random(-15, 15)
local z = base.Position.Z + math.random(-15, 15)
meteor.Position = Vector3.new(x, 40, z)
meteor.Parent = map
meteor.Touched:Connect(defeat)
Debris:AddItem(meteor, 4)
task.wait(0.5)
end
end)
end
-- Lesson 13: Shrinking Island는 여기에 들어갑니다
-- 라운드 반복문
while true do
for seconds = Settings.Intermission, 1, -1 do
setStatus("Intermission: " .. seconds)
task.wait(1)
end
local map = ServerStorage.Maps.Island:Clone()
map.Name = "Map"
map.Parent = workspace
local survivors = {}
for _, player in Players:GetPlayers() do
local character = player.Character
if character and character.Humanoid.Health > 0 then
teleport(player, map.Spawn)
survivors[player] = true
character.Humanoid.Died:Connect(function()
survivors[player] = nil
end)
end
end
Disasters.Meteors(map)
for seconds = Settings.RoundLength, 1, -1 do
setStatus("Time left: " .. seconds)
task.wait(1)
end
local names = {}
for player in survivors do
player.leaderstats.Wins.Value += 1
teleport(player, lobbySpawn)
table.insert(names, player.Name)
end
map:Destroy()
if #names > 0 then
setStatus("Winners: " .. table.concat(names, ", "))
else
setStatus("Nobody survived!")
end
task.wait(3)
end
Roblox 게임: 재난 생존의 모든 레슨
직접 연습해 보세요: Roblox 플레이그라운드