Beispiel #1
0
        static void Main(string[] args)
        {
            SoundPlayer Overworld = new SoundPlayer(Path.GetFullPath(@"Music\Overworld.wav"));

            Overworld.PlayLooping();
            Console.Title = "RPG";
            char playagain;
            bool play = true;

            while (play == true)
            {
                Console.SetWindowSize(100, 30);
                Hero hero  = new Hero(30, 5, 1, 0, 0);
                Map  world = new Map();
                world.Generate();
                world.refresh();
                while (hero.HP > 0)
                {
                    world.refresh();
                    hero.showstats();
                    Console.WriteLine("WSAD - nawigacja po mapie");
                    try
                    {
                        char side = char.Parse(Console.ReadLine());
                        world.movement(side, ref hero, ref world, Overworld);
                    }
                    catch (FormatException)
                    {
                    }
                    world.refresh();
                }
                Console.Clear();
                Console.WriteLine("przegrales! czy chcesz zagrac jeszcze raz? t/n");
                try
                {
                    playagain = char.Parse(Console.ReadLine());

                    if (playagain == 't')
                    {
                    }
                    else
                    {
                        play = false;
                    }
                }
                catch (FormatException) { };
            }
        }
Beispiel #2
0
        static public void fight(string mob, ref Hero hero, SoundPlayer Overworld, string songpath)
        {
            SoundPlayer Battle = new SoundPlayer(Path.GetFullPath(songpath));

            Battle.Play();
            Console.Clear();
            Console.BackgroundColor = ConsoleColor.Red;
            for (int height = 0; height < Console.WindowHeight; height++)
            {
                for (int width = 0; width < Console.WindowWidth; width++)
                {
                    Console.Write(" ");
                }
                Console.WriteLine();
                Thread.Sleep(25);
            }
            Console.ResetColor();
            Console.Clear();
            string[] mobstats = mob.Split(';');
            char     move;
            Random   HitChance = new Random();
            int      MobHP     = Convert.ToInt32(mobstats[1]);
            int      MobFullHP = MobHP;
            int      MobDMG    = Convert.ToInt32(mobstats[2]);
            int      MobDMGRoll;
            int      MobID       = Convert.ToInt32(mobstats[3]);
            string   MobName     = mobstats[0];
            int      MoneyReward = MobHP / 3 + MobDMG / 3;
            int      ExpReward   = MobHP * 2 + MobDMG;

            Console.Clear();
            Console.WriteLine("zaatakowal cie" + " " + MobName);
            Console.ReadKey();
            while (MobHP > 0 && hero.HP > 0)
            {
                MobDMGRoll = MobDMG + HitChance.Next(-3, 4);
                if (HitChance.Next(1, 11) > 5 && MobDMGRoll > 0)
                {
                    if (hero.Guard == true)
                    {
                        int blockedhit = MobDMGRoll - hero.Strength;
                        if (hero.Strength >= MobDMGRoll)
                        {
                            Console.Clear();
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("atak zablokowany!");
                            Console.ResetColor();
                            Console.ReadKey();
                        }
                        else
                        {
                            Console.Clear();
                            hero.HP -= blockedhit;
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("atak częściowo zablokowany! " + blockedhit + " dmg");
                            Console.ResetColor();
                            Console.ReadKey();
                        }
                        hero.Guard = false;
                    }
                    else
                    {
                        Console.Clear();
                        hero.HP -= MobDMGRoll;
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(MobName + " uderza za " + MobDMGRoll + " dmg");
                        Console.ResetColor();
                        Console.ReadKey();
                    }
                }
                else
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(MobName + " Pudluje!");
                    Console.ResetColor();
                    Console.ReadKey();
                }
                hero.showstats();
                if (hero.HP <= 0)
                {
                    Overworld.PlayLooping();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("osuwasz sie na ziemie i padasz w kaluzy swojej krwi");
                    Console.ReadKey();
                    Console.ResetColor();
                    break;
                }
                Console.Write("HP przeciwnika:" + MobHP);
                if (MobID == 1001)
                {
                    Console.WriteLine(@"
  ,   A           {}
 / \, | ,        .--.
|    =|= >      /.--.\
 \ /` | `       |====|
  `   |         |`::`|  
      |     .-;`\..../`;_.-^-._
     /\\/  /  |...::..|`   :   `|
     |:'\ |   /'''::''|   .:.   |
      \ /\;-,/\   ::  |..:::::..|
      |\ <` >  >._::_.| ':::::' |
      | `--`  /   ^^  |   ':'   |
      |       |       \    :    /
      |       |        \   :   / 
      |       |___/\___|`-.:.-`
      |        \_ || _/    `
      |        <_ >< _>
      |        |  ||  |
      |        |  ||  |
      |       _\.:||:./_
      |      /____/\____\");
                }
                hero.showbars(MobHP, MobFullHP, ConsoleColor.Green, ConsoleColor.Red);
                Console.WriteLine("co robisz: a-atak b-blok u-ucieczka h-użycie mikstury ");
                try
                {
                    move = Convert.ToChar(Console.ReadLine());


                    switch (move)
                    {
                    case 'b':
                        Console.WriteLine("przygotowujesz sie do bloku!");
                        hero.Guard = true;
                        break;

                    case 'a':
                        if (HitChance.Next(1, 11) > 2)
                        {
                            int hit = HitChance.Next(1, 5) * hero.Strength;
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("trafiasz za " + hit + " dmg");
                            Console.ForegroundColor = ConsoleColor.White;
                            MobHP -= hit;
                        }
                        else
                        {
                            Console.WriteLine("Pudlujesz!");
                        }
                        break;

                    case 'u':
                        if (MobID == 1001)
                        {
                            Console.WriteLine("Nie możesz uciec przed mrokiem");
                            break;
                        }
                        if (HitChance.Next(1, 11) > 5)
                        {
                            Overworld.PlayLooping();
                            Console.Clear();
                            Console.WriteLine("udało ci sie zwiać!");
                            Console.ReadKey();
                            return;
                        }
                        else
                        {
                            Console.WriteLine("nie udało ci sie uciec");
                        }
                        break;

                    case 'h':
                        if (hero.potions > 0)
                        {
                            Console.Clear();
                            hero.potions--;
                            hero.HP += 10;
                            Console.WriteLine("uleczyłeś 10HP");
                            Console.ReadKey();
                        }
                        else
                        {
                            Console.Clear();
                            Console.WriteLine("nie masz mikstur!");
                            Console.ReadKey();
                        }
                        break;
                    }
                    Console.ReadKey();
                }
                catch (FormatException) { }
                Console.Clear();
            }
            Console.WriteLine("koniec walki!");
            if (MobHP <= 0)
            {
                Overworld.PlayLooping();
                hero.Money      += MoneyReward;
                hero.Experience += ExpReward;
                Console.WriteLine("otrzymujesz " + MoneyReward + " sztuki zlota oraz " + ExpReward + " pkt doświadczenia");
            }
            Console.ReadKey();
        }