Example #1
0
        /// <summary>
        /// Initiate start values in the form
        /// </summary>
        private void initializeGUI()
        {

            ///Initiate the objects that is needed from the start
            loadSaveManager = new LoadSave();
            lingoGame = new Lingo();
            wordManager = new WordManager();
            resultColors = new Colors[5];
            foundLetters = new Colors[5] { Colors.Red, Colors.Red, Colors.Red,
                    Colors.Red, Colors.Red };
            
            ///Initiate the playboard and put all the 
            ///textboxes to the playboard-array
            playBoard = new TextBox[5, 5];
            getGuiBoxesToArray();

            getFirstLetter(); ///Get the first letter to ease up the game

            updateGUI();
        }
Example #2
0
        /// <summary>
        /// Save the current state of the game
        /// </summary>
        private void saveGame(string pPath)
        {
            earlierLetters = new String[5, 5];
            earlierResult = new Colors[5, 5];

            ///For each row
            for (int i = 0; i <= lingoGame.AmountOfGuesses; i++)

                ///For each letter
                for (int j = 0; j < 5; j++)
                {
                    ///Save the letter
                    earlierLetters[i, j] = playBoard[i, j].Text;

                    ///Save the color of the textbox on the playboard
                    if (playBoard[i, j].BackColor == Color.Green)
                    {
                        earlierResult[i, j] = Colors.Green;
                    }

                    else if (playBoard[i, j].BackColor == Color.Orange)
                    {
                        earlierResult[i, j] = Colors.Orange;
                    }

                    else if (playBoard[i, j].BackColor == Color.Red)
                    {
                        earlierResult[i, j] = Colors.Red;
                    }
                }

            ///Create savefile object with the games objects
            saveFile = new SaveFile(lingoGame, wordManager, resultColors, foundLetters, earlierResult,
                earlierLetters);

            ///Save to file
            loadSaveManager = new LoadSave();
            loadSaveManager.SaveData(saveFile, pPath);
        }
Example #3
0
        /// <summary>
        /// Load a previous game-session into the current session of the game
        /// </summary>
        /// <returns></returns>
        private bool loadGame()
        {


            LoadForm loadForm = new LoadForm();
            loadForm.ShowDialog();
            string loadPath = loadForm.saveFilePath;

            loadSaveManager = new LoadSave();
            saveFile = loadSaveManager.loadData(saveFile, loadPath);

            if (saveFile != null)
            {
                resetBoard();

                lingoGame = saveFile.lingoGame;
                wordManager = saveFile.wordManager;
                resultColors = saveFile.result;
                foundLetters = saveFile.foundLetters;
                earlierLetters = saveFile.earlierLetters;
                earlierResult = saveFile.earlierResult;

                ///If a game is loaded after the previous is finnished
                if (!btnCheck.Enabled) 
                    btnCheck.Enabled = true;

                return true;
            }

            else { return false; }
        }