Esempio n. 1
0
        public Processing(Level level)
        {
            inspect   = false;
            move      = false;
            attack    = false;
            lvlup     = false;
            open      = false;
            inventory = false;

            End = false;

            nextTurnStrings = new List <string>();

            Turn_Count             = 0;
            Level                  = level;
            Level.Player.Moved    += Next_Turn;
            Level.Player.Attacked += Next_Turn;
            Level.Player.Restored += Next_Turn;

            Display      = new string[15, 15];
            Display_char = new char[15, 15];

            toDisplay_1 = new List <LevelObject>();
            toDisplay_2 = new List <LevelObject>();
            toDisplay_3 = new List <LevelObject>();
            toDisplay_4 = new List <LevelObject>();

            Display_Player_Stats = new string[15, 5];

            rnd = new Random();

            using (c = Console.NewConsole(67, 35))
            {
                c.Text = "9ROGUE";
                c.Show();
                c.KeyDown += KeyDown;

                // Add main viewport that displays the level (1):
                Nesteruk.MdxConsole.Buffer main = new Nesteruk.MdxConsole.Buffer(15, 15);
                Viewport vp_main = new Viewport(main, new Size(main.Size.Width, main.Size.Height),
                                                new Point(0, 0), new Point(0, 0));

                // Add player general stats viewport (2):
                Nesteruk.MdxConsole.Buffer player_stats_buffer = new Nesteruk.MdxConsole.Buffer(25, 9);
                Viewport vp_player_stats = new Viewport(player_stats_buffer, new Size(player_stats_buffer.Size.Width, player_stats_buffer.Size.Height),
                                                        new Point(0, 0), new Point(0, 20));

                // Add messages box viewport (3):
                Nesteruk.MdxConsole.Buffer messages_buffer = new Nesteruk.MdxConsole.Buffer(40, 34);
                Viewport vp_messages = new Viewport(messages_buffer, new Size(messages_buffer.Size.Width, messages_buffer.Size.Height),
                                                    new Point(0, 0), new Point(26, 0));

                c.Viewports.Add(vp_main);
                c.Viewports.Add(vp_player_stats);
                c.Viewports.Add(vp_messages);
                //c.Viewports.Add(vp_dialogue);

                Font currentFont = c.TexManager.DefaultFont;
                Font italic      = new Font(currentFont, FontStyle.Italic);
                Font bold        = new Font(currentFont, FontStyle.Bold);
                c.TexManager.AddPreset(italic, Color.Transparent, Color.White);
                c.TexManager.AddPreset(bold, Color.Transparent, Color.White);
                c.TexManager.AddPreset(currentFont, Color.Transparent, Color.Green);
                c.TexManager.AddPreset(currentFont, Color.White, Color.Red);

                c.Viewports[3].Buffer.Write("You find yourself in a vast, dark dungeon \n");
                c.Viewports[3].Buffer.Write("To get out you will have to defeat each of 9 Guards securing the exit \n");
                c.Viewports[3].Buffer.Write("You make the first step into the darkness... \n");

                for (int i = 0; i < 15; i++)
                {
                    for (int j = 0; j < 15; j++)
                    {
                        Display[i, j] = "";
                    }
                }

                foreach (Creature creature in Level.Creatures)
                {
                    NearObjectsUpdate(creature);
                }

                for (int y = 0; y < 15; y++)
                {
                    for (int x = 0; x < 15; x++)
                    {
                        c.Viewports[1].Buffer.Write(Display[y, x]);
                    }
                    c.Viewports[1].Buffer.Write("\n");
                }

                while (ConsoleCreated)
                {
                    c.Render();
                    Application.DoEvents();
                }
            }
        }
Esempio n. 2
0
        static void Main()
        {
            using (c = Console.NewConsole(45, 30))
            {
                c.Text = "9ROGUE";
                c.Show();


                Font currentFont = c.TexManager.DefaultFont;
                Font italic      = new Font(currentFont, FontStyle.Italic);
                Font bold        = new Font(currentFont, FontStyle.Bold);
                c.TexManager.AddPreset(italic, Color.Transparent, Color.White);
                c.TexManager.AddPreset(bold, Color.Transparent, Color.White);
                c.TexManager.AddPreset(currentFont, Color.Transparent, Color.Green);
                c.TexManager.AddPreset(currentFont, Color.White, Color.Red);

                string        playerName = "";
                List <string> toName     = new List <string>();

                c.Viewports[0].Buffer.Editing = true;

                c.Write("Enter your name:\n");

                c.KeyPress += (sender, e) =>
                {
                    if (!char.IsControl(e.KeyChar) && c.Viewports[0].Buffer.Editing == true)
                    {
                        if (toName.Count < 15)
                        {
                            c.Viewports[0].Buffer.Write(e.KeyChar.ToString());
                            toName.Add(e.KeyChar.ToString().Replace(' ', '_'));
                        }
                    }
                    if ((e.KeyChar == 'Y' || e.KeyChar == 'y') && c.Viewports[0].Buffer.Editing == false)
                    {
                        Player = new Player(playerName);
                        c.Close();
                        Run();
                    }
                };

                c.KeyDown += (sender, e) =>
                {
                    if (e.KeyCode == Keys.Enter && c.Viewports[0].Buffer.Editing == true && toName.Any(x => x != ""))
                    {
                        c.Viewports[0].Buffer.Write("\n");

                        char[] name = new char[toName.Count];
                        for (int i = 0; i < toName.Count; i++)
                        {
                            name[i] = Convert.ToChar(toName[i]);
                        }

                        playerName = new string (name);

                        c.Write("\n");
                        c.Write("Hello, ");
                        c.Write(playerName);
                        c.Write("!\n");
                        c.Write("Welcome to ");
                        c.WriteFormat("9ROGUE\n\n", 2);
                        c.WriteLine("Movement controls:\n");
                        c.WriteLine("Q W E              7 8 9");
                        c.WriteLine("A   D  or  numpad: 4   6");
                        c.WriteLine("Z X C              1 2 3\n");
                        c.WriteLine("[F1] (in-game) for additional controls");
                        c.WriteLine("\n");
                        c.WriteLine("Ready to start your journey? (Y)");
                        c.WriteLine("\n");
                        c.WriteLine("(Loading may take a while!)");

                        c.Viewports[0].Buffer.Editing = false;
                    }


                    if (e.KeyCode == Keys.Back && c.Viewports[0].Buffer.Editing == true)
                    {
                        if (toName.Count > 0)
                        {
                            c.Viewports[0].Buffer.Backspace();
                            toName.RemoveAt(toName.Count - 1);
                        }
                    }
                };

                while (ConsoleCreated)
                {
                    c.Render();
                    Application.DoEvents();
                }
            }
        }