Esempio n. 1
0
        public void Advance(int command)
        {
            var    util = new RPGUtilities();
            var    cw = new ConsoleWriter();
            int    ordinate_y = 0, ordinate_x = 0, tile;
            string arrival = string.Empty, departure = string.Empty;

            switch (command)
            {
            case 1:
                ordinate_y = Get_Position()[0] - 1; ordinate_x = Get_Position()[1];
                departure  = "\n You leave to the north.\n";
                arrival    = "\n You arrive from the south.\n";
                break;

            case 2:
                ordinate_y = Get_Position()[0]; ordinate_x = Get_Position()[1] + 1;
                departure  = "\n You leave to the east.\n";
                arrival    = "\n You arrive from the west.\n";
                break;

            case 3:
                ordinate_y = Get_Position()[0] + 1; ordinate_x = Get_Position()[1];
                departure  = "\n You leave to the south.\n";
                arrival    = "\n You arrive from the north.\n";
                break;

            case 4:
                ordinate_y = Get_Position()[0]; ordinate_x = Get_Position()[1] - 1;
                departure  = "\n You leave to the west.\n";
                arrival    = "\n You arrive from the east.\n";
                break;
            }
            tile = World.Instance.GetWorld()[ordinate_y, ordinate_x];
            if (util.CheckMove(tile) == 1)
            {
                if (Move(ordinate_y, ordinate_x) != 0)
                {
                    cw.WriteMessage(departure, ConsoleColor.Gray);
                    Thread.Sleep(2000);
                    //Game_State.empty_MonsterCache();
                    Console.Clear();
                    cw.WriteMessage(arrival, ConsoleColor.Gray);
                    var worldRenderer = new WorldRenderer();
                    worldRenderer.Render(Get_Position()[0], Get_Position()[1]);
                    var enemy = new Monster();
                    enemy.Encounter(tile);
                    //Game_State.empty_MonsterCache();
                    //Cell.get_Info(tile);
                    //Encounter(tile);
                    //Format.Pseudo_Clear(5);
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            int  counter = 0;
            bool Playing = false;

            Player.Instance.Move(8, 3);
            Player.Attributes.Name = "Vendredi";
            var worldRenderer = new WorldRenderer();
            var util          = new RPGUtilities();

            util.HelpMenu();
            Console.WriteLine("Get started by entering a command.");
            Console.WriteLine("Try the [look] command. You are the @ symbol in the map.");
            while (!(Playing))
            {
                worldRenderer.SetStrategy(new BasicRenderStrategy(), 1);
                Player.Instance.RequestCommand(worldRenderer);
                counter++;
                if (counter == 1000)
                {
                    Playing = true;
                }
            }

            //ConsoleWriter cw = new ConsoleWriter();
            //var worldRenderer = new WorldRenderer();
            //Player.Attributes.Name = "Bob";

            //Console.WriteLine("Render Mode: Basic");
            //worldRenderer.SetStrategy(new BasicRenderStrategy());
            //worldRenderer.Render();

            //Console.WriteLine();

            //Console.WriteLine("Render Mode: Dark");
            //worldRenderer.SetStrategy(new DemonRenderStrategy());
            //worldRenderer.Render();
            //Console.WriteLine("An ASCII Fantasy Map via "); cw.WriteMessage("Multi-Dimensional Matrix", ConsoleColor.Red);
            //Console.WriteLine("");
            //Player.Attributes.Name = "2";
            //Console.WriteLine(Player.Attributes.Name + " = exp");
            //Console.WriteLine(Player.Instance.add_Experience(2) + " = exp");
            Console.ReadLine();
        }
Esempio n. 3
0
        public void RequestCommand(WorldRenderer worldRenderer)
        {
            var           cw   = new ConsoleWriter();
            var           util = new RPGUtilities();
            string        command;
            List <string> splitCommand;

            while (String.IsNullOrEmpty(command = Console.ReadLine()) || util.Split(command).Count() > 2)
            {
                Console.Clear();
                cw.WriteMessage("Invalid input ignored; please enter a valid command.\n", ConsoleColor.Red);
            }
            command = command.ToLower();
            int spaces = command.Count(Char.IsWhiteSpace);

            if (spaces == 0)
            {
                int option = util.ExecuteCommand(command);
                if (option == 0)
                {
                    cw.WriteMessage("\nNo such command detected\n", ConsoleColor.Red);
                    return;
                }
                if (option <= 4)
                {
                    Advance(option);
                }
                else if (option == 5)
                {
                    cw.WriteMessage("\n You take a good look around.\n", ConsoleColor.White);
                    Thread.Sleep(1500);
                    if (worldRenderer.GetStrategy() == 1)
                    {
                        worldRenderer.SetStrategy(new BasicRenderStrategy(), 1);
                    }
                    else
                    {
                        worldRenderer.SetStrategy(new DemonRenderStrategy(), 2);
                    }
                    worldRenderer.Render(Get_Position()[0], Get_Position()[1]);
                }
                else if (option == 6)
                {
                    cw.WriteMessage("\n You seek the gods for guidance.\n", ConsoleColor.White);
                    Thread.Sleep(1500);
                    util.HelpMenu();
                }
                else if (option == 11)
                {
                    if (worldRenderer.GetStrategy() == 1)
                    {
                        cw.WriteMessage("\n You take the form of a demon; you may now fly over terrain. \n", ConsoleColor.White);
                        Thread.Sleep(1500);
                        worldRenderer.SetStrategy(new DemonRenderStrategy(), 2);
                        Player.Attributes.Mana -= 10;
                    }
                    else
                    {
                        cw.WriteMessage("\n You return to your human form. \n", ConsoleColor.White);
                        Thread.Sleep(1500);
                        worldRenderer.SetStrategy(new BasicRenderStrategy(), 1);
                    }
                    worldRenderer.Render(Get_Position()[0], Get_Position()[1]);
                }
                else if (option == 12)
                {
                    cw.WriteMessage("\n You reflect on your current condition.\n", ConsoleColor.White);
                    Thread.Sleep(1500);
                    var pa = new PlayerAdapter(Player.instance);
                    pa.GetScore();
                }
            }
        }