示例#1
0
        private void WindowKeyDown(object sender, KeyEventArgs e)
        {
            Map.DrawMap(foxDraw);
            if (e.Key == Key.Left)
            {
                Hero.MoveLeft(foxDraw);
            }

            if (e.Key == Key.Right)
            {
                Hero.MoveRight(foxDraw);
            }

            if (e.Key == Key.Down)
            {
                Hero.MoveDown(foxDraw);
            }

            if (e.Key == Key.Up)
            {
                Hero.MoveUp(foxDraw);
            }
        }
示例#2
0
        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();
        }
示例#3
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();
        }
示例#4
-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();
        }