This repository has been archived by the owner on Aug 17, 2020. It is now read-only.
forked from snaverm/Pokemon-Go-Rocket-API
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
1,106 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,4 +107,4 @@ protected virtual void OnPropertyChanged(string propertyName) | |
|
||
#endregion | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.Devices.Geolocation; | ||
using Windows.Foundation; | ||
using Newtonsoft.Json; | ||
using PokemonGo_UWP.Utils; | ||
using PokemonGo_UWP.Utils.Helpers; | ||
using PokemonGo_UWP.Views; | ||
using POGOProtos.Enums; | ||
using POGOProtos.Map.Fort; | ||
using Template10.Common; | ||
using Template10.Mvvm; | ||
using POGOProtos.Networking.Responses; | ||
|
||
namespace PokemonGo_UWP.Entities | ||
{ | ||
public class IncensePokemon : IMapPokemon | ||
{ | ||
/// <summary> | ||
/// Infos on the current lured Pokemon | ||
/// </summary> | ||
[JsonProperty, JsonConverter(typeof(ProtobufJsonNetConverter))] | ||
private GetIncensePokemonResponse _incensePokemonResponse; | ||
|
||
public Point Anchor => new Point(0.5, 1); | ||
|
||
public IncensePokemon(GetIncensePokemonResponse incensePokemonResponse, double lat, double lng) | ||
{ | ||
_incensePokemonResponse = incensePokemonResponse; | ||
Geoposition = new Geopoint(GetLocation(lat, lng, 1)); | ||
} | ||
|
||
public void Update(IMapPokemon update) | ||
{ | ||
var incense = (IncensePokemon)update; | ||
|
||
_incensePokemonResponse = incense._incensePokemonResponse; | ||
Geoposition = incense.Geoposition; | ||
|
||
OnPropertyChanged(nameof(PokemonId)); | ||
OnPropertyChanged(nameof(EncounterId)); | ||
OnPropertyChanged(nameof(SpawnpointId)); | ||
OnPropertyChanged(nameof(Geoposition)); | ||
} | ||
|
||
#region Wrapped Properties | ||
|
||
public PokemonId PokemonId => _incensePokemonResponse.PokemonId; | ||
|
||
public ulong EncounterId => _incensePokemonResponse.EncounterId; | ||
|
||
public string SpawnpointId => _incensePokemonResponse.EncounterLocation; | ||
|
||
public Geopoint Geoposition { get; set; } | ||
|
||
#endregion | ||
|
||
private DelegateCommand _tryCatchPokemon; | ||
|
||
/// <summary> | ||
/// We're just navigating to the capture page, reporting that the player wants to capture the selected Pokemon. | ||
/// </summary> | ||
public DelegateCommand TryCatchPokemon => _tryCatchPokemon ?? ( | ||
_tryCatchPokemon = new DelegateCommand(() => | ||
{ | ||
NavigationHelper.NavigationState["CurrentPokemon"] = this; | ||
// Disable map update | ||
GameClient.ToggleUpdateTimer(false); | ||
BootStrapper.Current.NavigationService.Navigate(typeof(CapturePokemonPage)); | ||
}, () => true) | ||
); | ||
|
||
private BasicGeoposition GetLocation(double x0, double y0, int radius) | ||
{ | ||
var random = new Random(); | ||
|
||
// Convert radius from meters to degrees | ||
double radiusInDegrees = radius / 111000f; | ||
|
||
var u = random.NextDouble(); | ||
var v = random.NextDouble(); | ||
var w = radiusInDegrees * Math.Sqrt(u); | ||
var t = 2 * Math.PI * v; | ||
var x = w * Math.Cos(t); | ||
var y = w * Math.Sin(t); | ||
|
||
// Adjust the x-coordinate for the shrinking of the east-west distances | ||
var new_x = x / Math.Cos(y0); | ||
|
||
var foundLatitude = new_x + x0; | ||
var foundLongitude = y + y0; | ||
return new BasicGeoposition { Latitude = foundLatitude, Longitude = foundLongitude }; | ||
} | ||
|
||
#region INotifyPropertyChanged | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected virtual void OnPropertyChanged(string propertyName) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System.ComponentModel; | ||
using Newtonsoft.Json; | ||
using PokemonGo_UWP.Utils.Helpers; | ||
using POGOProtos.Map; | ||
using Windows.Devices.Geolocation; | ||
using Windows.Foundation; | ||
|
||
namespace PokemonGo_UWP.Entities | ||
{ | ||
/// <summary> | ||
/// We need to wrap this so we can reduce the number of ui updates. | ||
/// </summary> | ||
public class SpawnPointWrapper : IUpdatable<SpawnPoint>, INotifyPropertyChanged | ||
{ | ||
[JsonProperty, JsonConverter(typeof(ProtobufJsonNetConverter))] | ||
private SpawnPoint _spawnPoint; | ||
|
||
public Point Anchor => new Point(0.5, 1); | ||
|
||
public SpawnPointWrapper(SpawnPoint spawnPoint) | ||
{ | ||
_spawnPoint = spawnPoint; | ||
Geoposition = | ||
new Geopoint(new BasicGeoposition { Latitude = _spawnPoint.Latitude, Longitude = _spawnPoint.Longitude }); | ||
} | ||
|
||
/// <summary> | ||
/// The file name for spawnpoint, located in /Assets/Icons | ||
/// </summary> | ||
public string ImageFileName => "spawnpoint.png"; | ||
|
||
/// <summary> | ||
/// The file name for spawnpoint, located in /Assets/Icons | ||
/// </summary> | ||
public string ImageFilePath => $"ms-appx:///Assets/Icons/spawnpoint.png"; | ||
|
||
public void Update(SpawnPoint update) | ||
{ | ||
_spawnPoint = update; | ||
} | ||
|
||
#region Wrapped Properties | ||
|
||
//public float DistanceInMeters => _spawnPoint.DistanceInMeters; | ||
public Geopoint Geoposition { get; set; } | ||
|
||
#endregion | ||
|
||
#region INotifyPropertyChanged | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected virtual void OnPropertyChanged(string propertyName) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.