コード例 #1
0
ファイル: CartridgeTag.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.Models.CartridgeTag"/> class from cartridge meta data.
		/// </summary>
		/// <param name="cart">Cartridge for this tag.</param>
		public CartridgeTag(Cartridge cart)
		{
			if (cart == null)
			{
				throw new ArgumentNullException("cart");
			}
			// Basic metadata.
			Cartridge = cart;
			// Add savegames
			this.ImportSavegames();
		}
コード例 #2
0
//		private WebView webView;

		#region Android Event Handlers


		protected override void OnCreate (Bundle bundle)
		{
			// Set color schema for activity
			Main.SetTheme(this);

			int[] tabs = {
				Resource.String.detail_tab_overview,
				Resource.String.detail_tab_description,
				Resource.String.detail_tab_history,
				Resource.String.detail_tab_logs
			};

			base.OnCreate (bundle);

			SupportActionBar.NavigationMode = global::Android.Support.V7.App.ActionBar.NavigationModeTabs;
			SupportActionBar.SetDisplayHomeAsUpEnabled (true);

			// Get cartridge
			Intent intent = this.Intent;
			_cart = MainApp.Cartridges [intent.GetIntExtra("cartridge",0)];

			if (_cart == null)
				Finish ();

			string filename = System.IO.Path.Combine (global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "WF.Player", "poster.png");

			InitDetailInfo ();

//				using (FileStream stream = new FileStream(filename, FileMode.Create))
//				{
//					Bitmap bm = BitmapFactory.DecodeByteArray (cart.Poster.Data,0,cart.Poster.Data.Length);
//					bm.Compress (Bitmap.CompressFormat.Png, 100, stream);
//				} 
//			}
//			else {
//				if (File.Exists (filename))
//					File.Delete(filename);

			for (int i = 0; i < 4; i++) {
				var tab = SupportActionBar.NewTab ();
				tab.SetText (GetString(tabs[i]));
				tab.SetTabListener (this);
				SupportActionBar.AddTab (tab);
			}

			SupportActionBar.Title = _cart.Name;

		}
コード例 #3
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView (Resource.Layout.ScreenActivity);
			var layoutMain = FindViewById<LinearLayout> (Resource.Id.layoutMain);

			// Create your application here
			Intent intent = this.Intent;

			string cartFilename = intent.GetStringExtra ("cartridge");
			bool cartRestore = intent.GetBooleanExtra ("restore", false);

			if (File.Exists (cartFilename)) {
				cartridge = new Cartridge(cartFilename);
			}

			if (cartridge == null)
				Finish ();

			// Create engine
			engine = createEngine (cartridge);

			// Set correct icon
			if (cartridge.Icon != null) {
				Bitmap bm = BitmapFactory.DecodeByteArray (cartridge.Icon.Data, 0, cartridge.Icon.Data.Length);
				this.SupportActionBar.SetIcon(new BitmapDrawable(this.Resources, bm));
			}

			// Show main screen
			var ft = this.SupportFragmentManager.BeginTransaction ();
			ft.SetBreadCrumbTitle (cartridge.Name);
			ft.SetTransition (FragmentTransaction.TransitNone);
			ft.AddToBackStack (null);
			ft.Replace (Resource.Id.fragment, new ScreenMain (engine));
			ft.Commit ();

			layoutMain.Invalidate ();

			// Start cartridge
			if (cartRestore)
				Restore ();
			else
				Start ();
		}
コード例 #4
0
		public ScreenController (AppDelegate appDelegate, Cartridge cart, Boolean restore)
		{
			// Save for later use
			this.appDelegate = appDelegate;
			this.cart = cart;
			this.restore = restore;

			// Set color of NavigationBar and NavigationButtons (TintColor)
			if (new Version (UIDevice.CurrentDevice.SystemVersion) >= new Version(7,0)) 
				NavigationBar.SetBackgroundImage (Images.BlueTop, UIBarMetrics.Default);
			else
				NavigationBar.SetBackgroundImage (Images.Blue, UIBarMetrics.Default);

			// Create Location Manager
			locationManager = new CLLocationManager ();
			locationManager.DesiredAccuracy = CLLocation.AccurracyBestForNavigation;
			if (CLLocationManager.LocationServicesEnabled) {
				locationManager.StartUpdatingLocation ();
			}

			// Now check, if location is accurate enough
			checkLocation = new CheckLocation(this, locationManager);
			PushViewController (checkLocation, true);
		}
コード例 #5
0
		/// <summary>
		/// Constructs an uncached CartridgeTag from the basic metadata of a Cartridge.
		/// </summary>
		/// <param name="cart"></param>
		public CartridgeTag(Cartridge cart)
		{
			if (cart == null)
			{
				throw new ArgumentNullException("cart");
			}

			// Basic metadata.
			Cartridge = cart;
			Guid = cart.Guid;
			Title = cart.Name;
			PathToCache = GlobalCachePath + "/" + Guid;
		} 
コード例 #6
0
		/// <summary>
		/// Starts to play a Wherigo cartridge game.
		/// </summary>
		/// <param name="filename">Filename of the cartridge in the isolated storage.</param>
		public Cartridge InitAndStartCartridge(string filename)
		{
			// Boot Time: inits the cartridge and process position.
			Cartridge cart = new Cartridge(filename);

			using (IsolatedStorageFileStream fs = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(cart.Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
			{
				Init(fs, cart);
			}

			// Adds info about the cartridge to the crash reporter.
			Geowigo.Utils.DebugUtils.AddBugSenseCrashExtraData(cart);

			ApplySensorData();

			// Run Time: the game starts.

			Start();

			// TEMP DEBUG
			ApplySensorData();

			return cart;
		}
コード例 #7
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal LogMessageEventArgs(Cartridge cart, LogLevel level, string message)
     : base(cart)
 {
     Level   = level;
     Message = message;
 }
コード例 #8
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal AttributeChangedEventArgs(Cartridge cart, WherigoObject obj, string prop)
     : base(cart, obj)
 {
     PropertyName = prop;
 }
コード例 #9
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal WherigoEventArgs(Cartridge cart)
 {
     Cartridge = cart;
 }
コード例 #10
0
		/// <summary>
		/// Called when a game crashed. Displays a message and goes back home.
		/// </summary>
		/// <param name="crashMessageType"></param>
		/// <param name="exception"></param>
		/// <param name="cartridge"></param>
		public void HandleGameCrash(CrashMessageType crashMessageType, Exception exception, Cartridge cartridge)
		{
			// Prepares the message.
			StringBuilder sb = new StringBuilder();
			sb.Append("A problem occurred while ");
			switch (crashMessageType)
			{
				case CrashMessageType.NewGame:
					sb.Append("starting a new game");
					break;

				case CrashMessageType.Restore:
					sb.Append("restoring the saved game");
					break;

				case CrashMessageType.Runtime:
					sb.Append("running the game");
					break;

				default:
					sb.Append("running the game");
					break;
			}
			sb.Append(", therefore Geowigo cannot go on. This most likely happens because of a faulty cartridge");
			if (crashMessageType != CrashMessageType.NewGame)
			{
				sb.Append(" or savegame");
			}
			sb.Append(".\n\nIf the problem persists, you should contact the Cartridge owner, ");
			sb.Append(cartridge.GetFullAuthor());
			AggregateException agex = exception as AggregateException;
			if (agex == null || 
				(agex != null && agex.InnerExceptions != null && agex.InnerExceptions.Count > 0))
			{
				sb.Append(", quoting the following error messages that were raised during the crash:");
				List<string> messages = new List<string>();
				if (agex == null)
				{
					// In-depth dump of inner exception messages.
					Exception curex = exception;
					while (curex != null)
					{
						messages.Add(curex.Message);
						curex = curex.InnerException;
					}
					messages.Reverse();
				}
				else
				{
					foreach (Exception e in agex.InnerExceptions)
					{
						messages.Add(e.Message);
					}
				}
				int i = messages.Count;
				foreach (string message in messages)
				{
					sb.Append("\n" + i-- + "> " + message);
				}
			}
			else
			{
				sb.Append(".");
			}

			// Prepares the title.
			string caption = "";
			switch (crashMessageType)
			{
				case CrashMessageType.NewGame:
				case CrashMessageType.Restore:
					caption = "Cannot start game";
					break;

				case CrashMessageType.Runtime:
					caption = "Cartridge crashed";
					break;

				default:
					caption = "Game crash";
					break;
			}

			// Shows a message box.
			System.Windows.MessageBox.Show(
				sb.ToString(),
				caption,
				MessageBoxButton.OK
			);

			// Goes back!
			App.Current.ViewModel.NavigationManager.NavigateToAppHome(true);
		}
コード例 #11
0
		// Is called by other apps from "open in" dialogs
		public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
		{
			var sourceFile = url.Path;
			var destFile = System.IO.Path.Combine(Environment.GetFolderPath (Environment.SpecialFolder.Personal), System.IO.Path.GetFileName(sourceFile));

			if (!File.Exists (sourceFile))
				return false;

			var fileExists = false;

			if (File.Exists (destFile)) {
				fileExists = true;
				File.Delete (destFile);
			}

			File.Copy (sourceFile, destFile);

			Cartridge cart = new Cartridge(destFile);
			CartridgeLoaders.LoadMetadata(new FileStream(destFile, FileMode.Open), cart);

			// TODO
			// If there was a cartridge with the same filename, than replace
			if (fileExists) {
			}

			if (window.RootViewController.PresentedViewController is UINavigationController && window.RootViewController.PresentedViewController == navCartSelect) {
				// Now create a new list for cartridges
				viewCartSelect = new CartridgeList(this);
				// Add the cartridge view to the navigation controller
				// (it'll be the top most screen)
				navCartSelect.PopToRootViewController (true);
				navCartSelect.SetViewControllers(new UIViewController[] {(UIViewController)viewCartSelect}, false);
//				CartridgeDetail cartDetail = new CartridgeDetail(this);
//				((UINavigationController)window.RootViewController.PresentedViewController).PushViewController (cartDetail,true);
//				cartDetail.Cartridge = cart;
			}

			return true;
		}
コード例 #12
0
		private Engine createEngine (Cartridge cart)
		{
			Engine result;

			result = new Engine ();

			// Set all events for engine
			result.GetInputEvent += OnGetInput;
			result.LogMessageEvent += OnLogMessage;
			result.NotifyOSEvent += OnNotifyOS;
			result.PlayMediaEvent += OnPlayMedia;
			result.ShowMessageEvent += OnShowMessage;
			result.ShowScreenEvent += OnShowScreen;
			result.ShowStatusTextEvent += OnShowStatusText;
			result.SynchronizeEvent += OnSynchronize;

			// If there is a old logFile, close it
			if (logFile != null) {
				logFile.Flush ();
				logFile.Close ();
			}

			// Open logFile first time
			logFile = new StreamWriter(cart.LogFilename, true, Encoding.UTF8);
			logFile.AutoFlush = true;

			result.Init (new FileStream (cart.Filename,FileMode.Open), cart);

			return result;
		}
コード例 #13
0
		/// <summary>
		/// Constructs an uncached CartridgeTag from the basic metadata of a Cartridge.
		/// </summary>
		/// <param name="cart"></param>
		public CartridgeTag(Cartridge cart)
		{
			if (cart == null)
			{
				throw new ArgumentNullException("cart");
			}

			// Basic metadata.
			Cartridge = cart;
			Guid = cart.Guid;
			Title = cart.Name;
			Description = cart.LongDescription;
			StartingDescription = cart.StartingDescription;
			PathToCache = GlobalCachePath + "/" + Guid;
            PathToSavegames = String.Format("{0}/{1}_{2}",
                GlobalSavegamePath,
                Guid.Substring(0, 4),
                System.IO.Path.GetFileNameWithoutExtension(Cartridge.Filename)
            );

			// Event handlers.
			//Cartridge.PropertyChanged += new PropertyChangedEventHandler(OnCartridgePropertyChanged);
		}
コード例 #14
0
		public void CreateEngine (Cartridge cart)
		{
			if (engine != null)
				DestroyEngine ();

			var helper = new iOSPlatformHelper ();
			helper.Ctrl = this;

			engine = new Engine (helper);

			// Set all events for engine
			engine.AttributeChanged += OnAttributeChanged;
			engine.InventoryChanged += OnInventoryChanged;
			engine.ZoneStateChanged += OnZoneStateChanged;
			engine.CartridgeCompleted += OnCartridgeComplete;
			engine.InputRequested += OnGetInput;
			engine.LogMessageRequested += OnLogMessage;
			engine.PlayAlertRequested += OnPlayAlert;
			engine.PlayMediaRequested += OnPlayMedia;
			engine.SaveRequested += OnSaveCartridge;
			engine.ShowMessageBoxRequested += OnShowMessageBox;
			engine.ShowScreenRequested += OnShowScreen;
			engine.ShowStatusTextRequested += OnShowStatusText;
			engine.StopSoundsRequested += OnStopSound;

			// If there is a old logFile, close it
			if (logFile != null) {
				logFile.Flush ();
				logFile.Close ();
			}

			// Open logFile first time
			logFile = new StreamWriter(cart.LogFilename, true, System.Text.Encoding.UTF8);

			engine.Init (new FileStream (cart.Filename,FileMode.Open), cart);
		}
コード例 #15
0
		/// <summary>
		/// Creates the engine and sets all event handlers.
		/// </summary>
		/// <returns>The engine.</returns>
		/// <param name="cart">Cart.</param>
		public void CreateEngine (Cartridge cart)
		{
			var helper = new AndroidPlatformHelper(ApplicationContext);
			helper.Ctrl = this;

			engine = new Engine (helper);

			// Set all events for engine
			engine.AttributeChanged += OnAttributeChanged;
			engine.InventoryChanged += OnInventoryChanged;
			engine.ZoneStateChanged += OnZoneStateChanged;
			engine.CartridgeCompleted += OnCartridgeComplete;
			engine.InputRequested += OnGetInput;
			engine.LogMessageRequested += OnLogMessage;
			engine.PlayAlertRequested += OnPlayAlert;
			engine.PlayMediaRequested += OnPlayMedia;
			engine.SaveRequested += OnSaveCartridge;
			engine.ShowMessageBoxRequested += OnShowMessageBox;
			engine.ShowScreenRequested += OnShowScreen;
			engine.ShowStatusTextRequested += OnShowStatusText;
			engine.StopSoundsRequested += OnStopSound;

			// If there is a old logFile, close it
			if (logFile != null) {
				logFile.Flush ();
				logFile.Close ();
			}

			// Open logFile first time
			logFile = new StreamWriter(cart.LogFilename, true, System.Text.Encoding.UTF8);
			logFile.AutoFlush = true;

			// Open GPX file for the first time
//			if (!String.IsNullOrEmpty(cartridge.GpxFilename)) {
//				// Create new Gpx object
//				gpxFile = new GpxClass ();
//
//				if (File.Exists (cartridge.SaveFilename)) {
//					// Get existing data
//					gpxFile.FromFile (cartridge.SaveFilename);
//					if (gpxFile.trk == null)
//						gpxFile.trk = new trkTypeCollection ();
//				} else {
//					// Create new Gpx file
//					gpxFile.metadata = new metadataType () {
//						author=new personType(){name=WindowsIdentity.GetCurrent().Name},
//						link=new linkTypeCollection().AddLink(new linkType(){ href="www.BlueToque.ca",  text="Blue Toque Software" })
//					};
//					gpxFile.trk = new trkTypeCollection ();
//				}

				// Create new track segment
//				gpxFile.trk.trksgt = new trksegTypeCollection ();
//				gpxFile.trk.trksgt
//			}

			engine.Init (new FileStream (cart.Filename,FileMode.Open), cart);
		}
コード例 #16
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);
		}
コード例 #17
0
		public void CartStart(Cartridge cart)
		{
			Start (cart, false);
		}
コード例 #18
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal CrashEventArgs(Cartridge cart, Exception exception) : base(cart)
 {
     ExceptionObject = exception;
 }
コード例 #19
0
		public void CartRestore(Cartridge cart)
		{
			Start (cart, true);
		}
コード例 #20
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal ZoneStateChangedEventArgs(Cartridge cart, IEnumerable <Zone> z)
     : base(cart)
 {
     Zones = z;
 }
コード例 #21
0
		void Start(Cartridge cart, Boolean restore = false)
		{
			UIApplication.SharedApplication.IdleTimerDisabled = true;

			// Create main screen handler
			screenCtrl = new ScreenController(this, cart, restore);

			// Set as new navigation controll
			window.RootViewController = screenCtrl;
		}
コード例 #22
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal InventoryChangedEventArgs(Cartridge cart, Thing obj, Thing fromContainer, Thing toContainer)
     : base(cart, obj)
 {
     OldContainer = fromContainer;
     NewContainer = toContainer;
 }
コード例 #23
0
		public void OnSelect(Cartridge cart)
		{
			if (cartDetail == null)
				cartDetail = new CartridgeDetail(appDelegate);
			NavigationController.PushViewController (cartDetail,true);
			cartDetail.Cartridge = cart;
		}
コード例 #24
0
		/// <summary>
		/// Starts to play a Wherigo cartridge game.
		/// </summary>
		/// <param name="filename">Filename of the cartridge in the isolated storage.</param>
		public Cartridge InitAndStartCartridge(string filename)
		{
			// Boot Time: inits the cartridge and process position.
			Cartridge cart = new Cartridge(filename);

			using (IsolatedStorageFileStream fs = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(cart.Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
			{
				Init(fs, cart); 
			}

			ProcessPosition(_LastKnownPosition);

			// Run Time: the game starts.

			Start();

			return cart;
		}
コード例 #25
0
		public void UpdateData (Cartridge cart)
		{
			float maxWidth = this.Bounds.Width - 2 * Values.Frame;
			float maxHeight = 104.0f;
			float height = Values.Frame;

			textTitle.Text = cart.Name;
			if (!String.IsNullOrEmpty (cart.Version))
				// GETTEXT: Version for cartridge list in one line
				textVersion.Text += Catalog.Format(Catalog.GetString("Version {0}"), cart.Version);
			else
				textVersion.Text = "";
			if (!String.IsNullOrEmpty(cart.AuthorName) || !String.IsNullOrEmpty(cart.AuthorCompany))
				textAuthor.Text = Catalog.Format(Catalog.GetString("By {0}"), (String.IsNullOrEmpty(cart.AuthorName) ? "" : cart.AuthorName) + (!String.IsNullOrEmpty(cart.AuthorName) && !String.IsNullOrEmpty(cart.AuthorCompany) ? " / " : "") + (String.IsNullOrEmpty(cart.AuthorCompany) ? "" : cart.AuthorCompany));
			else
				textAuthor.Text = "";
			// TODO: Load default image for cart.ActivityType
			if (cart.Icon != null)
				this.imagePoster.Image = UIImage.LoadFromData (NSData.FromArray (cart.Icon.Data));
			else if (cart.Poster != null)
				this.imagePoster.Image = UIImage.LoadFromData (NSData.FromArray (cart.Poster.Data));
			else
				this.imagePoster.Image = null;

			// Do this, because of wrong values after rotating
			textTitle.Frame = new RectangleF (72, Values.Frame, maxWidth - directWidth - 72, 999999);
			textTitle.SizeToFit ();
			textTitle.Frame = new RectangleF (72, height, maxWidth - directWidth - 72, textTitle.Bounds.Height);

			textAuthor.Frame = new RectangleF (72, Values.Frame, maxWidth - directWidth - 72, 999999);
			textAuthor.SizeToFit ();
			textAuthor.Frame = new RectangleF (72, maxHeight - textAuthor.Bounds.Height - Values.Frame, maxWidth - directWidth - 72, textAuthor.Bounds.Height);

			height += textAuthor.Frame.Location.Y - Values.Frame;

			textVersion.Frame = new RectangleF (72, Values.Frame, maxWidth - directWidth - 72, 999999);
			textVersion.SizeToFit ();
			textVersion.Frame = new RectangleF (72, height - textVersion.Bounds.Height, maxWidth - directWidth - 72, textVersion.Bounds.Height);
		}
コード例 #26
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal MessageBoxEventArgs(Cartridge cart, MessageBox descriptor)
     : base(cart)
 {
     Descriptor = descriptor;
 }
コード例 #27
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal ObjectEventArgs(Cartridge cart, T obj)
     : base(cart)
 {
     Object = obj;
 }
コード例 #28
0
		public BaseViewModel()
		{
			// Base ressources construction.
			Model = App.Current.Model;
			Cartridge = Model.Core.Cartridge;
		}
コード例 #29
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal SavingEventArgs(Cartridge cart, bool closeAfterSave)
     : base(cart)
 {
     CloseAfterSave = closeAfterSave;
 }
コード例 #30
0
		/// <summary>
		/// Resumes playing a Wherigo cartridge saved game.
		/// </summary>
		/// <param name="filename">Filename of the cartridge in the isolated storage.</param>
		/// <param name="gwsFilename">Filename of the savegame to restore.</param>
		public Cartridge InitAndRestoreCartridge(string filename, string gwsFilename)
		{
			// Boot Time: inits the cartridge and process position.
			Cartridge cart = new Cartridge(filename);

			try
			{
				using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
				{
					using (IsolatedStorageFileStream fs = isf.OpenFile(cart.Filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
					{
						Init(fs, cart);
					}

					// Adds info about the cartridge to the crash reporter.
					Geowigo.Utils.DebugUtils.AddBugSenseCrashExtraData(cart);

					ApplySensorData();

					// Run Time: the game starts.

					using (IsolatedStorageFileStream fs = isf.OpenFile(gwsFilename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
					{
						Restore(fs);
					}

					ApplySensorData();
				}
			}
			catch (Exception)
			{
				// Re-throw any exception.
				lock (_SyncRoot)
				{
					_IsInCrash = true;
				}
				throw;
			}

			return cart;
		}
コード例 #31
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal ScreenEventArgs(Cartridge cart, ScreenType kind, UIObject obj)
     : base(cart, obj)
 {
     Screen = kind;
 }
コード例 #32
0
		/// <summary>
		/// Raised, when the activity is created.
		/// </summary>
		/// <param name="bundle">Bundle with cartridge and restore flag.</param>
		protected override void OnCreate (Bundle bundle)
		{
			// Set color schema for activity
			Main.SetTheme(this);

			base.OnCreate (bundle);

			// Load content of activity
			SetContentView (Resource.Layout.GameControllerScreen);

			// Get main layout to replace with fragments
			var layoutMain = FindViewById<LinearLayout> (Resource.Id.layoutMain);

			// Get data from intent
			Intent intent = this.Intent;

			string cartFilename = intent.GetStringExtra ("cartridge");
			cartRestore = intent.GetBooleanExtra ("restore", false);

			// Check, if cartridge files exists, and if yes, create a new cartridge object
			if (File.Exists (cartFilename)) {
				cartridge = new Cartridge(cartFilename);
			}

			// If cartridge object don't exist, than close activity
			if (cartridge == null)
				Finish ();

			audioManager = (AudioManager)GetSystemService(Context.AudioService);
			vibrator = (Vibrator)GetSystemService(Context.VibratorService);

			// Create CheckLocation
			GameCheckLocation checkLocation = new GameCheckLocation();

			// Show CheckLocation
			var ft = SupportFragmentManager.BeginTransaction ();
			ft.SetBreadCrumbTitle (cartridge.Name);
			ft.SetTransition (global::Android.Support.V4.App.FragmentTransaction.TransitNone);
			ft.Replace (Resource.Id.fragment, checkLocation);
			ft.Commit ();
		}
コード例 #33
0
ファイル: Events.cs プロジェクト: chier01/WF.Player.Core
 internal StatusTextEventArgs(Cartridge cart, string text)
     : base(cart)
 {
     Text = text;
 }
コード例 #34
0
ファイル: GameModel.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Creates the engine.
		/// </summary>
		/// <returns>The task.</returns>
		/// <param name="cartridge">Cartridge handled by this instance.</param>
		private async System.Threading.Tasks.Task CreateEngine(Cartridge cartridge)
		{
			if (this.engine != null)
			{
				this.DestroyEngine();
			}

			// Get device sound and vibration
			this.sound = DependencyService.Get<ISound>();
			this.vibration = DependencyService.Get<IVibration>();

			// Get os helper
			var helper = DependencyService.Get<IPlatformHelper>();

			this.engine = new Engine(helper);

			// Set all events for engine
			this.engine.AttributeChanged += this.OnAttributeChanged;
			this.engine.CommandChanged += this.OnCommandChanged;
			this.engine.InventoryChanged += this.OnInventoryChanged;
			this.engine.ZoneStateChanged += this.OnZoneStateChanged;
			this.engine.CartridgeCompleted += this.OnCartridgeComplete;
			this.engine.InputRequested += this.OnGetInput;
			this.engine.LogMessageRequested += this.OnLogMessage;
			this.engine.PlayAlertRequested += this.OnPlayAlert;
			this.engine.PlayMediaRequested += this.OnPlayMedia;
			this.engine.SaveRequested += this.OnSaveCartridge;
			this.engine.ShowMessageBoxRequested += this.OnShowMessageBox;
			this.engine.ShowScreenRequested += this.OnShowScreen;
			this.engine.ShowStatusTextRequested += this.OnShowStatusText;
			this.engine.StopSoundsRequested += this.OnStopSound;
			this.engine.PropertyChanged += this.OnPropertyChanged;
			this.engine.CartridgeCrashed += this.OnCartridgeCrashed;

			// Open logFile first time
			this.logFile = this.cartridgeTag.CreateLogFile();
			this.logFile.MinimalLogLevel = this.logLevel;

			await System.Threading.Tasks.Task.Run(() => this.engine.Init(new FileStream(Path.Combine(App.PathCartridges, Path.GetFileName(cartridge.Filename)), FileMode.Open), cartridge));
		}
コード例 #35
0
		/// <summary>
		/// Constructs an uncached CartridgeTag from the basic metadata of a Cartridge.
		/// </summary>
		/// <param name="cart"></param>
		public CartridgeTag(Cartridge cart)
		{
			if (cart == null)
			{
				throw new ArgumentNullException("cart");
			}

			// Basic metadata.
			Cartridge = cart;
			Guid = cart.Guid;
			Title = cart.Name;
			Description = cart.LongDescription;
			StartingDescription = cart.StartingDescription;
			PathToCache = GlobalCachePath + "/" + Guid;
            PathToSavegames = String.Format("{0}/{1}_{2}",
                GlobalSavegamePath,
                Guid.Substring(0, 4),
                System.IO.Path.GetFileNameWithoutExtension(Cartridge.Filename)
            );
			PathToLogs = PathToSavegames;

            // Lists
            _savegames = new List<CartridgeSavegame>();
		}