Пример #1
0
        // ----------------------------------------------------------------------------------------------------------------
        // Populates the Leader board with data of scores that are either from the local, or online text files.
        public static List <LeaderBoard> PopulateLeaderBoardData(bool isOnline)
        {
            string path = "";

            if (isOnline)
            {
                path = GameInterface.getCurrentGame().gOnlinePath + GameInterface.getCurrentGame().gOnlineFileName;
            }
            else
            {
                path = GameInterface.getCurrentGame().gLocalPath + GameInterface.getCurrentGame().gLocalFileName;
            }

            // A particular .txt file (local, or online) will be used determined by the string (path) parameter.
            List <string> unsortedList = ScarStorageSystem.readData(path);

            List <LeaderBoard> unsortedLb = new List <LeaderBoard>();

            if (unsortedList != null)
            {
                unsortedLb = addLeaderboardObjects(unsortedList, isOnline);
            }

            return(selectionSort(unsortedLb));
        }
Пример #2
0
        // ----------------------------------------------------------------------------------------------------------------
        // @param playersScore should be in the format Name-Score-Time
        // Will format the @parameter playersScore into the format Position-Name-Score-Time
        // Position - The position the player is in the list.
        // Name - Name of the player.
        // Score - The number of moves taken to win the game.
        // Time - How long it took to win the game.
        public static void addNewScore(string playersScore)
        {
            string localPath  = GameInterface.getCurrentGame().gLocalPath + GameInterface.getCurrentGame().gLocalFileName;
            string onlinePath = GameInterface.getCurrentGame().gOnlinePath + GameInterface.getCurrentGame().gOnlineFileName;

            // push scores up by one, starting after the onlinePosition (localPosition + 1)
            ScarStorageSystem.updateData(localPath, localPosition);
            if (ScarStorageSystem.reachedLimit(localPath, MAXNUMBEROFLOCALSCORES))
            {
                // Now we remove the score that has been pushed up to 21
                ScarStorageSystem.removeData(localPath, MAXNUMBEROFLOCALSCORES + 1);
            }
            // Now we can add the new score.
            // This will be in the format Position-Name-Diff-Score-Time
            ScarStorageSystem.addData(localPath, localPosition + "-" + playersScore);

            if (onlinePosition <= MAXNUMBEROFONLINESCORES)
            {
                // push scores up by one, starting after the onlinePosition (onlinePosition + 1)
                ScarStorageSystem.updateData(onlinePath, onlinePosition);
                if (ScarStorageSystem.reachedLimit(onlinePath, MAXNUMBEROFONLINESCORES))
                {
                    // Now we remove the score that has been pushed up to 101.
                    ScarStorageSystem.removeData(onlinePath, MAXNUMBEROFONLINESCORES + 1);
                }
                // Now we can add the new score.
                // This will be in the format Position-Name-Diff-Score-Time
                ScarStorageSystem.addData(onlinePath, onlinePosition + "-" + playersScore);
            }
        }
Пример #3
0
        // ----------------------------------------------------------------------------------------------------------------
        // Initializes the key components Game Menu will use.
        // Variable game must be initialized, from the GameInterface class.
        private void initializeKeyComponents()
        {
            if (!ScarStorageSystem.hasStorage())
            {
                // Determine the storage type.
                ScarStorageSystem.determineCurrentStorage(0, Assets);
            }

            if (game.gOnlinePath == null && game.gLocalPath == null)
            {
                // Assign the current game the player is playing.
                ScarStorageSystem.assignGameFilePaths(game);
            }

            // Add the description of the game.
            gameDescription.Text = ScarStorageSystem.readDescription(game.gDescription);
        }