コード例 #1
0
ファイル: LatLon.cs プロジェクト: Lopt/ascendancy
        /// <summary>
        /// Initializes a new instance of the <see cref="Core.Models.LatLon"/> class.
        /// </summary>
        /// <param name="position">Position which should be converted to a <see cref="Core.Models.LatLon"/>  Position.</param>
        public LatLon(Position position)
        {
            var zoom = Constants.EARTH_CIRCUMFERENCE / Constants.CELL_SIZE;
            var n = Math.PI - ((2.0 * Math.PI * position.Y) / zoom);

            Lon = (float)((position.X / zoom * 360.0) - 180.0);
            Lat = (float)(180.0 / Math.PI * Math.Atan(Math.Sinh(n)));
        }
コード例 #2
0
ファイル: PositionHelper.cs プロジェクト: Lopt/ascendancy
        /// <summary>
        /// Converts the Position to a world space position
        /// </summary>
        /// <returns>The world space position.</returns>
        /// <param name="position">game position.</param>
        public static CCPoint PositionToWorldspace(Position position)
        {
            var firstRegion = Geolocation.Instance.FirstGamePosition.RegionPosition;

            var pointX = (float)(position.RegionPosition.RegionX - firstRegion.RegionX) * ClientConstants.TILEMAP_HEX_CONTENTSIZE_WIDTH;
            var pointY = (float)(position.RegionPosition.RegionY - firstRegion.RegionY) * ClientConstants.TILEMAP_HEX_CONTENTSIZE_HEIGHT;
            pointX += (float)position.CellPosition.CellX / (float)(ClientConstants.TILEMAP_HEX_WIDTH - 1) * ClientConstants.TILEMAP_HEX_CONTENTSIZE_WIDTH;
            pointY += (float)position.CellPosition.CellY / (float)(ClientConstants.TILEMAP_HEX_HEIGHT - 1) * ClientConstants.TILEMAP_HEX_CONTENTSIZE_HEIGHT;

            return new CCPoint(pointX, -pointY);
        }
コード例 #3
0
ファイル: Position.cs プロジェクト: Lopt/ascendancy
 /// <summary>
 /// Distance from this to the specific position
 /// Warning: NOT ROOTED.
 /// </summary>
 /// <returns>Distance from this to the specific position.</returns>
 /// <param name="position">Other Position.</param>
 public double Distance(Position position)
 {
     var distanceX = position.X - X;
     var distanceY = position.Y - Y;
     return (distanceX * distanceX) + (distanceY * distanceY);
 }
コード例 #4
0
ファイル: PositionI.cs プロジェクト: Lopt/ascendancy
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.PositionI"/> class.
 /// </summary>
 /// <param name="position">Position which should be copied.</param>
 public PositionI(Position position)
 {
     X = (int)position.X;
     Y = (int)position.Y;
 }
コード例 #5
0
ファイル: CellPosition.cs プロジェクト: Lopt/ascendancy
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.CellPosition"/> class.
 /// </summary>
 /// <param name="position">GameWorld Position.</param>
 public CellPosition(Position position)
     : this((int)position.X, 
         (int)position.Y)
 {
 }
コード例 #6
0
 /// <summary>
 /// Gets the region by game position.
 /// </summary>
 /// <returns>The region by game position.</returns>
 /// <param name="gameWorldPosition">Game world position.</param>
 public Region GetRegionByGamePosition(Position gameWorldPosition)
 {
     RegionPosition regionPosition = new RegionPosition(gameWorldPosition);
     return GetRegion(regionPosition);
 }
コード例 #7
0
ファイル: Geolocation.cs プロジェクト: Lopt/ascendancy
 /// <summary>
 /// Raises the position changed event.
 /// </summary>
 /// <param name="sender">Sender is the event source.</param>
 /// <param name="eventPos">E the event data. If there is no event data, this parameter will be null.</param>
 private async void OnPositionChanged(object sender, PositionEventArgs eventPos)
 {
     try
     {
         CurrentGamePosition = new Core.Models.Position(new Core.Models.LatLon(eventPos.Position.Latitude, eventPos.Position.Longitude));
         if (FirstGamePosition == null)
         {
             FirstGamePosition = CurrentGamePosition;
         }
     }
     catch (Exception ex)
     {
         var text = ex.Message;
     }
 }
コード例 #8
0
ファイル: Geolocation.cs プロジェクト: Lopt/ascendancy
        /// <summary>
        /// Gets the position async.
        /// </summary>
        /// <returns>The position async.</returns>
        public async Task<Core.Models.Position> GetPositionAsync()
        {
            Core.Models.Position position = null;
            try
            {
                var latlon = await m_geolocator.GetPositionAsync(Client.Common.Constants.ClientConstants.GPS_GET_POSITION_TIMEOUT);
                position = new Core.Models.Position(latlon.Latitude, latlon.Longitude);
            }
            catch (Exception ex)
            {
                var text = ex.Message;
            }

            return position;
        }
コード例 #9
0
ファイル: RegionPosition.cs プロジェクト: Lopt/ascendancy
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.RegionPosition"/> class.
 /// </summary>
 /// <param name="position">Game Position.</param>
 public RegionPosition(Position position)
 {
     RegionX = (int)(position.X / Constants.REGION_SIZE_X);
     RegionY = (int)(position.Y / Constants.REGION_SIZE_Y);
 }