示例#1
0
    public override Dictionary <IPos, ILand> MakeLands(int _N)
    {
        Dictionary <string, IPos> pm        = GenerateBasicMap(_N);
        Dictionary <IPos, ILand>  landsDict = new Dictionary <IPos, ILand>();

        float[,] elevation   = NoiseGrid(_N);
        float[,] temperature = NoiseGrid(_N);

        MapUtil.TransformMapMinMax(ref elevation, MapUtil.dNormalize);
        MapUtil.TransformMapMinMax(ref temperature, MapUtil.dNormalize);

        foreach (IPos p in pm.Values)
        {
            float elev = elevation[(int)p.gridLoc.x(), (int)p.gridLoc.y()];
            float temp = temperature[(int)p.gridLoc.x(), (int)p.gridLoc.y()];
            Dictionary <string, float> _val = new Dictionary <string, float>()
            {
                { "elevation", elev }, { "temperature", temp }
            };
            ILand newLand = LandFactory.CreateLand(p, _val, game.landType);
            landsDict[p] = newLand;
        }

        return(landsDict);
    }
示例#2
0
        /// <summary>
        /// Gets the fertile plots of land in ascending order as a single string
        /// </summary>
        /// <param name="plotsToSaltAsStrings">The plots to salt as a collection of strings, with each string representing an plot to salt</param>
        /// <returns>A single string containing the fertile plots, separated by a space, in ascending order</returns>
        public static string GetFertileLandsAsOrderedString(string[] plotsToSaltAsStrings)
        {
            _logger.Debug($"Entering {nameof(GetFertileLandsAsOrderedString)}");

            var pointFactory     = new PointFactory();
            var rectangleFactory = new RectangleFactory();
            var landFactory      = new LandFactory();

            var landDefinition = rectangleFactory.CreateRectangle(pointFactory, COLUMNS_OF_LAND, ROWS_OF_LAND);
            var land           = landFactory.CreateLand(landDefinition);

            // Salt the land
            var plotsToSalt = plotsToSaltAsStrings.Select(plotToSaltAsString => rectangleFactory.CreateRectangle(pointFactory, plotToSaltAsString));

            foreach (var plotToSalt in plotsToSalt)
            {
                land.AddSalt(plotToSalt);
            }

            // This line satisfies the output requirements
            string fertileLandAsOrderedString = string.Join(" ", land.FertilePlotsInSquareMeters.OrderBy(plot => plot));

            _logger.Debug($"Exiting {nameof(GetFertileLandsAsOrderedString)} with a return value of \"{fertileLandAsOrderedString}\"");
            return(fertileLandAsOrderedString);
        }
示例#3
0
 public Texture ReadFromDisk(int LandID, IHue Hue)
 {
     if (this.m_Factory == null)
     {
         this.m_Factory = new LandFactory(this);
     }
     return(this.m_Factory.Load(LandID, Hue));
 }
示例#4
0
        public void Should_ReturnLand_When_LandDefinitionIsValid()
        {
            var landDefinition = new Rectangle(new Point(0, 0), new Point(400, 600));
            var land           = new LandFactory().CreateLand(landDefinition);

            Assert.AreEqual(400, land.ColumnsOfLand);
            Assert.AreEqual(600, land.RowsOfLand);
        }
示例#5
0
        public void set_land_and_station_cases() //Factory Done
        {
            Case   case_land = new LandFactory().GetCase();
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file = new System.IO.StreamReader(dir + "/Monopoly_SELMI_TRAN_DINH/Monopoly_SELMI_TRAN_DINH/bin/Debug/Land&Station.txt");
            while ((line = file.ReadLine()) != null)
            {
                string[] words = line.Split(',');
                board[int.Parse(words[0])] = case_land.GetCase();
            }
            file.Close();
        }
示例#6
0
    public Dictionary <IPos, ILand> InitializeLandsFromMidpointDisplacement(int _N, Dictionary <string, IPos> pm)
    {
        Dictionary <IPos, ILand> landsDict = new Dictionary <IPos, ILand>();

        float[,] elevation = NoiseGrid(_N);
        MapUtil.TransformMapMinMax(ref elevation, MapUtil.dNormalize);
        foreach (IPos p in pm.Values)
        {
            Dictionary <string, float> _val = new Dictionary <string, float>()
            {
                { "elevation", elevation[(int)p.gridLoc.x(), (int)p.gridLoc.y()] }
            };

            ILand newLand = LandFactory.CreateLand(p, _val, game.landType);
            landsDict[p] = newLand;
        }

        return(landsDict);
    }