Ejemplo n.º 1
0
 public static GameSettings EditSettings(IWin32Window owner, GameSettings settings)
 {
     using (FormSettings settingsForm = new FormSettings()) {
         settingsForm.SetSettings(settings);
         if (settingsForm.ShowDialog(owner) == DialogResult.OK) {
             return settingsForm.GetSettings();
         }
         return null;
     }
 }
Ejemplo n.º 2
0
 public MainGameForm()
 {
     InitializeComponent();
     this.Icon = CommonHelper.GetIconFromResource("WordGame.Data.Program.ico");
     GameDictionary.LoadDictionary();
     gameSettings = GameSettings.LoadSettigs();
     if (gameSettings == null) {
         int needWordsCount = GameDictionary.NeedWordsCount(GameDictionary.GetAllWordsCount());
         gameSettings = new GameSettings(1000, 10000, needWordsCount, GameDictionary.GetAllRules());
     }
 }
Ejemplo n.º 3
0
 void SetSettings(GameSettings settings)
 {
     tbSpeed.Value = (1100 - settings.LetterDownInterval) / 100;
     Dictionary<int, bool> selectedRules = new Dictionary<int, bool>();
     for (int i = 0; i < settings.Rules.Length; i++) {
         selectedRules[settings.Rules[i]] = true;
     }
     for (int i = 0; i < clbRules.Items.Count; i++) {
         if (selectedRules.ContainsKey(((FormSettingsRuleItem)clbRules.Items[i]).Rule)) {
             clbRules.SetItemChecked(i, true);
         }
     }
 }
Ejemplo n.º 4
0
 private void tsmiNewGame_Click(object sender, EventArgs e)
 {
     SetPauseState(true);
     try {
         GameSettings newGameSettings;
         if ((newGameSettings = FormSettings.EditSettings(this, gameSettings)) != null) {
             GameClear();
             gameSettings = newGameSettings;
             GameCreateAndStart();
         }
     } finally {
         SetPauseState(false);
     }
 }
Ejemplo n.º 5
0
 public static void SaveSettings(GameSettings settings)
 {
     if (!Directory.Exists(settingsPath)) Directory.CreateDirectory(settingsPath);
     using (FileStream file = new FileStream(settingsName, FileMode.Create, FileAccess.Write)) {
         XmlSerializer serializer = new XmlSerializer(typeof(GameSettings));
         serializer.Serialize(file, settings);
     }
 }
Ejemplo n.º 6
0
 public Game(int width, int height, GameSettings settings)
 {
     this.settings = settings;
     this.mainTable = new GameTable(width, height);
     this.gameErrorReadOnlyCollection = new ReadOnlyCollection<GameErrorInfo>(gameErrorList);
     this.rawWrods = new ReadOnlyCollection<string>(GameDictionary.GetRawWords(settings.Rules));
     if (rawWrods.Count == 0) throw new InvalidOperationException("Не нашел слов для выбранного набора правил.");
     this.syncContext = SynchronizationContext.Current;
     if (this.syncContext == null) throw new InvalidOperationException("Current thread has no synchronization context.");
     this.randomize = new Random(DateTime.Now.GetHashCode());
 }