예제 #1
0
        //This is where the actual *Game* takes place, after killing each set of bandits, the player is given gold
        //equal to their combined bounties.
        public void Hideout()
        {
            Program.p.HP = Program.p.Con * 4;
            int  phase         = 0;
            int  eIDint        = 0;
            int  rep           = 1;
            int  wepInt        = 0;
            bool inCombat      = false;
            bool playerDeath   = false;
            bool playerRetreat = false;

            foreach (Weapons wep in Weapons.WeaponsOwned)
            {
                wep.cRam = rep;
                rep++;
            }
            if (!playerDeath && !playerRetreat)
            {
                if (phase == 0)
                {
                    sC.TB("You walk up to the hideout, three gang members are lingering outside and notice you. ");
                    sC.RK(' ');
                    Console.Clear();
                    eIDint = 0;

                    //ph0 = Phase 0, spawns 3 of the weakest for the player to fight.
                    var ph0 = new List <Enemies>
                    {
                        new Thug(1),
                        new Thug(2),
                        new Thug(3)
                    };
                    inCombat = true;
                    while (inCombat)
                    {
                        Console.WriteLine("");
                        Console.Write("Name: ");
                        foreach (Enemies e in ph0)
                        {
                            Console.Write($"\t[{e.EID}] {e.Name}");
                        }
                        Console.Write("\nHealth: ");
                        foreach (Enemies e in ph0)
                        {
                            if (e.EHP > 0)
                            {
                                Console.Write($"{e.EHP}\t\t");
                            }
                            else
                            {
                                Console.Write("Dead\t\t");
                            }
                        }


                        Console.WriteLine();
                        Console.WriteLine($"Choose an enemy to attack\nCurrent Health: {Program.p.HP}");
                        sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref eIDint);
                        foreach (Enemies e in ph0)
                        {
                            if (eIDint == e.EID)
                            {
                                Console.WriteLine($"Choose a weapons to use");
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    Console.Write($"[{wep.cRam}] {wep.name}\t");
                                }
                                Console.WriteLine("");
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    Console.Write($"Damage: {wep.truDamage = wep.bDamage + (Program.p.Dex * wep.DexMod) + (Program.p.Str * wep.StrMod)}\t\t");
                                }
                                sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref wepInt);
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    if (wepInt == wep.cRam)
                                    {
                                        e.EHP -= wep.truDamage;
                                    }
                                }
                            }
                        }
                        Console.WriteLine();
                        int deadT = 0;
                        foreach (Enemies eCheck in ph0)
                        {
                            if (eCheck.EHP <= 0)
                            {
                                eCheck.IsAlive = false;
                            }

                            if (eCheck.IsAlive)
                            {
                                int tInt = h.R2H(0) + 7;
                                if (tInt >= Program.p.Per + Program.p.Dex)
                                {
                                    Console.WriteLine($"{eCheck.DPT} Damage Taken from thug [{eCheck.EID}]");
                                    Program.p.HP -= eCheck.DPT;
                                }
                                else
                                {
                                    Console.WriteLine($"Thug [{eCheck.EID}] missed!");
                                }
                            }
                            else
                            {
                                Console.WriteLine($"Thug [{eCheck.EID}] is dead.");
                                deadT++;
                            }
                            if (deadT >= 3)
                            {
                                sC.TB($"You collected {eCheck.Bounty * 3} Gold from their bounties");
                                Program.p.Gold += eCheck.Bounty * 3;
                                inCombat        = false;
                                phase           = 1;
                            }
                        }
                        if (Program.p.HP <= 0)
                        {
                            playerDeath = true;
                            inCombat    = false;
                        }
                    }
                }
            }
            if (!playerDeath && !playerRetreat)
            {
                //The player is given the opportunity to retreat here, if they
                //press R they get sent back to town and their health gets reset to full.
                sC.TB("As you push in through the entrance, you run into a captain and his guards investigating the commotion.\nPress [R] to retreat or [Enter] continue");
                char tempchar = sC.RK(' ');
                if (tempchar == 'r')
                {
                    phase = 3;
                    Program.p.Location = 1;
                    playerRetreat      = true;
                    inCombat           = false;
                }
                if (phase == 1)
                {
                    //Phase 1 spawns another set of enemies, this time with a captain among them.
                    var ph1 = new List <Enemies>
                    {
                        new Thug(1),
                        new Thug(2),
                        new Captain(3)
                    };
                    Console.Clear();
                    eIDint   = 0;
                    inCombat = true;
                    while (inCombat)
                    {
                        if (Program.p.HP <= 0)
                        {
                            playerDeath = true;
                            inCombat    = false;
                        }
                        Console.WriteLine("");
                        Console.Write("Name: ");
                        foreach (Enemies e in ph1)
                        {
                            Console.Write($"\t[{e.EID}] {e.Name}");
                        }
                        Console.Write("\nHealth: ");
                        foreach (Enemies e in ph1)
                        {
                            if (e.EHP > 0)
                            {
                                Console.Write($"{e.EHP}\t\t");
                            }
                            else
                            {
                                Console.Write("Dead\t\t");
                            }
                        }

                        Console.WriteLine("\n\n");
                        Console.WriteLine($"Choose an enemy to attack\nCurrent Health: {Program.p.HP}");
                        sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref eIDint);
                        foreach (Enemies e in ph1)
                        {
                            if (eIDint == e.EID)
                            {
                                Console.WriteLine($"Choose a weapons to use");
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    Console.Write($"[{wep.cRam}] {wep.name}\t");
                                }
                                Console.WriteLine("");
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    Console.Write($"{wep.truDamage = wep.bDamage + (Program.p.Dex * wep.DexMod) + (Program.p.Str * wep.StrMod)}\t\t");
                                }
                                sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref wepInt);
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    if (wepInt == wep.cRam)
                                    {
                                        e.EHP -= wep.truDamage;
                                    }
                                }
                            }
                        }
                        Console.WriteLine();
                        int deadT = 0;
                        foreach (Enemies eCheck in ph1)
                        {
                            if (eCheck.EHP <= 0)
                            {
                                eCheck.IsAlive = false;
                            }

                            if (eCheck.IsAlive)
                            {
                                int tInt = h.R2H(0) + 7;
                                if (tInt >= Program.p.Per + Program.p.Dex)
                                {
                                    Console.WriteLine($"{eCheck.DPT} Damage Taken from {eCheck.Name} [{eCheck.EID}]");
                                    Program.p.HP -= eCheck.DPT;
                                }
                                else
                                {
                                    Console.WriteLine($"{eCheck.Name} [{eCheck.EID}] missed!");
                                }
                            }
                            else
                            {
                                Console.WriteLine($"{eCheck.Name} [{eCheck.EID}] is dead.");
                                deadT++;
                            }
                            if (deadT >= 3)
                            {
                                int tInt = 0;
                                foreach (Enemies eDeath in ph1)
                                {
                                    tInt += eDeath.Bounty;
                                }
                                sC.TB($"You collected {tInt} Gold from their bounties");
                                Program.p.Gold += tInt;
                                inCombat        = false;
                                phase           = 2;
                            }
                        }
                    }
                }
            }
            if (!playerDeath && !playerRetreat)
            {
                sC.TB("As you move up the stairs, a honcho and his goons ambush you.\nPress [R] to retreat or [Enter] continue");
                char tempchar = sC.RK(' ');
                if (tempchar == 'r')
                {
                    phase = 3;
                    Program.p.Location = 1;
                    playerRetreat      = true;
                    inCombat           = false;
                }
                if (phase == 2)
                {
                    var ph2 = new List <Enemies>
                    {
                        new Thug(1),
                        new Honcho(2),
                        new Thug(3)
                    };
                    Console.Clear();
                    eIDint   = 0;
                    inCombat = true;
                    while (inCombat)
                    {
                        Console.WriteLine("");
                        Console.Write("Name: ");
                        foreach (Enemies e in ph2)
                        {
                            Console.Write($"\t[{e.EID}] {e.Name}");
                        }
                        Console.Write("\nHealth: ");
                        foreach (Enemies e in ph2)
                        {
                            if (e.EHP > 0)
                            {
                                Console.Write($"{e.EHP}\t\t");
                            }
                            else
                            {
                                Console.Write("Dead\t\t");
                            }
                        }

                        Console.WriteLine();
                        Console.WriteLine($"Choose an enemy to attack\nCurrent Health: {Program.p.HP}");
                        sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref eIDint);
                        foreach (Enemies e in ph2)
                        {
                            if (eIDint == e.EID)
                            {
                                Console.WriteLine($"Choose a weapons to use");
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    Console.Write($"[{wep.cRam}] {wep.name}\t");
                                }
                                Console.WriteLine("");
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    Console.Write($"{wep.truDamage = wep.bDamage + (Program.p.Dex * wep.DexMod) + (Program.p.Str * wep.StrMod)}\t\t");
                                }
                                sC.ITP(Console.ReadKey(true).KeyChar.ToString(), ref wepInt);
                                foreach (Weapons wep in Weapons.WeaponsOwned)
                                {
                                    if (wepInt == wep.cRam)
                                    {
                                        e.EHP -= wep.truDamage;
                                    }
                                }
                            }
                        }
                        Console.WriteLine();
                        int deadT = 0;
                        foreach (Enemies eCheck in ph2)
                        {
                            if (eCheck.EHP <= 0)
                            {
                                eCheck.IsAlive = false;
                            }

                            if (eCheck.IsAlive)
                            {
                                int tInt = h.R2H(0) + 7;
                                if (tInt >= Program.p.Per + Program.p.Dex)
                                {
                                    Console.WriteLine($"{eCheck.DPT} Damage Taken from {eCheck.Name} [{eCheck.EID}]");
                                    Program.p.HP -= eCheck.DPT;
                                }
                                else
                                {
                                    Console.WriteLine($"{eCheck.Name} [{eCheck.EID}] missed!");
                                }
                            }
                            else
                            {
                                Console.WriteLine($"{eCheck.Name} [{eCheck.EID}] is dead.");
                                deadT++;
                            }
                            if (deadT >= 3)
                            {
                                int tInt = 0;
                                foreach (Enemies eDeath in ph2)
                                {
                                    tInt += eDeath.Bounty;
                                }
                                sC.TB($"You collected {tInt} Gold from their bounties");
                                Program.p.Gold += tInt;
                                inCombat        = false;
                            }
                        }
                        if (Program.p.HP <= 0)
                        {
                            playerDeath = true;
                            inCombat    = false;
                        }
                    }
                }
            }
            if (phase == 3)
            {
            }

            //if the player were to die, then they would be sent here.
            if (playerDeath)
            {
                sC.TB("You have died. \n[L]oad a previous save or [Q]uit;");
                Program.p.isDead = true;
            }
            else if (!playerDeath && !playerRetreat)
            {
                sC.RL("Although you cleared out the bandits' hideout this time, \nyou know more will take their place soon.");
                Console.WriteLine("Press Any Key to Continue...");
                sC.RK(' ');
            }
        }
예제 #2
0
 //Reads the test.txt file and the PlayerInv.csv and applies their data to the current player.
 public void LoadSave()
 {
     Console.Clear();
     name = sC.FRL(0);
     sC.ITP(sC.FRL(1), ref Str);
     sC.ITP(sC.FRL(2), ref Dex);
     sC.ITP(sC.FRL(3), ref Int);
     sC.ITP(sC.FRL(4), ref Con);
     sC.ITP(sC.FRL(5), ref Per);
     sC.ITP(sC.FRL(6), ref Gold);
     sC.ITP(sC.FRL(7), ref Location);
     Console.WriteLine($" Name: {name}\n Strength: {Str}\n Dexterity: {Dex}" +
                       $"\n Intelligence: {Int}\n Constitution: {Con}\n Perception: {Per}\n Gold: {Gold}");
     using (StreamReader sR = new StreamReader("PlayerInv.csv"))
     {
         Weapons.WeaponsOwned.Clear();
         foreach (Weapons w in Weapons.PreviousSave)
         {
             Weapons  temp   = new Weapons();
             string   line   = sR.ReadLine();
             string[] Values = line.Split(',');
             temp.name          = Values[0];
             temp.price         = int.Parse(Values[1]);
             temp.maxRange      = int.Parse(Values[2]);
             temp.bDamage       = int.Parse(Values[3]);
             temp.StrMod        = int.Parse(Values[4]);
             temp.DexMod        = int.Parse(Values[5]);
             temp.ammoPerShot   = int.Parse(Values[7]);
             temp.ammoInMag     = int.Parse(Values[8]);
             temp.ownedByPlayer = bool.Parse(Values[9]);
             Weapons.WeaponsOwned.Add(temp);
         }
         sR.Close();
     }
     foreach (Weapons w in Weapons.WeaponsOwned)
     {
         Console.WriteLine($" {w.name}");
     }
 }