static void Main(string[] args) { LeapMotion leap = new LeapMotion(); leap.EnableGestures(); leap.FrameReady += Leap_FrameReady; leap.GestureRecognized += Leap_GestureRecognized; Console.ReadKey(); }
/// <summary> /// Játék előkészítése, elemek skálázása /// </summary> void Start() { Leap = LeapMotion.Instance; PreviousController = CurrentController = Controllers.Mouse; MousePosition = Input.mousePosition; if (PlayerPrefs.HasKey("Blade")) { SetBlade(PlayerPrefs.GetInt("Blade")); } if (PlayerPrefs.HasKey("Wallpaper")) { SetBackground(PlayerPrefs.GetInt("Wallpaper")); } for (int i = 0; i < (int)GameModes.Multiplayer; ++i) { TopScores[i] = PlayerPrefs.GetInt("Top" + i, 0); } BestCombo = PlayerPrefs.GetInt("BestCombo", 0); if (HoloLensMode) { Background.transform.localScale = new Vector3(Scale, Scale * .4f, 1); PreviousController = CurrentController = Controllers.HoloLens; BottomLeft = Background.transform.position + Background.transform.rotation * new Vector3(Scale * -.5f, Scale * -.2f, Scale * -.01f); BottomRight = BottomLeft + Background.transform.rotation * new Vector3(Scale, 0, 0); TopLeft = BottomLeft + new Vector3(0, Scale * .4f, 0); Forward = Quaternion.Euler(0, -90, 0) * (BottomRight - BottomLeft).normalized * (Scale * .06f) * DepthScale; } else { BottomLeft = Utils.ScreenPosInWorld(new Vector2(0, 0)); BottomRight = Utils.ScreenPosInWorld(new Vector2(Screen.width, 0)); TopLeft = Utils.ScreenPosInWorld(new Vector2(0, Screen.height)); Forward = Camera.main.transform.forward * Scale * .2f * DepthScale; } float NormalScale = Scale * .02f; Pointer.GetComponent <TrailRenderer>().startWidth *= NormalScale; Player2.GetComponent <TrailRenderer>().startWidth *= NormalScale; Physics.gravity *= NormalScale; CloserBL = BottomLeft - Forward; CloserBR = BottomRight - Forward; CloserTL = TopLeft - Forward; ForceRight = (BottomRight - BottomLeft).normalized * (Scale + Scale); ForceLeft = -ForceRight; SpawnMainMenu(); }
private void TSCBXInputDevice_SelectedIndexChanged(object sender, EventArgs e) { switch (TSCBXInputDevice.SelectedIndex) { case 0: if (DrawingDevice is LeapMotion) { (DrawingDevice as LeapMotion).Disconect(); } InputDevices.Mouse mouse = new Mouse(DZEditor); DrawingDevice = mouse; break; case 1: DrawingDevice = new NovintFalcon(); break; case 2: InputDevices.LeapMotion leap = new LeapMotion(); if (leap.IsConnected) { DrawingDevice = leap; } else { MessageBox.Show("Leap motion disconected"); } break; case 3: if (DrawingDevice is LeapMotion) { (DrawingDevice as LeapMotion).Disconect(); } InputDevices.TouchScreen touchscreen = new TouchScreen(DZEditor); DrawingDevice = touchscreen; break; } DrawingDevice.StartDrawing += DrawingDevice_StartDrawing; DrawingDevice.StopDrawing += DrawingDevice_StopDrawing; }
/// <summary> /// Event handler for Leap sensor listener class OnGesture event /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void ProcessGesture(object sender, LeapMotion.GestureEvent e) { // If a gesture has started if (e.State.Equals("STATESTART")) { // If it's a swipe if (e.Name.Equals("swipe")) { // If it's direction is going right if (e.Direction[0] > 0) { this.spotifyController.play(); } // It's direction is left else { this.spotifyController.pause(); } } // If it's a circle else if (e.Name.Equals("circle")) { if (e.isClockwise() == true) { // For each circle made for (int i = 0; i < e.Progress; i++) { this.spotifyController.volumeUp(); } } else if (e.isClockwise() == false) { // For each circle made for (int i = 0; i < e.Progress; i++) { this.spotifyController.volumeDown(); } } } } }