/// <summary> /// Sets the theme for the app. /// </summary> async Task SetAppTheme(AppThemeViewModel theme) { try { Application.Current.UserAppTheme = theme.Key; Settings.AppTheme = theme.Key; foreach (var item in AppThemes) { item.IsSelected = false; } AppThemes.FirstOrDefault(x => x.Key == Settings.AppTheme).IsSelected = true; RaisePropertyChanged(nameof(AppThemes)); //var statusBar = DependencyService.Get<IStatusBar>(); //statusBar?.SetStatusBarColor((OSAppTheme)theme.Key, Color.Black); HapticFeedback.Perform(HapticFeedbackType.Click); AnalyticsService.Track("App Theme Changed", nameof(theme), ((OSAppTheme)theme.Key).ToString() ?? "null"); } catch (Exception ex) { await DialogService.AlertAsync(Translations.error_couldntchangetheme, Translations.error_title, Translations.ok).ConfigureAwait(false); AnalyticsService.Report(ex); } }
public bool DropItem() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit)) { if (hit.transform.gameObject.CompareTag("Ground")) { transform.position = hit.point; gameObject.SetActive(true); PlaceBarricade(); hapticFeedback = GetComponent <HapticFeedback>(); hapticFeedback?.Activate(); return(true); } else { ServiceLocator.Get <GameManager>().barricadeSpawner?.ResetBarricade(); Destroy(gameObject); return(false); } } return(false); }
public void UpdateFeedbacks(HapticFeedback feedback) { if (motors == null) { return; } for (int i = 0; i < row * column; i++) { var motor = motors[i]; if (motor == null) { return; } var scale = feedback.Values[i] / 100f; motor.transform.localScale = new Vector3(0.2f + (scale * (.25f)), 0.2f + (scale * (.25f)), 0.2f + (scale * (.25f))); var rd = motor.GetComponentInChildren <Renderer>(); if (rd != null) { rd.material.color = new Color(0.8f + scale * 0.2f, 0.8f + scale * 0.01f, 0.8f - scale * 0.79f, 0.2f - 0.2f * scale); } } }
private void FixedUpdate() { collisionDetection.CastRayCast(); /* Since we are applying gravity constantly with our own physics, * we want to check if raycast hit anything, then we set the velocity.y back to 0, * so our ball don't fall through the platform. * We don't want to set velocity.y to 0 when bouncing, or else the ball won't bounce */ ballPhysics.ApplyVerticalCollision(collisionDetection); if (collisionDetection.collidedObject != null) // If our raycast system detects something { ground = collisionDetection.collidedObject.transform; // Set the ground variable to the detected gameobject } // If raycast hits something, we want the ball to bounce up if (collisionDetection.hasCollided) { ballBounce.Bounce(ref ballPhysics.velocity); HapticFeedback.Generate(UIFeedbackType.ImpactMedium); if (ground.GetComponent <PlatformController>() != null) { ground.GetComponent <PlatformController>().CallJiggle(); } } ballPhysics.ApplyPhysics(transform); }
public static void InitialiseiOSHaptics() { #if PLATFORM_IOS hapticFeedback = new HapticFeedback(); hapticFeedback.LightStyle(); #endif }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void HandleDeselected(ISelectableItem pItem) { print("Train Deselected"); HapticFeedback HapticFlags = Haptics.GetComponent <HapticFeedback>(); HapticFlags.HapticIndexFeedback = 0; }
private void OnStatusChanged(PlayerResponse playerResponse) { if (visualizeFeedback == false) { return; } if (_changedFeedback == null) { return; } lock (_changedFeedback) { foreach (var status in playerResponse.Status) { var pos = EnumParser.ToPositionType(status.Key); var val = status.Value; byte[] result = new byte[val.Length]; for (int i = 0; i < val.Length; i++) { result[i] = (byte)val[i]; } var feedback = new HapticFeedback(pos, result); _changedFeedback.Add(feedback); } } }
public void UpdateFeedbacks(HapticFeedback feedback) { if (motors == null) { return; } for (int i = 0; i < row * column; i++) { var motor = motors[i]; if (motor == null) { return; } var scale = feedback.Values[i] / 100f; motor.transform.localScale = new Vector3(0.2f + (scale * (.25f)), 0.2f + (scale * (.25f)), 0.2f + (scale * (.25f))); var im = motor.GetComponent <Image>(); if (im != null) { im.color = new Color(0.8f + scale * 0.2f, 0.8f + scale * 0.01f, 0.8f - scale * 0.79f, 1f); } } }
//private void HitHaptics() //{ // for (int i = 1000; i > 0; i++) // { // if(i % 10 == 0) // { // HapticFeedback.HapticAmount((int)(1.5f * i), true, true); // } // } //} IEnumerator HitHaptics(float timeBetween) { for (int i = 5; i > 0; i--) { yield return(new WaitForSeconds(timeBetween)); HapticFeedback.HapticAmount((int)((200 * i) + 1000), true, false); } }
void Update() { if (!visualizeFeedback) { return; } if (!BhapticsUtils.IsPlayerInstalled()) { return; } if (Application.platform == RuntimePlatform.Android) { if (!Monitor.TryEnter(_changedFeedback)) { Debug.Log("failed to enter"); return; } try { foreach (var feedback in _changedFeedback) { foreach (var vis in visualFeedback) { if (vis.Position == feedback.Position) { vis.UpdateFeedback(feedback); } } } _changedFeedback.Clear(); } finally { Monitor.Exit(_changedFeedback); } } else { foreach (var vis in visualFeedback) { HapticApi.status status; HapticApi.TryGetResponseForPosition(vis.Position, out status); byte[] result = new byte[20]; for (int i = 0; i < result.Length; i++) { result[i] = (byte)status.values[i]; } HapticFeedback feedback = new HapticFeedback(vis.Position, result); vis.UpdateFeedback(feedback); } } }
void OnCollisionEnter(Collision c) { HapticFeedback h = c.gameObject.GetComponent <HapticFeedback>(); if (h != null) { h.DoFeedback(); //Debug.Log("DoHapticFeedback"); } }
void OnCollisionExit(Collision c) { HapticFeedback h = c.gameObject.GetComponent <HapticFeedback>(); if (h != null) { h.StopFeedback(); //Debug.Log("StopHapticFeedback"); } }
/// <summary> /// We are detecting the ground and calculating offset variables for our stretch and squash function /// /// The original Stretch and Squash function has a hardcoded ground position of 0 at Y axis, /// so we need an offset for our ground to do the right calculations, because our ground is not always at 0. /// </summary> private void FixedUpdate() { if (disabled) { return; } collisionDetection.CastRayCast(); /* Since we are applying gravity constantly with our own physics, * we want to check if raycast hit anything, then we set the velocity.y back to 0, * so our ball don't fall through the platform. * We don't want to set velocity.y to 0 when bouncing, or else the ball won't bounce */ ballPhysics.ApplyVerticalCollision(collisionDetection); if (collisionDetection.collidedObject != null) // If our raycast system detects something { ground = collisionDetection.collidedObject.transform; // Set the ground variable to the detected gameobject if (ground != null) { groundBallLastTouched = ground.gameObject; } } // If raycast hits something, we want the ball to bounce up if (collisionDetection.hasCollided) { //bounce our ball ballBounce.Bounce(ref ballPhysics.velocity); //Phone haptic feedback HapticFeedback.Generate(UIFeedbackType.ImpactMedium); //if the platform we're hitting is a brick if (ground.GetComponent <PlatformController>() != null) { //Jiggle the brick ground.GetComponent <PlatformController>().CallJiggle(); if (ground.GetComponent <WinLevel>()) { ground.GetComponent <WinLevel>().TryWinGame(); } //if not we will raise the events that we need to if (ground.GetComponent <VictoryTag>() == null) { onNormalPlatformImpact.Raise(); onPlatformImpact.Raise(); } } } //ApplyPhysics recieves a transform and applies the final velocity vector which moves the ball ballPhysics.ApplyPhysics(transform); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void HandleSelected(ISelectableItem pItem) { print("Stop Selected"); HapticFeedback HapticFlags = Haptics.GetComponent <HapticFeedback>(); HapticFlags.HapticIndexFeedback = 1; StateMachine StateMachineFlags = StateMachine.GetComponent <StateMachine>(); StateMachineFlags.StopFlag = 1; }
/// <summary> /// Deletes a contribution. /// </summary> async Task DeleteContribution() { try { // Shouldn't be getting here anyway, so no need for a message. if (!CanBeEdited) { return; } if (!await VerifyInternetConnection()) { return; } // Ask for confirmation before deletion. var confirm = await DialogService.ConfirmAsync(Translations.contributiondetail_deleteconfirmation, Translations.warning_title, Translations.ok, Translations.cancel).ConfigureAwait(false); if (!confirm) { return; } State = LayoutState.Loading; var isDeleted = await MvpApiService.DeleteContributionAsync(Contribution); if (isDeleted) { // TODO: Pass back true to indicate it needs to refresh. // TODO: Be a bit more sensible with muh threads plz. MainThread.BeginInvokeOnMainThread(() => HapticFeedback.Perform(HapticFeedbackType.LongPress)); AnalyticsService.Track("Contribution Deleted"); await MainThread.InvokeOnMainThreadAsync(() => BackAsync()); //MessagingService.Current.SendMessage(MessageKeys.HardRefreshNeeded); MessagingService.Current.SendMessage(MessageKeys.HardRefreshNeeded); } else { await DialogService.AlertAsync(Translations.contributiondetail_notdeleted, Translations.error_title, Translations.ok).ConfigureAwait(false); } } catch (Exception ex) { AnalyticsService.Report(ex); await DialogService.AlertAsync(Translations.error_unexpected, Translations.error_title, Translations.ok).ConfigureAwait(false); } finally { State = LayoutState.None; } }
private void OnCollisionEnter2D(Collision2D collision) { Debug.Log(collision.gameObject.name); if (collision.gameObject.name == "Platform (8)") { this.gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector2(0.0f, 20.0f), ForceMode2D.Impulse); HapticFeedback.DoHaptic(HapticFeedback.NotificationType.Success); } else { HapticFeedback.DoHaptic(HapticFeedback.HapticForce.Medium); } }
// Start is called before the first frame update protected override void Start() { base.Start(); if (GameManager.Instance.playerPlatform == PlayerPlatform.OCULUS && handSide == HandSide.UNSPECIFIED) { Debug.LogWarning("Hand side not selected."); } if (!(GameManager.Instance.playerPlatform == PlayerPlatform.EDITOR)) { hapticFeedback = GetComponent <HapticFeedback>(); } }
// Update is called once per frame void Update() { if (PlayerScript._deviceNonDominant.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && !_isSettingMenuOpen) { _isSettingMenuOpen = true; _settingMenuObj.SetActive(true); HapticFeedback.HapticAmount(500, false, true); } if (_isSettingMenuOpen) { OpenSettings(); } }
public void CryFace() { // HideFaces(); GameManager.instance.OnFailureEvent(); GameManager.instance.gameOver = true; isDead = true; DOTween.KillAll(); GameManager.instance.OnGameOver(); HapticFeedback.Generate(UIFeedbackType.Error); int rand = Random.Range(0, 2); GameManager.instance.PlaySound(rand == 1 ? GameManager.instance.missmatch01 : GameManager.instance.missmatch02); StartCoroutine(GameManager.instance.IncreaseXp()); }
public static void HapticFeedbackLongPress() { try { // Perform click feedback HapticFeedback.Perform(HapticFeedbackType.LongPress); } catch (FeatureNotSupportedException ex) { // Feature not supported on device } catch (Exception ex) { // Other error has occurred. } }
public void GettingResource() { if (coolTimeImage.fillAmount >= 1) { Tower tower = ServiceLocator.Get <LevelManager>().towerInstance.GetComponent <Tower>(); tower.GetComponent <Tower>().HealTower(healValue); coolTimeImage.fillAmount = 0; hapticFeedback = GetComponent <HapticFeedback>(); hapticFeedback?.Activate(); // For tutorial if (tutorial2) { tutorial2.usedTrashToHeal = true; } } }
async void Button_Clicked2(System.Object sender, System.EventArgs e) { try { // Haptic HapticFeedback.Perform(HapticFeedbackType.Click); } catch (FeatureNotSupportedException ex) { await DisplayAlert("Sorry", "No can do amigo - no device support", "Ok"); } catch (Exception ex) { await DisplayAlert("Ooops", ex.Message, "Ok"); } }
void Update() { //if (_trackedObj.gameObject.activeInHierarchy) //{ // _device = SteamVR_Controller.Input((int)_trackedObj.index); //} if (PlayerScript._deviceDominant.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && !_isInventoryOpen) { _isInventoryOpen = true; //CheckInventoryItemPlacement(); _inventoryObj.SetActive(true); //ShowInventoryItems(true); PostProcessControl.PostExposureFade(_exposureInventoryOn, _exposureFadeSpeed); //PostProcessControl.DOFFade(_focalLengthInventoryOn, _focusDistanceInventoryOn, _focalLengthFadeSpeed, _focusDistanceFadeSpeed); HapticFeedback.HapticAmount(500, true, false); PlaceItemsInInventory(false, true); CheckHandModelVisibility(); //_handModelObj.gameObject.SetActive(true); //if (_inHandObj != null) //{ // _inHandObj.SetActive(false); // _hasItemInHand = false; //} } if (_isInventoryOpen) { OpenInventory(); } //if (_hasItemInHand) //{ // _inHandObj.transform.position = Vector3.Lerp(_inHandObj.transform.position, transform.position, Time.deltaTime * 12f); // _inHandObj.transform.rotation = Quaternion.Slerp(_inHandObj.transform.rotation, transform.rotation, Time.deltaTime * 12f); //} else //{ // foreach (var slot in _inventorySlots) // { // if (slot.hasItemInHand) // { // PutInInventory(slot); // } // } //} }
private void IsCheckedChanged(bool isChecked) { Todo.Completed = isChecked; try { HapticFeedback.Perform(HapticFeedbackType.Click); } catch (FeatureNotSupportedException ex) { Console.WriteLine($"Haptics not supported.{Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}"); } catch (Exception ex) { Console.WriteLine($"{ex.Message}{Environment.NewLine}{ex.StackTrace}"); } StateHasChanged(); }
private void ShowFeedbackEffect(HapticFeedback feedback) { if (visualMotors == null) { return; } for (int i = 0; i < visualMotors.Length; i++) { var motor = visualMotors[i]; var power = feedback.Values[i] / 100f; var meshRenderer = motor.GetComponent <MeshRenderer>(); if (meshRenderer != null) { meshRenderer.material.color = hapticColor.Evaluate(power); } } }
private void ProgressBar() { if (PlayerScript._dominantHand.gameObject.activeInHierarchy && PlayerScript._nonDominnatHand.gameObject.activeInHierarchy) { if (_progressBarObj.fillAmount < 1) { if (PlayerScript._deviceDominant.GetPress(SteamVR_Controller.ButtonMask.Trigger) || PlayerScript._deviceDominant.GetPress(SteamVR_Controller.ButtonMask.Grip) || PlayerScript._deviceDominant.GetPress(SteamVR_Controller.ButtonMask.Touchpad) || PlayerScript._deviceDominant.GetPress(SteamVR_Controller.ButtonMask.ApplicationMenu) || PlayerScript._deviceNonDominant.GetPress(SteamVR_Controller.ButtonMask.Trigger) || PlayerScript._deviceNonDominant.GetPress(SteamVR_Controller.ButtonMask.Grip) || PlayerScript._deviceNonDominant.GetPress(SteamVR_Controller.ButtonMask.Touchpad) || PlayerScript._deviceNonDominant.GetPress(SteamVR_Controller.ButtonMask.ApplicationMenu)) { _progressBarObj.fillAmount += Time.deltaTime * .5f; if (_hapticClickTimer > 0) { _hapticClickTimer -= Time.deltaTime; } else { HapticFeedback.HapticAmount(500, true, true); } } else { if (_progressBarObj.fillAmount > 0) { _progressBarObj.fillAmount -= Time.deltaTime * .25f; } if (_progressBarObj.fillAmount <= 0) { _progressBarObj.fillAmount = 0; } } } else { if (!_isProgressBarFilled) { ProgressBarFilled(); _isProgressBarFilled = true; } } } }
private void ShowHapticFeedbackOnMotors() { if (changedFeedback == null) { return; } if (Application.platform == RuntimePlatform.Android) { if (!System.Threading.Monitor.TryEnter(changedFeedback)) { return; } try { foreach (var feedback in changedFeedback) { if (tactPositionType == feedback.Position) { ShowFeedbackEffect(feedback); } } changedFeedback.Clear(); } finally { System.Threading.Monitor.Exit(changedFeedback); } } else { HapticApi.status status; HapticApi.TryGetResponseForPosition(tactPositionType, out status); byte[] result = new byte[20]; for (int i = 0; i < result.Length; i++) { result[i] = (byte)status.values[i]; } HapticFeedback feedback = new HapticFeedback(tactPositionType, result); ShowFeedbackEffect(feedback); } }
private void Start() { VariableLoader variableLoader = ServiceLocator.Get <VariableLoader>(); _player = ServiceLocator.Get <LevelManager>().playerInstance.GetComponent <Player>(); _tower = ServiceLocator.Get <LevelManager>().towerInstance.GetComponent <Tower>(); if (variableLoader.useGoogleSheets) { moveSpeed = variableLoader.PlayerStats["Speed"]; agent.speed = moveSpeed; attackCoolDown = variableLoader.PlayerAbilties["Attack"]["Cooldown"]; poisonAttackCoolDown = variableLoader.PlayerAbilties["Poison"]["Cooldown"]; intimidateAttackCoolDown = variableLoader.PlayerAbilties["Stun"]["Cooldown"]; } hapticPoisonAbility = poisonUIbutton.gameObject.GetComponent <HapticFeedback>(); hapticIntimidateAbility = intimidateUIbutton.gameObject.GetComponent <HapticFeedback>(); hapticUltAbility = ultUIbutton.gameObject.GetComponent <HapticFeedback>(); }
private async void ButtonTimer_Elapsed(object sender, ElapsedEventArgs e) { if (_elements == null) { return; } _elements.Index = LeftRightButton ? _elements.MaxElement() : 0; try { HapticFeedback.Perform(HapticFeedbackType.LongPress); } catch (FeatureNotSupportedException) { Vibration.Vibrate(100); } await Device.InvokeOnMainThreadAsync(() => RefreshPage(false)).ConfigureAwait(false); }
/// <summary> /// Sets the app icon to whatever the user chose. /// </summary> async Task SetAppIcon(AppIconViewModel icon) { try { var iconSwitcher = DependencyService.Get <IIconService>(); if (iconSwitcher == null) { return; } if (icon.Key == AppIcon.Default) { await iconSwitcher?.SwitchAppIcon(null); } else { await iconSwitcher?.SwitchAppIcon(icon.Key.ToString()); } Settings.AppIcon = icon.Key; foreach (var item in AppIcons) { item.IsSelected = false; } AppIcons.FirstOrDefault(x => x.Key == Settings.AppIcon).IsSelected = true; RaisePropertyChanged(nameof(AppIcons)); HapticFeedback.Perform(HapticFeedbackType.Click); AnalyticsService.Track("App Icon Changed", nameof(icon), icon.Key.ToString() ?? "null"); } catch (Exception ex) { await DialogService.AlertAsync(Translations.error_couldntchangeicon, Translations.error_title, Translations.ok).ConfigureAwait(false); AnalyticsService.Report(ex); } }