Esempio n. 1
0
        public bool Move(Direction dir)
        {
            bool ret = false;

            switch (dir)
            {
            case Direction.NONE:
                ret = true;
                break;

            case Direction.EAST:
                if (X < (G.MapSize - 1))
                {
                    X++;
                    ret = true;
                }
                else
                {
                    CrossMap?.Invoke(this, dir);
                }
                break;

            case Direction.WEST:
                if (X > 0)
                {
                    X--;
                    ret = true;
                }
                else
                {
                    CrossMap?.Invoke(this, dir);
                }
                break;

            case Direction.NORTH:
                if (Y > 0)
                {
                    Y--;
                    ret = true;
                }
                else
                {
                    CrossMap?.Invoke(this, dir);
                }
                break;

            case Direction.SOUTH:
                if (Y < (G.MapSize - 1))
                {
                    Y++;
                    ret = true;
                }
                else
                {
                    CrossMap?.Invoke(this, dir);
                }
                break;

            default:
                break;
            }

            return(ret);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            MapSettings customMapSettings = new MapSettings(50, 25, 15, 5, 5, 2, 1, 2);
            List <Map>  createdMaps       = new List <Map>();
            Map         currentMap        = null;

            Console.WriteLine("Hello, welcome to the Map Generator.");
            Console.ReadLine();
            Map lastMap = null;

            while (true)
            {
                Console.WriteLine("InsertCommand");
                var commandLine = Console.ReadLine();

                if (int.TryParse(commandLine, out var commandNo))
                {
                    switch (commandNo)
                    {
                    case 0:
                        Console.WriteLine("Creating new Map");
                        Map firstMap = new Map(new MapSettings());
                        firstMap.Populate();
                        Console.WriteLine("Map created...<Press Enter to Continue>");
                        Console.ReadLine();
                        Console.WriteLine($"Displaying Map with size {firstMap.Settings.Size}...");
                        Console.ReadLine();
                        DrawMap(firstMap);
                        Console.ReadLine();
                        lastMap = firstMap;
                        break;



                    case 1:
                        Console.WriteLine("Creating new Map");
                        Map secondMap = new Map(new MapSettings(40, 40, 30, 4, 20, 2, 1, 100));
                        secondMap.Populate();
                        Console.WriteLine("Map created...<Press Enter to Continue>");
                        Console.ReadLine();
                        Console.WriteLine($"Displaying Map with size {secondMap.Settings.Size}...");
                        Console.ReadLine();
                        DrawMap(secondMap);
                        Console.ReadLine();
                        lastMap = secondMap;
                        break;

                    case 2:
                        Console.WriteLine("Creating new Map");

                        Console.WriteLine("Enter Width");
                        int width = Convert.ToInt32(Console.ReadLine());

                        Console.WriteLine("Enter Height");
                        int height = Convert.ToInt32(Console.ReadLine());

                        Console.WriteLine("Enter Water Density");
                        int waterDens = Convert.ToInt32(Console.ReadLine());

                        Console.WriteLine("Enter Water Clusters");
                        int waterClus = Convert.ToInt32(Console.ReadLine());

                        Console.WriteLine("Enter Mountain Density");
                        int mountainDens = Convert.ToInt32(Console.ReadLine());

                        Console.WriteLine("Enter Mountain Clusters");
                        int mountainClus = Convert.ToInt32(Console.ReadLine());

                        Console.WriteLine("Enter Road Count");
                        Console.ReadLine();
                        int roadC = 1;

                        bool verLen     = false;
                        int  roadLength = 0;
                        while (!verLen)
                        {
                            Console.WriteLine("Enter minimum Road Length");
                            roadLength = Convert.ToInt32(Console.ReadLine());
                            if (roadLength > (width * height) / 4)
                            {
                                Console.WriteLine("Road too long for the size");
                            }
                            else
                            {
                                verLen = true;
                            }
                        }

                        Map thirdMap = new Map(new MapSettings(width, height, waterDens, waterClus, mountainDens, mountainClus, roadC, roadLength));
                        thirdMap.Populate();
                        Console.WriteLine("Map created...<Press Enter to Continue>");
                        Console.ReadLine();
                        Console.WriteLine($"Displaying Map with size {thirdMap.Settings.Size}...");
                        Console.ReadLine();
                        DrawMap(thirdMap);
                        Console.ReadLine();
                        lastMap = thirdMap;
                        break;

                    case 3:
                        Console.WriteLine("Creating new CrossMap");
                        Map fourthMap = new CrossMap(new MapSettings());
                        fourthMap.Populate();
                        Console.WriteLine("Map created...<Press Enter to Continue>");
                        Console.ReadLine();
                        Console.WriteLine($"Displaying Map with size {fourthMap.Settings.Size}...");
                        Console.ReadLine();
                        DrawMap(fourthMap);
                        Console.ReadLine();
                        lastMap = fourthMap;
                        break;

                    case 4:
                        Console.WriteLine("Creating new LineMap");
                        Map fifthMap = new LinesMap(new MapSettings());
                        fifthMap.Populate();
                        Console.WriteLine("Map created...<Press Enter to Continue>");
                        Console.ReadLine();
                        Console.WriteLine($"Displaying Map with size {fifthMap.Settings.Size}...");
                        Console.ReadLine();
                        DrawMap(fifthMap);
                        Console.ReadLine();
                        lastMap = fifthMap;
                        break;


                    //case 3:
                    //    if (currentMap != null)
                    //    {
                    //        Console.WriteLine($"Displaying Map with size {currentMap.Settings.Size}...");
                    //        Console.ReadLine();
                    //        DrawMap(currentMap);
                    //        Console.ReadLine();
                    //    }
                    //    else
                    //    {
                    //        Console.WriteLine("No map currently selected");
                    //        Console.ReadLine();
                    //    }
                    //    break;
                    //case 4:
                    //    Console.WriteLine("Creating new Map");
                    //    Console.WriteLine("How big is each side of the map?");
                    //    int inputSize = Convert.ToInt32(Console.ReadLine());
                    //    Map normalMap = new Map(new MapSettings());
                    //    normalMap.Populate();
                    //    Console.WriteLine("Map created...<Press Enter to Continue>");
                    //    createdMaps.Add(normalMap);
                    //    currentMap = normalMap;
                    //    Console.ReadLine();
                    //    break;
                    //case 5:
                    //    Console.WriteLine("Creating & Convert new Map");

                    //    LinesMap convertingMap = new LinesMap(new MapSettings());
                    //    convertingMap.Populate();
                    //    Console.WriteLine("Map created...<Press Enter to Continue>");
                    //    createdMaps.Add(convertingMap);
                    //    currentMap = convertingMap;
                    //    Console.ReadLine();
                    //    Console.WriteLine($"Displaying Map with size {currentMap.Settings.Size}...");
                    //    DrawMap(currentMap);
                    //    Console.ReadLine();
                    //    //Map convertedMap = MapConversion.ConvertToMap(convertingMap);
                    //    Console.WriteLine($"Converting {currentMap.GetType().Name} to a normal map and showing the result!");
                    //    DrawMap(currentMap);
                    //    Console.ReadLine();

                    //    break;
                    //case 6:
                    //    Console.WriteLine("Create Supermap");
                    //    Console.WriteLine("Enter how long a single side of the map should be");
                    //    int mapSize = Convert.ToInt32(Console.ReadLine());
                    //    Console.WriteLine("How many maps do you want to use for the supermap (2, 4 , 8 etc..)?");
                    //    int mapAmount = Convert.ToInt32(Console.ReadLine());
                    //    List<Map> mapList = new List<Map>();
                    //    for (int c = 0; c < mapAmount; c++)
                    //    {
                    //        Map map = new Map(new MapSettings());
                    //        map.Populate();
                    //        mapList.Add(map);
                    //    }
                    //    Console.WriteLine($"Drawing a supermap, consisting of {mapList.Count} maps");
                    //    Console.ReadLine();
                    //    // DrawMultiMap(mapList);
                    //    break;
                    //case 7:
                    //    Console.WriteLine("Creating new LayeredMap");
                    //    LinesMap layeredMap = new LinesMap();
                    //    layeredMap.Populate();
                    //    Console.WriteLine("Map created...<Press Enter to Continue>");
                    //    createdMaps.Add(layeredMap);
                    //    currentMap = layeredMap;
                    //    Console.ReadLine();
                    //    break;
                    //case 8:
                    //    Console.WriteLine("Creating new CrossMap");
                    //    CrossMap crossMap = new CrossMap(new MapSettings());
                    //    crossMap.Populate();
                    //    Console.WriteLine("Map created...<Press Enter to Continue>");
                    //    createdMaps.Add(crossMap);
                    //    currentMap = crossMap;
                    //    Console.ReadLine();
                    //    break;
                    case 8:
                        bool inf = true;
                        while (inf)
                        {
                            Console.WriteLine("Creating new Map");
                            Map infMap = new Map(new MapSettings());
                            infMap.Populate();
                            Console.WriteLine("Map created...<Press Enter to Continue>");
                            currentMap = infMap;
                            Console.WriteLine($"Displaying Map with size {currentMap.Settings.Size}...");

                            DrawMap(currentMap);
                        }
                        break;

                    case 9:
                        Console.WriteLine("Displaying Map Creation Process");
                        if (lastMap != null)
                        {
                            Console.WriteLine($"Displaying Map with size {lastMap.Settings.Size}...");
                            Console.ReadLine();

                            DrawMap(lastMap, lastMap.layer1);
                            Console.ReadLine();
                            DrawMap(lastMap, lastMap.layerRoads);
                            Console.ReadLine();
                            DrawMap(lastMap, lastMap.layer2);
                            Console.ReadLine();
                            DrawMap(lastMap, lastMap.layer2b);
                            Console.ReadLine();
                            DrawMap(lastMap, lastMap.layer3);
                            Console.ReadLine();
                            DrawMap(lastMap, lastMap.layer4);
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.WriteLine("No map currently selected");
                            Console.ReadLine();
                        }
                        break;

                    //case 10:
                    //    bool inf = true;
                    //    while (inf)
                    //    {
                    //        Console.WriteLine("Creating new Map");
                    //        Map infMap = new Map(new MapSettings());
                    //        infMap.Populate();
                    //        Console.WriteLine("Map created...<Press Enter to Continue>");
                    //        currentMap = infMap;
                    //        Console.WriteLine($"Displaying Map with size {currentMap.Settings.Size}...");
                    //        Console.ReadLine();
                    //        DrawMap(currentMap);
                    //        Console.ReadLine();
                    //    }
                    //    break;
                    default:
                        Console.WriteLine("Creating new default Map");
                        Map newMap = new Map();
                        newMap.Populate();
                        Console.WriteLine("Map created...<Press Enter to Continue>");
                        createdMaps.Add(newMap);
                        currentMap = newMap;
                        Console.WriteLine($"Displaying Map with size {currentMap.Settings.Size}...");
                        Console.ReadLine();
                        DrawMap(currentMap);

                        Console.ReadLine();
                        break;
                    }
                }
            }
        }