Пример #1
0
        public static void RunHighscore()
        {
            bool again = true;

            while (again)
            {
                Console.Clear();
                HighscoreList.RunHighScoreAll();
                HighscoreList.TextMenuHighscores();
                int choice = InputNumber(0, 4);
                switch (choice)
                {
                case 1:
                    Console.Clear();
                    HighScoreEachGame.OpenHighscores("highscoresnake.txt", HighScoreEachGame.ListSnake);
                    HighscoreList.PrintHighscoreEachGame("SNAKE", HighScoreEachGame.ListSnake);
                    Console.WriteLine();
                    Console.WriteLine("\t\tTryck valfri knapp för att återgå till menyn.");
                    Console.ReadKey(true);
                    break;

                case 2:
                    Console.Clear();
                    HighScoreEachGame.OpenHighscores("yatzyhighscorelist.txt", HighScoreEachGame.ListYatzy);
                    HighscoreList.PrintHighscoreEachGame("YATZY", HighScoreEachGame.ListYatzy);
                    Console.WriteLine();
                    Console.WriteLine("\t\tTryck valfri knapp för att återgå till menyn.");
                    Console.ReadKey(true);
                    break;

                case 3:
                    Console.Clear();
                    HighScoreEachGame.OpenHighscores("flappybirdhighscore.txt", HighScoreEachGame.ListFlappyBird);
                    HighscoreList.PrintHighscoreEachGame("FLAPPY BIRD", HighScoreEachGame.ListFlappyBird);
                    Console.WriteLine();
                    Console.WriteLine("\t\tTryck valfri knapp för att återgå till menyn.");
                    Console.ReadKey(true);
                    break;

                case 4:
                    Console.Clear();
                    HighScoreEachGame.OpenAndPrintHighscore();
                    Console.WriteLine("\t\tTryck valfri knapp för att återgå till menyn.");
                    Console.ReadKey(true);
                    break;

                case 0:
                    again = false;
                    break;

                default:
                    break;
                }
            }
        }
Пример #2
0
        public static void PutHighScoreInListSecretCode(int place, int lap)
        {
            HighScoreEachGame highscore = new HighScoreEachGame(GetName(), lap, SecretCodeGame.Seconds);

            ListSecretCode.Insert(place, highscore);
            if (place < 5)
            {
                ListSecretCode.RemoveAt(5);
            }
            else if (place > 4 && place < 10)
            {
                ListSecretCode.RemoveAt(10);
            }
            else if (place > 9 && place < 15)
            {
                ListSecretCode.RemoveAt(15);
            }
        }
Пример #3
0
        public static void PlayFlappyBird()
        {
            Console.SetWindowSize(95, 28);
            Console.OutputEncoding = Encoding.Unicode;
            HeightOfGameWindow     = 25;
            WidhtOfGameWindow      = 94;
            bool playAgain = true;

            GreenField.StartYPositionForWhole           = 3;
            GreenField.HeightOfWholeInField             = 6;
            GreenField.WidthSizeOfField                 = 8;
            GreenField.NumberOfPositionBetweenEachField = 22;
            GreenField.StartPositonFirstField           = 40;
            while (playAgain)
            {
                playAgain           = false;
                LapNumber           = 0;
                Points              = 0;
                Bird.Alive          = true;
                Bird.XStartPosition = 12;
                Bird.YStartPosition = 10;
                Screen.XHere        = 0;

                Field1 = new GreenField(GreenField.StartPositonFirstField);
                Field2 = new GreenField(GreenField.StartPositonFirstField + GreenField.NumberOfPositionBetweenEachField);
                Field3 = new GreenField(GreenField.StartPositonFirstField + GreenField.NumberOfPositionBetweenEachField * 2);
                Field4 = new GreenField(GreenField.StartPositonFirstField + GreenField.NumberOfPositionBetweenEachField * 3);
                Field5 = new GreenField(GreenField.StartPositonFirstField + GreenField.NumberOfPositionBetweenEachField * 4);
                Bird.CreateBird();
                Screen.StringsMakingScreen = new string[FlappyBirdGame.HeightOfGameWindow, FlappyBirdGame.WidhtOfGameWindow];

                Screen.StartGame();

                while (Bird.Alive)
                {
                    LapNumber++;
                    Console.SetCursorPosition(0, 0);

                    if (LapNumber < 1000)
                    {
                        if (LapNumber % 2 == 0)
                        {
                            GreenField.SetStartPositionOneStepBack();
                        }
                    }
                    else if (LapNumber > 1000 && LapNumber < 2000)
                    {
                        if (LapNumber % 2 == 0 || LapNumber % 3 == 0)
                        {
                            GreenField.SetStartPositionOneStepBack();
                        }
                    }
                    else
                    {
                        GreenField.SetStartPositionOneStepBack();
                    }

                    if (LapNumber % 2 == 0)
                    {
                        Bird.YStartPosition++;
                        if (Bird.YStartPosition + Bird.BirdSizeY > 26)
                        {
                            Bird.Alive = false;
                        }
                    }
                    if (Bird.YStartPosition < 0)
                    {
                        Bird.Alive = false;
                    }
                    if (Console.KeyAvailable)
                    {
                        switch (Console.ReadKey(true).Key)
                        {
                        case ConsoleKey.UpArrow:
                        {
                            Bird.YStartPosition = Bird.YStartPosition - 2;
                        }
                        break;

                        case ConsoleKey.Spacebar:
                        {
                            Bird.YStartPosition = Bird.YStartPosition - 3;
                        }
                        break;

                        case ConsoleKey.Escape:
                        {
                            Bird.Alive = false;
                        }
                        break;

                        default:
                            break;
                        }
                    }

                    Screen.CreateScreen();
                    Screen.PrintScreen();

                    System.Threading.Thread.Sleep(15);
                }

                Console.SetCursorPosition(0, 0);
                Screen.EndGame();
                Console.SetWindowSize(110, 45);
                Console.Clear();
                HighScoreEachGame.OpenHighscores("flappybirdhighscore.txt", HighScoreEachGame.ListFlappyBird);
                HighScoreEachGame.PrintOutHighscores("-------------FLAPPY BIRD-------------", HighScoreEachGame.ListFlappyBird);
                Console.WriteLine();
                Console.WriteLine($"\t\t\t\t\tDu fick {FlappyBirdGame.Points} poäng.\n");
                int maybeHighscore = HighScoreEachGame.SeeIfHighscore(HighScoreEachGame.ListFlappyBird, FlappyBirdGame.Points);
                if (maybeHighscore < 11)
                {
                    Console.WriteLine("\t\t\t\t\tGrattis! Du kom in på Highscore-listan!");
                    HighScoreEachGame.PutHighScoreInList(maybeHighscore, Points, HighScoreEachGame.ListFlappyBird);
                    HighScoreEachGame.PutHighScoreInFile("flappybirdhighscore.txt", HighScoreEachGame.ListFlappyBird);
                    Console.Clear();
                    HighScoreEachGame.OpenHighscores("flappybirdhighscore.txt", HighScoreEachGame.ListFlappyBird);
                    HighScoreEachGame.PrintOutHighscores("-------------FLAPPY BIRD-------------", HighScoreEachGame.ListFlappyBird);
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("\t\t\t\t\tBättre lycka nästa gång!\n\n");
                }
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("\t\t\t\t\tVill du spela igen?");
                Console.WriteLine("\t\t\t\t\t[1] --> JA!");
                Console.WriteLine("\t\t\t\t\t[0] --> EXIT.");
                Console.Write("\t\t\t\t\t");
                int choice = InputNumber(0, 1);
                if (choice == 1)
                {
                    playAgain = true;
                }
                Console.Clear();
            }
            Console.Clear();
            Console.ReadLine();
        }
Пример #4
0
        public static void PlaySecretCode()
        {
            Console.SetWindowSize(120, 45);
            bool playAgain = true;

            while (playAgain)
            {
                playAgain         = false;
                Code.CodeRevealed = false;
                SecretCodeScreen.Welcome();
                Code.SecretCode  = new Code(LengthOfCode);
                Code.ListOfCodes = new List <Code>();
                Console.ReadLine();
                StartTime = DateTime.Now;
                int LapCounter = 0;

                while (!Code.CodeRevealed)
                {
                    Console.Clear();
                    //for (int j = 0; j < Code.SecretCode.CodeList.Count; j++)
                    //{
                    //    Console.Write($"{Code.SecretCode.CodeList[j].Number}");
                    //}
                    SecretCodeScreen.GameName();
                    SecretCodeScreen.Choices();
                    SecretCodeScreen.HiddenSecretCode();
                    Code.PlayField(Code.ListOfCodes);
                    SecretCodeScreen.ChooseYourGuess();
                    Code.CompareCodeWithSecretCode(LapCounter);
                    LapCounter++;
                }
                Console.Clear();
                SecretCodeScreen.GameName();
                SecretCodeScreen.Choices();
                SecretCodeScreen.Result(LapCounter);
                Code.PrintCode(Code.SecretCode);
                Console.ReadLine();

                Console.Clear();
                SecretCodeScreen.GameName();
                HighScoreEachGame.OpenAndPrintHighscore();
                SecretCodeScreen.Result(LapCounter);
                Console.ForegroundColor = ConsoleColor.Red;
                int maybeHighscore = HighScoreEachGame.SeeIfHighscoreSecretCode(LapCounter, Seconds, LengthOfCode - 3);
                if (maybeHighscore < 5)
                {
                    SecretCodeScreen.YouMadeItToList();
                    HighScoreEachGame.PutHighScoreInListSecretCode(maybeHighscore + (LengthOfCode - 3) * 5, LapCounter);
                    HighScoreEachGame.PutHighScoreInFile();
                    Console.Clear();
                    SecretCodeScreen.GameName();
                    HighScoreEachGame.OpenAndPrintHighscore();
                }
                else
                {
                    SecretCodeScreen.BetterLuck();
                }

                Console.ForegroundColor = ConsoleColor.Blue;
                SecretCodeScreen.PlayAgain();
                int choice = SecretCodeScreen.InputNumber(0, 1);
                if (choice == 1)
                {
                    playAgain = true;
                }
                Console.Clear();
            }
        }
Пример #5
0
        public static void PlaySnake()
        {
            bool playAgain = true;

            Console.OutputEncoding = Encoding.Unicode;
            while (playAgain)
            {
                playAgain = false;

                Counter = 0;
                GameBoardSnake.XSize = 25;
                GameBoardSnake.YSize = 15;
                Apple         apple         = new Apple();
                Snake         snake         = new Snake(5, 5);
                SnakeFragment snakeFragment = new SnakeFragment(0, 0);
                Console.Clear();
                Intro();
                Console.ForegroundColor = ConsoleColor.Gray;
                //Console.WriteLine("\u263A");
                Console.WriteLine("\n");
                Console.WriteLine("\t\t\t\tTryck valfri tangent för att starta.\n");
                Console.ReadKey(true);
                Console.Clear();
                while (snake.Alive)
                {
                    AddSnakeFragment = false;
                    Console.SetCursorPosition(0, 0);
                    Console.WriteLine("\n\n\n\n");
                    GameBoardSnake.PrintOutGameBoard(snake.WholeSnake, apple);

                    if (Console.KeyAvailable)
                    {
                        switch (Console.ReadKey(true).Key)
                        {
                        case ConsoleKey.UpArrow:
                            if (snake.DirectionY != 1)
                            {
                                snake.DirectionX = 0;
                                snake.DirectionY = -1;
                            }
                            break;

                        case ConsoleKey.DownArrow:
                            if (snake.DirectionY != -1)
                            {
                                snake.DirectionX = 0;
                                snake.DirectionY = +1;
                            }
                            break;

                        case ConsoleKey.LeftArrow:
                            if (snake.DirectionX != 1)
                            {
                                snake.DirectionX = -1;
                                snake.DirectionY = 0;
                            }
                            break;

                        case ConsoleKey.RightArrow:
                            if (snake.DirectionX != -1)
                            {
                                snake.DirectionX = +1;
                                snake.DirectionY = 0;
                            }
                            break;

                        default:
                            break;
                        }
                    }

                    //if (AddSnakeFragment)
                    //{ snakeFragment = snake.LastSnakeFragment(); }
                    snake.WholeSnake = snake.NewPositionsForSnakeFragments();
                    //if (AddSnakeFragment)
                    //{ snake.AddOneMoreSnakeFragment(snakeFragment); }
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine($"\t\t\t\t\tPOÄNG: {SnakeGame.Counter}");
                    snake.CheckIfDies();
                    if (snake.DirectionY != 0)
                    {
                        System.Threading.Thread.Sleep(150);
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                }
                Console.WriteLine();
                Console.WriteLine("\t\t\t\t\tDu är död :(\n\n");
                System.Threading.Thread.Sleep(1000);
                Console.WriteLine("\t\t\t\t\tTryck för att se Highscore.");
                Console.ReadKey(true);

                Console.Clear();
                HighScoreEachGame.OpenHighscores("highscoresnake.txt", HighScoreEachGame.ListSnake);
                HighScoreEachGame.PrintOutHighscores("----------------------SNAKE--------------------", HighScoreEachGame.ListSnake);
                Console.WriteLine();
                Console.WriteLine($"\t\t\t\t\tDu fick {SnakeGame.Counter} poäng.\n");
                int maybeHighscore = HighScoreEachGame.SeeIfHighscore(HighScoreEachGame.ListSnake, SnakeGame.Counter);
                if (maybeHighscore < 11)
                {
                    Console.WriteLine("\t\t\t\t\tGrattis! Du kom in på Highscore-listan!");
                    HighScoreEachGame.PutHighScoreInList(maybeHighscore, SnakeGame.Counter, HighScoreEachGame.ListSnake);
                    HighScoreEachGame.PutHighScoreInFile("highscoresnake.txt", HighScoreEachGame.ListSnake);
                    Console.Clear();
                    HighScoreEachGame.OpenHighscores("highscoresnake.txt", HighScoreEachGame.ListSnake);
                    HighScoreEachGame.PrintOutHighscores("----------------SNAKE----------------", HighScoreEachGame.ListSnake);
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("\t\t\t\t\tBättre lycka nästa gång!\n\n");
                }
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("\t\t\t\t\tVill du spela igen?");
                Console.WriteLine("\t\t\t\t\t[1] --> JA!");
                Console.WriteLine("\t\t\t\t\t[0] --> EXIT.");
                Console.Write("\t\t\t\t\t");
                int choice = InputNumber(0, 1);
                if (choice == 1)
                {
                    playAgain = true;
                }
            }
            Console.ReadLine();
        }
Пример #6
0
 public static void OpenAndPrintHighscore()
 {
     HighScoreEachGame.OpenHighscoresSecretCode();
     HighScoreEachGame.PrintOutHighscoresSecretCode();
     Console.WriteLine();
 }
Пример #7
0
        //public static void OpenAndPrintHighscore()
        //{
        //    Console.Clear();
        //    HighScoreEachGame.OpenHighscores();
        //    HighScoreEachGame.PrintOutHighscores();
        //    Console.WriteLine();
        //}
        public static void PutHighScoreInList(int place, int record, List <HighScoreEachGame> lista)
        {
            HighScoreEachGame highscore = new HighScoreEachGame(GetName(), record);

            lista.Insert(place, highscore);
        }