Пример #1
0
        private static void Fight(Kvadrat kvadrat, Spelare spelare)
        {
            playerInFight = true;

            while (playerInFight)
            {
                Console.Clear();
                DrawFight(kvadrat, spelare);
            }
        }
Пример #2
0
        public static void PrintStats(Spelare spelare)
        {
            Console.Write("╔");

            for (int i = 0; i < Spelare.Namn.Length + spelare.PlayerLevel.ToString().Length + Spelare.Hp.ToString().Length + Spelare.Ras.Length + 25; i++)
            {
                Console.Write("═");
            }

            Console.WriteLine("╗");


            Console.Write($"║");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write("LVL");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write($": { spelare.PlayerLevel}│");
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.Write($"NAME");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write($": { Spelare.Namn}│");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write($"HP");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write($": {Spelare.Hp}│");
            Console.ForegroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write($"Race: ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write($"{Spelare.Ras}");
            Console.Write($" ║");
            Console.WriteLine();

            Console.Write("╚");

            for (int i = 0; i < Spelare.Namn.Length + +spelare.PlayerLevel.ToString().Length + Spelare.Hp.ToString().Length + Spelare.Ras.Length + 25; i++)
            {
                Console.Write("═");
            }

            Console.Write("╝");
        }
Пример #3
0
        public static void Event(Level level, Spelare spelare)
        {
            Kvadrat[,] kvadratArray = level.kvadrater;

            for (int i = 0; i < kvadratArray.GetLength(0); i++)
            {
                for (int j = 0; j < kvadratArray.GetLength(1); j++)
                {
                    if (kvadratArray[i, j].Monster && kvadratArray[i, j].Spelare)
                    {
                        Fight(kvadratArray[i, j], spelare);
                    }


                    if (kvadratArray[i, j].Kista && kvadratArray[i, j].Spelare)
                    {
                        Collect(kvadratArray[i, j]);
                    }
                }
            }
        }
Пример #4
0
        private static void SkapaKaraktär()
        {
            string[,] rasVal = { { "Human", "1" }, { "Dwarf", "0" }, { "Elf", "0" }, { "Orc", "0" } };
            int  menyVal   = 0;
            bool inmatning = false;

            while (!inmatning)
            {
                Console.Clear();

                Console.WriteLine("╔═══════════════╗");
                for (int i = 0; i < rasVal.GetLength(0); i++)
                {
                    if (rasVal[i, 1] == "1")
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("     " + " ► ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(rasVal[i, 0]);
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(" ◄ ");
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    else
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("     " + rasVal[i, 0]);
                    }
                }
                Console.WriteLine("╚═══════════════╝");

                if (menyVal == 0)
                {
                    Console.WriteLine("╔════════════════════════════════╗");
                    Console.WriteLine("║ The Human race is average when ║");
                    Console.WriteLine("║ it comes to health and attack  ║");
                    Console.WriteLine("╚════════════════════════════════╝");
                }

                if (menyVal == 1)
                {
                    Console.WriteLine("╔═══════════════════════════════════════════════════╗");
                    Console.WriteLine("║ The dwarven race is slightly bulky, the bulkiness ║");
                    Console.WriteLine("║ slightly increases HP but decreases attack.       ║");
                    Console.WriteLine("╚═══════════════════════════════════════════════════╝");
                }

                if (menyVal == 2)
                {
                    Console.WriteLine("╔═══════════════════════════════════════════════════╗");
                    Console.WriteLine("║ The elven race is less bulky, less bulkiness      ║");
                    Console.WriteLine("║ results in decreased HP but increased attack.     ║");
                    Console.WriteLine("╚═══════════════════════════════════════════════════╝");
                }

                if (menyVal == 3)
                {
                    Console.WriteLine("╔══════════════════════════════════════════════════════════════╗");
                    Console.WriteLine("║ The orcish race is very strong but lack armour, this results ║");
                    Console.WriteLine("║ in vastly decreased HP but it vastly increases attack.       ║");
                    Console.WriteLine("╚══════════════════════════════════════════════════════════════╝");
                }

                ConsoleKeyInfo input = Console.ReadKey(true);

                if (input.Key == ConsoleKey.UpArrow && menyVal != 0)
                {
                    rasVal[menyVal, 1] = "0";
                    menyVal--;
                    rasVal[menyVal, 1] = "1";
                }


                if (input.Key == ConsoleKey.DownArrow && menyVal != 3)
                {
                    rasVal[menyVal, 1] = "0";
                    menyVal++;
                    rasVal[menyVal, 1] = "1";
                }

                if (input.Key == ConsoleKey.Enter)
                {
                    inmatning = true;
                    string valdRas = rasVal[menyVal, 0];
                    Console.WriteLine("Enter your name: ");
                    string namn = Console.ReadLine();
                    spelare = new Spelare(namn, valdRas);
                    spela   = true;
                }
            }
        }
Пример #5
0
        public static void Print(Level level, Spelare spelare)
        {
            Console.Clear();
            Kvadrat[,] levelInnehåll = level.kvadrater;
            Console.WriteLine($"{level.levelNamn}  Score: {Spelare.Score}");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            for (int i = -1; i <= levelInnehåll.GetLength(0); i++)
            {
                for (int j = -1; j <= levelInnehåll.GetLength(1); j++)
                {
                    if (i == -1)
                    {
                        if (j == -1)
                        {
                            Console.Write("╔");
                        }

                        if (j > -1 && j < levelInnehåll.GetLength(1))
                        {
                            Console.Write("═");
                        }

                        if (j == levelInnehåll.GetLength(1))
                        {
                            Console.Write("╗");
                        }
                    }

                    else if (j == -1 && i != -1 && i != levelInnehåll.GetLength(0) || j == levelInnehåll.GetLength(1) && i != -1 && i != levelInnehåll.GetLength(0))
                    {
                        Console.Write("║");
                    }

                    else if (i == levelInnehåll.GetLength(0))
                    {
                        if (j == -1)
                        {
                            Console.Write("╚");
                        }

                        if (j > -1 && j < levelInnehåll.GetLength(1))
                        {
                            Console.Write("═");
                        }

                        if (j == levelInnehåll.GetLength(1))
                        {
                            Console.Write("╝");
                        }
                    }

                    else if (levelInnehåll[i, j].Monster)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.Write("☻");
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                    }

                    else if (levelInnehåll[i, j].Kista)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkYellow;
                        Console.Write("■");
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                    }

                    else if (levelInnehåll[i, j].Spelare)
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("☻");
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                    }

                    else
                    {
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.Write(" ");
                    }
                }

                Console.WriteLine();
            }

            Console.ForegroundColor = ConsoleColor.White;
            PrintStats(spelare);
        }
Пример #6
0
        private static void DrawFight(Kvadrat kvadrat, Spelare spelare)
        {
            PrintEnemy(kvadrat);
            PrintStats(spelare);
            Console.WriteLine();

            if (spelaresTur)
            {
                Console.WriteLine("╔════════════════════════════════╗");
                for (int i = 0; i < fightMeny.GetLength(0); i++)
                {
                    Console.Write("   ");

                    if (fightMeny[i, 1] == "1")
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write(fightMeny[i, 0]);
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    else
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(fightMeny[i, 0]);
                    }
                }

                Console.WriteLine();
                Console.WriteLine("╚════════════════════════════════╝");


                Console.WriteLine();

                ConsoleKeyInfo input = Console.ReadKey(true);

                if (input.Key == ConsoleKey.RightArrow && fightMenyVal != 3)
                {
                    fightMeny[fightMenyVal, 1] = "0";
                    fightMenyVal++;
                    fightMeny[fightMenyVal, 1] = "1";
                }


                if (input.Key == ConsoleKey.LeftArrow && fightMenyVal != 0)
                {
                    fightMeny[fightMenyVal, 1] = "0";
                    fightMenyVal--;
                    fightMeny[fightMenyVal, 1] = "1";
                }

                if (input.Key == ConsoleKey.Enter)
                {
                    if (fightMenyVal == 0)
                    {
                        Attack(kvadrat);
                    }

                    else if (fightMenyVal == 1)
                    {
                        Spelare.Inventory[0].Vald = true;

                        bool vald = false;

                        int menyVal = 0;

                        while (!vald)
                        {
                            Console.Clear();
                            PrintEnemy(kvadrat);
                            PrintStats(spelare);
                            Console.WriteLine();
                            spelare.PrintInventory();


                            ConsoleKeyInfo input2 = Console.ReadKey(true);

                            if (input2.Key == ConsoleKey.UpArrow)
                            {
                                if (menyVal != 0)
                                {
                                    Spelare.Inventory[menyVal].Vald = false;
                                    menyVal--;
                                    Spelare.Inventory[menyVal].Vald = true;

                                    Console.Beep(300, 100);
                                }
                            }

                            if (input2.Key == ConsoleKey.DownArrow)
                            {
                                if (menyVal < Spelare.Inventory.Count - 1)
                                {
                                    Spelare.Inventory[menyVal].Vald = false;
                                    menyVal++;
                                    Spelare.Inventory[menyVal].Vald = true;

                                    Console.Beep(300, 100);
                                }
                            }

                            if (input2.Key == ConsoleKey.Enter)
                            {
                                Spelare.Inventory[menyVal].AnvändFöremål(kvadrat);
                                vald        = true;
                                spelaresTur = false;
                            }

                            Console.Clear();
                        }
                    }

                    else if (fightMenyVal == 2)
                    {
                        Pass();
                        spelaresTur = false;
                    }

                    else
                    {
                        Flee();
                        spelaresTur = false;
                    }
                }
            }

            else if (!spelaresTur)
            {
                FiendeAttack(kvadrat.Fiende);
                spelaresTur = true;
            }
        }
Пример #7
0
        public static void MovePlayer(Level level, Spelare spelare)
        {
            Kvadrat[,] kvadratArray = level.kvadrater;

            ConsoleKeyInfo input = Console.ReadKey();

            try
            {
                for (int i = 0; i < kvadratArray.GetLength(0); i++)
                {
                    for (int j = 0; j < kvadratArray.GetLength(1); j++)
                    {
                        if (kvadratArray[i, j].Spelare)
                        {
                            currentYPos = i;
                            currentXPos = j;
                            kvadratArray[i, j].Spelare = false;
                        }
                    }
                }

                if (input.Key == ConsoleKey.UpArrow)
                {
                    currentYPos--;
                    kvadratArray[currentYPos, currentXPos].Spelare = true;
                }

                if (input.Key == ConsoleKey.RightArrow)
                {
                    currentXPos++;
                    kvadratArray[currentYPos, currentXPos].Spelare = true;
                }

                if (input.Key == ConsoleKey.DownArrow)
                {
                    currentYPos++;
                    kvadratArray[currentYPos, currentXPos].Spelare = true;
                }

                if (input.Key == ConsoleKey.LeftArrow)
                {
                    currentXPos--;
                    kvadratArray[currentYPos, currentXPos].Spelare = true;
                }

                Event(level, spelare);
                Print(level, spelare);
            }
            catch (IndexOutOfRangeException)
            {
                if (input.Key == ConsoleKey.UpArrow)
                {
                    currentYPos++;
                    kvadratArray[currentYPos, currentXPos].Spelare = true;
                }

                if (input.Key == ConsoleKey.RightArrow)
                {
                    currentXPos--;
                    kvadratArray[currentYPos, currentXPos].Spelare = true;
                }

                if (input.Key == ConsoleKey.DownArrow)
                {
                    currentYPos--;
                    kvadratArray[currentYPos, currentXPos].Spelare = true;
                }

                if (input.Key == ConsoleKey.LeftArrow)
                {
                    currentXPos++;
                    kvadratArray[currentYPos, currentXPos].Spelare = true;
                }
            }
        }