aboutsummaryrefslogtreecommitdiff
path: root/gamemode/hud
diff options
context:
space:
mode:
authorAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-02-27 17:39:53 -0500
committerAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-02-27 17:39:53 -0500
commit7196ee72bcec68bc0efe6af76e6644275c8b74ef (patch)
tree217ff20f63f7d884309a0ab935761e8f65e641e7 /gamemode/hud
parent013139a91ac495ebc76429f04c9b921bd4d92ce2 (diff)
downloadwintersurvival2-7196ee72bcec68bc0efe6af76e6644275c8b74ef.tar.gz
wintersurvival2-7196ee72bcec68bc0efe6af76e6644275c8b74ef.tar.bz2
wintersurvival2-7196ee72bcec68bc0efe6af76e6644275c8b74ef.zip
More work on rubickcircle minigame
Diffstat (limited to 'gamemode/hud')
-rw-r--r--gamemode/hud/draw_spell.lua7
-rw-r--r--gamemode/hud/games/connectthedots.lua2
-rw-r--r--gamemode/hud/games/rubickscircle.lua271
3 files changed, 279 insertions, 1 deletions
diff --git a/gamemode/hud/draw_spell.lua b/gamemode/hud/draw_spell.lua
index b68e988..97c702b 100644
--- a/gamemode/hud/draw_spell.lua
+++ b/gamemode/hud/draw_spell.lua
@@ -13,6 +13,13 @@ Spells = {
["draw"] = "Draw",
["difficulty"] = 1,
},
+ ["Gateway"] = {
+ ["file"] = "rubickscircle.lua",
+ ["minigame"] = "Cast",
+ ["interupt"] = "AddItem",
+ ["draw"] = "Draw",
+ ["difficulty"] = 1,
+ },
}
Games = {}
diff --git a/gamemode/hud/games/connectthedots.lua b/gamemode/hud/games/connectthedots.lua
index fe6cef2..eab3521 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 = 100
+ self.Score = math.max(0,self.Score)
self.scoreboard:Remove()
end
end
diff --git a/gamemode/hud/games/rubickscircle.lua b/gamemode/hud/games/rubickscircle.lua
index 5982fd1..3155055 100644
--- a/gamemode/hud/games/rubickscircle.lua
+++ b/gamemode/hud/games/rubickscircle.lua
@@ -1,11 +1,282 @@
--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
+ \ | /
+ \ | /
+ \|/
+ 6---------2
+ /|\
+ / | \
+ / | \
+]]-- 5 4 3
+
--Required functions
--Called once when the plyer starts casting
Game.Cast = function(spelltab,difficulty)
+
+ --Create a dummy panel so that the mouse is trapped, untrap it when it right clicks
+ local scoreboard = vgui.Create("MBFrame")
+ if(!scoreboard) then return end
+ scoreboard:SetPos(0,0)
+ scoreboard:SetSize(0,0)
+ scoreboard:MakePopup()
+ spelltab.scoreboard = scoreboard
+ if(difficulty == 3) then
+ Game.numcircle = Game.numcircle+2
+ end
+ for i=0, Game.numcircle-1 do
+ Game.AnimateRemoveingPoints[i] = {}
+ Game.Circles[i] = {}
+ for j = 0, 7 do
+ Game.AnimateRemoveingPoints[i][j] = false
+ Game.Circles[i][j] = math.Round(math.random(0,3))
+ end
+ end
+ for i=0, 7 do
+ Game.AnimateFallingColumnNum[i] = false
+ Game.AnimateFallingStartLvl[i] = -1
+ end
+ Game.NextInputDirection = math.Round(math.random(0,7))
+ Game.NextInputColor = math.Round(math.random(1,3))
+
end
--Called continuously while the player is casting
Game.Draw = function(self)
+ 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
+ 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))
+ else
+ surface.DrawCircle(ScrW()/2,ScrH()/2,(i+1)*100,Color(255,255,255))
+ 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)
+ for j = 0, 7 do
+ if(Game.Circles[i][j] != 0) then
+ local angle = (-j*45)+90
+ if(i == Game.SelectedCircle)then
+ angle = angle+angadd
+ end
+ local mul = (i+1)*100
+ if(Game.AnimateFallingColumnNum[j] and i > Game.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
+ radius = 40 - altraid
+ end
+
+ surface.DrawCircle(x,y,radius,Game.ColorFor(Game.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
+
+ --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]
+ for i = 0, 6 do
+ Game.Circles[Game.SelectedCircle][7-i]=Game.Circles[Game.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]
+ for i = 0, 6 do
+ Game.Circles[Game.SelectedCircle][i]=Game.Circles[Game.SelectedCircle][i+1]
+ end
+ Game.Circles[Game.SelectedCircle][7] = tmp
+ Game.Animateingringnum = -1
+ Game.Animateingdirection = 0
+ Game.ProcessMoved()
+ end
+ end
+ elseif(Game.AnimateFalling and CurTime() > Game.AnimateFallingStartTime + Game.ANIMATE_FALLING_DURATION) then
+ for k,v in pairs(Game.AnimateFallingColumnNum) do
+ if(v) then
+ for i = Game.AnimateFallingStartLvl[k], Game.numcircle-2 do
+ Game.Circles[i][k] = Game.Circles[i+1][k]
+ end
+ Game.Circles[Game.numcircle-1][k] = 0
+ end
+ end
+ for i = 0, 7 do
+ Game.AnimateFalling = false
+ Game.AnimateFallingColumnNum[i] = false
+ Game.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
+ end
+ end
+ end
+ Game.AnimateRemoveing = false
+ elseif(input.IsKeyDown(KEY_Q)) then
+ --Rotate stuff counter-clockwise
+ Game.Animateingringnum = Game.SelectedCircle
+ Game.Animateingdirection = 1
+ Game.Animateingstart = CurTime()
+ elseif(input.IsKeyDown(KEY_E)) then
+ --Rotate stuff clockwise
+ Game.Animateingringnum = Game.SelectedCircle
+ Game.Animateingdirection = -1
+ Game.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
+ if(offset > (100*(i+1))-50 and offset < (100*(1+i))+50) then
+ Game.SelectedCircle = i
+ end
+ end
+ end
+
+
+ if(input.IsMouseDown(MOUSE_RIGHT)) then
+ self.Score = 0
+ self.scoreboard:Remove()
+ end
+end
+
+--What to do when anything moved
+Game.ProcessMoved = function()
+ --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]
+ if(tomatch == 0) then continue end
+ local ismatching = true
+ for k = 0, 2 do
+ if(Game.Circles[j+k][i] != tomatch) then
+ ismatching = false
+ break
+ end
+ end
+ if(ismatching) then
+ --PrintTable(Game.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()
+ end
+ end
+ end
+ end
+
+ --Next, check to see if anything is 3 in a row
+ for i = 0, Game.numcircle-1 do
+ for j = 0, 7 do
+ local tomatch = Game.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
+ ismatching = false
+ break
+ end
+ end
+ if(ismatching) then
+ --PrintTable(Game.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()
+ end
+ end
+ end
+ end
+
+ --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
+ --return
+ break
+ end
+ end
+ end
+ end
+ end
+end
+
+Game.ColorFor = function(num)
+ if(num == 0) then return nil end
+ 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
end