コード例 #1
0
ファイル: MainForm.cs プロジェクト: svd62rus/Tic-Tac-Toe
 /// <summary>
 /// Game draw method
 /// </summary>
 /// <param name="result">Result of game</param>
 private void Game_Draw(string result)
 {
     Enabled = true;
     profile.Draw(game.Difficult.ToString());
     GameDataBus.SaveGameResultInScore(profile, locale);
     DeleteSubscribes();
     GameDataBus.ShowResult(result, locale);
     GamePanel.Visible = false;
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: svd62rus/Tic-Tac-Toe
 /// <summary>
 /// Set russian language
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void RussianItem_Click(object sender, EventArgs e)
 {
     locale = CreateLocale(InterfaceLanguage.ru);
     SetLocale(locale);
     GameDataBus.SaveGameResultInScore(profile, locale);
     SetLanguageFlags(locale.Localization);
     if (game != null)
     {
         ((SinglePlayer)game).ChangeBotNameWithLocale(locale);
     }
     ShowParameters();
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: svd62rus/Tic-Tac-Toe
        /// <summary>
        /// Click on game field buttons method
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event</param>
        private void GameFieldButton_Click(object sender, EventArgs e)
        {
            var button = (Button)sender;
            int i      = int.Parse(button.Tag.ToString());

            game.PlayerStep(i, out bool isPossible);
            if (!isPossible)
            {
                GameDataBus.ShowImpossibleStepMessage(locale);
            }
            UpdateButtons();
            game.CheckGameStatus();
            if (game.GameInProgress && isPossible)
            {
                game.ChangeCurrentPlayer();
            }
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: svd62rus/Tic-Tac-Toe
 /// <summary>
 /// Game win method
 /// </summary>
 /// <param name="result">Result of game</param>
 private void Game_Win(string result)
 {
     Enabled = true;
     if (game.Winner == game.Player1)
     {
         profile.Win(game.Difficult.ToString());
         GameDataBus.SaveGameResultInScore(profile, locale);
         ChangeButtonColor(Color.Green);
     }
     else
     {
         profile.Lose(game.Difficult.ToString());
         GameDataBus.SaveGameResultInScore(profile, locale);
         ChangeButtonColor(Color.Red);
     }
     GameDataBus.ShowResult(result, locale);
     DeleteSubscribes();
     GamePanel.Visible = false;
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: svd62rus/Tic-Tac-Toe
        /// <summary>
        /// Main form load event method
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event</param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (!SaveLoadProfile.CheckExistFileSave())
            {
#pragma warning disable IDE0067 // Dispose objects before losing scope
                NewProfile addUserForm = new NewProfile(profile, locale);
#pragma warning restore IDE0067 // Dispose objects before losing scope
                addUserForm.ShowDialog();
                if (!GameDataBus.ProfileIsCreated)
                {
                    Close();
                    return;
                }
                profile = GameDataBus.TempProfile;
            }
            else
            {
                profile = GameDataBus.LoadGameResultInScore(locale);
            }

            locale = CreateLocale(profile.PlayerLocale);
            SetLocale(locale);
            SetLanguageFlags(locale.Localization);
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: svd62rus/Tic-Tac-Toe
 /// <summary>
 /// Show game score method
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Param</param>
 private void ScoreMenu_Click(object sender, EventArgs e)
 {
     GameDataBus.ShowScore(profile, locale);
 }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: svd62rus/Tic-Tac-Toe
 /// <summary>
 /// Main form exit event method
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Event</param>
 private void ExitMenu_Click(object sender, EventArgs e)
 {
     GameDataBus.SaveGameResultInScore(profile, locale);
     Application.Exit();
 }