diff options
| author | Alexander Pickering <Alexander.Pickering@anondomain.site90.net> | 2016-02-27 18:35:34 -0500 |
|---|---|---|
| committer | Alexander Pickering <Alexander.Pickering@anondomain.site90.net> | 2016-02-27 18:35:34 -0500 |
| commit | 21fca07b8e449daf8446ff67b0169d0fd39bec9c (patch) | |
| tree | ec97e75994cc991a5f3487ffd51e8446c20afffa /gamemode | |
| parent | 7196ee72bcec68bc0efe6af76e6644275c8b74ef (diff) | |
| download | wintersurvival2-21fca07b8e449daf8446ff67b0169d0fd39bec9c.tar.gz wintersurvival2-21fca07b8e449daf8446ff67b0169d0fd39bec9c.tar.bz2 wintersurvival2-21fca07b8e449daf8446ff67b0169d0fd39bec9c.zip | |
Fixed the rubicks circle minigame not re-appearing after finishing
Diffstat (limited to 'gamemode')
| -rw-r--r-- | gamemode/hud/draw_spell.lua | 1 | ||||
| -rw-r--r-- | gamemode/hud/games/connectthedots.lua | 2 | ||||
| -rw-r--r-- | gamemode/hud/games/rubickscircle.lua | 292 |
3 files changed, 168 insertions, 127 deletions
diff --git a/gamemode/hud/draw_spell.lua b/gamemode/hud/draw_spell.lua index 97c702b..32c1bc6 100644 --- a/gamemode/hud/draw_spell.lua +++ b/gamemode/hud/draw_spell.lua @@ -138,6 +138,7 @@ end function DrawSpellOverlay() if(CASTING_SPELL) then + print("Calling casting_spell's draw...") CASTING_SPELL["draw"](CASTING_SPELL) if(CASTING_SPELL.Score != nil) then finishedcasting(CASTING_SPELL.Score) diff --git a/gamemode/hud/games/connectthedots.lua b/gamemode/hud/games/connectthedots.lua index eab3521..20cc601 100644 --- a/gamemode/hud/games/connectthedots.lua +++ b/gamemode/hud/games/connectthedots.lua @@ -112,7 +112,7 @@ Game.Draw = function(self) --print("X:" .. gui.MouseX() .. " Y:" .. gui.MouseY()) if(input.IsMouseDown(MOUSE_RIGHT)) then - self.Score = math.max(0,self.Score) + self.Score = 0 self.scoreboard:Remove() end end diff --git a/gamemode/hud/games/rubickscircle.lua b/gamemode/hud/games/rubickscircle.lua index 3155055..56e4a44 100644 --- a/gamemode/hud/games/rubickscircle.lua +++ b/gamemode/hud/games/rubickscircle.lua @@ -1,39 +1,6 @@ --A file to show what functions are used for minigames print("rubick's circle included!") ---[[The cirlces for this game, each cirlce has dots, represtented as a number, 0 is empty]]-- -Game.Circles = {} ---The currently selected circle number, 0 is the inner most -Game.SelectedCircle = 0 ---The Points that need to be filled, represtented as circle, then a number 0-7 on which direction needs to be filled -Game.Requirements = {} - ---How many circles there are on the lowest difficulty -Game.numcircle = 3 - ---The Next input, the color(as a number) and a number 0-7 of the direction -Game.NextInputColor = 0 -Game.NextInputDirection = 0 - ---When things are moveing -Game.Animateingringnum = -1 -Game.Animateingdirection = 0 -Game.Animateingstart = 0 -Game.ANIMATE_MOVEING_DURATION = 2 - ---If the column is falling, can be more than one -Game.AnimateFalling = false -Game.AnimateFallingColumnNum = {} -Game.AnimateFallingStartLvl = {} -Game.AnimateFallingStartTime = 0 -Game.ANIMATE_FALLING_DURATION = 2 - -Game.AnimateRemoveing = false ---All the points that need to be animated to be removed ---Organized the same way as Game.Circles -Game.AnimateRemoveingPoints = {} -Game.AnimateRemoveingStartTime = 0 -Game.ANIMATE_REMOVE_DURATION = 2 --[[ 7 0 1 \ | / @@ -48,43 +15,85 @@ Game.ANIMATE_REMOVE_DURATION = 2 --Required functions --Called once when the plyer starts casting Game.Cast = function(spelltab,difficulty) + --Initalization stuff + --[[The cirlces for this spelltab, each cirlce has dots, represtented as a number, 0 is empty]]-- + spelltab.Circles = {} + --The currently selected circle number, 0 is the inner most + spelltab.SelectedCircle = 0 + --The Points that need to be filled, represtented as circle, then a number 0-7 on which direction needs to be filled + spelltab.Requirements = {} + + --How many circles there are on the lowest difficulty + spelltab.numcircle = 3 + + --The Next input, the color(as a number) and a number 0-7 of the direction + spelltab.NextInputColor = 0 + spelltab.NextInputDirection = 0 + + --When things are moveing + spelltab.Animateingringnum = -1 + spelltab.Animateingdirection = 0 + spelltab.Animateingstart = 0 + spelltab.ANIMATE_MOVEING_DURATION = 0.5 + + --If the column is falling, can be more than one + spelltab.AnimateFalling = false + spelltab.AnimateFallingColumnNum = {} + spelltab.AnimateFallingStartLvl = {} + spelltab.AnimateFallingStartTime = 0 + spelltab.ANIMATE_FALLING_DURATION = 0.5 + + spelltab.AnimateRemoveing = false + --All the points that need to be animated to be removed + --Organized the same way as spelltab.Circles + spelltab.AnimateRemoveingPoints = {} + spelltab.AnimateRemoveingStartTime = 0 + spelltab.ANIMATE_REMOVE_DURATION = 0.5 + + spelltab.MaxColor = 3 + + --Create a dummy panel so that the mouse is trapped, untrap it when it right clicks + spelltab.Score = nil local scoreboard = vgui.Create("MBFrame") if(!scoreboard) then return end scoreboard:SetPos(0,0) scoreboard:SetSize(0,0) scoreboard:MakePopup() spelltab.scoreboard = scoreboard + spelltab.numcircle = 3 if(difficulty == 3) then - Game.numcircle = Game.numcircle+2 + spelltab.numcircle = spelltab.numcircle+2 end - for i=0, Game.numcircle-1 do - Game.AnimateRemoveingPoints[i] = {} - Game.Circles[i] = {} + for i=0, spelltab.numcircle-1 do + spelltab.AnimateRemoveingPoints[i] = {} + spelltab.Circles[i] = {} for j = 0, 7 do - Game.AnimateRemoveingPoints[i][j] = false - Game.Circles[i][j] = math.Round(math.random(0,3)) + spelltab.AnimateRemoveingPoints[i][j] = false + --spelltab.Circles[i][j] = math.Round(math.random(0,3)) + spelltab.Circles[i][j] = 0 end end for i=0, 7 do - Game.AnimateFallingColumnNum[i] = false - Game.AnimateFallingStartLvl[i] = -1 + spelltab.AnimateFallingColumnNum[i] = false + spelltab.AnimateFallingStartLvl[i] = -1 end - Game.NextInputDirection = math.Round(math.random(0,7)) - Game.NextInputColor = math.Round(math.random(1,3)) + spelltab.NextInputDirection = math.Round(math.random(0,7)) + spelltab.NextInputColor = math.Round(math.random(1,spelltab.MaxColor)) end --Called continuously while the player is casting Game.Draw = function(self) + print("Draw function being called") if not input.IsKeyTrapping() then input.StartKeyTrapping() end draw.DrawText( "Fill in the empty circles with the appropriate colors", "TargetID", ScrW() * 0.5, ScrH() * 0.25, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER ) --Draw the rings - for i = 0, Game.numcircle-1 do - if(Game.SelectedCircle == i) then + for i = 0, self.numcircle-1 do + if(self.SelectedCircle == i) then surface.DrawCircle(ScrW()/2,ScrH()/2,(i+1)*100,Color(255,255,255)) surface.DrawCircle(ScrW()/2,ScrH()/2,((i+1)*100)+5,Color(255,255,255)) surface.DrawCircle(ScrW()/2,ScrH()/2,((i+1)*100)-5,Color(255,255,255)) @@ -93,103 +102,131 @@ Game.Draw = function(self) end --Draw the circles on the rings - local angadd = ((Game.Animateingstart-CurTime())/Game.ANIMATE_MOVEING_DURATION)*45*Game.Animateingdirection - local subdist = (((Game.AnimateFallingStartTime-CurTime())/Game.ANIMATE_FALLING_DURATION)*100) + 100 - local altraid = 20 - (((Game.AnimateRemoveingStartTime-CurTime())/Game.ANIMATE_REMOVE_DURATION)*20) + local angadd = ((self.Animateingstart-CurTime())/self.ANIMATE_MOVEING_DURATION)*45*self.Animateingdirection + local subdist = (((self.AnimateFallingStartTime-CurTime())/self.ANIMATE_FALLING_DURATION)*100) + local altraid = 20 - (((self.AnimateRemoveingStartTime-CurTime())/self.ANIMATE_REMOVE_DURATION)*20) for j = 0, 7 do - if(Game.Circles[i][j] != 0) then + if(self.Circles[i][j] != 0) then local angle = (-j*45)+90 - if(i == Game.SelectedCircle)then + if(i == self.SelectedCircle)then angle = angle+angadd end local mul = (i+1)*100 - if(Game.AnimateFallingColumnNum[j] and i > Game.AnimateFallingStartLvl[j]) then + if(self.AnimateFallingColumnNum[j] and i > self.AnimateFallingStartLvl[j]) then mul = mul + subdist end local x = (math.cos(math.rad(angle))*mul) + (ScrW()/2) local y = (math.sin(math.rad(angle))*mul) + (ScrH()/2) local radius = 20 - if(Game.AnimateRemoveingPoints[i][j]) then + if(self.AnimateRemoveingPoints[i][j]) then radius = 40 - altraid end - surface.DrawCircle(x,y,radius,Game.ColorFor(Game.Circles[i][j])) + surface.DrawCircle(x,y,radius,self.ColorFor(self.Circles[i][j])) end end - --Draw the next-to-add circle - local mul = (Game.numcircle+1)*100 - local nextang = Game.NextInputDirection - local x = (math.cos(math.rad(nextang))*mul) + (ScrW()/2) - local y = (math.sin(math.rad(nextang))*mul) + (ScrH()/2) - local nextcol = Game.ColorFor(Game.NextInputColor) - surface.DrawCircle(x,y,20,nextcol) end + --Draw the next-to-add circle + local mul = ((self.numcircle+1)*100)-50 + local nextang = (-self.NextInputDirection*45)+90 + local x = (math.cos(math.rad(nextang))*mul) + (ScrW()/2) + local y = (math.sin(math.rad(nextang))*mul) + (ScrH()/2) + local nextcol = self.ColorFor(self.NextInputColor) + surface.DrawCircle(x,y,20,nextcol) --Deal with moveing stuff - if(Game.Animateingringnum != -1) then - if(CurTime() > Game.Animateingstart+Game.ANIMATE_MOVEING_DURATION) then - if(Game.Animateingdirection == 1) then - local tmp = Game.Circles[Game.SelectedCircle][7] + if(self.Animateingringnum != -1) then + if(CurTime() > self.Animateingstart+self.ANIMATE_MOVEING_DURATION) then + if(self.Animateingdirection == 1) then + local tmp = self.Circles[self.SelectedCircle][7] for i = 0, 6 do - Game.Circles[Game.SelectedCircle][7-i]=Game.Circles[Game.SelectedCircle][6-i] + self.Circles[self.SelectedCircle][7-i]=self.Circles[self.SelectedCircle][6-i] end - Game.Circles[Game.SelectedCircle][0] = tmp - Game.Animateingringnum = -1 - Game.Animateingdirection = 0 - Game.ProcessMoved() - elseif(Game.Animateingdirection == -1) then - local tmp = Game.Circles[Game.SelectedCircle][0] + self.Circles[self.SelectedCircle][0] = tmp + self.Animateingringnum = -1 + self.Animateingdirection = 0 + self.ProcessMoved(self) + elseif(self.Animateingdirection == -1) then + local tmp = self.Circles[self.SelectedCircle][0] for i = 0, 6 do - Game.Circles[Game.SelectedCircle][i]=Game.Circles[Game.SelectedCircle][i+1] + self.Circles[self.SelectedCircle][i]=self.Circles[self.SelectedCircle][i+1] end - Game.Circles[Game.SelectedCircle][7] = tmp - Game.Animateingringnum = -1 - Game.Animateingdirection = 0 - Game.ProcessMoved() + self.Circles[self.SelectedCircle][7] = tmp + self.Animateingringnum = -1 + self.Animateingdirection = 0 + self.ProcessMoved(self) end end - elseif(Game.AnimateFalling and CurTime() > Game.AnimateFallingStartTime + Game.ANIMATE_FALLING_DURATION) then - for k,v in pairs(Game.AnimateFallingColumnNum) do + elseif(self.AnimateFalling and CurTime() > self.AnimateFallingStartTime + self.ANIMATE_FALLING_DURATION) then + for k,v in pairs(self.AnimateFallingColumnNum) do if(v) then - for i = Game.AnimateFallingStartLvl[k], Game.numcircle-2 do - Game.Circles[i][k] = Game.Circles[i+1][k] + for i = self.AnimateFallingStartLvl[k], self.numcircle-2 do + self.Circles[i][k] = self.Circles[i+1][k] end - Game.Circles[Game.numcircle-1][k] = 0 + self.Circles[self.numcircle-1][k] = 0 end end for i = 0, 7 do - Game.AnimateFalling = false - Game.AnimateFallingColumnNum[i] = false - Game.AnimateFallingStartLvl[i] = -1 + self.AnimateFalling = false + self.AnimateFallingColumnNum[i] = false + self.AnimateFallingStartLvl[i] = -1 end - elseif(Game.AnimateRemoveing and CurTime() > Game.AnimateRemoveingStartTime + Game.ANIMATE_REMOVE_DURATION) then - for k,_ in pairs(Game.AnimateRemoveingPoints) do - for n,o in pairs(Game.AnimateRemoveingPoints[k]) do - if(o) then - Game.Circles[k][n] = 0 - Game.AnimateRemoveingPoints[k][n] = false + self.ProcessMoved(self) + --[[ + elseif(self.AnimateRemoveing and CurTime() > self.AnimateRemoveingStartTime + self.ANIMATE_REMOVE_DURATION) then + for i = 0, self.numcircle-1 do + for k = 0, 7 do + if(self.AnimateRemoveingPoints[i][k]) then + self.Circles[k][n] = 0 + self.AnimateRemoveingPoints[k][n] = false end end end - Game.AnimateRemoveing = false + self.AnimateRemoveing = false + self.ProcessMoved() + ]]-- elseif(input.IsKeyDown(KEY_Q)) then + --If anything is animateing, don't allow the player input + if(self.Animateingringnum != -1 or self.AnimateFalling) then return end + --Add the new dot in, or fail if we can't + if(self.Circles[self.numcircle-1][self.NextInputDirection] != 0) then + print("self fail :(") + self.Score = 0 + self.scoreboard:Remove() + else + self.Circles[self.numcircle-1][self.NextInputDirection] = self.NextInputColor + self.NextInputDirection = math.Round(math.random(0,7)) + self.NextInputColor = math.Round(math.random(1,self.MaxColor)) + end --Rotate stuff counter-clockwise - Game.Animateingringnum = Game.SelectedCircle - Game.Animateingdirection = 1 - Game.Animateingstart = CurTime() + self.Animateingringnum = self.SelectedCircle + self.Animateingdirection = 1 + self.Animateingstart = CurTime() elseif(input.IsKeyDown(KEY_E)) then + --Don't move if animations are happeneing + if(self.Animateingringnum != -1 or self.AnimateFalling) then return end + --Add the new dot in, or fail if we can't + if(self.Circles[self.numcircle-1][self.NextInputDirection] != 0) then + print("self fail :(") + self.Score = 0 + self.scoreboard:Remove() + else + self.Circles[self.numcircle-1][self.NextInputDirection] = self.NextInputColor + self.NextInputDirection = math.Round(math.random(0,7)) + self.NextInputColor = math.Round(math.random(1,self.MaxColor)) + end --Rotate stuff clockwise - Game.Animateingringnum = Game.SelectedCircle - Game.Animateingdirection = -1 - Game.Animateingstart = CurTime() + self.Animateingringnum = self.SelectedCircle + self.Animateingdirection = -1 + self.Animateingstart = CurTime() --Detect mouse input elseif(input.IsMouseDown(MOUSE_LEFT)) then local offset = math.Distance(gui.MouseX(),gui.MouseY(),ScrW()/2,ScrH()/2) print("Offset:" .. offset) - for i = 0, Game.numcircle-1 do + for i = 0, self.numcircle-1 do if(offset > (100*(i+1))-50 and offset < (100*(1+i))+50) then - Game.SelectedCircle = i + self.SelectedCircle = i end end end @@ -202,49 +239,52 @@ Game.Draw = function(self) end --What to do when anything moved -Game.ProcessMoved = function() +Game.ProcessMoved = function(self) + print("Processing:") + PrintTable(self) --First, check to see if anything is 3 in a column for i = 0, 7 do - for j = 0, Game.numcircle-3 do - local tomatch = Game.Circles[j][i] + for j = 0, self.numcircle-3 do + local tomatch = self.Circles[j][i] if(tomatch == 0) then continue end local ismatching = true for k = 0, 2 do - if(Game.Circles[j+k][i] != tomatch) then + if(self.Circles[j+k][i] != tomatch) then ismatching = false break end end if(ismatching) then - --PrintTable(Game.Circles) + --PrintTable(self.Circles) --print("Found a matching column ring " .. j .. " column " .. i .. " " .. tomatch) for k = 0, 2 do - Game.AnimateRemoveingPoints[j+k][i] = true - Game.AnimateRemoveingStartTime = CurTime() + self.Circles[j+k][i] = 0 + --self.AnimateRemoveingPoints[j+k][i] = true + --self.AnimateRemoveingStartTime = CurTime() end end end end --Next, check to see if anything is 3 in a row - for i = 0, Game.numcircle-1 do + for i = 0, self.numcircle-1 do for j = 0, 7 do - local tomatch = Game.Circles[i][j] + local tomatch = self.Circles[i][j] if(tomatch == 0) then continue end local ismatching = true for k = 0,2 do - if(Game.Circles[i][(j+k)%8] != tomatch) then + if(self.Circles[i][(j+k)%8] != tomatch) then ismatching = false break end end if(ismatching) then - --PrintTable(Game.Circles) + --PrintTable(self.Circles) --print("Found a matching row ring " .. i .. " column " .. j .. " " .. tomatch) for k = 0,2 do - --Game.Circles[i][(j+k)%7] = 0 - Game.AnimateRemoveingPoints[i][(j+k)%8] = true - Game.AnimateRemoveingStartTime = CurTime() + self.Circles[i][(j+k)%8] = 0 + --self.AnimateRemoveingPoints[i][(j+k)%8] = true + --self.AnimateRemoveingStartTime = CurTime() end end end @@ -252,16 +292,16 @@ Game.ProcessMoved = function() --Next, check to see if we need to drop anything for i = 0, 7 do - for j = 0, Game.numcircle-1 do - if(Game.Circles[j][i] == 0) then - for k=j, Game.numcircle-1 do - if(Game.Circles[k][i] != 0) then - --Game.Circles[j][i] = Game.Circles[k][i] - --Game.Circles[k][i] = 0 - Game.AnimateFallingStartLvl[i] = j - Game.AnimateFallingColumnNum[i] = true - Game.AnimateFallingStartTime = CurTime() - Game.AnimateFalling = true + for j = 0, self.numcircle-1 do + if(self.Circles[j][i] == 0) then + for k=j, self.numcircle-1 do + if(self.Circles[k][i] != 0) then + --self.Circles[j][i] = self.Circles[k][i] + --self.Circles[k][i] = 0 + self.AnimateFallingStartLvl[i] = j + self.AnimateFallingColumnNum[i] = true + self.AnimateFallingStartTime = CurTime() + self.AnimateFalling = true --return break end @@ -276,7 +316,7 @@ Game.ColorFor = function(num) if(num == 1) then return Color(255,0,0) end if(num == 2) then return Color(0,255,0) end if(num == 3) then return Color(0,0,255) end - //if(num == 4) then return Color(255,0,255) end - //if(num == 5) then return Color(0,255,255) end - //if(num == 6) then return Color(255,255,0) end + if(num == 4) then return Color(255,0,255) end + if(num == 5) then return Color(0,255,255) end + if(num == 6) then return Color(255,255,0) end end |
