-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFactory.cs
66 lines (54 loc) · 1.76 KB
/
Factory.cs
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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace AzulApp
{
class Factory : Panel
{
private readonly TileButton[] buttons;
private readonly Game model;
public int Index { get; }
public Factory(Game m, int ndx)
{
model = m;
Index = ndx;
SuspendLayout();
BackgroundImageLayout = ImageLayout.Zoom;
BackgroundImage = Properties.Resources.factory;
Name = "Factory" + Index;
Size = new Size(240, 240);
buttons = new TileButton[4];
for (int i = 0; i < 4; ++i)
{
buttons[i] = new TileButton();
Controls.Add(buttons[i]);
int x = (i % 2 == 0) ? FIRST_POSITION : SECOND_POSITION;
int y = (i < 2) ? FIRST_POSITION : SECOND_POSITION;
buttons[i].Location = new Point(x, y);
buttons[i].Click += new EventHandler(model.PickTiles);
}
ResumeLayout();
}
/**
* Removes old tiles (if any) and creates new ones; updates buttons to match.
*/
public void UpdateTiles()
{
SuspendLayout();
// Disable buttons
foreach (TileButton b in buttons)
{
b.Enabled = false;
b.TileColor = null;
}
// Get new tiles and enable buttons (as appropriate)
TileCollection tc = model.getFactoryTiles(Index);
for (int i = 0; i < tc.Count; ++i)
{
buttons[i].TileColor = tc[i];
}
ResumeLayout();
}
private static readonly int FIRST_POSITION = 57, SECOND_POSITION = 123;
}
}