Exemplo n.º 1
0
        public override void SetStatus(ObservableCollection <ObservableCollection <Cell> > CellGrid, Cell Cell)
        {
            if (Cell.Alive)
            {
                switch (CoordinatesHelper.CountLivingNeighbours(Cell.Neighbours, CellGrid))
                {
                case 2:
                case 3:
                    Cell.state = CellState.None;
                    break;

                default:
                    Cell.state = CellState.Dying;
                    break;
                }
            }
            else
            {
                switch (CoordinatesHelper.CountLivingNeighbours(Cell.Neighbours, CellGrid))
                {
                case 3:
                    Cell.state = CellState.Growing;
                    break;

                default:
                    Cell.state = CellState.None;
                    break;
                }
            }
        }
Exemplo n.º 2
0
 public void AddEnemies(int count)
 {
     _enemies = new List <Enemy>(count);
     for (int i = 0; i < count; i++)
     {
         var position = CoordinatesHelper.GenerateRandomPosition(_width - 1, _height - 1);
         _enemies.Add(new Enemy(position));
     }
 }
Exemplo n.º 3
0
        public static Point CalculatePosition(GeoCoordinate coordinates, Star star)
        {
            double alt  = 0;
            double azim = 0;
            var    ha   = CoordinatesHelper.ConvRAToHA(star.RaDec, DateTime.Now.ToUniversalTime(), coordinates.Longitude);

            CoordinatesHelper.ConvEquToHor(coordinates.Longitude, ha, star.Dec, ref alt, ref azim);

            return(new Point(alt, azim));
        }
Exemplo n.º 4
0
        public override void Use(Layer activeLayer, Layer previewLayer, IEnumerable <Layer> allLayers, IReadOnlyList <Coordinates> recordedMouseMovement, SKColor color)
        {
            int     thickness    = Toolbar.GetSetting <SizeSetting>("ToolSize").Value;
            var     hasFillColor = Toolbar.GetSetting <BoolSetting>("Fill").Value;
            Color   temp         = Toolbar.GetSetting <ColorSetting>("FillColor").Value;
            SKColor fill         = new SKColor(temp.R, temp.G, temp.B, temp.A);

            var(start, end) = Session.IsShiftDown ?
                              CoordinatesHelper.GetSquareCoordiantes(recordedMouseMovement) :
                              (recordedMouseMovement[0], recordedMouseMovement[^ 1]);
Exemplo n.º 5
0
        public BitmapSize GetOffsetFromCoordinates(MapPoint coordinates, BitmapSize totalSize, double mapZoom)
        {
            // double correctionScale = Math.Pow(2.0, mapZoom - _tile.Zoom);
            double    xScale        = (double)_bounds.Width / _square.Size.LongitudeOffset;// *correctionScale;
            MapVector leftTopOffset = new MapVector(_square.LeftTop.Latitude - coordinates.Latitude, coordinates.Longitude - _square.LeftTop.Longitude);
            int       x             = (int)Math.Round(/*(double)totalSize.Width / 2.0 */ leftTopOffset.LongitudeOffset * xScale);
            double    yTiles        = CoordinatesHelper.GetTilesFromLatitude(_square.LeftTop.Latitude, _tile.Zoom) - CoordinatesHelper.GetTilesFromLatitude(coordinates.Latitude, _tile.Zoom);
            int       y             = (int)Math.Round(/*(double)totalSize.Height / 2.0*/ -(double)_bounds.Height * yTiles);// * correctionScale);

            return(new BitmapSize(x, y));
        }
Exemplo n.º 6
0
        private BitmapRect GetSquareBitmapBounds(MapTile tile)
        {
            MapSquare square          = tile.GetActualSquare();
            double    correctionScale = Math.Pow(2.0, _zoom - tile.Zoom);
            MapVector leftTopOffset   = new MapVector(square.LeftTop.Latitude - _center.Latitude, square.LeftTop.Longitude - _center.Longitude);
            MapVector squareSize      = square.Size;
            double    xScale          = (double)_tileSize.Width / squareSize.LongitudeOffset * correctionScale;
            int       x      = (int)Math.Round((double)_totalSize.Width / 2.0 + leftTopOffset.LongitudeOffset * xScale);
            double    yTiles = CoordinatesHelper.GetTilesFromLatitude(square.LeftTop.Latitude, tile.Zoom) - CoordinatesHelper.GetTilesFromLatitude(_center.Latitude, tile.Zoom);
            int       y      = (int)Math.Round((double)_totalSize.Height / 2.0 + (double)_tileSize.Height * yTiles * correctionScale);

            return(new BitmapRect(x, y, (int)Math.Ceiling(_tileSize.Width * correctionScale), (int)Math.Ceiling(_tileSize.Height * correctionScale)));
        }
Exemplo n.º 7
0
        public override Cell FactoryMethod(string Type, Coordinates coords)
        {
            switch (Type)
            {
            case "Connway":
                Cell cell = new Cell(false, coords);
                cell.Neighbours = CoordinatesHelper.GetNeighbours(cell.Coordinates);
                cell.ChangeGenerationStrategy = new ConnwayCellChangeGenerationStrategy();
                return(cell);

            default:
                throw new ArgumentException("Invalid Type", Type);
            }
        }
        private void CreatePointsOfInterest(TravelBuddyEntities db)
        {
            _fraumuenster = new POI()
            {
                Name          = "Fraumünster Church",
                Description   = "Old church, beautiful, has a tower to go up.",
                VisitDuration = (int)TimeSpan.FromMinutes(40).TotalSeconds,
                Coordinates   = CoordinatesHelper.CreatePoint(47.369741, 8.541631),
            };
            db.POI.Add(_fraumuenster);

            _lakeOfZurich = new POI()
            {
                Name          = "Lake of Zürich",
                Description   = "The lake of Zürich is a nice place for having a swim during summer time",
                VisitDuration = (int)TimeSpan.FromMinutes(60).TotalSeconds,
                Coordinates   = CoordinatesHelper.CreatePoint(47.366202, 8.541840),
            };
            db.POI.Add(_lakeOfZurich);

            _stateMuseumZurich = new POI()
            {
                Name          = "State Museum",
                Description   = "This museum just next to the main station shows the history of Switzerland",
                VisitDuration = (int)TimeSpan.FromMinutes(150).TotalSeconds
            };
            db.POI.Add(_stateMuseumZurich);

            _uetliberg = new POI()
            {
                Name        = "Üetliberg",
                Description =
                    "Walk up the house mountain of Zürich and enjoy the view over Zürich and perhaps the alps as well.",
                VisitDuration = (int)TimeSpan.FromMinutes(240).TotalSeconds,
                Coordinates   = CoordinatesHelper.CreatePoint(47.351703, 8.492508),
            };
            db.POI.Add(_uetliberg);

            _oldCityWallCartagena = new POI
            {
                Name          = "Old city wall",
                Description   = "Visit the old city wall of cartagena. Bla bla bla.",
                VisitDuration = (int)TimeSpan.FromMinutes(70).TotalSeconds
            };
            db.POI.Add(_oldCityWallCartagena);
        }
Exemplo n.º 9
0
 private void saturationCanvas_MouseMove(object sender, MouseEventArgs e)
 {
     try
     {
         Bitmap bmp = new Bitmap(saturationCanvas.Width, saturationCanvas.Height);
         saturationCanvas.DrawToBitmap(bmp, new Rectangle(0, 0, saturationCanvas.Width, saturationCanvas.Height));
         Point CurrentLocation = CoordinatesHelper.ClipLocationToBounds(e.Location, saturationCanvas.Size);
         hoverCanvas.BackColor = bmp.GetPixel(CurrentLocation.X, CurrentLocation.Y);
         if (SaturationChangeActive)
         {
             SelectedColor = bmp.GetPixel(CurrentLocation.X, CurrentLocation.Y);
             currentColorCanvas.BackColor = SelectedColor;
             SetCurrentColorInfo();
         }
     }
     catch
     {
     }
 }
Exemplo n.º 10
0
        private void hueCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                Point  CurrentLocation = CoordinatesHelper.ClipLocationToBounds(e.Location, hueCanvas.Size);
                Bitmap bmp             = new Bitmap(hueCanvas.Width, hueCanvas.Height);
                hueCanvas.DrawToBitmap(bmp, new Rectangle(0, 0, hueCanvas.Width, hueCanvas.Height));
                if (HueChangeActive)
                {
                    SelectedHue = bmp.GetPixel(CurrentLocation.X, CurrentLocation.Y);
                    SetCurrentColorInfo();

                    CreateSaturationCanvas();
                }
            }
            catch
            {
            }
        }
Exemplo n.º 11
0
        public override void Execute()
        {
            var coordinates = new List <Coordinate>();

            GetView().PrintMessage("Enter the coordinates:");

            var coordinate = new Coordinate();

            while (coordinate != null)
            {
                var userInput = GetView().RequestInput();
                coordinate = CoordinatesHelper.ParseUserInputToCoordinate(userInput);
                if (coordinate != null)
                {
                    coordinates.Add(coordinate);
                }
            }

            GetView().PrintCoordinates(coordinates);
        }
Exemplo n.º 12
0
        public override void Execute()
        {
            var coordinates = new List <Coordinate>();

            using (var streamReader = new StreamReader(_path, Encoding.Default))
            {
                while (!streamReader.EndOfStream)
                {
                    var line       = streamReader.ReadLine();
                    var coordinate = CoordinatesHelper.ParseUserInputToCoordinate(line);

                    if (coordinate != null)
                    {
                        coordinates.Add(coordinate);
                    }
                }
            }

            GetView().PrintCoordinates(coordinates);
        }
        /// <summary>
        /// Gets the route from one point to another by latitude and longitude.
        /// </summary>
        /// <param name="originLatitude">The origin latitude.</param>
        /// <param name="originLongitude">The origin longitude.</param>
        /// <param name="destinationLatitude">The destination latitude.</param>
        /// <param name="destinationLongitude">The destination longitude.</param>
        /// <returns></returns>
        public IEnumerable <CoordinateDTO> GetRoute(double originLatitude, double originLongitude, double destinationLatitude,
                                                    double destinationLongitude)
        {
            DirectionsRequest directionsRequest = new DirectionsRequest()
            {
                Origin      = CoordinatesHelper.ToString(originLatitude, originLongitude),
                Destination = CoordinatesHelper.ToString(destinationLatitude, destinationLongitude),
                TravelMode  = TravelMode.Walking
            };

            DirectionsResponse directions = GoogleMaps.Directions.Query(directionsRequest);
            IEnumerable <Step> steps      = directions.Routes.First().Legs.First().Steps;

            return
                (steps.SelectMany(step => step.PolyLine.Points)
                 .Select(step => new CoordinateDTO()
            {
                Latitude = step.Latitude, Longitude = step.Longitude
            }));
        }
Exemplo n.º 14
0
        internal void Update()
        {
            for (int i = 0; i < _enemies.Count; i++)
            {
                Point2D from = _enemies[i].Position.Clone();
                Point2D to   = from;
                if (_enemies[i].CanMove)
                {
                    var moveDirection = CoordinatesHelper.GetRandomDirection();
                    _enemies[i].MoveTo(moveDirection);

                    CorrectPosition(_enemies[i]);

                    to = _enemies[i].Position.Clone();

                    if (TryKillPlayer(_enemies[i]))
                    {
                        IsPlayerAlive = false;
                    }
                }
                _renderingPlan.Add(from, to, new EnemyView(_enemies[i].Direction));
            }
            _renderingPlan.Add(_player.Position, _player.Position, new PlayerView(_player.Direction));
        }
Exemplo n.º 15
0
        public double GetDistanceToNextPOI(int userID, double latitude, double longitude)
        {
            POI nextPoi = GetNextPOIInternal(userID);

            return(nextPoi.Coordinates.Distance(CoordinatesHelper.CreatePoint(latitude, longitude)).Value);
        }
Exemplo n.º 16
0
 private Int32Rect CreateRectangle(Layer layer, SKColor color, SKColor?fillColor, IReadOnlyList <Coordinates> coordinates, int thickness)
 {
     var(start, end) = Session.IsShiftDown ? CoordinatesHelper.GetSquareCoordiantes(coordinates) : (coordinates[0], coordinates[^ 1]);
Exemplo n.º 17
0
        public static TimeSpan CalculateTimeLeft(double initLat, double initLong, double destLat, double destLong)
        {
            var distance = CoordinatesHelper.CalculaDistanciaEmMetros(initLat, initLong, destLat, destLong) / 1000;

            if (distance <= 2)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(60)));
            }
            if (distance > 2 && distance <= 5)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(120)));
            }
            if (distance > 5 && distance <= 7)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(300)));
            }

            if (distance > 7 && distance <= 10)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(420)));
            }

            if (distance > 10 && distance <= 12)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(480)));
            }
            if (distance > 12 && distance <= 18)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(600)));
            }

            if (distance > 18 && distance <= 26)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(900)));
            }

            if (distance > 26 && distance <= 42)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(1140)));
            }

            if (distance > 42 && distance <= 65)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(1320)));
            }

            if (distance > 65 && distance <= 81)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(1500)));
            }

            if (distance > 81 && distance <= 100)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(2100)));
            }

            if (distance > 100 && distance <= 200)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(2400)));
            }

            if (distance > 200 && distance <= 250)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(2700)));
            }

            if (distance > 250 && distance <= 350)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(3060)));
            }

            if (distance > 350 && distance <= 460)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(3480)));
            }

            if (distance > 460 && distance <= 500)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(3600)));
            }

            if (distance > 500 && distance <= 565)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(4020)));
            }

            if (distance > 565 && distance <= 700)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(4500)));
            }

            if (distance > 700 && distance <= 716)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(4860)));
            }

            if (distance > 716 && distance <= 830)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(5160)));
            }

            if (distance > 830 && distance <= 1000)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(5400)));
            }

            if (distance > 1000 && distance <= 1499)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(6500)));
            }
            if (distance > 1500)
            {
                return(TimeSpan.FromSeconds(CalculateOtherShit(7200)));
            }


            return(TimeSpan.FromSeconds(CalculateOtherShit(10000)));
        }
Exemplo n.º 18
0
        public static string FormatCoordinates(string userInput)
        {
            var coordinate = CoordinatesHelper.ParseUserInputToCoordinate(userInput);

            return(coordinate != null?coordinate.ToString() : string.Empty);
        }