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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications
{
[Launcher("ShiftSweeper", true, "shiftsweeper", "Games")]
[RequiresUpgrade("shiftsweeper")]
[WinOpen("shiftsweeper")]
[DefaultIcon("iconShiftSweeper")]
public partial class ShiftSweeper : UserControl, IShiftOSWindow
{
private bool gameplayed = false;
private int mineCount = 0;
private int[,] minemap;
public ShiftSweeper()
{
InitializeComponent();
}
public void OnLoad()
{
buttonE.Visible = true;
buttonM.Visible = ShiftoriumFrontend.UpgradeInstalled("shiftsweeper_medium");
buttonH.Visible = ShiftoriumFrontend.UpgradeInstalled("shiftsweeper_hard");
}
public void OnSkinLoad() { }
public bool OnUnload() { return true; }
public void OnUpgrade()
{
}
private void buttonE_Click(object sender, EventArgs e)
{
startGame(0);
}
private void startGame(int d)
{
switch (d)
{
case 0:
mineCount = 10;
minefieldPanel.ColumnCount = 9;
minefieldPanel.RowCount = 9;
break;
default:
throw new NullReferenceException();
}
makegrid();
}
private void makegrid()
{
Random rnd1 = new Random();
minemap = new int[minefieldPanel.ColumnCount, minefieldPanel.RowCount];
for (int x = 0; x < minefieldPanel.ColumnCount; x++)
{
for (int y = 0; y < minefieldPanel.RowCount; y++)
{
minemap[x, y] = 0;
minefieldPanel.Controls.Add(makeButton(x, y), x, y);
}
}
}
private Button makeButton(int col, int row)
{
Button bttn = new Button();
bttn.Text = "";
bttn.Name = col.ToString() + " " + row.ToString();
Controls.AddRange(new System.Windows.Forms.Control[] { bttn, });
bttn.Click += new System.EventHandler(bttnOnclick);
bttn.MouseDown += new MouseEventHandler(mouseDwn);
bttn.MouseUp += new MouseEventHandler(mauseUp);
bttn.MouseHover += new EventHandler(mauseHov);
bttn.BackgroundImage = Properties.Resources.SweeperTileBlock;
return bttn;
}
private void mauseHov(object sender, EventArgs e)
{
pictureBox1.BackgroundImage = Properties.Resources.SweeperNormalFace;
}
private void mauseUp(object sender, MouseEventArgs e)
{
pictureBox1.BackgroundImage = Properties.Resources.SweeperNormalFace;
}
private void mouseDwn(object sender, EventArgs e)
{
pictureBox1.BackgroundImage = Properties.Resources.SweeperClickFace;
}
private void bttnOnclick(object sender, EventArgs e)
{
}
}
}
|