Esempio n. 1
0
        public void Variations_Works_Correctly()
        {
            var variations = TileOperations.Variations(_tile).ToList();

            Assert.That(variations.Count, Is.EqualTo(8));
            Assert.That(variations.All(v => v.Id == _tile.Id), Is.True);
        }
Esempio n. 2
0
        private void saveToHighScoresButton_Click(object sender, RoutedEventArgs e)
        {
            highScores.Add(new HighScore()
            {
                Initials = initialsTextBox.Text.ToUpper(), Score = thescore
            });

            //add the high score
            IsolatedStorageOperations.AddToHighScores(highScores);

            //create an application tile now so the most updated high score is shown
            TileOperations.CreateApplicationTile();

            //also save the users initials so when they come back next time they dont have to enter them
            //
            var settings = IsolatedStorageSettings.ApplicationSettings;

            if (settings.Contains("LastInitials"))
            {
                settings["LastInitials"] = initialsTextBox.Text.ToUpper();
            }
            else
            {
                settings.Add("LastInitials", initialsTextBox.Text.ToUpper());
            }

            settings.Save();
            //


            //Navigate to the high score page.
            (Application.Current.RootVisual as PhoneApplicationFrame).Source = new Uri("/HighScorePage.xaml", UriKind.Relative);
        }
Esempio n. 3
0
        public void CreateImageTile_Works_Correctly(string imageStr)
        {
            var image           = Solver.CreateImageTile(_tiles);
            var imageVariations = TileOperations.Variations(image);

            Assert.That(imageVariations
                        .Select(im => Environment.NewLine + TileOperations.ToString(im))
                        .Any(str => str == imageStr));
        }
Esempio n. 4
0
        public void FlipHorizontal_Works_Correctly()
        {
            var flipped = TileOperations.FlipHorizontal(_tile);

            Assert.That(flipped.Id, Is.EqualTo(_tile.Id));
            Assert.That(flipped.Right, Is.EqualTo(_tile.Left));
            Assert.That(flipped.Left, Is.EqualTo(_tile.Right));
            Assert.That(flipped.Top, Is.EqualTo(0b0100101100));    // inverted tile top
            Assert.That(flipped.Bottom, Is.EqualTo(0b1110011100)); // inverted tile bottom
        }
Esempio n. 5
0
        public void RotateClockwise_Works_Correctly()
        {
            var rotated = TileOperations.RotateClockwise(_tile);

            Assert.That(rotated.Id, Is.EqualTo(_tile.Id));
            Assert.That(rotated.Right, Is.EqualTo(_tile.Top));
            Assert.That(rotated.Bottom, Is.EqualTo(0b1001101000)); // inverted tile right
            Assert.That(rotated.Left, Is.EqualTo(_tile.Bottom));
            Assert.That(rotated.Top, Is.EqualTo(0b0100111110));    // inverted left
        }
Esempio n. 6
0
        public void FlipHorizontal_2Times_ReturnsTheSame()
        {
            var flipped = TileOperations.FlipHorizontal(_tile);

            flipped = TileOperations.FlipHorizontal(flipped);

            Assert.That(flipped.Top, Is.EqualTo(_tile.Top));
            Assert.That(flipped.Bottom, Is.EqualTo(_tile.Bottom));
            Assert.That(flipped.Left, Is.EqualTo(_tile.Left));
            Assert.That(flipped.Right, Is.EqualTo(_tile.Right));
        }
Esempio n. 7
0
        public void RotateClockwise_4Times_ReturnsTheSame()
        {
            var rotated = TileOperations.RotateClockwise(_tile);

            rotated = TileOperations.RotateClockwise(rotated);
            rotated = TileOperations.RotateClockwise(rotated);
            rotated = TileOperations.RotateClockwise(rotated);

            Assert.That(_tile.Top, Is.EqualTo(rotated.Top));
            Assert.That(_tile.Bottom, Is.EqualTo(rotated.Bottom));
            Assert.That(_tile.Left, Is.EqualTo(rotated.Left));
            Assert.That(_tile.Right, Is.EqualTo(rotated.Right));
        }
Esempio n. 8
0
        public void Copy_Works_Correctly()
        {
            var copy = TileOperations.Copy(_tile);

            Assert.That(copy, Is.Not.EqualTo(_tile));
            Assert.That(copy.Id, Is.EqualTo(_tile.Id));
            for (var y = 0; y < _tile.Size; y++)
            {
                for (var x = 0; x < _tile.Size; x++)
                {
                    Assert.That(copy.GetCell(x, y), Is.EqualTo(_tile.GetCell(x, y)));
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Gets the pins in the specified circular area.
        /// </summary>
        internal void GetPinsInView(
            MercatorBoundingBox mercatorBox,
            MercatorBoundingCircle mercatorBoundingCircle,
            float levelOfDetail,
            ClusterMapPin clusterMapPinPrefab,
            Transform parentTransform,
            out List <MapPin> mapPins,
            out List <ClusterMapPin> clusterMapPins)
        {
            var lod         = (short)Mathf.Min(Mathf.Round(levelOfDetail), _maxLod.Value);
            var tileLod     = new TileLevelOfDetail(lod);
            var tileLodData = _tiledSpatialIndex[lod - 1];
            var tiles       = TileOperations.GetCoveredTileIds(mercatorBox, tileLod);

            mapPins        = new List <MapPin>();
            clusterMapPins = new List <ClusterMapPin>();

            foreach (var tile in tiles)
            {
                var tileBounds = tile.ToMercatorBoundingBox();
                var isTileCompletelyInsideMap = mercatorBoundingCircle.Contains(tileBounds);

                if (tileLodData.TryGetValue(tile.Value, out var tileData))
                {
                    if (tileData.IsClustered())
                    {
                        var latLon             = new LatLon(tileData.TotalLat / tileData.MapPinCount, tileData.TotalLon / tileData.MapPinCount);
                        var mercatorCoordinate = latLon.ToMercatorCoordinate();
                        if (isTileCompletelyInsideMap || mercatorBoundingCircle.Intersects(mercatorCoordinate))
                        {
                            // Use the ClusterMapPin.
                            if (tileData.ClusterMapPin == null)
                            {
                                // Deactivate the GO to start with. It will get activated once elevation has been sampled and it's in view.
                                clusterMapPinPrefab.gameObject.SetActive(false);
                                var newClusterMapPin = UnityEngine.Object.Instantiate(clusterMapPinPrefab);

                                if (parentTransform != null)
                                {
                                    newClusterMapPin.transform.SetParent(parentTransform, false);
                                }
                                newClusterMapPin.LevelOfDetail = tileLod.Value;
                                tileData.ClusterMapPin         = newClusterMapPin;

                                _clusterMapPins.Add(newClusterMapPin);
                            }

                            tileData.ClusterMapPin.Size     = tileData.MapPinCount;
                            tileData.ClusterMapPin.Location = new LatLon(latLon.LatitudeInDegrees, latLon.LongitudeInDegrees);
                            clusterMapPins.Add(tileData.ClusterMapPin);
                        }
                    }
                    else
                    {
                        // Add all of the MapPins in this tile to the list.
                        if (isTileCompletelyInsideMap)
                        {
                            foreach (var mapPin in tileData.MapPins)
                            {
                                mapPins.Add(mapPin);
                            }
                        }
                        else
                        {
                            foreach (var mapPin in tileData.MapPins)
                            {
                                if (mercatorBoundingCircle.Intersects(mapPin.MercatorCoordinate))
                                {
                                    mapPins.Add(mapPin);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        public void ParseTile_Works_Correctly(string data)
        {
            var tile = Parser.ParseTile(data);

            Assert.That(Environment.NewLine + TileOperations.ToString(tile), Is.EqualTo(data));
        }