1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
--The connet the dots spell game
print("Hi from connectthedots.lua")
--Minigame is held in self.dots, each dot is a table,
--dot[num] = {dot x, dot y, {{armor_start_angle,armor_end_angle},{armor_start_angle,armor_end_angle}}}
Game.Cast = function(self,difficulty)
print("Cast with dificulty: " .. difficulty)
self.Score = nil
--Create a dummy panel so that the mouse is trapped, untrap it when it right clicks
scoreboard = vgui.Create("MBFrame")
if(!scoreboard) then return end
scoreboard:SetPos(0,0)
scoreboard:SetSize(0,0)
scoreboard:MakePopup()
self.scoreboard = scoreboard
--Create the minigame
end
Game.Draw = function(self)
if not input.IsKeyTrapping() then
input.StartKeyTrapping()
end
draw.DrawText( "You're casting a spell!", "TargetID", ScrW() * 0.5, ScrH() * 0.25, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER )
print("X:" .. gui.MouseX() .. " Y:" .. gui.MouseY())
if(input.IsMouseDown(MOUSE_RIGHT)) then
self.Score = 100
self.scoreboard:Remove()
end
end
--A basic dot, can be accessed from anywhere.
Game.AddRegDot = function(self)
--Find the most recently added dot
local fd = table.GetFirstValue(self.dots)
local armors = {}
for k,v in pairs(fd[2]) do
armors[k] = v
end
--Since armor can have multiple segments, pick all open segments, and find the surface area they occupy.
local totalsurface = 360
for k,v in pairs(armors) do
print("Found armor between " .. v[1] .. " and " .. v[2])
totalsurface = totalsurface - (v[1]-v[2])
end
print("Looks like there's " .. totalsurface .. " of avaliable angle!")
--Pick a number between 0 and totalsurface that represents how much un-armored space is before us
local position = math.random(totalsurface)
--Find the angles that we will add outselves between
for k,v in pairs(fd[2]) do
if(position > v[1]) then
position += v[2]-v[1]
end
end
print("Adding new dot at an angle of " .. position)
--Pick a random distance from this dot to the screen edge, and put a dot there
local rand = 0
--If we're in the first quadrent
if(math.cos(position) > 0) then
rand = math.random(fd[0],ScrW())
end
Game.AddDots = function(self)
print("Add dots function called!")
end
Game.InstantFail = function(self)
self.Score = 0
end
|