コード例 #1
0
ファイル: GameModel.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.GameModel"/> class.
		/// </summary>
		/// <param name="tag">CartridgeTag handled by this instance.</param>
		public GameModel(CartridgeTag tag)
		{
			this.cartridgeTag = tag;
			this.screenQueue = new Queue<Screens>(8);
		}
コード例 #2
0
ファイル: CartridgeListPage.cs プロジェクト: Surfoo/WF.Player
		private static async void HandleAutosave()
		{
			var gwcFilename = Path.Combine(App.PathForCartridges, Path.GetFileName(Settings.Current.GetValueOrDefault<string>(Settings.AutosaveGWCKey)));
			var gwsFilename = Path.Combine(App.PathForSavegames, Path.GetFileName(Settings.Current.GetValueOrDefault<string>(Settings.AutosaveGWSKey)));

			if (!File.Exists(gwsFilename) || !File.Exists(gwcFilename))
			{
				// Remove settings
				Settings.Current.Remove(Settings.AutosaveGWCKey);
				Settings.Current.Remove(Settings.AutosaveGWSKey);

				return;
			}

			bool result = await UserDialogs.Instance.ConfirmAsync(Catalog.GetString("There is an automatic savefile from a cartridge you played before. Would you resume this last game?"), Catalog.GetString("Automatical savefile"), Catalog.GetString("Yes"), Catalog.GetString("No"));

			if (result)
			{
				var cartridge = new Cartridge(gwcFilename);
				var cartridgeTag = new CartridgeTag(cartridge);
				var cartridgeSavegame = CartridgeSavegame.FromStore(cartridgeTag, gwsFilename);

				// We have a autosave file, so start this cartridge

				// Create a new navigation page for the game
				App.GameNavigation = new ExtendedNavigationPage(new GameCheckLocationView(new GameCheckLocationViewModel(cartridgeTag, cartridgeSavegame, App.Navigation.CurrentPage)), false) {
					BarBackgroundColor = App.Colors.Bar,
					BarTextColor = App.Colors.BarText,
					ShowBackButton = true,
				};
				App.Navigation.CurrentPage.Navigation.PushModalAsync(App.GameNavigation);

				App.GameNavigation.ShowBackButton = true;
			}
			else
			{
				// Remove file from directory
				File.Delete(gwsFilename);
			}

			// Remove settings
			Settings.Current.Remove(Settings.AutosaveGWCKey);
			Settings.Current.Remove(Settings.AutosaveGWSKey);
		}
コード例 #3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.CartridgeDetailViewModel"/> class.
		/// </summary>
		/// <param name="tag">CartridgeTag to show.</param>
		public CartridgeDetailViewModel(CartridgeTag tag)
		{
			this.cartridgeTag = tag;

			this.geoMathHelper = new GeoMathHelper();
			this.target = new ZonePoint(cartridgeTag.Cartridge.StartingLocationLatitude, cartridgeTag.Cartridge.StartingLocationLongitude, 0);

			Direction = double.NegativeInfinity;
			Distance = double.NegativeInfinity;

			if (App.GPS.LastKnownPosition != null)
			{
				HandlePositionChanged(this, new PositionEventArgs(App.GPS.LastKnownPosition));
			}
		}
コード例 #4
0
ファイル: CartridgeSavegame.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Froms the store.
		/// </summary>
		/// <returns>The store.</returns>
		/// <param name="tag">Tag of cartridge.</param>
		/// <param name="filename">Name of file.</param>
		public static CartridgeSavegame FromStore(CartridgeTag tag, string filename)
		{
			return new CartridgeSavegame(tag, filename);
		}
コード例 #5
0
ファイル: CartridgeSavegame.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.Models.CartridgeSavegame"/> class.
		/// </summary>
		/// <param name="tag">Tag of cartridge.</param>
		internal CartridgeSavegame(CartridgeTag tag)
		{
			this.Tag = tag;
			this.Filename = this.CreateSavegameFilename(tag);
			this.Metadata = null;
		}
コード例 #6
0
ファイル: CartridgeSavegame.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.Models.CartridgeSavegame"/> class.
		/// </summary>
		/// <param name="tag">Tag of cartridge.</param>
		/// <param name="gwsFilename">Gws filename.</param>
		public CartridgeSavegame(CartridgeTag tag, string gwsFilename)
		{
			this.Tag = tag;
			this.Filename = gwsFilename;
			this.Metadata = GWS.LoadMetadata(new FileStream(gwsFilename, FileMode.Open));
		}
コード例 #7
0
ファイル: CartridgeSavegame.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Creates the savegame filename.
		/// </summary>
		/// <returns>The savegame filename.</returns>
		/// <param name="tag">Tag of cartridge.</param>
		private string CreateSavegameFilename(CartridgeTag tag)
		{
			// TODO
			// If cartridge don't allow multiple save files, than return default name
			if (true)
			{
				return string.Format(
					"{0}.gws",
					Path.Combine(App.PathForSavegames, Path.GetFileNameWithoutExtension(tag.Cartridge.Filename)));
			}
			else
			{
				return string.Format(
					"{0}.{1}.gws",
					Path.Combine(App.PathForSavegames, Path.GetFileNameWithoutExtension(tag.Cartridge.Filename)),
					DateTime.Now.ToLocalTime().ToString("yyyyMMddHHmmss"));
			}
		}
コード例 #8
0
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.GameCheckLocationViewModel"/> class.
		/// </summary>
		/// <param name="tag">CartridgeTag to use.</param>
		/// <param name="savegame">Savegame object to use for restore.</param>
		/// <param name="lastPage">Info about which was the last page before call of check location</param>
		public GameCheckLocationViewModel(CartridgeTag tag, CartridgeSavegame savegame = null, Page lastPage = null)
		{
			this.cartridgeTag = tag;
			this.savegame = savegame;

			// Is GPS running?
			if (!App.GPS.IsListening)
			{
				// Start listening when app is on screen
				App.GPS.StartListening(500, 2.0, true);
			}

			App.GPS.PositionChanged += OnPositionChanged;
			Position = App.GPS.LastKnownPosition;
		}