GE = Game.EntityBlock
GR = Game.Rule
ScoreCT = Game.SyncValue.Create("ScoreCT")
ScoreTR = Game.SyncValue.Create("ScoreTR")
MaxScore = Game.SyncValue.Create("MaxScore")
GameTime = 0
PlayerSignal = 2
StopSignal = 3
ScoreCT.value = 0
ScoreTR.value = 0
MaxScore.value = 5
a1 = GE.Create({x=0,y=0,z=0})
a2 = GE.Create({x=2,y=0,z=0})
function GR:OnUpdate(time)
if GameTime < 20 then
if GR.respawnable ~= true then GR.respawnable = true end
elseif GameTime >= 20 then
if GR.respawnable ~= false then GR.respawnable = false end
end
end
function a1:OnUse (player) --대테러리스트 승리, 5점 되면 종료
ScoreCT.value = ScoreCT.value + 1
if ScoreCT.value <= 4 then Game.Rule:Win (Game.TEAM.CT, false)
elseif ScoreCT.value == MaxScore.value then Game.Rule:Win (Game.TEAM.CT, true)
end
player:Signal (PlayerSignal)
end
function a2:OnUse (player) --테러리스트 승리, 5점 되면 종료
ScoreTR.value = ScoreTR.value + 1
if ScoreTR.value <= 4 then Game.Rule:Win (Game.TEAM.TR, false)
elseif ScoreTR.value == MaxScore.value then Game.Rule:Win (Game.TEAM.TR, true)
end
player:Signal (PlayerSignal)
end
function GR:OnPlayerSpawn (player)
player:Signal (StopSignal)
GameTime = Game.GetTime()
end
GameSignal = 1
PlayerSignal = 2
StopSignal = 3
ScoreCT = UI.SyncValue.Create("ScoreCT")
ScoreTR = UI.SyncValue.Create("ScoreTR")
MaxScore = UI.SyncValue.Create("MaxScore")
screen = UI.ScreenSize()
center = {x = screen.width / 2, y = screen.height / 2}
scoreBG = UI.Box.Create()
scoreBG:Set({x = center.x - 100, y = 0, width = 200, height = 50, r = 255, g = 255, b = 255, a = 150})
goalBG = UI.Box.Create()
goalBG:Set({x = center.x - 50, y = 0, width = 100, height = 50, r = 40, g = 40, b = 40, a = 150})
goalLabel = UI.Text.Create()
goalLabel:Set({text='00', font='large', align='center', x = center.x - 50, y = 10, width = 100, height = 50, r = 80, g = 255, b = 80})
ctLabel = UI.Text.Create()
ctLabel:Set({text='00', font='medium', align='left', x = center.x - 95, y = 20, width = 50, height = 50, r = 80, g = 80, b = 255})
trLabel = UI.Text.Create()
trLabel:Set({text='00', font='medium', align='right', x = center.x + 45, y = 20, width = 50, height = 50, r = 255, g = 80, b = 80})
function ScoreCT:OnSync()
local str = string.**at("%02d", self.value)
ctLabel:Set({text = str})
end
function ScoreTR:OnSync()
local str = string.**at("%02d", self.value)
trLabel:Set({text = str})
end
function MaxScore:OnSync()
local str = string.**at("%02d", self.value)
goalLabel:Set({text = str})
end
function UI.Event:OnSignal (signal)
if signal == PlayerSignal then
UI.StopPlayerControl (true)
elseif signal == StopSignal then
UI.StopPlayerControl (false)
end
end