전략게시판

전략게시판 [스튜디오]
스크립트: 라운드 20초 대기 / 버튼 누르면 점수 증가/5점종료/이동불가/라운드 재시작
2020.01.22 13:04 조회 : 2017
Lv. 57익스트림트롤 가입된 패밀리가 없습니다. 작성자 게시물 더보기
game.lua <<<

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




ui.lua<<<



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

추천 : 0
댓글을 남기시려면 로그인 해주세요
댓글 : 0