Ejemplo n.º 1
0
 private IAsciiField GetField(int row, int column)
 {
     return(MapMatrix
            .Where(x => x.Key.Row == row && x.Key.Column == column)
            .Select(y => y.Value)
            .FirstOrDefault());
 }
Ejemplo n.º 2
0
 public BasicCafe(Tilemap tilemap, int width, int height)
 {
     this.tilemap   = tilemap;
     this.width     = width;
     this.height    = height;
     this.mapMatrix = new MapMatrix();
 }
Ejemplo n.º 3
0
    public void BuildMap(CafeType cafeType)
    {
        switch (cafeType)
        {
        case CafeType.BASIC:
            builder = new BasicCafe(tilemap, Width, Height);
            builder.BuildBackground();
            builder.BuildMisc();
            MapMatrix = builder.GetProduct();
            break;

        default:
            break;
        }
    }
Ejemplo n.º 4
0
        //Test for the Class Ground
        public void testGround()
        {
            try
            {
                MapMatrix m = new MapMatrix();
                Ground g = new Ground(m, "W",new Point(0,0));

            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally {
                MessageBox.Show("testGround Completed");
            }
        }
Ejemplo n.º 5
0
        public void TestCellsMatrix()
        {
            MapSize  size  = new MapSize(1000, 1000);
            MapPlace place = new MapPlace(new MapImage(MapImageType.Bmp, null), 1);
            MapCell  cell  = new MapCell(place, null);

            MapMatrix <MapCell> matrix1 = new MapMatrix <MapCell>(size);

            MapCell[,] matrix2 = new MapCell[size.Width, size.Height];

            for (int x = 0; x < size.Width; x++)
            {
                for (int y = 0; y < size.Height; y++)
                {
                    matrix1[x, y] = cell;
                    matrix2[x, y] = cell;
                }
            }

            DateTime start1 = DateTime.Now;

            for (int i = 0; i < 1000000; i++)
            {
                cell = matrix1[25, 68];
            }

            DateTime finish1 = DateTime.Now;

            DateTime start2 = DateTime.Now;

            for (int i = 0; i < 1000000; i++)
            {
                cell = matrix2[25, 68];
            }

            DateTime finish2 = DateTime.Now;

            double result1 = (finish1 - start1).TotalMilliseconds;
            double result2 = (finish2 - start2).TotalMilliseconds;

            Assert.IsTrue(result1 < 100);
        }
Ejemplo n.º 6
0
    //最終影響マップ生成
    private void Mapping()
    {
        MapMatrix enemyMap = new MapMatrix {
            map = EnemyMapping(), coefficient = enemyCoefficient
        };
        MapMatrix itemMap = new MapMatrix {
            map = ItemMapping(), coefficient = itemCoefficient
        };

        switch (fusionSwitch)
        {
        case 0:
            map = influenceMap.WeightedAverage(new List <MapMatrix> {
                enemyMap, itemMap
            });
            break;

        case 1:
            map = influenceMap.Ceiling(new List <MapMatrix> {
                enemyMap, itemMap
            });
            break;

        case 2:
            map = influenceMap.Floor(new List <MapMatrix> {
                enemyMap, itemMap
            });
            break;

        default:
            map = new float[mapRange.x, mapRange.y];
            break;
        }
        influenceMap.MatrixOperate((xcount, ycount) =>
        {
            if (terrains[xcount, ycount].GetComponent <Renderer>().material.color != Color.gray)
            {
                terrains[xcount, ycount].GetComponent <Renderer>().material.color = new Color(map[xcount, ycount], 0, 0);
                terrains[xcount, ycount].transform.GetChild(0).GetChild(0).GetComponent <Text>().text = map[xcount, ycount].ToString("f3");
            }
        });
    }
Ejemplo n.º 7
0
        //Test for the Class Ground
        public void testMapMatrix()
        {
            try
            {
                MapMatrix m = new MapMatrix(4,4,"C:\\temp\\map.txt");
                Console.Write("Element in 0,0");
                Console.Write(m.mapM.Single(S => S.coordn.positionx == 0 & S.coordn.positiony == 0).groundtype);
                Console.Write("Element in 0,1");
                Console.Write(m.mapM.Single(S => S.coordn.positionx == 1 & S.coordn.positiony == 1).groundtype);

            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                MessageBox.Show("testMapMatrix Completed");
            }
        }
        /// <summary>
        /// Состояние уровня карты
        /// </summary>
        /// <param name="Level">Уровень</param>
        /// <param name="Index">Координата уровня</param>
        public MapLevelState(MapLevel Level, UInt16 Index)
        {
            if (Level == null) throw new ArgumentNullException("Level", "Level of MapLevelState cannot be null");

            this.Index = Index;
            this.Level = Level;

            Cells = new MapMatrix<MapCellState>(Level.Size);

            for (UInt16 x = 0; x < Size.Width; x++)
                for (UInt16 y = 0; y < Size.Height; y++)
                {
                    if (Level.Cells[x, y] == null)
                        Cells[x, y] = null;
                    else
                    {
                        Cells[x, y] = new MapCellState(Level.Cells[x, y], new MapPoint(Index, x, y));
                        Cells[x, y].WallDestroying += (sender, cell, args) => { OnWallDestroying(cell, args.Wall); };
                        Cells[x, y].WallDestroyed += (sender, cell, args) => { OnWallDestroyed(cell, args.Wall); };
                    }
                }
        }
Ejemplo n.º 9
0
        public string[] DistanceCalculator(string source, string destination) // method to get the distance between two given locations
        {
            List <string> Distances = new List <string>();                    // string that will contain the distance and duration

            string[]  temp1;                                                  // temporary string array needed for generating the api call link
            string[]  temp2;                                                  // temporary string array needed for generating the api call link
            string    tempo1;                                                 // temprorary string needed for generating the api call
            string    tempo2;                                                 // temprorary string needed for generating the api call
            int       t        = 0;                                           // temporary variable
            MapMatrix distance = new MapMatrix();                             // creating objec of class MapMatrix, needed to parse json response

            try                                                               // try-catch statement to catch exceptions
            {
                temp1  = source.Split(new[] { ' ' });                         // splitting the source location string, based on whitespaces
                tempo1 = temp1[0];                                            // storing the first element in splitted string into tempo1
                for (int i = 1; i < temp1.Length; i++)                        // for loop for generating the source location of proper format
                {
                    tempo1 = tempo1 + "+" + temp1[i];
                }
                temp2  = destination.Split(new[] { ' ' }); // splitting the destination location string, based on whitespaces
                tempo2 = temp2[0];                         // storing the first element in splitted string into tempo1
                for (int i = 1; i < temp2.Length; i++)     // for loop for generating the destination location of proper format
                {
                    tempo2 = tempo2 + "+" + temp2[i];
                }
                WebClient wc                = new WebClient();                                                                                                                        // creating a WebClient object
                var       strSearch         = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=" + tempo1 + "&destinations=" + tempo2 + "&key='KEY'"; // generating the api call
                var       strSearchResponse = wc.DownloadString(strSearch);                                                                                                           // calling the api, and storing the json response into a string variable
                distance = JsonConvert.DeserializeObject <MapMatrix>(strSearchResponse);                                                                                              // parsing the json response and storing parsed data into object distance
                Distances.Add(distance.rows[0].elements[0].distance.text);                                                                                                            // storing the distance information between source and destinaction locations into the first element of Distance list
                Distances.Add(distance.rows[0].elements[0].duration.text);                                                                                                            // storing the time taken to reach destination from source, into the second element of list Distance
            }
            catch (Exception e)                                                                                                                                                       // catch statement to catch an exception
            {
                Distances.Add("You may have entered a vague or incorrect address. Please specify the complete and correct addresses.");                                               // writing an error statement into the first element of list Distance
            }
            return(Distances.ToArray());                                                                                                                                              // converting list Distance into string array, and returning it
        }
Ejemplo n.º 10
0
        /// <summary>
        /// All values in the map data are added up,
        /// and the sum indicates how many tasks are
        /// allocated in a specific allocation.
        /// </summary>
        public int CountTasks()
        {
            if (MapMatrix == null)
            {
                return(-1);
            }

            int nRow      = MapMatrix.GetLength(0);
            int nCol      = MapMatrix.GetLength(1);
            int sumOfTask = 0;

            for (int row = 0; row < nRow; row++)
            {
                for (int col = 0; col < nCol; col++)
                {
                    int value;
                    int.TryParse(MapMatrix[row, col], out value);
                    sumOfTask += value;
                }
            }

            return(sumOfTask);
        }
Ejemplo n.º 11
0
        public void TestCellsMatrix()
        {
            MapSize size = new MapSize(1000, 1000);
            MapPlace place = new MapPlace(new MapImage(MapImageType.Bmp, null), 1);
            MapCell cell = new MapCell(place, null);

            MapMatrix<MapCell> matrix1 = new MapMatrix<MapCell>(size);
            MapCell[,] matrix2 = new MapCell[size.Width, size.Height];

            for (int x = 0; x < size.Width; x++)
                for (int y = 0; y < size.Height; y++)
                {
                    matrix1[x, y] = cell;
                    matrix2[x, y] = cell;
                }

            DateTime start1 = DateTime.Now;

            for (int i = 0; i < 1000000; i++)
            {
                cell = matrix1[25, 68];
            }

            DateTime finish1 = DateTime.Now;

            DateTime start2 = DateTime.Now;

            for (int i = 0; i < 1000000; i++)
            {
                cell = matrix2[25, 68];
            }

            DateTime finish2 = DateTime.Now;

            double result1 = (finish1 - start1).TotalMilliseconds;
            double result2 = (finish2 - start2).TotalMilliseconds;

            Assert.IsTrue(result1 < 100);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Уровень карты
        /// </summary>
        /// <param name="Size">Размер (в клетках)</param>
        public MapLevel(MapSize Size)
        {
            this.Size = Size;

            Cells = new MapMatrix<MapCell>(Size);
        }