示例#1
0
 public static void PrintName(Hero myhero)
 {
     Console.SetCursorPosition(62, 0);
     Console.Write("".PadRight(11, ' '));
     Console.SetCursorPosition(62, 0);
     Console.Write("Name: {0}", myhero.Name);
 }
示例#2
0
 public static void PrintMoney(Hero myHero)
 {
     Console.SetCursorPosition(62, 2);
     Console.Write("".PadRight(11, ' '));
     Console.SetCursorPosition(62, 2);
     Console.Write("Money: {0}", myHero.Money);
 }
示例#3
0
 public static void PrintHealth(Hero myhero)
 {
     Console.SetCursorPosition(62, 1);
     Console.Write("".PadRight(11, ' '));
     Console.SetCursorPosition(62, 1);
     Console.Write("Health: {0}",myhero.Health);
 }
示例#4
0
        public void GiveAward(Hero myhero)
        {
            if(this.questToGive.Name=="First Quest")
            {
                if (myhero.HealthQuestFinished == false)
                {
                    MessageBox.Print("Your health is now 200!");
                    myhero.Health = 200;
                    myhero.Money -= 200;
                    InfoBox.PrintHealth(myhero);
                    myhero.HealthQuestFinished = true;
                    System.Threading.Thread.Sleep(1000);
                }
            }
            else if (this.questToGive.Name=="Second Quest")
            {
                if (myhero.KeyQuestFinished == false)
                {
                    MessageBox.Print("Here, this is the key for the bridge gates");
                    myhero.Money -= 400;

                    myhero.keyFound = true;
                    myhero.KeyQuestFinished = true;
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
示例#5
0
 public static bool IsTheGameFinished(Hero myhero)
 {
     if(myhero.Position.X>16 && myhero.Position.X<22 && myhero.Position.Y>53)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#6
0
 public static bool HeroNearby(Map mymap, Hero myHero, Creeper creeper)
 {
     for (int i = creeper.Position.X - 1; i <= creeper.Position.X + 1; i++)
     {
         for (int j = creeper.Position.Y - 1; j <= creeper.Position.Y + 1; j++)
         {
             if (myHero.Position.X == i && myHero.Position.Y == j)
             {
                 return true;
             }
         }
     }
     return false;
 }
示例#7
0
 public static void GiveQuestIfNeccessary(List<NPC> NPCs, Hero myHero)
 {
     foreach(var NPC in NPCs)
     {
         if(NPC.IsHeroNear(myHero))
         {
             if(NPC.IsQuestFinished(myHero,NPC.questToGive)==false)
             {
                 NPC.GiveQuest(myHero);
             }
             else
             {
                 NPC.GiveAward(myHero);
             }
         }
     }
 }
示例#8
0
 public void Walk(Map mymap, Hero myHero, Creeper creeper)
 {
     if (!HeroInRange(myHero, creeper))
     {
         if (this.Orientation == 0)
         {
             if (mymap.CanBeStepped(this.Position.X - 1, this.Position.Y))
             {
                 this.MoveUp();
             }
         }
         else if (this.Orientation == 1)
         {
             if (mymap.CanBeStepped(this.Position.X, this.Position.Y + 1))
             {
                 this.MoveRight();
             }
         }
         else if (this.Orientation == 2)
         {
             if (mymap.CanBeStepped(this.Position.X + 1, this.Position.Y))
             {
                 this.MoveDown();
             }
         }
         else if (this.Orientation == 3)
         {
             if (mymap.CanBeStepped(this.Position.X, this.Position.Y - 1))
             {
                 this.MoveLeft();
             }
         }
     }
     else
     {
         this.MoveTowardsHero(mymap, myHero, creeper);
     }
 }
示例#9
0
        public static void AllCreepersWalk(Map map, Hero myHero, List<Creeper> creepers)
        {
            foreach (var creeper in creepers)
            {
                Console.SetCursorPosition(creeper.Position.Y, creeper.Position.X);
                Console.Write(" ");
                map.WriteToMap(creeper.Position.X, creeper.Position.Y, "0");
                creeper.Walk(map, myHero, creeper);

                string creeperNumber = "0";

                if (creeper.GetType().Name == "Goblin")
                {
                    creeperNumber = "5";
                }
                else if (creeper.GetType().Name == "Orc")
                {
                    creeperNumber = "6";
                }

                map.WriteToMap(creeper.Position.X, creeper.Position.Y, creeperNumber);
            }
        }
示例#10
0
 internal static void OpenDoorIfQuestIsFinished(Hero myHero,Map mymap)
 {
     if (myHero.keyFound)
     {
         mymap.WriteToMap(18, 53, "0");
         mymap.WriteToMap(19, 53, "0");
     }
 }
示例#11
0
 public bool IsQuestFinished(Hero myhero,Quest quest)
 {
     if (this.questToGive.Name == "First Quest" && myhero.Money>199)
     {
         return true;
     }
     else if (this.questToGive.Name == "Second Quest" && myhero.Money>399)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#12
0
 public bool IsHeroNear(Hero myhero)
 {
     if (Math.Abs(myhero.Position.X - this.Position.X) < 2 && Math.Abs(myhero.Position.Y - this.Position.Y) < 2)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#13
0
 public void GiveQuest(Hero myHero)
 {
     if (questToGive.Name == "First Quest" && myHero.FirstQuestTold == false)
     {
         foreach (var message in this.questToGive.QuestMessage)
         {
             MessageBox.Print(message);
         }
         myHero.FirstQuestTold = true;
         System.Threading.Thread.Sleep(1000);
     }
     else if (questToGive.Name == "Second Quest" && myHero.SecondQuestTold == false)
     {
         foreach (var message in this.questToGive.QuestMessage)
         {
             MessageBox.Print(message);
         }
         myHero.SecondQuestTold = true;
         System.Threading.Thread.Sleep(1000);
     }
 }
示例#14
0
 internal static void HitNearby(Hero myHero, List<Creeper> creepers)
 {
     for (int i = 0; i < creepers.Count; i++)
     {
         if (Math.Abs(creepers[i].Position.X - myHero.Position.X) < 2 && Math.Abs(creepers[i].Position.Y - myHero.Position.Y) < 2)
         {
             creepers[i].Health -= myHero.Damage;
             Console.Beep(5000, 50);
         }
     }
 }
示例#15
0
 public static void PrintInfo(Hero myHero)
 {
     PrintHealth(myHero);
     PrintMoney(myHero);
     PrintName(myHero);
 }
示例#16
0
        public static void Main()
        {
            ConsoleClass.SetConsoleSize();

            // printing intro page
            Intro.PrintYellowBird();

            string heroName = Hero.EnterName();
            Hero myHero = new Hero(heroName);
            Map mymap = new Map(MapPath);
            ConsoleClass.PrintBorders();
            DateTime now = new DateTime();
            now = DateTime.Now;

            List<NPC> NPCs = new List<NPC>();
            AddNPCs(NPCs,mymap);

            List<Creeper> creepers = new List<Creeper>();
            for (int i = 0; i < 10; i++)
            {
                creepers.Add(new Orc("Orc" + (i + 1), mymap.RandomFreePosition()));
            }
            for (int i = 0; i < 15; i++)
            {
                creepers.Add(new Goblin("Goblin" + (i + 1), mymap.RandomFreePosition()));
            }

            mymap.InputCreaturesInMap(creepers);
            InfoBox.PrintInfo(myHero);
            mymap.PrintAroundPoint(myHero.Position.X, myHero.Position.Y);
            mymap.MarkAsVisited(myHero.Position.X, myHero.Position.Y);
            myHero.PrintHero();
            MessageBox.Print("Hello "+myHero.Name+"!");
            MessageBox.Print("This is Team Yellow Bird's RPG game, hope you enjoy it :)");
            Console.ReadKey();
            MessageBox.Clear();
            while (true)
            {

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();

                    if (key.Key == ConsoleKey.UpArrow)
                    {
                        if (mymap.CanBeStepped(myHero.Position.X - 1, myHero.Position.Y))
                        {
                            mymap.WriteToMap(myHero.Position.X, myHero.Position.Y, "0");
                            myHero.MoveUp();
                            mymap.WriteToMap(myHero.Position.X, myHero.Position.Y, "7");
                        }
                    }
                    else if (key.Key == ConsoleKey.DownArrow)
                    {
                        if (mymap.CanBeStepped(myHero.Position.X + 1, myHero.Position.Y))
                        {
                            mymap.WriteToMap(myHero.Position.X, myHero.Position.Y, "0");
                            myHero.MoveDown();
                            mymap.WriteToMap(myHero.Position.X, myHero.Position.Y, "7");
                        }
                    }
                    else if (key.Key == ConsoleKey.LeftArrow)
                    {
                        if (mymap.CanBeStepped(myHero.Position.X, myHero.Position.Y - 1))
                        {
                            mymap.WriteToMap(myHero.Position.X, myHero.Position.Y, "0");
                            myHero.MoveLeft();
                            mymap.WriteToMap(myHero.Position.X, myHero.Position.Y, "7");
                        }
                    }
                    else if (key.Key == ConsoleKey.RightArrow)
                    {
                        if (mymap.CanBeStepped(myHero.Position.X, myHero.Position.Y + 1))
                        {
                            mymap.WriteToMap(myHero.Position.X, myHero.Position.Y, "0");
                            myHero.MoveRight();
                            mymap.WriteToMap(myHero.Position.X, myHero.Position.Y, "7");
                        }
                    }
                    else if (key.Key == ConsoleKey.Spacebar)
                    {
                        Hero.HitNearby(myHero, creepers);
                    }

                    if (mymap.WasVisited(myHero.Position.X, myHero.Position.Y) == false)
                    {
                        mymap.PrintAroundPoint(myHero.Position.X, myHero.Position.Y);
                        mymap.MarkAsVisited(myHero.Position.X, myHero.Position.Y);
                    }
                    if (key.Key != ConsoleKey.Spacebar)
                    {
                        mymap.PrintAroundPoint(myHero.Position.X, myHero.Position.Y);
                        myHero.PrintHero();
                    }
                    RemoveDeadCreepers(mymap, myHero, creepers);
                }

                NPC.GiveQuestIfNeccessary(NPCs, myHero);
                NPC.OpenDoorIfQuestIsFinished(myHero, mymap);
                if(NPC.IsTheGameFinished(myHero))
                {
                    break;
                }
                MessageBox.Clear();
                now = DateTime.Now;

                if (now.Millisecond % 200 == 0)
                {
                    myHero.PrintHero();

                    Creeper.TurnIfNeccessary(mymap, creepers);
                    Creeper.AllCreepersWalk(mymap, myHero, creepers);
                    Creeper.PrintCreepers(mymap, creepers);
                    Creeper.HitIfNearby(mymap, myHero, creepers);
                }

                if (myHero.Health < 1)
                {
                    GameOver.EndGame();
                    break;
                }
            }

            if (NPC.IsTheGameFinished(myHero))
            {
                GameOver.GameWon();
            }
            ConsoleKeyInfo endKey = Console.ReadKey();
            while (endKey.Key != ConsoleKey.Enter)
            {
                endKey = Console.ReadKey();
            }
            MessageBox.Clear();
            Console.ReadLine();
        }
示例#17
0
 private static bool HeroInRange(Hero myHero, Creeper creeper)
 {
     for (int i = creeper.Position.X - RangeAroundCreeper; i < creeper.Position.X + RangeAroundCreeper; i++)
     {
         for (int j = creeper.Position.Y - RangeAroundCreeper; j < creeper.Position.Y + RangeAroundCreeper; j++)
         {
             if (myHero.Position.X == i && myHero.Position.Y == j)
             {
                 return true;
             }
         }
     }
     return false;
 }
示例#18
0
        private void MoveTowardsHero(Map mymap, Hero myHero, Creeper creeper)
        {
            for (int i = creeper.Position.X - RangeAroundCreeper; i < creeper.Position.X + RangeAroundCreeper; i++)
            {
                for (int j = creeper.Position.Y - RangeAroundCreeper; j < creeper.Position.Y + RangeAroundCreeper; j++)
                {
                    if (myHero.Position.X == i && myHero.Position.Y == j)
                    {
                        if (i < creeper.Position.X)
                        {
                            if (mymap.CanBeStepped(this.Position.X - 1, this.Position.Y))
                            {
                                creeper.Orientation = 0;
                                if (mymap.CanBeStepped(this.Position.X - 1, this.Position.Y))
                                {
                                    this.MoveUp();
                                }
                            }
                            else if (j < creeper.Position.Y)
                            {
                                if (mymap.CanBeStepped(this.Position.X, this.Position.Y - 1))
                                {
                                    creeper.MoveLeft();
                                }
                            }
                            else if (j > creeper.Position.Y)
                            {
                                if (mymap.CanBeStepped(this.Position.X, this.Position.Y + 1))
                                {
                                    creeper.MoveRight();
                                }
                            }
                        }
                        else if (i > creeper.Position.X)
                        {
                            if (mymap.CanBeStepped(this.Position.X + 1, this.Position.Y))
                            {
                                creeper.Orientation = 2;
                                if (mymap.CanBeStepped(this.Position.X + 1, this.Position.Y))
                                {
                                    this.MoveDown();
                                }
                            }
                            else if (j < creeper.Position.Y)
                            {
                                if (mymap.CanBeStepped(this.Position.X, this.Position.Y - 1))
                                {
                                    creeper.MoveLeft();
                                }
                            }
                            else if (j > creeper.Position.Y)
                            {
                                if (mymap.CanBeStepped(this.Position.X, this.Position.Y + 1))
                                {
                                    creeper.MoveRight();
                                }
                            }
                        }
                        else if (j < creeper.Position.Y)
                        {
                            if (mymap.CanBeStepped(this.Position.X, this.Position.Y - 1))
                            {
                                creeper.Orientation = 3;
                                if (mymap.CanBeStepped(this.Position.X, this.Position.Y - 1))
                                {
                                    this.MoveLeft();
                                }
                            }
                            else if (mymap.CanBeStepped(this.Position.X - 1, this.Position.Y))
                            {
                                creeper.MoveUp();
                            }
                            else if (mymap.CanBeStepped(this.Position.X + 1, this.Position.Y))
                            {
                                creeper.MoveDown();
                            }
                        }
                        else if (j > creeper.Position.Y)
                        {
                            if (mymap.CanBeStepped(this.Position.X, this.Position.Y + 1))
                            {
                                creeper.Orientation = 1;
                                if (mymap.CanBeStepped(this.Position.X, this.Position.Y + 1))
                                {
                                    this.MoveRight();
                                }
                            }
                            else if (mymap.CanBeStepped(this.Position.X - 1, this.Position.Y))
                            {
                                creeper.MoveUp();
                            }
                            else if (mymap.CanBeStepped(this.Position.X + 1, this.Position.Y))
                            {
                                creeper.MoveDown();
                            }
                        }
                    }

                }
            }
        }
示例#19
0
 internal static void HitIfNearby(Map mymap, Hero myHero, List<Creeper> creepers)
 {
     foreach (var creeper in creepers)
     {
         if (Creeper.HeroNearby(mymap, myHero, creeper))
         {
             myHero.Health -= creeper.Damage;
             InfoBox.PrintHealth(myHero);
             Console.Beep();
         }
     }
 }
示例#20
0
 private static void RemoveDeadCreepers(Map mymap, Hero myHero, List<Creeper> creepers)
 {
     for (int i = 0; i < creepers.Count; i++)
     {
         if (creepers[i].Health < 1)
         {
             mymap.WriteToMap(creepers[i].Position.X, creepers[i].Position.Y, "0");
             Console.SetCursorPosition(creepers[i].Position.Y, creepers[i].Position.X);
             Console.Write(" ");
             Console.SetCursorPosition(creepers[i].Position.Y, creepers[i].Position.X);
             if (creepers[i].GetType().Name == "Orc")
             {
                 creepers[i] = new Orc("Orc" + (i + 1), mymap.RandomFreePosition());
                 myHero.Health += 3;
                 myHero.Money += 20;
                 InfoBox.PrintMoney(myHero);
             }
             else if (creepers[i].GetType().Name == "Goblin")
             {
                 creepers[i] = new Goblin("Goblin" + (i + 1), mymap.RandomFreePosition());
                 myHero.Health += 2;
                 myHero.Money += 10;
                 InfoBox.PrintMoney(myHero);
             }
         }
     }
 }
示例#21
0
 public Game(Hero hero, Fight fight)
 {
     this.Hero  = hero;
     this.Fight = fight;
 }
示例#22
-1
        public static void Main()
        {
            ConsoleClass.SetConsoleSize(); // old name Justify

            // printing intro page
            Intro.PrintYellowBird();

            string heroName = Hero.EnterName();  // moved from class Intro to Hero + renamed
            Hero myHero = new Hero(heroName);

            Map mymap = new Map(MapPath);
            ConsoleClass.PrintBorders();

            List<Creeper> creepers = new List<Creeper>();
            for (int i = 0; i < 5; i++)
            {
                creepers.Add(new Orc("Orc"+(i+1), mymap.RandomFreePosition()));
                //Console.WriteLine(creepers[i].Name);
            }
            for (int i = 0; i < 10; i++)
            {
                creepers.Add(new Goblin("Goblin" + (i + 1), mymap.RandomFreePosition()));
            }

            mymap.PrintAroundPoint(myHero.Position.X, myHero.Position.Y);
            myHero.PrintHero();
            //MessageBox.Print("Hello, " + myHero.Name);
            //MessageBox.Print("This is  Team Yellow Bird's RPG Game");
            //MessageBox.Print("Enjoy !");

            mymap.InputCreaturesInMap(creepers);
            //mymap.PrintMatrix();
            while (true)
            {

                //TODO:Make methods MoveUp,MoveDown,MoveLeft,MoveRight in the Alive class (abstract in the Alive class, also in the IAlive and in Hero class)!!!!!!!
                //Methods should use mymap.CanBeStepped() method !!!!

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();

                    if (key.Key == ConsoleKey.UpArrow)
                    {
                        if (mymap.CanBeStepped(myHero.Position.X - 1, myHero.Position.Y))
                        {
                            myHero.MoveUp();
                        }
                    }
                    else if (key.Key == ConsoleKey.DownArrow)           //TODO: MOVE ALL THIS METHODS IN THE HERO CLASS and check if the position is avaliable to step by using
                    {                                                   //mymap.CanBeStepped();
                        if (mymap.CanBeStepped(myHero.Position.X + 1, myHero.Position.Y))
                        {
                            myHero.MoveDown();
                        }
                    }
                    else if (key.Key == ConsoleKey.LeftArrow)
                    {
                        if (mymap.CanBeStepped(myHero.Position.X, myHero.Position.Y - 1))
                        {
                            myHero.MoveLeft();
                        }
                    }
                    else if (key.Key == ConsoleKey.RightArrow)
                    {
                        if (mymap.CanBeStepped(myHero.Position.X, myHero.Position.Y + 1))
                        {
                            myHero.MoveRight();
                        }
                    }

                    if (mymap.WasVisited[myHero.Position.X, myHero.Position.Y] == false)
                    {
                        mymap.PrintAroundPoint(myHero.Position.X, myHero.Position.Y);
                        mymap.WasVisited[myHero.Position.X, myHero.Position.Y] = true;
                    }
                    myHero.PrintHero();
                }
            }

            //TOVA E TESTOV KOMENTAR S CEL PROVERKA NA RABOTATA S GITHUB.......==
            // test OK ... - lenchev

            //mymap.PrintWholeMap();

            Console.ReadLine();
            MessageBox.Clear();
            Console.ReadLine();
        }