Beispiel #1
0
        /// <summary>
        /// Funkcja zapisuje wynik w TOP 10
        /// </summary>
        /// <param name="score">Wynik skończonej gry</param>
        /// <returns>Czy wynik jest najwyższym wynikiem do tej pory (TOP 1)</returns>
        public Boolean SaveScore(Int64 score)
        {
            Boolean isHighscore = false;
            AppMemory am = new AppMemory();

            for (int i = 0; i < _amountOfPlaces; i++)
            {
                if (score > TopTen[i].Value)
                {
                    TopTen.Insert(i, new KeyValuePair<string, Int64>(_playerName, score));

                    if (i == 0)
                    {
                        //TODO: highscore
                        isHighscore = true;
                    }

                    break;
                }
            }

            for (int i = 0; i < _amountOfPlaces; i++)
            {
                am.SaveValue("score" + Convert.ToString(i + 1), TopTen[i].Value);
                am.SaveValue("playerName" + Convert.ToString(i + 1), TopTen[i].Key);
            }

            return isHighscore;
        }
Beispiel #2
0
        private void SaveName(String name)
        {
            if (name.Length <= 30)
            {
                AppMemory am = new AppMemory();
                am.SaveValue("playerName", name);

                MessageBox.Show("Player's name successfully changed to \"" + nameBox.Text + "\"");
            }
            else
            {
                MessageBox.Show("Player's name is too long. Limit is 30 characters.");
            }
        }