Example #1
0
        public static void SaveHighScore(string name, int score, int level)
        {
            // Create the data to save
            HighScoreData data = LoadHighScores("highscore.xml");

            int scoreIndex = -1;

            for (int i = 0; i < data.level[level].Count; i++)
            {
                if (score > data.level[level].Score[i])
                {
                    scoreIndex = i;
                    break;
                }
            }

            if (scoreIndex > -1)
            {
                //New high score found ... do swaps
                for (int i = data.level[level].Count - 1; i > scoreIndex; i--)
                {
                    data.level[level].PlayerName[i] = data.level[level].PlayerName[i - 1];
                    data.level[level].Score[i]      = data.level[level].Score[i - 1];
                }

                data.level[level].PlayerName[scoreIndex] = name; //Retrieve User Name Here
                data.level[level].Score[scoreIndex]      = score;


                SaveHighScores(data, "highscore.xml");
            }
        }
Example #2
0
        /// <summary>
        /// Show all highscores on enable
        /// </summary>
        void OnEnable()
        {
            for (int i = 0; i < highScores.Length; i++)
            {
                HighScoreData hsd = GameManager.instance.gsData.hsds[i];
                if (hsd != null && hsd.areaName != null)
                {
                    highScores[i].Init(hsd);
                }
                else
                {
                    highScores[i].Init();
                }
            }

            for (int i = 0; i < achievements.Length; i++)
            {
                achievements[i].SetSprite(GameManager.instance.achievementSprites[i]);
                achievements[i].SetTooltip(i);
                achievements[i].SetColour(GameManager.instance.gsDataCurrent.achievementsUnlocked[i]);
            }

            monstersAmount.SetText(GameManager.instance.gsData.mostMonsters.ToString());
            WAXAmount.SetText(GameManager.instance.gsData.mostWAX.ToString());
            eventsAmount.SetText(GameManager.instance.gsData.mostEvents.ToString());
            if (GameManager.instance.gsData.fastestTime == -1)
            {
                timeAmount.SetText("--");
            }
            else
            {
                timeAmount.SetText(TimeSpan.FromSeconds(GameManager.instance.gsData.fastestTime).ToString(@"hh\:mm\:ss\.ff"));
            }
        }
Example #3
0
        public void Ini()
        {
            // Get the path of the save game
            string fullpath = "highscores.dat";

            // Check to see if the save exists

            if (!File.Exists(fullpath))
            {
                //If the file doesn't exist, make a fake one...
                // Create the data to save
                data = new HighScoreData(5);
                data.PlayerName[0] = "botneil";
                data.Score[0] = 20;

                data.PlayerName[1] = "botshawn";
                data.Score[1] = 10;

                data.PlayerName[2] = "botmark";
                data.Score[2] = 9;

                data.PlayerName[3] = "botcindy";
                data.Score[3] = 8;

                data.PlayerName[4] = "botsam";
                data.Score[4] = 2;

                SaveHighScores2(data, HighScoresFilename, device);
            }
        }
Example #4
0
    public static string ConvertRankingToJson(List <List <int> > ranking)
    {
        HighScoreData data = new HighScoreData();

        data.highScores = ranking;
        return(JsonConvert.SerializeObject(data));
    }
Example #5
0
        /*
         * Voids
         */

        private void SaveHighScore()
        {
            // Create the data to save
            HighScoreData data = LoadHighScores(HighScoresFilename);

            int scoreIndex = -1;

            for (int i = 0; i < data.Count; i++)
            {
                if (PlayerScore >= data.Score[i])
                {
                    scoreIndex = i;
                }
            }

            if (scoreIndex > -1)
            {
                // New high score found, do swaps
                for (int i = 0; i < scoreIndex; i++)
                {
                    data.Score[i] = data.Score[i + 1];
                }
                data.Score[scoreIndex] = PlayerScore;

                SaveHighScores(data, HighScoresFilename);
            }
        }
Example #6
0
    public void Show(HighScoreData scores)
    {
        int          rank          = 0;
        int          previousScore = 0;
        HighScoreRow row;

        for (int i = 1; i <= Rows.Count; i++)
        {
            row = Rows[i - 1];
            if (scores.records.Count < i)
            {
                row.UpdateText("");
                continue;
            }


            var score = scores.records[i - 1];

            if (score.Score != previousScore)
            {
                rank++;
                previousScore = score.Score;
            }

            row.UpdateText(string.Format("{0}. {1} {2}", rank, score.Name, score.Score));
        }

        gameObject.SetActive(true);
    }
Example #7
0
        private static int CompareByPlayerScore(HighScoreData x, HighScoreData y)
        {
            if (x.Equals(null))
            {
                if (y.Equals(null))
                {
                    return 0;
                }
                else
                {
                    return -1;
                }
            }
            else
            {
                if (y.Equals(null))
                {
                    return 1;
                }
                else
                {

                    int retval = y.Score.CompareTo(x.Score);

                    if (retval != 0)
                    {
                        return retval;
                    }
                    else
                    {
                        return y.Score.CompareTo(x.Score);
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //creates a highscore .dat file using he scores below if there isn't one.
            string fullpath = "highscores.dat";

            if (!File.Exists(fullpath))
            {
                data          = new HighScoreData(5);
                data.Score[0] = 2500;
                data.Score[1] = 1500;
                data.Score[2] = 1000;
                data.Score[3] = 500;
                data.Score[4] = 300;

                SaveHighScores(data, HighScoresFilename, null);

                IsFixedTimeStep = false;
            }
            // TODO: Add your initialization logic here


            base.Initialize();
            InitializeBindings();
            interactiveMusic.musicsystem.setParameterValue(1, 1);
        }
Example #9
0
        public void saveHighScores()
        {
            string line;
            int i = 0;

            StreamReader sr = new StreamReader("highscore.txt");
            while ((line = sr.ReadLine()) != null)
            {
                HighScoreData dataskornya = new HighScoreData();
                string[] parts = line.Split('-');
                dataskornya.PlayerName = parts[0].Trim();
                dataskornya.Score = Int32.Parse(parts[1].Trim());
                highScores.Add(dataskornya);
                i++;
            }
            sr.Close();

            HighScoreData dataskornya2 = new HighScoreData();
            dataskornya2.PlayerName = ime;
            dataskornya2.Score = poeni;
            highScores.Add(dataskornya2);

            highScores.Sort(CompareByPlayerScore);

            StreamWriter sw = new StreamWriter("highscore.txt");
            for (i = 0; i < 5; i++)
            {
                line = highScores[i].PlayerName + " - " + highScores[i].Score;
                String stringToSave = ime.Replace("_", " ");
                sw.WriteLine(line);
            }
            sw.Close();
        }
Example #10
0
 void CreateFile()
 {
     m_data = new HighScoreData();
     m_data.m_highScores = new uint[m_maxHighScores];
     m_json = JsonUtility.ToJson(m_data);
     File.WriteAllText(m_dataPath, m_json);
 }
Example #11
0
 private void Awake()
 {
     if (HighScoreManager.m_instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         HighScoreManager.m_instance = this;
         m_dataPath = Application.persistentDataPath + "/scores.json";
         if (File.Exists(m_dataPath))
         {
             m_json = File.ReadAllText(m_dataPath);
             m_data = JsonUtility.FromJson <HighScoreData>(m_json);
             if (m_data.m_highScores.Length != m_maxHighScores)
             {
                 m_data.m_highScores = new uint[m_maxHighScores];
             }
         }
         else
         {
             CreateFile();
         }
         DontDestroyOnLoad(gameObject);
     }
 }
Example #12
0
        public void GetHighScores()
        {
            HighScoreData data;
            // Get the path of the save game
            string fullpath = "highscores.dat";

            // Open the file
            FileStream stream = File.Open(fullpath, FileMode.OpenOrCreate, FileAccess.Read);

            try
            {
                // Read the data from the file
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                data = (HighScoreData)serializer.Deserialize(stream);
                for (int i = 0; i < data.Count; i++)
                {
                    highScores += "High Score " + (i + 1) + ": " + data.scores[i] + "\n\n";
                }
            }
            finally
            {
                // Close the file
                stream.Close();
            }
        }
Example #13
0
        void SetStats()
        {
            if (difficultyTabGroup.SelectedTab != null)
            {
                HighScoreData = HighScoreManager.Instance.GetHighScoreForSong(
                    songData.SongInfoFileData.SongName,
                    songData.SongInfoFileData.LevelAuthorName,
                    songData.SongInfoFileData.DifficultyBeatmapSets[difficultySetIndex].BeatmapCharacteristicName,
                    songData.SongInfoFileData.DifficultyBeatmapSets[difficultySetIndex].DifficultyBeatmaps[difficultyIndex].Difficulty);

                if (HighScoreData.Score == 0)
                {
                    ScoreText.text = "-";
                }
                else
                {
                    ScoreText.text = HighScoreData.Score.ToString();
                }
            }

            BPMValueText.text = songData.SongInfoFileData.BeatsPerMinute.ToString();

            if (songData.AudioClip != null)
            {
                timeValueText.text = $"{math.floor(songData.AudioClip.length / 60)}:{math.floor(songData.AudioClip.length % 60).ToString("00")}";
            }
        }
Example #14
0
        private void SaveHighScore()
        {
            HighScoreData data = LoadHighScores(HighScoreFileName);

            int scoreIndex = -1;

            for (int i = data.Count - 1; i > -1; i--)
            {
                if (score >= data.scores[i])
                {
                    scoreIndex = i;
                }
            }

            if (scoreIndex > -1)
            {
                for (int i = data.Count - 1; i > scoreIndex; i--)
                {
                    data.scores[i] = data.scores[i];
                }

                data.scores[scoreIndex] = score;

                SaveHighScores(data, HighScoreFileName);
            }
        }
Example #15
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            Shared.stage = new Vector2(graphics.PreferredBackBufferWidth,
                                       graphics.PreferredBackBufferHeight);

            string highScorePath = "highscores.dat";

            if (!File.Exists(highScorePath))
            {
                //If the file doesn't exist, make a fake one...
                // Create the data to save
                data           = new HighScoreData(5);
                data.scores[0] = 1000000;

                data.scores[1] = 18;

                data.scores[2] = 15;

                data.scores[3] = 10;

                data.scores[4] = 5;

                SaveHighScores(data, highScorePath);
            }

            base.Initialize();
        }
Example #16
0
        public static void SaveNewScore(int score)
        {
            var appReader     = new ApplicationDataReader <HighScoreData>();
            var highScoreData = appReader.LoadData(highScoreDataFilePath);

            if (highScoreData != null)
            {
                var scores = highScoreData.GetScores();

                for (int i = 0; i < scores.Length; i++)
                {
                    if (score > scores[i])
                    {
                        scores[i] = score;
                        break;
                    }
                }

                highScoreData.SetScores(scores.OrderByDescending(x => x).ToArray());
            }
            else
            {
                var scores = new int[10];
                scores[0]     = score;
                highScoreData = new HighScoreData();
                highScoreData.SetScores(scores);
            }

            appReader.SaveData(highScoreData, highScoreDataFilePath);
        }
Example #17
0
        private void SaveHighScore()
        {
            HighScoreData data = LoadHighScores(HighScoresFilename);

            int scoreIndex = -1;

            for (int i = 0; i < data.Count; i++)
            {
                if (score > data.highScore[i])
                {
                    scoreIndex = i;
                    break;
                }
            }

            if (scoreIndex > -1)
            {
                for (int i = data.Count - 1; i > scoreIndex; i--)
                {
                    data.playerName[i] = data.playerName[i - 1];
                    data.highScore[i]  = data.highScore[i - 1];
                }

                data.playerName[scoreIndex] = "Player"; //Retrieve User Name Here
                data.highScore[scoreIndex]  = score;

                SaveHighScores(data, HighScoresFilename);
            }
        }
Example #18
0
        public LevelManager()
        {
            levels = new List<FileInfo>();
            DirectoryInfo dir = new DirectoryInfo( Directory.GetCurrentDirectory() + "/Levels" );
            Console.WriteLine( Directory.GetCurrentDirectory() + "/Levels" );
            try {
                levels.AddRange( dir.GetFiles( "Level*.*" ) );
            }
            catch {
                Console.WriteLine( "ERROR LOADING LEVELS" );
            }
            current_level = 0;
            foreach ( FileInfo name in levels ) {
                Console.WriteLine( name.Name );
                current_level++;
            }

            string fullpath = Path.Combine( Directory.GetCurrentDirectory(), HighScoresFilename );
            if ( !File.Exists( fullpath ) ) {
                //If the file doesn't exist, make a fake one...
                // Create the data to save
                HighScoreData data = new HighScoreData( current_level );
                for ( int i = 0; i < current_level; i++ )
                    data.Score[i] = 0;

                SaveHighScores( data, HighScoresFilename );
            }
            else {
                high_scores = LoadHighScores( HighScoresFilename );
            }
            current_level = 0;
        }
        private void heapify(List <HighScoreData> table, int n, int i)
        {
            int small = i;         // Initialize largest as root
            int l     = 2 * i + 1; // left = 2*i + 1
            int r     = 2 * i + 2; // right = 2*i + 2

            // If left child is larger than root
            if (l < n && table[l].score < table[small].score)
            {
                small = l;
            }

            // If right child is larger than largest so far
            if (r < n && table[r].score < table[small].score)
            {
                small = r;
            }

            // If largest is not root
            if (small != i)
            {
                HighScoreData swap = table[i];
                table[i]     = table[small];
                table[small] = swap;

                // Recursively heapify the affected sub-tree
                heapify(table, n, small);
            }
        }
Example #20
0
    public static void Save(HighScoreData data)
    {
        data.PrepareForSave();
        var output = JsonUtility.ToJson(data);

        File.WriteAllText(Path.Combine(Application.persistentDataPath, string.Format("{0}.json", "saveNameTest")), output);
    }
Example #21
0
 public UserDataManager()
 {
     currentPlayData = new UserData(true);
     recordedData    = new HighScoreData();
     profileSettings = new ProfileSettings();
     CheckSaveDataDirectory();
     LoadData();
 }
Example #22
0
        void saveStorage()
        {
            HighScoreData.save(storage);

            ColorData.save(storage);

            TextureData.save(storage);
        }
Example #23
0
        public void gameOver(string message)
        {
            data.setData(message, time, score, totalDeleted, level);

            HighScoreData.addScore(data);

            GameOver(this, new EventArgs());
        }
Example #24
0
 public static void SaveHighScores(HighScoreData data, string filename)
 {
     using (Stream stream = TitleContainer.OpenStream(filename))
     {
         var serializer = new XmlSerializer(typeof(HighScoreData));
         serializer.Serialize(stream, data);
     }
 }
Example #25
0
    public void InsertScore()
    {
        HighScoreData score = new HighScoreData {
            score = FindObjectOfType <ScoreCounter>().score, player = "test player"
        };

        StartCoroutine(_table.Insert <HighScoreData>(score, OnInsertCompleted));
    }
Example #26
0
    public void Delete()
    {
        HighScoreData score = new HighScoreData {
            score = FindObjectOfType <ScoreCounter>().score, player = "test player"
        };

        StartCoroutine(_table.Delete <HighScoreData>(score.id, OnDeleteCompleted));
    }
 public void SaveHighScores()
 {
     BinaryFormatter oFormatter = new BinaryFormatter();
     FileStream oFile = File.Create(Application.persistentDataPath + "/HighScores.dat");
     HighScoreData oData = new HighScoreData();
     oData.registeredHighScores = highScores;
     oFormatter.Serialize(oFile, oData);
     oFile.Close();
 }
    public void ReceiveSubmittedName()
    {
        playerName = nameInput.text;
        HighScoreData newPlayerScore = new HighScoreData(playerName, playerScore);

        scoreList.Add(newPlayerScore);
        UpdateList();
        WriteFile();
    }
Example #29
0
 private void Awake()
 {
     highScoreData    = SaveSystem.LoadHighScore();
     characterData    = SaveSystem.LoadCharacterData();
     currentCharacter = characterData.currentCharacter;
     characterLevel   = characterData.levels[currentCharacter];
     currentExp       = characterData.experience[currentCharacter];
     currentScore     = highScoreData.currentScore;
 }
Example #30
0
    public static void Load(HighScoreData data, string filepath = "saveNameTest")
    {
        var path = Path.Combine(Application.persistentDataPath, string.Format("{0}.json", filepath));

        if (File.Exists(path))
        {
            JsonUtility.FromJsonOverwrite(File.ReadAllText(path), data);
        }
    }
Example #31
0
        public override void InitHUD()
        {
            base.InitHUD();
            //Re-orient title and subtitle to be towards the top of the screen
            titleText.relativePosition    += new Vector2(0, 40);
            titleText.relativeAnchor       = new Vector2(0.5f, 0.1f);
            subtitleText.relativePosition += new Vector2(0, 40);
            subtitleText.relativeAnchor    = new Vector2(0.5f, 0.1f);

            highScoreTitle = new HUDElement("High   Scores:", Vector2.Zero);
            highScoreTitle.relativeAnchor = new Vector2(0.5f, 0.5f);
            highScoreTitle.alignment      = new Vector2(0.5f);
            hudManager.AddElement(highScoreTitle);

            var currentScore = GameEventManager.Instance.score;

            currentScoreText = new HUDElement("Score:   " + currentScore.ToString(), new Vector2(0, -40));
            currentScoreText.relativeAnchor = new Vector2(0.5f, 0.5f);
            currentScoreText.alignment      = new Vector2(0.5f);
            hudManager.AddElement(currentScoreText);

            resetText = new HUDElement("Press   R    to    reset    scoreboard", new Vector2(0, -40));
            resetText.relativeAnchor = new Vector2(0.5f, 1.0f);
            resetText.alignment      = new Vector2(0.5f);
            hudManager.AddElement(resetText);

            //Set up the list of high scores
            var highScoreData = GameData.GetHighScoreData();

            if (highScoreData == null)
            {
                highScoreData = new HighScoreData();
            }

            highScoreData.Update(currentScore);

            float spacing = 40.0f;

            //Create spaced list of high scores
            for (int i = 0; i < highScoreData.scores.Length; i++)
            {
                var amount = highScoreData.scores[i];

                HUDElement scoreText = new HUDElement(amount.ToString(), new Vector2(0, spacing * i));
                scoreText.relativeAnchor = new Vector2(0.5f, 0.6f);
                scoreText.alignment      = new Vector2(0.5f);

                highScoreTexts.Add(scoreText);
                hudManager.AddElement(scoreText);
            }

            highScoreData.Save();

            //Score has been recorded if relevant, now reset
            GameEventManager.Instance.ResetScore();
        }
    //it's static so we can call it from anywhere
    public static void SaveHighScore(HighScoreData newHighScore)
    {
        SaveLoad.highScores.Add(newHighScore);
        BinaryFormatter bf = new BinaryFormatter();
        //Application.persistentDataPath is a string, so if you wanted you can put that into debug.log if you want to know where save games are located
        FileStream file = File.Create(Application.persistentDataPath + "/highscores.gd"); //you can call it anything you want

        bf.Serialize(file, SaveLoad.highScores);
        file.Close();
    }
Example #33
0
        void initializeStorage()
        {
            storage = new StorageComponent("Quatrix HD");

            HighScoreData.load(storage);

            ColorData.load(storage);

            TextureData.load(storage);
        }
Example #34
0
    public static void SaveData(HighScoreManager _highscoreManager)
    {
        BinaryFormatter bf     = new BinaryFormatter();
        FileStream      stream = new FileStream(Application.persistentDataPath + "/HighScoreData.sav", FileMode.Create);

        HighScoreData data = new HighScoreData(_highscoreManager);

        bf.Serialize(stream, data);
        stream.Close();
    }
Example #35
0
        /*
         * Constructor
         */
        public HighScores(int score)
        {
            SetUp();

            this.data = LoadHighScores(HighScoresFilename);

            this.PlayerScore = score;

            SaveHighScore();
        }
Example #36
0
    public static void SaveHighScore(HighScore hSData)
    {
        BinaryFormatter bN_Formatter = new BinaryFormatter();
        string          filePath     = Application.persistentDataPath + "/highscore.data";
        FileStream      stream       = new FileStream(filePath, FileMode.Create);
        HighScoreData   data         = new HighScoreData(hSData);

        bN_Formatter.Serialize(stream, data);
        stream.Close();
    }
Example #37
0
 //Consulta de puntajes altos
 public void generaHighScores(SFSObject dataObject)
 {
     //obtiene arreglo resultado
     this.ultimaConsultaHighScores= new ArrayList();
     ISFSArray resultado = dataObject.GetSFSArray("result");
     for (int i=0; i < resultado.Size(); i++){
         SFSObject item= (SFSObject) resultado.GetSFSObject(i);
         string user= item.GetUtfString("userid");
         string score= ((double) item.GetDouble("score")).ToString();
         HighScoreData nuevo= new HighScoreData(user, score);
         this.ultimaConsultaHighScores.Insert(i, nuevo);
     }
 }
 void CreateHighScores(string[] initiatedNames, int[] initiatedScores)
 {
     for (int i = 0; i < 10; i++)
     {
         highScores[i] = new Script_PlayerClass();
         highScores[i].PlayerName = initiatedNames[i];
         highScores[i].Score = initiatedScores[i];
     }
     BinaryFormatter oFormatter = new BinaryFormatter();
     FileStream oFile = File.Create(Application.persistentDataPath + "/HighScores.dat");
     HighScoreData oData = new HighScoreData();
     oData.registeredHighScores = highScores;
     oFormatter.Serialize(oFile, oData);
     oFile.Close();
 }
    public void saveHighScore()
    {
        if (CountScore.score > Menu_controller.bestSocre) {

            //Animation Save Score
            Menu_controller.bestSocre = CountScore.score;
            bestScoreText.text = getScore.text;
            // Save New Score
            BinaryFormatter bf = new BinaryFormatter();
            FileStream file = File.Create(Application.persistentDataPath+"/playerInfo.dat");
            HighScoreData data = new HighScoreData();
            data.highScoreData = CountScore.score;
            bf.Serialize(file,data);
            file.Close();

        }
    }
Example #40
0
        public static void SaveHighScores( HighScoreData data, string filename )
        {
            // Get the path of the save game
            string fullpath = Path.Combine( Directory.GetCurrentDirectory(), filename );

            // Open the file, creating it if necessary
            FileStream stream = File.Open( fullpath, FileMode.OpenOrCreate );
            try {
                // Convert the object to XML data and put it in the stream
                XmlSerializer serializer = new XmlSerializer( typeof( HighScoreData ) );
                serializer.Serialize( stream, data );
            }
            finally {
                // Close the file
                stream.Close();
            }
        }
Example #41
0
 public static void SaveHighScores(HighScoreData highScoreData, string filename)
 {
     // Get the path of the save game
     string fullPath = "highscores.dat";
     // Open the file, creating it if necessary
     FileStream stream = File.Open(fullPath, FileMode.OpenOrCreate, FileAccess.Write);
     try
     {
         // Convert the object to XML data and put it in the stream
         XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
         serializer.Serialize(stream, highScoreData);
     }
     finally
     {
         // Close the file
         stream.Close();
     }
 }
        /// <summary>
        /// Method to save highscore to a file
        /// </summary>
        /// <param name="data"></param>
        /// <param name="filename"></param>
        public static void SaveHighScore(HighScoreData data, string filename)
        {
            //Get path of the scores file
            string fullPath = Path.Combine(GameConstants.GAME_ROOT_DIRECTORY, filename);

            //Open file. Create if necessary
            FileStream stream = File.Open(fullPath, FileMode.Create);
            try
            {
                // Convert the object to XML data and put it in the stream
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                serializer.Serialize(stream, data);
            }
            finally
            {
                //Close the file
                stream.Close();
            }
        }
Example #43
0
        protected override void Initialize()
        {
            base.Initialize();

            // Testing
            HighScoreData highScoreData = new HighScoreData(3);
            highScoreData.Name[0] = "Bobby";
            highScoreData.Score[0] = 1000;

            highScoreData.Name[1] = "Nikit";
            highScoreData.Score[1] = 988;

            highScoreData.Name[2] = "Anna";
            highScoreData.Score[2] = 900;

            WriteScore(highScoreData);

            base.Initialize();
        }
    private void updateText(int pos, HighScoreData hs)
    {
        TextMesh player = null, score = null;

        if(pos == 0){

            player = this.name1;
            score = this.score1;

        }
        else{

            if(pos == 1){
                player = this.name2;
                score = this.score2;
            }
            else{
                if(pos==2){
                    player = this.name3;
                    score = this.score3;
                }
                else{
                    if(pos==3){
                        player = this.name4;
                        score = this.score4;
                    }
                    else{
                        if(pos==4){
                            player = this.name5;
                            score = this.score5;
                        }
                    }
                }
            }

        }

        if(player != null && score != null){
            player.text = hs.getName();
            score.text = hs.getScore();
        }
    }
Example #45
0
        /* Load highscores */
        public static HighScoreData LoadHighScores(string filename)
        {
            HighScoreData data;

            // Get the path of the save game
            string fullpath = "highscores.dat";

            #if WINDOWS

            // Open the file
            FileStream stream = File.Open(fullpath, FileMode.OpenOrCreate, FileAccess.Read);
            try
            {
                // Read the data from the file
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                data = (HighScoreData)serializer.Deserialize(stream);
            }
            finally
            {
                // Close the file
                stream.Close();
            }

            return (data);

            #elif XBOX

            using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fullpath, FileMode.Open,iso))
                {
                    // Read the data from the file
                    XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                    data = (HighScoreData)serializer.Deserialize(stream);
                }
            }

            return (data);

            #endif
        }
Example #46
0
 /* Save highscores */
 public static void SaveHighScores2(HighScoreData data, string filename, StorageDevice device)
 {
     FileStream stream;
     if (!File.Exists(filename))
     {
         stream = File.Open(filename, FileMode.OpenOrCreate);
     }
     else
     {
         stream = File.Open(filename, FileMode.Truncate);
     }
     try
     {
         // Convert the object to XML data and put it in the stream
         XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
         serializer.Serialize(stream, data);
     }
     finally
     {
         // Close the file
         stream.Close();
     }
 }
Example #47
0
        /* Save highscores */
        public static void SaveHighScores(HighScoreData data, string filename, StorageDevice device)
        {
            // Get the path of the save game
            string fullpath = "highscores.dat";

            #if WINDOWS
            // Open the file, creating it if necessary
            FileStream stream = File.Open(fullpath, FileMode.OpenOrCreate);
            try
            {
                // Convert the object to XML data and put it in the stream
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                serializer.Serialize(stream, data);
            }
            finally
            {
                // Close the file
                stream.Close();
            }

            #elif XBOX

            using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
                {

                    using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fullpath, FileMode.Create, iso))
                    {

                        XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                        serializer.Serialize(stream, data);

                    }

                }

            #endif
        }
Example #48
0
        private void WriteScore(HighScoreData highScores)
        {
            try
            {
                FileStream fileStream = new FileStream(HIGH_SCORE_FILE, FileMode.OpenOrCreate, FileAccess.Write);

                //BinaryWriter binaryWriter = new BinaryWriter(fileStream);
                //binaryWriter.Write(highScore);

                //binaryWriter.Close();

                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                serializer.Serialize(fileStream, highScores);
                fileStream.Close();
            }
            catch (IOException)
            {
            }

            isNewHighScore = false;
        }
Example #49
0
        public void Ini()
        {
            // Get the path of the save game
            string fullpath = "highscores.dat";

            // Check to see if the save exists
            #if WINDOWS
            if (!File.Exists(fullpath))
            {
                //If the file doesn't exist, make a fake one...
                // Create the data to save
                data = new HighScoreData(5);
                data.PlayerName[0] = "botneil";
                data.Score[0] = 20;

                data.PlayerName[1] = "botshawn";
                data.Score[1] = 10;

                data.PlayerName[2] = "botmark";
                data.Score[2] = 9;

                data.PlayerName[3] = "botcindy";
                data.Score[3] = 8;

                data.PlayerName[4] = "botsam";
                data.Score[4] = 2;

                SaveHighScores(data, HighScoresFilename, device);
            }
            #elif XBOX

            using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!iso.FileExists(fullpath))
                {
                    //If the file doesn't exist, make a fake one...
                    // Create the data to save
                    data = new HighScoreData(5);
                     data.PlayerName[0] = "botneil";
                data.Score[0] = 20;

                data.PlayerName[1] = "botshawn";
                data.Score[1] = 10;

                data.PlayerName[2] = "botmark";
                data.Score[2] = 9;

                data.PlayerName[3] = "botcindy";
                data.Score[3] = 8;

                data.PlayerName[4] = "botsam";
                data.Score[4] = 2;

                    SaveHighScores(data, HighScoresFilename, device);
                }
            }

            #endif
        }
Example #50
0
 public static void SaveHighScores(HighScoreData data, string filename, StorageDevice device)
 {
     string fullpath = "highscores.dat";
     FileStream stream = File.Open(fullpath, FileMode.OpenOrCreate);
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
         serializer.Serialize(stream, data);
     }
     finally
     {
         stream.Close();
     }
 }
 public void addPlayer(HighScoreData hs)
 {
     this.players.Add(hs);
 }
Example #52
0
        public static void SaveHighScores(HighScoreData data)
        {
            // Get the path of the saved game
            string fullpath;
            #if WINDOWS
            fullpath = Path.Combine(Path.Combine(Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                "My Games"),
                "SHMUP"),
                localHighScoreFileName);
            #elif XBOX
            fullpath = Path.Combine(container.Path, localHighScoreFileName);
            #endif

            // Open the file, creating it if necessary
            FileStream stream = File.Open(fullpath, FileMode.Create);
            try
            {
                // Convert the object to XML data and put it in the stream
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                serializer.Serialize(stream, data);
            }
            finally
            {
                // Close the file
                stream.Close();
            }
        }
Example #53
0
 public void reload_scores()
 {
     high_scores = LoadHighScores( HighScoresFilename );
 }
Example #54
0
 public static void WriteHighscoresToFile(HighScoreData data, String fileName)
 {
     // Open the file, creating it if necessary
     FileStream stream = File.Open(fileName, FileMode.OpenOrCreate);
     try
     {
         // Convert the object to XML data and put it in the stream
         XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
         //TODO: This will crash the game incase the format of the Highscore.lst file is incorrect.
         serializer.Serialize(stream, data);
     }
     finally
     {
         // Close the file
         stream.Close();
     }
 }
        /// <summary>
        /// write to an XML file the high score data for this game type
        /// </summary>
        private void saveHighScoreData()
        {
            HighScoreData highScore = new HighScoreData();
            highScore.GameType = this.ToString();
            highScore.HighScore = score;
            highScore.date = DateTime.Now;
            //if the new score is larger than the current high score, reset the high score; else do nothing.
            if (score > readHighScoreData().HighScore)
            {
                XmlSerializer writer = new XmlSerializer(typeof(HighScoreData));
                StreamWriter file = new StreamWriter("HighScore.xml");

                writer.Serialize(file, highScore);
                file.Close();
            }
        }
Example #56
0
        /* Load highscores */
        public HighScoreData LoadHighScores(string filename)
        {
            HighScoreData data;

            // Open the file
            FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Read);
            try
            {
                // Read the data from the file
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
                data = (HighScoreData)serializer.Deserialize(stream);
            }
            finally
            {
                // Close the file
                stream.Close();
            }
            return (data);
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            IsFixedTimeStep = true;

            gameTimer = new Timer();

            //try opening the high score file.  If it does not open, presume that it has not been created before
            try
            {
                StreamReader file = new StreamReader("HighScore.xml");
                file.Close();
            }
            catch
            {
                //create a new high score where the score is 0 and the date and time is the first time this game was opened
                HighScoreData highScore = new HighScoreData();
                highScore.HighScore = 0;
                highScore.date = DateTime.Now;
                XmlSerializer writer = new XmlSerializer(typeof(HighScoreData));
                StreamWriter file = new StreamWriter("HighScore.xml");
                writer.Serialize(file, highScore);
                file.Close();
            }
        }
Example #58
0
 public static HighScoreData LoadHighScores(string filename)
 {
     HighScoreData data;
     string fullpath = "highscores.dat";
     FileStream stream = File.Open(fullpath, FileMode.OpenOrCreate,
         FileAccess.Read);
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
         data = (HighScoreData)serializer.Deserialize(stream);
     }
     finally
     {
         stream.Close();
     }
     return (data);
 }
Example #59
0
        public void SetUp()
        {
            //  Get the path of the save game
            string fullPath = "highscores.dat";

            // Check to see if the save exists
            if (!File.Exists(fullPath))
            {
                //If the file doesn't exist, make a fake one...
                // Create the data to save
                data = new HighScoreData(5);
                data.Score[4] = 5;

                data.Score[3] = 4;

                data.Score[2] = 3;

                data.Score[1] = 2;

                data.Score[0] = 1;

                SaveHighScores(data, HighScoresFilename);
            }
        }
Example #60
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //creates a highscore .dat file using he scores below if there isn't one.
            string fullpath = "highscores.dat";
            if (!File.Exists(fullpath))
            {
                data = new HighScoreData(5);
                data.Score[0] = 2500;
                data.Score[1] = 1500;
                data.Score[2] = 1000;
                data.Score[3] = 500;
                data.Score[4] = 300;

                SaveHighScores(data, HighScoresFilename, null);

                IsFixedTimeStep = false;
            }
            // TODO: Add your initialization logic here

            base.Initialize();
            InitializeBindings();
            interactiveMusic.musicsystem.setParameterValue(1, 1);
        }