コード例 #1
0
ファイル: Score.cs プロジェクト: KrzysztofTomaszek/SirTet
        /// <summary>
        /// Method for saving records scores to file
        /// </summary>
        public void SetRecords()
        {
            int    tmpScore = mainScore;
            string tmpName  = playerNick;

            for (int i = 0; i < 10; i++)
            {
                if (tmpScore > recordsPkt[i])
                {
                    int tmpScores = recordsPkt[i];
                    recordsPkt[i] = tmpScore;
                    tmpScore      = tmpScores;

                    string tmpNames = recordsNames[i];
                    recordsNames[i] = tmpName;
                    tmpName         = tmpNames;
                }
            }

            string[] stringRecords = new string[10];
            for (int i = 1; i <= 10; i++)
            {
                stringRecords[i - 1] = (i + ". " + recordsPkt[i - 1] + " pkt " + recordsNames[i - 1] + " \n");
            }

            for (int i = 0; i < 10; i++)
            {
                stringRecords[i] = SaveScore.EncryptString(stringRecords[i], key);
            }

            SaveScore.SaveFile(stringRecords, @"C:\Users\Public\SirTet", "Records.aes");
        }
コード例 #2
0
ファイル: Score.cs プロジェクト: KrzysztofTomaszek/SirTet
        /// <summary>
        /// Method for displaying records scores form file
        /// </summary>
        /// <param name="RecordText">Variable contains reference to canvas element</param>
        public static void DrawRecords(ref TextBlock RecordText)
        {
            string[] records      = new string[0];
            string   recordString = "";

            try
            {
                records = SaveScore.ReadFile(@"C:\Users\Public\SirTet\Records.aes");

                for (int i = 0; i < 10; i++)
                {
                    records[i]    = SaveScore.DecryptString(records[i], key);
                    recordString += records[i];
                }

                RecordText.Text = "Record: \n" + recordString;
            }
            catch
            {
                string[] defaultRecords = new string[10];
                for (int i = 1; i <= 10; i++)
                {
                    defaultRecords[i - 1] = (i + ". 1000 pkt Player \n");
                }

                for (int i = 0; i < 10; i++)
                {
                    defaultRecords[i] = SaveScore.EncryptString(defaultRecords[i], key);
                }

                SaveScore.SaveFile(defaultRecords, @"C:\Users\Public\SirTet", "Records.aes");
                DrawRecords(ref RecordText);
            }
        }
コード例 #3
0
ファイル: Score.cs プロジェクト: KrzysztofTomaszek/SirTet
        /// <summary>
        /// Method for displaying records scores from file
        /// </summary>
        void DrawRecords()
        {
            //recordText
            string[] records      = new string[0];
            string   recordString = "";

            try
            {
                records = SaveScore.ReadFile(@"C:\Users\Public\SirTet\Records.aes");

                for (int i = 0; i < 10; i++)
                {
                    records[i]      = SaveScore.DecryptString(records[i], key);
                    recordString   += records[i];
                    recordsPkt[i]   = Int32.Parse(records[i].Split(' ')[1]);
                    recordsNames[i] = records[i].Split(' ')[3];
                }

                recordText.Text = "Record: \n" + recordString;
            }
            catch
            {
                string[] defaultRecords = new string[10];
                for (int i = 1; i <= 10; i++)
                {
                    defaultRecords[i - 1] = (i + ". 1000 pkt Player \n");
                }

                for (int i = 0; i < 10; i++)
                {
                    defaultRecords[i] = SaveScore.EncryptString(defaultRecords[i], key);
                }

                SaveScore.SaveFile(defaultRecords, @"C:\Users\Public\SirTet", "Records.aes");
                DrawRecords();
            }
        }