public static void WinGame()
 {
     GameBackground.CleanBackground();
     Console.SetCursorPosition(28, 16);
     Console.WriteLine("Congradulations, You Win!");
     System.Threading.Thread.Sleep(3000);
     GameBackground.CleanBackground();
 }
Exemple #2
0
        private void CheckForEquals()
        {
            if (Check.Count == 1)
            {
                CardPosition firstCard = Check[0];
                this.CardFace[firstCard.X, firstCard.Y].IsVisible = true;
                this.CardBack[firstCard.X, firstCard.Y].IsVisible = false;
            }
            if (Check.Count == 2)
            {
                CardPosition firstCard = Check[0];
                this.CardFace[firstCard.X, firstCard.Y].IsVisible = true;
                this.CardBack[firstCard.X, firstCard.Y].IsVisible = false;
                CardPosition secondCard = Check[1];
                this.CardFace[secondCard.X, secondCard.Y].IsVisible = true;
                this.CardBack[secondCard.X, secondCard.Y].IsVisible = false;

                Refresh();

                if (this.CardFace[firstCard.X, firstCard.Y] != this.CardFace[secondCard.X, secondCard.Y])
                {
                    this.CardFace[firstCard.X, firstCard.Y].IsVisible   = false;
                    this.CardFace[firstCard.X, firstCard.Y].IsVisible   = true;
                    this.CardFace[secondCard.X, secondCard.Y].IsVisible = false;
                    this.CardFace[secondCard.X, secondCard.Y].IsVisible = true;
                    this.Player.SuccessCoEfficient--;
                    PrintPlayerInfo("Fail");
                }
                else
                {
                    this.Player.Score += this.Player.SuccessCoEfficient > 0 ? point * this.Player.SuccessCoEfficient : point;
                    PrintPlayerInfo("Success");

                    if (CheckForGameEnd())
                    {
                        if (this.Level < maxLevel)
                        {
                            NextLevel();
                            GameBackground.CleanBackground();
                            Refresh();
                            Grid();
                        }
                        else
                        {
                            GameBackground.CleanBackground();
                            GameManager.SaveScore(this.Player);
                            GameManager.WinGame();
                        }
                    }
                }
                Check.Clear();
                System.Threading.Thread.Sleep(800);
            }
            Refresh();
        }
        public static void Menu()
        {
            const int menuItemCount      = 3;
            int       menuSwitchPosition = 0;
            int       position           = 0;

            for (int row = 0; row < menuItemCount; row++)
            {
                GameBackground.MenuBackGround(row, ConsoleColor.Black, ConsoleColor.Red);
            }

            while (true)
            {
                if (Console.KeyAvailable)
                {
                    var keyInfo = Console.ReadKey(true);
                    if (keyInfo.Key.Equals(ConsoleKey.UpArrow))
                    {
                        if (menuSwitchPosition > 0)
                        {
                            menuSwitchPosition--;
                        }
                    }
                    if (keyInfo.Key.Equals(ConsoleKey.DownArrow))
                    {
                        menuSwitchPosition++;
                    }
                    if (keyInfo.Key.Equals(ConsoleKey.Enter))
                    {
                        break;
                    }
                }
                GameBackground.MenuBackGround(position, ConsoleColor.Black, ConsoleColor.Red);
                position = menuSwitchPosition % menuItemCount;
                GameBackground.MenuBackGround(position, ConsoleColor.Cyan, ConsoleColor.Blue);
                System.Threading.Thread.Sleep(400);
            }
            GameBackground.CleanBackground();
            switch (position)
            {
            case 0:
                NewGame(level);
                break;

            case 1:
                LoadGame();
                break;

            case 2:
                Help.SomeHelp();
                break;
            }
        }
Exemple #4
0
        public static void SomeHelp()
        {
            GameBackground.CleanBackground();

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.SetCursorPosition(38, 11);
            Console.WriteLine("Help\n\n");

            Console.Write(new string(' ', 6));
            Console.WriteLine("1)  At the start of the game all the cards are laid face down.");

            Console.Write(new string(' ', 6));
            Console.WriteLine("2)  Only two cards are flipped face up over each turn.");

            Console.Write(new string(' ', 6));
            Console.WriteLine("3)  The objective is to turn over pairs of matching cards.");

            Console.Write(new string(' ', 6));
            Console.WriteLine("4)  If the cards are the same, they remain flipped until the game ends.");

            Console.Write(new string(' ', 6));
            Console.WriteLine("5)  If they are not the same, they are flipped back");

            Console.WriteLine("\n\n\n");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.SetCursorPosition(36, 22);
            Console.WriteLine("Credits:\n");

            Console.SetCursorPosition(0, 24);
            Console.Write(new string(' ', 6));
            Console.WriteLine("");

            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.SetCursorPosition(31, 27);
            Console.WriteLine("Current Highscores");
            HighScores.Read();

            Console.WriteLine("\n");
            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(27, 44);
            Console.WriteLine("Press any key to return.");
            Console.SetCursorPosition(28, 45);
            Console.WriteLine("     ...     ");
            Console.SetCursorPosition(39, 46);

            Console.ReadLine();
            GameBackground.CleanBackground();
            GameManager.Menu();
        }
 public void SerializeObject(string fileName, SerializeObject serializeObject)
 {
     try
     {
         BinaryFormatter binaryFormatter = new BinaryFormatter();
         using (Stream stream = File.Open(fileName, FileMode.Create))
         {
             binaryFormatter.Serialize(stream, serializeObject);
         }
     }
     catch (Exception)
     {
         GameBackground.CleanBackground();
         Console.SetCursorPosition(16, 10);
         Console.WriteLine("Error occured while trying to write to file.");
         System.Threading.Thread.Sleep(1000);
         GameBackground.CleanBackground();
         GameManager.Menu();
     }
 }
 public static void LoadGame()
 {
     try
     {
         string          fileName        = "../../../Save.memory";
         Serializer      serializer      = new Serializer();
         SerializeObject serializeObject = new SerializeObject();
         serializeObject = serializer.Deserializeobject(fileName);
         GameEngine gameEngine = serializeObject.GameEngine;
         gameEngine.Run();
     }
     catch (Exception)
     {
         GameBackground.CleanBackground();
         Console.SetCursorPosition(8, 10);
         Console.WriteLine("Error occureed while trying to open file, or file doesn't exist ");
         System.Threading.Thread.Sleep(1000);
         GameBackground.CleanBackground();
         GameManager.Menu();
     }
 }
Exemple #7
0
        public static string GetInput()
        {
            Console.SetCursorPosition(34, 8);
            Console.WriteLine("Enter your name below please.");

            Console.SetCursorPosition(37, 11);
            string input = Console.ReadLine();

            while (CheckInput(input) != true)
            {
                GameBackground.CleanBackground();

                Console.SetCursorPosition(27, 8);
                Console.WriteLine("The name you entereed is too short.  Please try again.");

                Console.SetCursorPosition(37, 11);
                input = Console.ReadLine();
            }
            GameBackground.CleanBackground();
            return(input);
        }
Exemple #8
0
 static void Main(string[] args)
 {
     Console.SetWindowSize(78, 50);
     GameBackground.Logo();
     GameManager.Menu();
 }