示例#1
0
        public void Generate(int seed, int worldSize)
        {
            Tiles = new Dictionary <Position, Tile>();

            GameObjects.CharacterLibrary characterLibrary = new GameObjects.CharacterLibrary();
            List <Character>             characterList    = characterLibrary.GetAllCharacters();
            Random rand = new Random(seed);

            for (int i = 1; i <= worldSize; i++)
            {
                for (int j = 1; j <= worldSize; j++)
                {
                    Tile tile = new Tile();
                    Tiles.Add(new Position(i, j), tile);


                    int enemyChance = 10;
                    int crateChance = 10;

                    if (rand.Next(1, 100) <= enemyChance)
                    {
                        tile.Add(characterLibrary.Characters[rand.Next(0, characterLibrary.Characters.Count - 1)]);
                    }

                    if (rand.Next(1, 100) <= crateChance)
                    {
                        Character crate = (from c in characterList where c.Name.Contains("Treasure") select c).First();
                        tile.Add(crate);
                    }
                }
            }
        }
示例#2
0
        //WORK IN PROGRESS
        public void Start()
        {
            GameObjects.CharacterLibrary cl = new GameObjects.CharacterLibrary();
            player     = cl.Characters[0];
            player.Tag = "player";

            Console.WriteLine("Welcome to " + GameName + " Demo! Do you wish to start? Type 'Yes' to start or 'No' to quit.");
            string response = Console.ReadLine();

            if (response.ToLower() == "yes")
            {
                Console.WriteLine("Would you like to generate a new world or make your own?");
                Console.WriteLine("1.Generate a new world.");
                Console.WriteLine("2.Make my own.");

                response = Console.ReadLine();
                if (response == "1")
                {
                    Console.WriteLine("Input a seed.");
                    response = Console.ReadLine();
                    int seed = Convert.ToInt32(response);

                    World.WorldInstance.Generate(seed, 50);

                    player.SetPosition(new Position(1, 1));
                }
                else if (response == "2")
                {
                }
            }
        }