Example #1
0
        /// <summary>
        /// The class constructor. Loads a GameValues instance and the
        /// computer's high score table, creates a board and random number
        /// generator instance, and generates the first level.
        /// </summary>
        /// <param name="gameValues">The files that will manage every important
        /// thing to begin the level. Can be 'loaded' from a saved game or
        /// a new one.</param>
        public Game(GameValues gameValues)
        {
            // Loads the highscore table and current game values.
            this.gameValues = gameValues;
            highscoreTable  = SaveManager.Load();

            // Create board and rand instance
            board = new Board(gameValues.Width, gameValues.Height);
            rand  = new Random();

            GenerateLevel();
        }
Example #2
0
        static void Main(string[] args)
        {
            // Makes it so that the program supports unicode characters.
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            // Gets the arguments from the command line and creates a new
            // GameValue object with the same arguments.
            GameValues gameValues = GameValues.ConvertArgs(args);
            Game       game       = new Game(gameValues);

            // Starts the game.
            game.Initiate();
        }
Example #3
0
        /// <summary>
        /// Saves the game progress inside a file
        /// </summary>
        /// <param name="gameValues"> Class that contains the data to be
        /// saved</param>
        /// <param name="fileName"> Name of the file choosen by the user
        /// where the data is saved</param>
        public static void Save(GameValues gameValues, string fileName)
        {
            // Open file in writeable mode
            StreamWriter sw = new StreamWriter(fileName);


            // Save the game data in the file
            sw.WriteLine(gameValues.Width);
            sw.WriteLine(gameValues.Height);
            sw.WriteLine(gameValues.Level);
            sw.WriteLine(gameValues.Hp);


            // Close file
            sw.Close();
        }