コード例 #1
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));
		}
コード例 #2
0
 /**
  * Set the delegate implementation.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public void SetDelegate(IVibration _delegate)
 {
     this._delegate = _delegate;
 }
コード例 #3
0
ファイル: Vibration.shared.cs プロジェクト: sung-su/maui
 public static void Vibrate(this IVibration vibration, double duration) =>
 vibration.Vibrate(TimeSpan.FromMilliseconds(duration));
コード例 #4
0
 /**
  * Constructor with delegate.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public VibrationBridge(IVibration _delegate) : base()
 {
     this._delegate = _delegate;
 }
コード例 #5
0
ファイル: App.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Play click sounds and vibrate if that is selected in the preferences.
		/// </summary>
		public static void Click()
		{
			if (sound == null)
			{
				sound = DependencyService.Get<ISound>();
			}
				
			if (sound != null && Settings.Current.GetValueOrDefault<bool>(Settings.FeedbackSoundKey))
			{
				sound.PlayKeyboardSound();
			}

			if (vibrate == null)
			{
				vibrate = DependencyService.Get<IVibration>();
			}

			if (vibrate != null && Settings.Current.GetValueOrDefault<bool>(Settings.FeedbackVibrationKey))
			{
				vibrate.Vibrate(150);
			}
		}