public Map(int[][] intMap, DisplayConsole display, GameHandler gm, int rowAmmount, int ColumnAmmount)
        {
            dontShow       = false;
            gameMaster     = gm;
            mapRowLimit    = rowAmmount;
            mapColumnLimit = ColumnAmmount;
            this.display   = display;
            this.tileMap   = new Tile[mapRowLimit][];
            int rowCounter = 0;

            foreach (int[] intRow in intMap)
            {
                this.tileMap[rowCounter] = new Tile[mapColumnLimit];
                int columnCounter = 0;
                foreach (int integer in intRow)
                {
                    if (integer == 2)
                    {
                        tileMap[rowCounter][columnCounter]     = gameMaster.hero;
                        gameMaster.hero.positionX              = columnCounter;
                        gameMaster.hero.positionY              = rowCounter;
                        gameMaster.hero.currentCenterPositionX = columnCounter;
                        gameMaster.hero.currentCenterPositionY = rowCounter;
                    }
                    else
                    {
                        this.tileMap[rowCounter][columnCounter] = TileFactory.Get(integer, columnCounter, rowCounter, this);
                    }

                    columnCounter++;
                }
                rowCounter++;
            }
            enemies = new EnemyIterator(tileMap);
        }
예제 #2
0
        static void Main(string[] args)
        {
            SoundPlayer soundMenu = new SoundPlayer("8bit 2.wav");

            soundMenu.PlayLooping();
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.Black;
            Console.OutputEncoding  = System.Text.Encoding.UTF8;
            DisplayConsole display   = DisplayConsole.Instance;
            List <string>  menuItems = new List <string>()
            {
                "Start Game",
                "Plot",
                "Credits",
                "Quit Game"
            };

            Console.CursorVisible = false;
            while (true)
            {
                string line;
                System.IO.StreamReader frameFile = new System.IO.StreamReader("display/dragon.txt");
                while ((line = frameFile.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                }
                frameFile.Close();

                string selectedMenu = DrowMainMenu(menuItems);
                if (selectedMenu == "Start Game")
                {
                    while (Console.KeyAvailable)
                    {
                        Console.ReadKey(true);
                    }
                    Console.Clear();
                    Console.WriteLine("Enter hero name: ");
                    string name = Console.ReadLine();
                    while (name.Length > 16 || name.Length == 0)
                    {
                        Console.Clear();
                        Console.WriteLine("Enter hero name: (shorter than 16 characters)");
                        name = Console.ReadLine();
                    }
                    Console.Clear();
                    soundMenu = new SoundPlayer("piano.wav");
                    soundMenu.PlayLooping();
                    display.DrawFrame();

                    GameHandler gameMaster = new GameHandler(display);
                    gameMaster.CreateHero(name);
                    gameMaster.GenerateRandom(gameMaster.floorNumber);
                    gameMaster.PlayInMap();
                    Console.ReadKey();
                }
                else if (selectedMenu == "Plot")
                {
                    display.DrowStory();
                }
                else if (selectedMenu == "Credits")
                {
                    display.DrowCredits();
                }
                else if (selectedMenu == "Quit Game")
                {
                    Environment.Exit(0);
                }
                Console.Clear();
            }
            ;
        }
        int whatInControl = 0; //0-hero, 1-game menu, 2-death menu, 3-start menu, 4 ending

        public GameHandler(DisplayConsole display)
        {
            this.display = display;
            input        = new Input();
            floorNumber  = 1;
        }