Exemplo n.º 1
0
 /// <summary>
 /// Button create player profile click method
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Event</param>
 private void ButtonCreateProfile_Click(object sender, EventArgs e)
 {
     profile.PlayerName   = TxtBoxPlayerName.Text;
     profile.PlayerLocale = locale.Localization;
     SaveLoadProfile.Save(profile);
     GameDataBus.ProfileIsCreated = true;
     GameDataBus.TempProfile      = profile;
     Close();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Load game result in score method
        /// </summary>
        /// <param name="locale">Locale</param>
        /// <returns>Game profile</returns>
        public static GameProfile LoadGameResultInScore(Locale locale)
        {
            var loadResult = SaveLoadProfile.Load();

            if (loadResult.IsError)
            {
                MessageBox.Show(locale.GetSavesLoadingErrorText(), locale.GetErrorText());
            }
            return(loadResult.Profile);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Save game result in score method
        /// </summary>
        /// <param name="profile">Game profile</param>
        /// <param name="locale">Locale</param>
        public static void SaveGameResultInScore(GameProfile profile, Locale locale)
        {
            profile.PlayerLocale = locale.Localization;
            var saveResult = SaveLoadProfile.Save(profile);

            if (saveResult.IsError)
            {
                MessageBox.Show(locale.GetSavesSavingErrorText(), locale.GetErrorText());
            }
        }
Exemplo n.º 4
0
        /// <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);
        }