From: <kro...@us...> - 2008-03-29 20:13:52
|
Revision: 1559 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1559&view=rev Author: kroko_koenig Date: 2008-03-29 13:13:49 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Update version to 0.2 for release Modified Paths: -------------- trunk/plugins/My Minesweeper/Release/language/MyMinesweeper/strings_de.xml trunk/plugins/My Minesweeper/Release/language/MyMinesweeper/strings_en.xml trunk/plugins/My Minesweeper/Source/MyMinesweeper/LocalizeStrings.cs trunk/plugins/My Minesweeper/Source/MyMinesweeper/MyMinesweeper.cs trunk/plugins/My Minesweeper/readme.txt Added Paths: ----------- trunk/plugins/My Minesweeper/Release/plugins/Windows/MyMinesweeper.dll Modified: trunk/plugins/My Minesweeper/Release/language/MyMinesweeper/strings_de.xml =================================================================== --- trunk/plugins/My Minesweeper/Release/language/MyMinesweeper/strings_de.xml 2008-03-29 19:33:18 UTC (rev 1558) +++ trunk/plugins/My Minesweeper/Release/language/MyMinesweeper/strings_de.xml 2008-03-29 20:13:49 UTC (rev 1559) @@ -25,7 +25,7 @@ 0 neues Spiel Viel Glück -Mark König 2007 (kroko)</String> +Mark König 2008 (kroko)</String> </Section> </Language> \ No newline at end of file Modified: trunk/plugins/My Minesweeper/Release/language/MyMinesweeper/strings_en.xml =================================================================== --- trunk/plugins/My Minesweeper/Release/language/MyMinesweeper/strings_en.xml 2008-03-29 19:33:18 UTC (rev 1558) +++ trunk/plugins/My Minesweeper/Release/language/MyMinesweeper/strings_en.xml 2008-03-29 20:13:49 UTC (rev 1559) @@ -25,6 +25,6 @@ 0 new game Good luck -Mark Koenig 2007 (kroko)</String> +Mark Koenig 2008 (kroko)</String> </Section> </Language> \ No newline at end of file Added: trunk/plugins/My Minesweeper/Release/plugins/Windows/MyMinesweeper.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/My Minesweeper/Release/plugins/Windows/MyMinesweeper.dll ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/plugins/My Minesweeper/Source/MyMinesweeper/LocalizeStrings.cs =================================================================== --- trunk/plugins/My Minesweeper/Source/MyMinesweeper/LocalizeStrings.cs 2008-03-29 19:33:18 UTC (rev 1558) +++ trunk/plugins/My Minesweeper/Source/MyMinesweeper/LocalizeStrings.cs 2008-03-29 20:13:49 UTC (rev 1559) @@ -1,7 +1,7 @@ -#region Copyright (C) 2005-2007 Team MediaPortal +#region Copyright (C) 2005-2008 Team MediaPortal /* - * Copyright (C) 2005-2007 Team MediaPortal + * Copyright (C) 2005-2008 Team MediaPortal * http://www.team-mediaportal.com * * This Program is free software; you can redistribute it and/or modify Modified: trunk/plugins/My Minesweeper/Source/MyMinesweeper/MyMinesweeper.cs =================================================================== --- trunk/plugins/My Minesweeper/Source/MyMinesweeper/MyMinesweeper.cs 2008-03-29 19:33:18 UTC (rev 1558) +++ trunk/plugins/My Minesweeper/Source/MyMinesweeper/MyMinesweeper.cs 2008-03-29 20:13:49 UTC (rev 1559) @@ -1,7 +1,7 @@ -#region Copyright (C) 2005-2007 Team MediaPortal +#region Copyright (C) 2005-2008 Team MediaPortal /* - * Copyright (C) 2005-2007 Team MediaPortal + * Copyright (C) 2005-2008 Team MediaPortal * http://www.team-mediaportal.com * * This Program is free software; you can redistribute it and/or modify @@ -38,1070 +38,1070 @@ namespace MediaPortal.GUI.MyMinesweeper { - [PluginIcons("MyMinesweeper.minesweeper.png", "MyMinesweeper.minesweeperDisabled.png")] - public class MyMinesweeperGUI : GUIWindow, ISetupForm + [PluginIcons("MyMinesweeper.minesweeper.png", "MyMinesweeper.minesweeperDisabled.png")] + public class MyMinesweeperGUI : GUIWindow, ISetupForm + { + #region enums + + private enum Level { - #region enums + Easy = 0, + Medium = 1, + Hard = 2 + } - private enum Level - { - Easy = 0, - Medium = 1, - Hard = 2 - } + #endregion - #endregion + #region SkinControl - #region SkinControl + [SkinControlAttribute(2)] + protected GUIButtonControl btnStart = null; + [SkinControlAttribute(4)] + protected GUIButtonControl btnLevel = null; + [SkinControlAttribute(5)] + protected GUIToggleButtonControl btnSound = null; + [SkinControlAttribute(10)] + protected GUIButtonControl btnWhatsThis = null; - [SkinControlAttribute(2)] - protected GUIButtonControl btnStart = null; - [SkinControlAttribute(4)] - protected GUIButtonControl btnLevel = null; - [SkinControlAttribute(5)] - protected GUIToggleButtonControl btnSound = null; - [SkinControlAttribute(10)] - protected GUIButtonControl btnWhatsThis = null; + #endregion - #endregion + #region Private variables - #region Private variables + Level _currentLevel = Level.Easy; + bool GameOver = false; // not game over + bool GameON = false; // Game is on + bool _soundOn = true; - Level _currentLevel = Level.Easy; - bool GameOver = false; // not game over - bool GameON = false; // Game is on - bool _soundOn = true; + int[,] board = new int[30, 30]; + int[,] bombs = new int[30, 30]; + bool initBoard = false; - int[,] board = new int[30, 30]; - int[,] bombs = new int[30, 30]; - bool initBoard = false; + int bx = 10; + int by = 10; + int bcnt = 10; - int bx = 10; - int by = 10; - int bcnt = 10; + int time = 0; + string time_rec = "999"; + string time_name = "unknown"; - int time = 0; - string time_rec = "999"; - string time_name = "unknown"; + string t_pro; + string t_nor; + string t_am; - string t_pro; - string t_nor; - string t_am; + string n_pro; + string n_nor; + string n_am; - string n_pro; - string n_nor; - string n_am; + int ID = 0; - int ID = 0; + private static OnActionHandler ah; - private static OnActionHandler ah; + // game ticker for the timer + private System.Windows.Forms.Timer _Game = new System.Windows.Forms.Timer(); - // game ticker for the timer - private System.Windows.Forms.Timer _Game = new System.Windows.Forms.Timer(); + int[] posX = { -1, 0, 1, -1, 1, -1, 0, 1 }; + int[] posY = { -1, -1, -1, 0, 0, 1, 1, 1 }; - int[] posX = { -1, 0, 1, -1, 1, -1 , 0 , 1 }; - int[] posY = { -1, -1, -1, 0, 0, 1, 1, 1 }; + #endregion - #endregion + #region ISetupForm Members - #region ISetupForm Members + // Returns the name of the plugin which is shown in the plugin menu + public string PluginName() + { + return "My Minesweeper"; + } - // Returns the name of the plugin which is shown in the plugin menu - public string PluginName() - { - return "My Minesweeper"; - } + // Returns the description of the plugin is shown in the plugin menu + public string Description() + { + return "My Minesweeper"; + } - // Returns the description of the plugin is shown in the plugin menu - public string Description() - { - return "My Minesweeper"; - } + // Returns the author of the plugin which is shown in the plugin menu + public string Author() + { + return "Mark Koenig 2008 (kroko)"; + } - // Returns the author of the plugin which is shown in the plugin menu - public string Author() - { - return "Mark Koenig (kroko)"; - } + // show the setup dialog + public void ShowPlugin() + { + MessageBox.Show("Nothing to configure, this is just an example"); + } - // show the setup dialog - public void ShowPlugin() - { - MessageBox.Show("Nothing to configure, this is just an example"); - } + // Indicates whether plugin can be enabled/disabled + public bool CanEnable() + { + return true; + } - // Indicates whether plugin can be enabled/disabled - public bool CanEnable() - { - return true; - } + // get ID of windowplugin belonging to this setup + public int GetWindowId() + { + return 32327501; + } - // get ID of windowplugin belonging to this setup - public int GetWindowId() - { - return 32327501; - } + // Indicates if plugin is enabled by default; + public bool DefaultEnabled() + { + return true; + } - // Indicates if plugin is enabled by default; - public bool DefaultEnabled() - { - return true; - } + // indicates if a plugin has its own setup screen + public bool HasSetup() + { + return false; + } - // indicates if a plugin has its own setup screen - public bool HasSetup() - { - return false; - } + /// <summary> + /// If the plugin should have its own button on the main menu of MediaPortal then it + /// should return true to this method, otherwise if it should not be on home + /// it should return false + /// </summary> + /// <param name="strButtonText">text the button should have</param> + /// <param name="strButtonImage">image for the button, or empty for default</param> + /// <param name="strButtonImageFocus">image for the button, or empty for default</param> + /// <param name="strPictureImage">subpicture for the button or empty for none</param> + /// <returns>true : plugin needs its own button on home + /// false : plugin does not need its own button on home</returns> - /// <summary> - /// If the plugin should have its own button on the main menu of MediaPortal then it - /// should return true to this method, otherwise if it should not be on home - /// it should return false - /// </summary> - /// <param name="strButtonText">text the button should have</param> - /// <param name="strButtonImage">image for the button, or empty for default</param> - /// <param name="strButtonImageFocus">image for the button, or empty for default</param> - /// <param name="strPictureImage">subpicture for the button or empty for none</param> - /// <returns>true : plugin needs its own button on home - /// false : plugin does not need its own button on home</returns> + public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) + { + strButtonText = MyMinesweeper.GUILocalizeStrings.Get(0); ; + strButtonImage = String.Empty; + strButtonImageFocus = String.Empty; + strPictureImage = @"hover_my_minesweeper.png"; + return true; + } - public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) - { - strButtonText = MyMinesweeper.GUILocalizeStrings.Get(0); ; - strButtonImage = String.Empty; - strButtonImageFocus = String.Empty; - strPictureImage = @"hover_my_minesweeper.png"; - return true; - } + #endregion - #endregion + #region Overrides - #region Overrides + public override int GetID + { + get + { + return 32327501; + } + set + { + base.GetID = value; + } + } - public override int GetID - { - get - { - return 32327501; - } - set - { - base.GetID = value; - } - } + public override bool Init() + { + MyMinesweeper.GUILocalizeStrings.Load(GUI.Library.GUILocalizeStrings.CurrentLanguage()); - public override bool Init() - { - MyMinesweeper.GUILocalizeStrings.Load(GUI.Library.GUILocalizeStrings.CurrentLanguage()); + if (ah == null) ah = new OnActionHandler(OnAction2); - if (ah == null) ah = new OnActionHandler(OnAction2); + bool result = Load(GUIGraphicsContext.Skin + @"\MyMinesweeper.xml"); + return result; + } - bool result = Load(GUIGraphicsContext.Skin + @"\MyMinesweeper.xml"); - return result; - } + public override bool OnMessage(GUIMessage message) + { + if (message.Message == GUI.Library.GUIMessage.MessageType.GUI_MSG_SETFOCUS) + { + ID = message.TargetControlId; + } + return base.OnMessage(message); + } - public override bool OnMessage(GUIMessage message) - { - if (message.Message == GUI.Library.GUIMessage.MessageType.GUI_MSG_SETFOCUS) - { - ID = message.TargetControlId; - } - return base.OnMessage(message); - } + protected override void OnPageLoad() + { - protected override void OnPageLoad() - { + // start game ticker + _Game.Interval = 1000; + _Game.Tick += new EventHandler(_Game_Tick); + _Game.Start(); - // start game ticker - _Game.Interval = 1000; - _Game.Tick += new EventHandler(_Game_Tick); - _Game.Start(); + base.OnPageLoad(); - base.OnPageLoad(); + LoadSettings(); - LoadSettings(); + OnBtnStart(); - OnBtnStart(); + GUIGraphicsContext.OnNewAction -= ah; + GUIGraphicsContext.OnNewAction += ah; - GUIGraphicsContext.OnNewAction -= ah; - GUIGraphicsContext.OnNewAction += ah; + GUIPropertyManager.SetProperty("#minesweeper_bombs", "Bombs: " + bcnt.ToString()); + GUIPropertyManager.SetProperty("#minesweeper_seconds", "Time: " + time.ToString()); - GUIPropertyManager.SetProperty("#minesweeper_bombs", "Bombs: " + bcnt.ToString()); - GUIPropertyManager.SetProperty("#minesweeper_seconds", "Time: " + time.ToString()); + GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\smile.png"); - GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\smile.png"); + // set localized labels for static controls + GUIPropertyManager.SetProperty("#header_label", MyMinesweeper.GUILocalizeStrings.Get(0)); // MyMinesweeper + GUIControl.SetControlLabel(GetID, btnStart.GetID, MyMinesweeper.GUILocalizeStrings.Get(1)); // New Game + GUIControl.SetControlLabel(GetID, btnSound.GetID, MyMinesweeper.GUILocalizeStrings.Get(9)); // Sounds + GUIControl.SetControlLabel(GetID, btnWhatsThis.GetID, MyMinesweeper.GUILocalizeStrings.Get(31)); // What is MyMinesweeper? - // set localized labels for static controls - GUIPropertyManager.SetProperty("#header_label", MyMinesweeper.GUILocalizeStrings.Get(0)); // MyMinesweeper - GUIControl.SetControlLabel(GetID, btnStart.GetID, MyMinesweeper.GUILocalizeStrings.Get(1)); // New Game - GUIControl.SetControlLabel(GetID, btnSound.GetID, MyMinesweeper.GUILocalizeStrings.Get(9)); // Sounds - GUIControl.SetControlLabel(GetID, btnWhatsThis.GetID, MyMinesweeper.GUILocalizeStrings.Get(31)); // What is MyMinesweeper? + UpdateButtonStates(); + } - UpdateButtonStates(); - } + protected override void OnPageDestroy(int new_windowId) + { + _Game.Stop(); + _Game.Tick -= new EventHandler(_Game_Tick); - protected override void OnPageDestroy(int new_windowId) - { - _Game.Stop(); - _Game.Tick -= new EventHandler(_Game_Tick); + SaveSettings(); + } - SaveSettings(); - } + protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) + { + if ((controlId >= 500) && (!GameOver)) + { + GameON = true; - protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) - { - if ((controlId >= 500) && (!GameOver)) - { - GameON = true; + int y = controlId - 500; + y = (int)y / 30; - int y = controlId - 500; - y = (int)y / 30; + int x = controlId - 500; + x = x - (y * 30); - int x = controlId - 500; - x = x - (y * 30); + x = x - 1; + y = y - 1; - x = x - 1; - y = y - 1; + if ((x >= 0) && (y >= 0) && (x < bx) && (y < by)) + { + Point pt = new Point(); + pt.X = x; + pt.Y = y; - if ((x >= 0) && (y >= 0) && (x < bx) && (y < by)) - { - Point pt = new Point(); - pt.X = x; - pt.Y = y; - - SetPlace(pt); - } - } - - - if (control == btnWhatsThis) - { - OnBtnWhatsThis(); - } - if (control == btnLevel) - { - OnBtnLevel(); - } - if (control == btnStart) - { - OnBtnStart(); - } - if (control == btnSound ) - { - OnBtnSound(); - } - + SetPlace(pt); } + } - protected override void OnShowContextMenu() - { - base.OnShowContextMenu(); - } - #endregion + if (control == btnWhatsThis) + { + OnBtnWhatsThis(); + } + if (control == btnLevel) + { + OnBtnLevel(); + } + if (control == btnStart) + { + OnBtnStart(); + } + if (control == btnSound) + { + OnBtnSound(); + } - #region Implementation + } - private void OnBtnStart() - { - GameOver = false; - GameON = false; - time = 0; - ID = 0; + protected override void OnShowContextMenu() + { + base.OnShowContextMenu(); + } - GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\smile.png"); + #endregion - if (_currentLevel == Level.Easy) - { - bx = 10; - by = 10; - bcnt = 10; - time_rec = t_am; - time_name = n_am; - } - if (_currentLevel == Level.Medium) - { - bx = 15; - by = 15; - bcnt = 40; - time_rec = t_nor; - time_name = n_nor; - } - if (_currentLevel == Level.Hard) - { - bx = 20; - by = 20; - bcnt = 100; - time_rec = t_pro; - time_name = n_pro; - } + #region Implementation - GUIPropertyManager.SetProperty("#minesweeper_record", "Record: " + time_rec + "s - " + time_name); + private void OnBtnStart() + { + GameOver = false; + GameON = false; + time = 0; + ID = 0; - // remove controls from form - try - { - for (int i = 500; i < 1180; i++) - { - Remove(i); - } - } - catch - { - - } + GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\smile.png"); - for (int i = 0; i < 30; i++) - { - for (int j = 0; j < 30; j++) - { // 20 = not checked - board[i, j] = 20; - // no bombs - bombs[i, j] = 0; - } - } + if (_currentLevel == Level.Easy) + { + bx = 10; + by = 10; + bcnt = 10; + time_rec = t_am; + time_name = n_am; + } + if (_currentLevel == Level.Medium) + { + bx = 15; + by = 15; + bcnt = 40; + time_rec = t_nor; + time_name = n_nor; + } + if (_currentLevel == Level.Hard) + { + bx = 20; + by = 20; + bcnt = 100; + time_rec = t_pro; + time_name = n_pro; + } - Random rnd = new Random(); + GUIPropertyManager.SetProperty("#minesweeper_record", "Record: " + time_rec + "s - " + time_name); - for (int i = 0; i < bcnt; i++) - { - int x = rnd.Next(0, bx); - int y = rnd.Next(0, by); - if (bombs[x, y] == 1) - { // already bomb - i = i - 1; - } - else - { - Point px = new Point(); - px.X = x; - px.Y = y; - if (GetValue(px) < 4) - { - bombs[x, y] = 1; - } - else - { - i = i - 1; - } - } + // remove controls from form + try + { + for (int i = 500; i < 1180; i++) + { + Remove(i); + } + } + catch + { - } + } - Init_board(); + for (int i = 0; i < 30; i++) + { + for (int j = 0; j < 30; j++) + { // 20 = not checked + board[i, j] = 20; + // no bombs + bombs[i, j] = 0; } + } - private void OnBtnLevel() - { //Choose level for the game - { - switch (_currentLevel) - { - case Level.Easy: - _currentLevel = Level.Medium; - break; - case Level.Medium: - _currentLevel = Level.Hard; - break; - case Level.Hard: - _currentLevel = Level.Easy; - break; - } + Random rnd = new Random(); - OnBtnStart(); - - UpdateButtonStates(); - } + for (int i = 0; i < bcnt; i++) + { + int x = rnd.Next(0, bx); + int y = rnd.Next(0, by); + if (bombs[x, y] == 1) + { // already bomb + i = i - 1; } - - private void OnBtnSound() + else { - _soundOn = btnSound.Selected; - UpdateButtonStates(); + Point px = new Point(); + px.X = x; + px.Y = y; + if (GetValue(px) < 4) + { + bombs[x, y] = 1; + } + else + { + i = i - 1; + } } - private void OnBtnWhatsThis() - { - GUIDialogText dlg = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT); - dlg.SetHeading(MyMinesweeper.GUILocalizeStrings.Get(31)); // help dialog heading - dlg.SetText(MyMinesweeper.GUILocalizeStrings.Get(32)); // help dialog text - dlg.DoModal(GetID); - } + } - private void OnRenderSound(string strFilePath) + Init_board(); + } + + private void OnBtnLevel() + { //Choose level for the game + { + switch (_currentLevel) { - if (_soundOn) - { - MediaPortal.Util.Utils.PlaySound(strFilePath, false, true); - } + case Level.Easy: + _currentLevel = Level.Medium; + break; + case Level.Medium: + _currentLevel = Level.Hard; + break; + case Level.Hard: + _currentLevel = Level.Easy; + break; } - private void UpdateButtonStates() - { - // enable/disable buttons - btnSound.Selected = _soundOn; + OnBtnStart(); - // refresh label for btnLevel - string strLine = MyMinesweeper.GUILocalizeStrings.Get(10); // Level: - switch (_currentLevel) - { - case Level.Easy: - strLine += MyMinesweeper.GUILocalizeStrings.Get(11); // easy - break; - case Level.Medium: - strLine += MyMinesweeper.GUILocalizeStrings.Get(12); // medium - break; - case Level.Hard: - strLine += MyMinesweeper.GUILocalizeStrings.Get(13); // difficult - break; - } - GUIControl.SetControlLabel(GetID, btnLevel.GetID, strLine); + UpdateButtonStates(); + } + } - // refresh label for btnMode - strLine = MyMinesweeper.GUILocalizeStrings.Get(20); // Mode: Play vs + private void OnBtnSound() + { + _soundOn = btnSound.Selected; + UpdateButtonStates(); + } - } + private void OnBtnWhatsThis() + { + GUIDialogText dlg = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT); + dlg.SetHeading(MyMinesweeper.GUILocalizeStrings.Get(31)); // help dialog heading + dlg.SetText(MyMinesweeper.GUILocalizeStrings.Get(32)); // help dialog text + dlg.DoModal(GetID); + } - #endregion + private void OnRenderSound(string strFilePath) + { + if (_soundOn) + { + MediaPortal.Util.Utils.PlaySound(strFilePath, false, true); + } + } - public void Dispose() - { - _Game.Stop(); - _Game.Tick -= new EventHandler(_Game_Tick); - } + private void UpdateButtonStates() + { + // enable/disable buttons + btnSound.Selected = _soundOn; - #region Actions + // refresh label for btnLevel + string strLine = MyMinesweeper.GUILocalizeStrings.Get(10); // Level: + switch (_currentLevel) + { + case Level.Easy: + strLine += MyMinesweeper.GUILocalizeStrings.Get(11); // easy + break; + case Level.Medium: + strLine += MyMinesweeper.GUILocalizeStrings.Get(12); // medium + break; + case Level.Hard: + strLine += MyMinesweeper.GUILocalizeStrings.Get(13); // difficult + break; + } + GUIControl.SetControlLabel(GetID, btnLevel.GetID, strLine); - public override void OnAction(Action action) - { - base.OnAction(action); - } + // refresh label for btnMode + strLine = MyMinesweeper.GUILocalizeStrings.Get(20); // Mode: Play vs - public void OnAction2(Action action) - { - switch (action.wID) - { - case Action.ActionType.ACTION_KEY_PRESSED: - switch (action.m_key.KeyChar) - { - case '1': - SetBomb(); - break; - case '2': - SetQuest(); - break; - case '3': - Check9(); - break; - case '0': - OnBtnStart(); - break; - } - break; - } - } + } - #endregion + #endregion - private void CreateButton(int ID, int posx, int posy, int height, int width, string focusimg, string nofocusimg) - { - GUIButtonControl button = new GUIButtonControl(GetID, ID, posx, posy, width, height, focusimg, nofocusimg); - button.AllocResources(); - GUIControl btnControl = (GUIControl)button; - Add(ref btnControl); - } + public void Dispose() + { + _Game.Stop(); + _Game.Tick -= new EventHandler(_Game_Tick); + } - void _Game_Tick(object sender, EventArgs e) - { - if ((!GameOver) && (time<999) && (GameON == true)) - { - time++; - } - GUIPropertyManager.SetProperty("#minesweeper_seconds", "Time: " + time.ToString()); - GUIPropertyManager.SetProperty("#minesweeper_bombs", "Bombs: " + bcnt.ToString()); - } + #region Actions - private void Init_board() - { - // get position from the start button - int StartX = GetControl(1200).XPosition; - int StartY = GetControl(1200).YPosition; - // Disable level control - GUIControl.HideControl(GetID, 1200); + public override void OnAction(Action action) + { + base.OnAction(action); + } - try - { - int StartT = GetControl(500).XPosition; - } - catch - { - initBoard = false; - } + public void OnAction2(Action action) + { + switch (action.wID) + { + case Action.ActionType.ACTION_KEY_PRESSED: + switch (action.m_key.KeyChar) + { + case '1': + SetBomb(); + break; + case '2': + SetQuest(); + break; + case '3': + Check9(); + break; + case '0': + OnBtnStart(); + break; + } + break; + } + } - if (!initBoard) - { - initBoard = true; + #endregion - // set start button navigation - GetControl(2).SetNavigation(8, 4, 2, 531); + private void CreateButton(int ID, int posx, int posy, int height, int width, string focusimg, string nofocusimg) + { + GUIButtonControl button = new GUIButtonControl(GetID, ID, posx, posy, width, height, focusimg, nofocusimg); + button.AllocResources(); + GUIControl btnControl = (GUIControl)button; + Add(ref btnControl); + } - for (int y = 0; y < (by+2); y++) - { - for (int x = 0; x < (bx+2); x++) - { - int nr = 500 + x + (y * 30); + void _Game_Tick(object sender, EventArgs e) + { + if ((!GameOver) && (time < 999) && (GameON == true)) + { + time++; + } + GUIPropertyManager.SetProperty("#minesweeper_seconds", "Time: " + time.ToString()); + GUIPropertyManager.SetProperty("#minesweeper_bombs", "Bombs: " + bcnt.ToString()); + } - int xp = StartX + (20 * x); - int yp = StartY + (20 * y); + private void Init_board() + { + // get position from the start button + int StartX = GetControl(1200).XPosition; + int StartY = GetControl(1200).YPosition; + // Disable level control + GUIControl.HideControl(GetID, 1200); - //default navigation - int up = nr - 30; - int dn = nr + 30; - int le = nr - 1; - int ri = nr + 1; - //top bottom navigation - if ((y == 0) || (y==by+1)) - { - up = nr; - dn = nr; - le = nr; - ri = nr; - } - //left right navigation - if ((x == 0) || (x == bx + 1)) - { - up = nr; - dn = nr; - le = nr; - ri = nr; - } - //left to start - if (x == 1) - { - le = 2; - } - // right stop - if (x == bx) - { - ri = nr; - } - // top stop - if (y == 1) - { - up = nr; - } - // right stop - if (y == by) - { - dn = nr; - } + try + { + int StartT = GetControl(500).XPosition; + } + catch + { + initBoard = false; + } - CreateButton(nr, xp, yp, 20, 20, "#F" + nr, "#NF" + nr); - GetControl(nr).SetNavigation(up, dn, le, ri); + if (!initBoard) + { + initBoard = true; - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\unchecksel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\uncheckunsel.png"); - - } - } - for (int x = 0; x < (bx + 2); x++) - { - int nr = 500 + x; - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\topborder.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\topborder.png"); - } - for (int x = 0; x < (bx + 2); x++) - { - int nr = 500 + (30*(by+1)) + x; - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\bottomborder.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\bottomborder.png"); - } - for (int y = 0; y < by; y++) - { - int nr = 530 + (y*30); - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\leftborder.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\leftborder.png"); - nr = nr + bx + 1; - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\rightborder.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\rightborder.png"); - } - GUIPropertyManager.SetProperty("#F" + 500, @"\Minesweeper\Board\topleftcorner.png"); - GUIPropertyManager.SetProperty("#NF" + 500, @"\Minesweeper\Board\topleftcorner.png"); - GUIPropertyManager.SetProperty("#F" + (501+bx), @"\Minesweeper\Board\toprightcorner.png"); - GUIPropertyManager.SetProperty("#NF" + (501+bx), @"\Minesweeper\Board\toprightcorner.png"); - - GUIPropertyManager.SetProperty("#F" + (500+(30*(by+1))), @"\Minesweeper\Board\bottomleftcorner.png"); - GUIPropertyManager.SetProperty("#NF" + (500+(30*(by+1))), @"\Minesweeper\Board\bottomleftcorner.png"); - GUIPropertyManager.SetProperty("#F" + (501+(30*(by+1)+bx)), @"\Minesweeper\Board\bottomrightcorner.png"); - GUIPropertyManager.SetProperty("#NF" + (501+(30*(by+1)+bx)), @"\Minesweeper\Board\bottomrightcorner.png"); - } + // set start button navigation + GetControl(2).SetNavigation(8, 4, 2, 531); - GUIControl.FocusControl(GetID, 531); - } - - private void SetPlace(Point pos) + for (int y = 0; y < (by + 2); y++) { - if ((bombs[pos.X, pos.Y] != 0) && (board[pos.X, pos.Y] != 9)) - { - GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\sad.png"); - GameOver = true; - OnRenderSound ("bomb.wav"); - EndGame(); - board[pos.X, pos.Y] = 12; - SetPoint(pos); - } - if (board[pos.X, pos.Y] == 20) - { - board[pos.X, pos.Y] = GetValue(pos); - SetPoint(pos); + for (int x = 0; x < (bx + 2); x++) + { + int nr = 500 + x + (y * 30); - OnRenderSound("tick.wav"); + int xp = StartX + (20 * x); + int yp = StartY + (20 * y); - if (board[pos.X, pos.Y] == 0) - { - EmptyPos(); - } - if (Finished() == true) - { - CheckAllBoms(); - GameOver = true; - GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\cool.png"); - CheckHiScore(); - } - } - } - - private void SetPoint(Point pos) - { - int nr = 531 + (pos.Y * 30) + pos.X; - - if (board[pos.X, pos.Y] == 0) + //default navigation + int up = nr - 30; + int dn = nr + 30; + int le = nr - 1; + int ri = nr + 1; + //top bottom navigation + if ((y == 0) || (y == by + 1)) { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check0sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check0unsel.png"); + up = nr; + dn = nr; + le = nr; + ri = nr; } - if (board[pos.X, pos.Y] == 1) + //left right navigation + if ((x == 0) || (x == bx + 1)) { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check1sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check1unsel.png"); + up = nr; + dn = nr; + le = nr; + ri = nr; } - if (board[pos.X, pos.Y] == 2) + //left to start + if (x == 1) { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check2sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check2unsel.png"); + le = 2; } - if (board[pos.X, pos.Y] == 3) + // right stop + if (x == bx) { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check3sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check3unsel.png"); + ri = nr; } - if (board[pos.X, pos.Y] == 4) + // top stop + if (y == 1) { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check4sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check4unsel.png"); + up = nr; } - if (board[pos.X, pos.Y] == 5) + // right stop + if (y == by) { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check5sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check5unsel.png"); + dn = nr; } - if (board[pos.X, pos.Y] == 6) - { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check6sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check6unsel.png"); - } - if (board[pos.X, pos.Y] == 7) - { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check7sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check7unsel.png"); - } - if (board[pos.X, pos.Y] == 8) - { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check8sel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check8unsel.png"); - } - if (board[pos.X, pos.Y] == 9) - { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\markedasbomsel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\markedasbom.png"); - } - if (board[pos.X, pos.Y] == 10) - { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\questionmarksel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\questionmark.png"); - } - if (board[pos.X, pos.Y] == 11) - { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\bomb.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\bomb.png"); - } - if (board[pos.X, pos.Y] == 12) - { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\bombexplode.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\bombexplode.png"); - } - if (board[pos.X, pos.Y] == 20) - { - GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\unchecksel.png"); - GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\uncheckunsel.png"); - } - } - private int GetValue(Point pos) - { - int val=0; + CreateButton(nr, xp, yp, 20, 20, "#F" + nr, "#NF" + nr); + GetControl(nr).SetNavigation(up, dn, le, ri); - for (int i = 0; i < 8; i++) - { - int x = pos.X + posX[i]; - int y = pos.Y + posY[i]; - if ((x>=0) && (y>=0) && (x<bx) && (y<by)) - { - if (bombs[x, y] != 0) - { - val++; - } - } + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\unchecksel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\uncheckunsel.png"); - } - return val; + } } - - private int GetMBombs(Point pos) + for (int x = 0; x < (bx + 2); x++) { - int val = 0; + int nr = 500 + x; + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\topborder.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\topborder.png"); + } + for (int x = 0; x < (bx + 2); x++) + { + int nr = 500 + (30 * (by + 1)) + x; + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\bottomborder.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\bottomborder.png"); + } + for (int y = 0; y < by; y++) + { + int nr = 530 + (y * 30); + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\leftborder.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\leftborder.png"); + nr = nr + bx + 1; + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\rightborder.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\rightborder.png"); + } + GUIPropertyManager.SetProperty("#F" + 500, @"\Minesweeper\Board\topleftcorner.png"); + GUIPropertyManager.SetProperty("#NF" + 500, @"\Minesweeper\Board\topleftcorner.png"); + GUIPropertyManager.SetProperty("#F" + (501 + bx), @"\Minesweeper\Board\toprightcorner.png"); + GUIPropertyManager.SetProperty("#NF" + (501 + bx), @"\Minesweeper\Board\toprightcorner.png"); - for (int i = 0; i < 8; i++) - { - int x = pos.X + posX[i]; - int y = pos.Y + posY[i]; - if ((x >= 0) && (y >= 0) && (x < 30) && (y < 30)) - { - if (board[x, y] == 9) - { - val++; - } - } + GUIPropertyManager.SetProperty("#F" + (500 + (30 * (by + 1))), @"\Minesweeper\Board\bottomleftcorner.png"); + GUIPropertyManager.SetProperty("#NF" + (500 + (30 * (by + 1))), @"\Minesweeper\Board\bottomleftcorner.png"); + GUIPropertyManager.SetProperty("#F" + (501 + (30 * (by + 1) + bx)), @"\Minesweeper\Board\bottomrightcorner.png"); + GUIPropertyManager.SetProperty("#NF" + (501 + (30 * (by + 1) + bx)), @"\Minesweeper\Board\bottomrightcorner.png"); + } - } - return val; - } + GUIControl.FocusControl(GetID, 531); + } - private void EndGame() + private void SetPlace(Point pos) + { + if ((bombs[pos.X, pos.Y] != 0) && (board[pos.X, pos.Y] != 9)) + { + GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\sad.png"); + GameOver = true; + OnRenderSound("bomb.wav"); + EndGame(); + board[pos.X, pos.Y] = 12; + SetPoint(pos); + } + if (board[pos.X, pos.Y] == 20) + { + board[pos.X, pos.Y] = GetValue(pos); + SetPoint(pos); + + OnRenderSound("tick.wav"); + + if (board[pos.X, pos.Y] == 0) { - for (int y = 0; y < by; y++) - { - for (int x = 0; x < bx; x++) - { - if (bombs[x, y] != 0) - { - board[x, y] = 11; - Point pos = new Point(); - pos.X = x; - pos.Y = y; - SetPoint(pos); - } - } - } + EmptyPos(); } - - private void EmptyPos() + if (Finished() == true) { - bool rep = true; + CheckAllBoms(); + GameOver = true; + GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\cool.png"); + CheckHiScore(); + } + } + } - while (rep) - { - rep = false; - for (int y = 0; y < by; y++) - { - for (int x = 0; x < bx; x++) - { - if (board[x, y] == 0) - { - // bomb counter = 0 - int cnt = 0; - for (int i = 0; i < 8; i++) - { - int x1 = x + posX[i]; - int y1 = y + posY[i]; - if ((x1 >= 0) && (y1 >= 0) && (x1 < bx) && (y1 < by)) - { - if (bombs[x1, y1] != 0) - { // found bomb - cnt++; - } - } - } + private void SetPoint(Point pos) + { + int nr = 531 + (pos.Y * 30) + pos.X; - if (cnt == 0) - { - for (int i = 0; i < 8; i++) - { - int x1 = x + posX[i]; - int y1 = y + posY[i]; - if ((x1 >= 0) && (y1 >= 0) && (x1 < bx) && (y1 < by)) - { - if (board[x1, y1] == 20) - { - Point pos = new Point(); - pos.X = x1; - pos.Y = y1; + if (board[pos.X, pos.Y] == 0) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check0sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check0unsel.png"); + } + if (board[pos.X, pos.Y] == 1) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check1sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check1unsel.png"); + } + if (board[pos.X, pos.Y] == 2) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check2sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check2unsel.png"); + } + if (board[pos.X, pos.Y] == 3) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check3sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check3unsel.png"); + } + if (board[pos.X, pos.Y] == 4) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check4sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check4unsel.png"); + } + if (board[pos.X, pos.Y] == 5) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check5sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check5unsel.png"); + } + if (board[pos.X, pos.Y] == 6) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check6sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check6unsel.png"); + } + if (board[pos.X, pos.Y] == 7) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check7sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check7unsel.png"); + } + if (board[pos.X, pos.Y] == 8) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\check8sel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\check8unsel.png"); + } + if (board[pos.X, pos.Y] == 9) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\markedasbomsel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\markedasbom.png"); + } + if (board[pos.X, pos.Y] == 10) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\questionmarksel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\questionmark.png"); + } + if (board[pos.X, pos.Y] == 11) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\bomb.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\bomb.png"); + } + if (board[pos.X, pos.Y] == 12) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\bombexplode.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\bombexplode.png"); + } + if (board[pos.X, pos.Y] == 20) + { + GUIPropertyManager.SetProperty("#F" + nr, @"\Minesweeper\Board\unchecksel.png"); + GUIPropertyManager.SetProperty("#NF" + nr, @"\Minesweeper\Board\uncheckunsel.png"); + } + } - board[x1, y1] = GetValue(pos) ; - SetPoint(pos); - rep = true; - } - } - } - } - } - } - } - } - + private int GetValue(Point pos) + { + int val = 0; + + for (int i = 0; i < 8; i++) + { + int x = pos.X + posX[i]; + int y = pos.Y + posY[i]; + if ((x >= 0) && (y >= 0) && (x < bx) && (y < by)) + { + if (bombs[x, y] != 0) + { + val++; + } } - private void SetBomb() + } + return val; + } + + private int GetMBombs(Point pos) + { + int val = 0; + + for (int i = 0; i < 8; i++) + { + int x = pos.X + posX[i]; + int y = pos.Y + posY[i]; + if ((x >= 0) && (y >= 0) && (x < 30) && (y < 30)) { - if ((ID >= 500) && (!GameOver)) - { - GameON = true; + if (board[x, y] == 9) + { + val++; + } + } - int y = ID - 500; - y = (int)y / 30; + } + return val; + } - int x = ID - 500; - x = x - (y * 30); + private void EndGame() + { + for (int y = 0; y < by; y++) + { + for (int x = 0; x < bx; x++) + { + if (bombs[x, y] != 0) + { + board[x, y] = 11; + Point pos = new Point(); + pos.X = x; + pos.Y = y; + SetPoint(pos); + } + } + } + } - x = x - 1; - y = y - 1; + private void EmptyPos() + { + bool rep = true; - int val = board[x, y]; + while (rep) + { + rep = false; + for (int y = 0; y < by; y++) + { + for (int x = 0; x < bx; x++) + { + if (board[x, y] == 0) + { + // bomb counter = 0 + int cnt = 0; + for (int i = 0; i < 8; i++) + { + int x1 = x + posX[i]; + int y1 = y + posY[i]; + if ((x1 >= 0) && (y1 >= 0) && (x1 < bx) && (y1 < by)) + { + if (bombs[x1, y1] != 0) + { // found bomb + cnt++; + } + } + } - if ((x >= 0) && (y >= 0) && (x < bx) && (y < by)) + if (cnt == 0) + { + for (int i = 0; i < 8; i++) { - if (val == 20) + int x1 = x + posX[i]; + int y1 = y + posY[i]; + if ((x1 >= 0) && (y1 >= 0) && (x1 < bx) && (y1 < by)) + { + if (board[x1, y1] == 20) { - Point pt = new Point(); - pt.X = x; - pt.Y = y; - board[x, y] = 9; - SetPoint(pt); - bcnt--; + Point pos = new Point(); + pos.X = x1; + pos.Y = y1; + + board[x1, y1] = GetValue(pos); + SetPoint(pos); + rep = true; } - if (val == 9) - { - Point pt = new Point(); - pt.X = x; - pt.Y = y; - board[x, y] = 20; - SetPoint(pt); - bcnt++; - } + } } - if (Finished() == true) - { - CheckAllBoms(); - GameOver = true; - GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\cool.png"); - CheckHiScore(); - } + } } + } } + } - private void SetQuest() - { - if ((ID >= 500) && (!GameOver)) - { - GameON = true; + } - int y = ID - 500; - y = (int)y / 30; + private void SetBomb() + { + if ((ID >= 500) && (!GameOver)) + { + GameON = true; - int x = ID - 500; - x = x - (y * 30); + int y = ID - 500; + y = (int)y / 30; - x = x - 1; - y = y - 1; + int x = ID - 500; + x = x - (y * 30); - int val = board[x, y]; + x = x - 1; + y = y - 1; - if ((x >= 0) && (y >= 0) && (x < bx) && (y < by)) - { - if (val == 20) - { - Point pt = new Point(); - pt.X = x; - pt.Y = y; - board[x, y] = 10; - SetPoint(pt); - } - if (val == 10) - { - Point pt = new Point(); - pt.X = x; - pt.Y = y; - board[x, y] = 20; - SetPoint(pt); - } - } - } - } + int val = board[x, y]; - private void Check9() + if ((x >= 0) && (y >= 0) && (x < bx) && (y < by)) { - if ((ID >= 500) && (!GameOver) && (GameON)) - { - int y = ID - 500; - y = (int)y / 30; + if (val == 20) + { + Point pt = new Point(); + pt.X = x; + pt.Y = y; + board[x, y] = 9; + SetPoint(pt); + bcnt--; + } + if (val == 9) + { + Point pt = new Point(); + pt.X = x; + pt.Y = y; + board[x, y] = 20; + SetPoint(pt); + bcnt++; + } + } + if (Finished() == true) + { + CheckAllBoms(); + GameOver = true; + GUIPropertyManager.SetProperty("#minesweeper_smiley", @"\Minesweeper\cool.png"); + CheckHiScore(); + } + } + } - int x = ID - 500; - x = x - (y * 30); + private void SetQuest() + { + if ((ID >= 500) && (!GameOver)) + { + GameON = true; - x = x - 1; - y = y - 1; + int y = ID - 500; + y = (int)y / 30; - if ((x >= 0) && (y >= 0) && (x < bx) && (y < by)) - { - int val = board[x, y]; - Point pt = new Point(); - pt.X = x; - pt.Y = y; + int x = ID - 500; + x = x - (y * 30); - if (val == GetMBombs(pt)) - { - for (int i = 0; i < 8; i++) - { - Point px = new Point(); - px.X = x + posX[i]; - px.Y = y + posY[i]; + x = x - 1; + y = y - 1; - if ((px.X >= 0) && (px.Y >= 0) && (px.X < bx) && (px.Y < by)) - { - SetPlace(px); - } - } - } - } - } + int val = board[x, y]; - } - - private void CheckAllBoms() + if ((x >= 0) && (y >= 0) && (x < bx) && (y < by)) { - for (int y = 0; y < by; y++) - { - for (int x = 0; x < bx; x++) - { - if ((board[x,y]==20) && (bombs[x,y]==1)) - { - board[x, y] = 9; - Point px = new Point(); - px.X = x; - px.Y = y; - SetPoint(px); - } - } - } - bcnt = 0; + if (val == 20) + { + Point pt = new Point(); + pt.X = x; + pt.Y = y; + board[x, y] = 10; + SetPoint(pt); + } + if (val == 10) + { + Point pt = new Point(); + pt.X = x; + pt.Y = y; + board[x, y] = 20; + SetPoint(pt); + } } + } + } - private bool Finished() + private void Check9() +... [truncated message content] |