private void Awake() { if (!instance) { instance = this; } else { instance = null; } }
void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } }
public void ShakeCamera(float power = 2f, float duration = 0.2f, int vibro = 2, float elasitcy = 0.5f) { if (isShaking) { return; } isShaking = true; transform.DOPunchRotation(Vector3.forward * power, duration, vibro, elasitcy).OnComplete(() => isShaking = false); HapticManager.Haptic(HapticTypes.RigidImpact); }
private void Start() { hapticManager = FindObjectOfType <HapticManager>(); if (hapticManager == null) { Debug.LogError("Cannot play any haptic reactions as there is no haptic manager in the scene.", this); enabled = false; } }
private void Awake() { if (instance == null) { instance = this; } if (instance != this) { Debug.LogWarning("Multiple Haptic Managers found in scene!"); Destroy(this); } }
private void UpdateScaleAndLabels() { // Cast ray from center of UI and assign the detected center button to the centerButton // gameobject. Ray centerRay = GUICamera.ScreenPointToRay(new Vector2( _guiTex.width / 2, _guiTex.height / 2)); RaycastHit centerRayHit; GameObject center_button = null; if (Physics.Raycast(centerRay, out centerRayHit, Mathf.Infinity)) { center_button = centerRayHit.collider.gameObject; } _centerButtonChanged = center_button != _centerButton; if (_centerButtonChanged) { _centerButton = center_button; //// Provide user with haptic feedback. HapticManager.HapticFeedback(); //// Update button label based on center button. if (_centerButton.GetComponent <SceneButton>() != null) { string centerButtonLabel = _centerButton.GetComponent <SceneButton>().SceneLabel; if (centerButtonLabel != null) { ButtonLabel.text = centerButtonLabel; } } } // Scale down buttons that aren't in the center, and scale up the center button. foreach (SceneButton button in _buttons) { if (button.gameObject == _centerButton) { float scale = button.transform.localScale.x + (0.25f * (1.12f - button.transform.localScale.x)); button.transform.localScale = new Vector3(scale, scale, scale); } else { float scale = button.transform.localScale.x + (0.1f * (1.0f - button.transform.localScale.x)); button.transform.localScale = new Vector3(scale, scale, scale); } } }
private void MetroWindow_Closed(object sender, EventArgs e) { Keymapper.Stop(); ProcessWatcher.Stop(); HapticManager.Stop(); var aC = ControllerManager.GetActiveController(); aC?.SetLightbar(0, 0, 0); aC?.Stop(); ControllerManager.Stop(); _notifyIcon.Visible = false; _notifyIcon.Dispose(); WindowClosing?.Invoke(); }
public MainWindow() { InitializeComponent(); var currentVersion = Assembly.GetExecutingAssembly().GetName().Version; Logger.Write("------------------------------------------"); Logger.Write("WoWmapper {0} initializing...", currentVersion); Logger.Write("Operating System: Windows {0}, {1}", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "x64" : "x86"); Logger.Write("Application Path: {0}", System.AppDomain.CurrentDomain.BaseDirectory); var dxKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\DirectX"); var dxVersion = new Version(); var dxVersionString = (string)dxKey?.GetValue("Version"); if (dxVersionString != null) { dxVersion = new Version(dxVersionString); } if (dxVersion < new Version("4.09.00.0904")) { var downloadDXnow = System.Windows.MessageBox.Show( "DirectX 9.0c is required for Xbox controller support. Would you like to download it now?", "DirectX not found", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (downloadDXnow == MessageBoxResult.Yes) { Process.Start("https://www.microsoft.com/en-us/download/confirmation.aspx?id=8109"); } Settings.Default.EnableXbox = false; Settings.Default.Save(); } if (new Version(Settings.Default.LastRunVersion) < currentVersion) { Logger.Write("Upgrading application settings"); Settings.Default.Upgrade(); } Settings.Default.LastRunVersion = currentVersion.ToString(); Settings.Default.Save(); AppDataDir = Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "WoWmapper"); if (!Directory.Exists(AppDataDir)) { Logger.Write("App data dir not found\nCreating{0}", AppDataDir); Directory.CreateDirectory(AppDataDir); } // Add notification menu items ((MenuItem)_notifyMenu.Items[0]).Click += NotifyMenu_Open_WoWmapper; ((MenuItem)_notifyMenu.Items[2]).Click += NotifyMenu_Controllers; ((MenuItem)_notifyMenu.Items[3]).Click += NotifyMenu_Keybinds; ((MenuItem)_notifyMenu.Items[5]).Click += NotifyMenu_Exit; _notifyIcon = new NotifyIcon(); _notifyIcon.Click += NotifyIcon_Click; _notifyIcon.DoubleClick += NotifyIcon_DoubleClick; _notifyIcon.Visible = true; _notifyIcon.Icon = Properties.Resources.WoWmapper_Icon; // Add custom accents ThemeManager.AddAccent("DeathKnight", new Uri("pack://application:,,,/Resources/Accents/DeathKnight.xaml")); ThemeManager.AddAccent("Druid", new Uri("pack://application:,,,/Resources/Accents/Druid.xaml")); ThemeManager.AddAccent("Hunter", new Uri("pack://application:,,,/Resources/Accents/Hunter.xaml")); ThemeManager.AddAccent("Mage", new Uri("pack://application:,,,/Resources/Accents/Mage.xaml")); ThemeManager.AddAccent("Monk", new Uri("pack://application:,,,/Resources/Accents/Monk.xaml")); ThemeManager.AddAccent("Paladin", new Uri("pack://application:,,,/Resources/Accents/Paladin.xaml")); ThemeManager.AddAccent("Priest", new Uri("pack://application:,,,/Resources/Accents/Priest.xaml")); ThemeManager.AddAccent("Rogue", new Uri("pack://application:,,,/Resources/Accents/Rogue.xaml")); ThemeManager.AddAccent("Shaman", new Uri("pack://application:,,,/Resources/Accents/Shaman.xaml")); ThemeManager.AddAccent("Warlock", new Uri("pack://application:,,,/Resources/Accents/Warlock.xaml")); ThemeManager.AddAccent("Warrior", new Uri("pack://application:,,,/Resources/Accents/Warrior.xaml")); // Load saved theme and accent var appTheme = ThemeManager.AppThemes.FirstOrDefault(theme => theme.Name == Settings.Default.AppTheme); var appAccent = ThemeManager.Accents.FirstOrDefault(accent => accent.Name == Settings.Default.AppAccent); // Load defaults if invalid if (appTheme == null) { appTheme = ThemeManager.GetAppTheme("BaseLight"); Settings.Default.AppTheme = "BaseLight"; Settings.Default.Save(); } if (appAccent == null) { appAccent = ThemeManager.GetAccent("Blue"); Settings.Default.AppAccent = "Blue"; Settings.Default.Save(); } // Set drop shadow if (Settings.Default.AppDropShadow) { BorderThickness = new Thickness(0); GlowBrush = Brushes.Black; } // Apply theme ThemeManager.ChangeAppStyle(Application.Current, appAccent, appTheme); // Hook events AdvancedSettings.ShowFeedbackWarning += AdvancedSettings_ShowFeedbackWarning; AdvancedSettings.DoResetAll += AdvancedSettings_DoResetAll; ShowMessage += MainWindow_ShowMessage; ShowKeybindDialogEvent += OnShowKeybindDialog; // Initialize UI timer _timerUpdateUi.Elapsed += Timer_UpdateUI; _timerUpdateUi.Interval = 100; _timerUpdateUi.Start(); // Initialize controllers BindingManager.LoadKeybinds(); // Initialize process watcher ProcessWatcher.Start(); ControllerManager.Start(); HapticManager.Start(); Keymapper.Start(); }
private void TapInput() { if (Input.GetMouseButtonDown(0)) { tapInputDownTime = Time.time; } if (Input.GetMouseButtonUp(0)) { tapDuration = Mathf.Abs(tapInputDownTime - Time.time); if (tapDuration < 0.2f) { OnTapInput.Invoke(); HapticManager.Haptic(HapticTypes.SoftImpact); //Debug.Log("Tap " + tapDuration); } tapDuration = 0; } //Editor Input //#if UNITY_EDITOR // if (Input.GetMouseButtonDown(0)) // tapInputDownTime = Time.time; // if (Input.GetMouseButtonUp(0)) // { // tapDuration = Mathf.Abs(tapInputDownTime - Time.time); // if (tapDuration < 0.2f) // { // OnTapInput.Invoke(); // //Debug.Log("Tap " + tapDuration); // } // tapDuration = 0; // } //#else //Android and IOS Input // if(Input.touchCount > 0) // { // Touch touch = Input.GetTouch(0); // switch (touch.phase) // { // case TouchPhase.Began: // tapInputDownTime = Time.time; // break; // case TouchPhase.Moved: // break; // case TouchPhase.Stationary: // break; // case TouchPhase.Ended: // tapDuration = Mathf.Abs(tapInputDownTime - Time.time); // if (tapDuration < 0.2f) // { // OnTapInput.Invoke(); // //Debug.Log("Tap " + tapDuration); // } // tapDuration = 0; // GameManager.Instance.StartGame(); // LevelManager.Instance.StartLevel(); // break; // case TouchPhase.Canceled: // tapDuration = Mathf.Abs(tapInputDownTime - Time.time); // if (tapDuration < 0.2f) // { // OnTapInput.Invoke(); // //Debug.Log("Tap " + tapDuration); // } // tapDuration = 0; // break; // default: // break; // } // } //#endif }
public void Play(bool rightHand) { HapticManager.Play(this, rightHand); }