Exemplo n.º 1
0
        //true if new game, false if loaded
        static bool StartMenu(List <Game> Games)
        {
            Graphics.Title(1);
            Menu StartMenu = new Menu(12, true);
            bool exit      = false;
            bool output    = true;

            while (!exit)
            {
                StartMenu.Erase();
                switch (StartMenu.Read(new string[] { "Nueva partida", "Cargar Partida", "Salón de la Fama", "Conectar BDD local", "Salir" }, "Hola!", 18))
                {
                case 0:
                    exit   = true;
                    output = true;
                    break;

                case 1:
                    exit   = SavedGames.LoadMenu(Games);
                    output = false;
                    break;

                case 2:
                    Boxy noMsn = new Boxy(12, 0, true, "Esta función se encuentra en desarrollo");
                    Console.ReadKey();
                    noMsn.Erase();
                    break;

                case 3:
                    Boxy   NameBoxy = new Boxy("Introduce la dirección de la BDD (ejemplo 'THIS-PC\\SQLEXPRESS'", 2, 0, 5, true);
                    string url      = Console.ReadLine();
                    SavedGames.Connect(url);

                    try
                    {
                        Games = SavedGames.GetAll();
                        SuccesfulConnection = true;
                        Boxy dBError = new Boxy(22, 13, 0, true, "Conectado a la base de datos con éxito!");
                        Console.ReadKey();
                        dBError.Erase();
                    }
                    catch
                    {
                        Boxy dBError = new Boxy(22, 13, 0, true, "No se ha podido conectar con la base de datos. Las funciones de carga y de guardado no estarán disponibles");
                        Console.ReadKey();
                        Console.Clear();
                        dBError.Erase();
                    }

                    NameBoxy.Erase();
                    break;

                case 4:
                    Console.Clear();
                    Boxy thanks = new Boxy(12, 0, true, "Gracias por jugar :')");
                    Console.ReadKey();
                    Environment.Exit(0);
                    break;
                }
            }

            Console.Clear();
            return(output);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //while (1 < 2)
            //{
            //    Console.WriteLine(FantasyGen.Fantastic());
            //    Console.ReadKey();
            //}

            //Connection to database
            //INSERT HERE YOUR DATABASE PATH
            SavedGames.Connect("THIS-PC\\SQLEXPRESS");


            Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);

            //Preset
            string msg = null;

            //Game Bucle
            while (1 < 2)
            {
                //First of all - Loading savedgames list
                List <Game> Games = new List <Game>();


                try
                {
                    Games = SavedGames.GetAll();
                    SuccesfulConnection = true;
                }
                catch
                {
                    Boxy dBError = new Boxy(22, 13, 0, true, "No se ha podido conectar con la base de datos. Las funciones de carga y de guardado no estarán disponibles");
                    Console.ReadKey();
                    Console.Clear();
                }

                //StartMenu - false load, true new Player
                if (StartMenu(Games))
                {
                    Inventory = new Inventory();
                    Gea       = new World();

                    //Creating new player
                    Player.NewPlayer();
                }

                //Once the player is created or loaded, we refresh the statics
                Mob          = new Mob(Gea.corruption);
                PlayerStatus = new PlayerStatus(15, 3);
                gameover     = false;

                //Gameplay
                while (!gameover)
                {
                    //Pre-turn
                    PlayerStatus.Refresh();

                    //Setting world corruption
                    if (!loot)
                    {
                        if (Random.Next(1, 4) == 4)
                        {
                            Gea.corruption++;
                        }
                    }
                    else
                    {
                        loot = false;
                        if (Random.Next(1, 4) <= 3)
                        {
                            Gea.corruption++;
                        }
                    }

                    //Setting starting turn msg
                    switch (lastAct)
                    {
                    case "born":
                        msg = "Amanece un hermoso día.";
                        break;

                    case "fight":
                        msg = "Menuda carnicería!";
                        break;

                    case "camp":
                        msg = "Amanece un hermoso día.";
                        break;

                    case "dialogue":
                        msg = "Menudo combate dialéctico!";
                        break;

                    case "runaway":
                        msg = "Por los pelos!";
                        break;
                    }


                    //Turn Itself
                    if (!Journey.Direction(msg))
                    {
                        gameover = true;
                    }
                    else
                    {
                        if (Encounter())
                        {
                            Combat();
                        }

                        Gea.months += Random.Next(1, 4);
                    }



                    //End of turn checkout


                    while (Gea.months >= 12)
                    {
                        Gea.months -= 12;
                        Gea.age++;
                        Player.Age++;
                    }
                }

                if (Player.Hp[0] <= 0)
                {
                    Console.Clear();
                    Graphics.Death(5);
                    SavedGames.DeleteCurrentGame();
                    Console.ReadKey();
                }

                Console.Clear();
            }
        }