/// <summary>
        /// Initialize all documents
        /// </summary>
        public async void Init(int width, int height)
        {
            //Initialize controllers
            documentController        = new DocumentController(this);
            cardController            = new CardController(this);
            sortingBoxController      = new SortingBoxController(this);
            touchController           = new TouchController(this);
            gestureController         = new GestureController(this);
            listenerController        = new GestureListenerController(this);
            baseLayerController       = new BaseLayerController(this);
            cardLayerController       = new CardLayerController(this);
            sortingBoxLayerController = new SortingBoxLayerController(this);
            menuLayerController       = new MenuLayerController(this);
            //Initialize layers
            touchController.Init();
            gestureController.Init();
            listenerController.Init();
            baseLayerController.Init(width, height);
            Coordination.Baselayer = baseLayerController.BaseLayer;//Set the base layer to the coordination helper
            cardLayerController.Init(width, height);
            sortingBoxLayerController.Init(width, height);
            menuLayerController.Init(width, height);
            //Load the documents, cards and add them to the card layer
            Document[] docs = await documentController.Init(FilePath.NewsArticle);//Load the document

            Card[] cards = await cardController.Init(docs);

            CardLayerController.LoadCards(cards);
            //Load the sorting box and add them to the sorting box layer
            sortingBoxController.Init();
            SortingBoxLayerController.LoadBoxes(sortingBoxController.GetAllSortingBoxes());
            //Start the gesture detection thread
            gestureController.StartGestureDetection();
        }
        public MainWindow()
        {
            // NetworkIt
            client.MessageReceived += Client_MessageReceived;

            client.Connected += Client_Connected;
            client.StartConnection();

            messageCount = 0;

            // Kinect

            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _sensor.Open();

                _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
                _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

                _gestureController = new GestureController();
                _gestureController.GestureRecognized += GestureController_GestureRecognized;
            }
        }
Example #3
0
    public override void CastSpell(GestureController controller)
    {
        base.CastSpell(controller);

        Transform gpTr = GameObject.Instantiate<GameObject>(Consts.GroundPound.Prefab).transform;

        //Position the ground-pound.
        Vector3 startPos = controller.PalmTracker.MyTransform.position;
        startPos.y = Terrain.activeTerrain.SampleHeight(startPos);
        gpTr.position = startPos;

        //Set the ground-pound's strength and direction.
        UnityEngine.Assertions.Assert.IsTrue(controller.SwipeVerticalStrength < 0.0f);
        Vector3 dir = controller.FingerTrackers[2].MyTransform.forward;
        GroundPoundController gpC = gpTr.gameObject.GetComponent<GroundPoundController>();
        gpC.Setup(-controller.SwipeVerticalStrength - GestureConstants.Instance.SwipeVelocityThreshold,
                  dir.Horz().normalized);

        //Update discovery image.
        if (!Consts.UsedGroundPoundYet)
        {
            Consts.UsedGroundPoundYet = true;
            Consts.CreateDiscoveryImage(Consts.DiscoveryImage_GroundPound);
        }
    }
Example #4
0
        void kinectSensorChooser_KinectChanged(object sender, KinectChangedEventArgs e)
        {
            KinectSensor oldSensor = (KinectSensor)e.OldSensor;

            if (oldSensor != null)
            {
                oldSensor.Stop();
            }

            KinectSensor newSensor = (KinectSensor)e.NewSensor;

            if (newSensor == null)
            {
                return;
            }

            //register for event and enable Kinect sensor features you want
            newSensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(newSensor_AllFramesReady);
            newSensor.ColorStream.Enable();
            newSensor.DepthStream.Enable();
            newSensor.SkeletonStream.Enable();

            try
            {
                newSensor.Start();
            }
            catch (System.IO.IOException)
            {
                kinectSensorChooser.TryResolveConflict();
            }

            // initialize the gesture recognizer
            gestureController = new GestureController();
            gestureController.GestureRecognized += new EventHandler <GestureEventArgs>(gestureController_GestureRecognized);
        }
    void Start()
    {
        controller = GestureController.Instance;
        ReSetCanvas();
        List <string> btnsName = new List <string> ();

        btnsName.Add("Retry");
        btnsName.Add("Continue");
        //	btnsName.Add ("Retrain");
        btnsName.Add("Back");
        btnsName.Add("Replay");
        btnsName.Add("Cancel");
        foreach (string btnName in btnsName)
        {
            //	Debug.Log ("add "+ btnName);
            GameObject btnobj = GameObject.Find(btnName);
            Button     btn    = btnobj.GetComponent <Button> ();
            btn.onClick.AddListener(delegate {
                this.OnClick(btnobj);
            });
        }
        btnretry    = GameObject.Find("Retry");
        btncontinue = GameObject.Find("Continue");
        judgeData   = GameObject.Find("JudgeData");
        conclusion  = GameObject.Find("Conclusion");
        videoShow   = GameObject.Find("Video");
        conclusion.SetActive(false);
        judgeData.SetActive(false);
    }
Example #6
0
        void Initialize()
        {
            if (this.sensor != null)
            {
                // open the sensor
                this.sensor.Open();

                //bodies = new Body[sensor.BodyFrameSource.BodyCount];

                // open the reader for the body frames
                reader = sensor.BodyFrameSource.OpenReader();

                if (this.reader != null)
                {
                    this.reader.FrameArrived += this.sensor_SkeletonFrameReady;
                }


                KinectConnectionState = "Connected";
                // add timer for clearing last detected gesture
                _clearTimer          = new Timer(2000);
                _clearTimer.Elapsed += new ElapsedEventHandler(clearTimer_Elapsed);

                // initialize the gesture recognizer
                gestureController = new GestureController();
                gestureController.GestureRecognized += OnGestureRecognized;

                // register the gestures for this demo
                RegisterGestures();
            }
        }
Example #7
0
        public MainWindow()
        {
            InitializeComponent();

            _sensor = KinectSensor.GetDefault();

            mqttEnabled = true;

            if (mqttEnabled == true)
            {
                _mqttClient = new MqttClient(ipAddress);
                _mqttCode   = _mqttClient.Connect(Guid.NewGuid().ToString());
            }

            if (_sensor != null)
            {
                _sensor.Open();

                _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth
                                                             | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
                _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

                _gestureController = new GestureController();
                _gestureController.GestureRecognized += GestureController_GestureRecognized;
            }
        }
    public WebPage(Director director)
    {
        SetupComponents();
        SetupButtonListener(director);

        gestureController = new GestureController("192.168.137.1", 50001);
    }
        private void SetupKinect()
        {
            foreach (var potentialKinect in KinectSensor.KinectSensors)
            {
                if (potentialKinect.Status == KinectStatus.Connected)
                {
                    kinect = potentialKinect;
                    break;
                }
            }

            if (kinect != null)
            {
                kinect.SkeletonStream.Enable();

                kinect.SkeletonFrameReady += kinect_SkeletonFrameReady;

                gestureController = new GestureController();
                gestureController.GestureRecognized += gestureController_GestureRecognized;
                gestureController.AddGesture(new SwipeGestureTest.Segments.DoubleSwipeDown());
                gestureController.AddGesture(new SwipeGestureTest.Segments.DoubleSwipeUp());
                //gestureController.AddGesture(new SwipeGestureTest.Segments.SwipeLeftDefinition());
                //gestureController.AddGesture(new SwipeGestureTest.Segments.SwipeRightDefinition());

                kinect.Start();
                kinect.ElevationAngle = 5;
            }
        }
Example #10
0
        void Unitialize()
        {
            if (this.reader != null)
            {
                // BodyFrameReder is IDisposable
                this.reader.Dispose();
                this.reader = null;
            }

            // Body is IDisposable
            if (this.bodies != null)
            {
                bodies = null;
                //foreach (Body body in this.bodies)
                //{
                //    if (body != null)
                //    {
                //        body.Dispose();
                //    }
                //}
            }

            if (this.sensor != null)
            {
                this.sensor.Close();
                this.sensor = null;
            }

            if (gestureController != null)
            {
                gestureController.GestureRecognized -= OnGestureRecognized;
                gestureController = null;
            }
        }
Example #11
0
 private void OnDestroy()
 {
     if (GestureController.HasInstance())
     {
         GestureController.Instance.OnSwipe -= OnSwipe;
     }
 }
Example #12
0
 private void Start()
 {
     _canMove           = false;
     _gestureController = GestureController.Instance;
     _animations        = GetComponent <PlayerMovementAnimations>();
     _rigidbody         = GetComponent <Rigidbody>();
 }
Example #13
0
        public Leap()
        {
            _leap = new Controller();

            Gesture = new GestureController();
            _leap.AddListener(Gesture);
        }
Example #14
0
        public KinectTester()
        {
            InitializeComponent();

            sensor       = new SmartKinectSensor();
            renderCanvas = new RenderCanvas(TimeSpan.FromSeconds(10));
            sensor.EnableSkeletonRenderingSensor();

            renderCanvas.ImageRendered += DisplayRenderedImage;

            capturedLabel.Visible = false;

            jointController   = new JointController();
            gestureController = new GestureController();
            skeletonRender    = new SkeletonRenderer(sensor.Sensor);

            sensor.SkeletonController.AddFunction(jointController);
            sensor.SkeletonController.AddFunction(gestureController);
            sensor.SkeletonController.AddFunction(skeletonRender);

            skeletonRender.SkeletonRendered       += renderCanvas.SkeletonFrameCaptured;
            gestureController.GestureCaptured     += GestureCaptured;
            jointController.JointTrackingCaptured += JointTrackingCaptured;

            ArduinoSerialPort serialPort = new ArduinoSerialPort("COM5", 115200);

            serialPort.Open();
            bodyTracker = new KinectBodyTracker(sensor, serialPort);

            GestureBuilderForm test = new GestureBuilderForm(sensor);

            test.Show();

            // InitializeArduino();
        }
        /// <summary>
        /// Sets up main program as soon as main window loads.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Get the default kinect sensor and open it
            kinectSensor = KinectSensor.GetDefault();

            // Set IsAvailableChanged event notifier
            kinectSensor.IsAvailableChanged += Sensor_IsAvailableChanged;

            kinectSensor.Open();

            // Create a new voice recognition instance
            voiceRecognition = new VoiceRecognition(kinectSensor, this);

            bodyFrameReader = kinectSensor.BodyFrameSource.OpenReader();
            bodyFrameReader.FrameArrived += BodyFrameReader_FrameArrived;

            // Create a new gesture controller and assign the method that runs
            // when a gesture is recognized.
            gestureController = new GestureController();
            gestureController.GestureRecognized += GestureController_GestureRecognized;

            imageManager = new ImageManager(this);
            storyBoard   = FindResource("BorderAnimation") as Storyboard;
            Storyboard.SetTarget(storyBoard, SelectionBox);

            // Create the kinect region for the user view
            KinectRegion.SetKinectRegion(this, kinectRegion);

            App app = ((App)Application.Current);

            app.KinectRegion = kinectRegion;

            // Use the default sensor
            kinectRegion.KinectSensor = kinectSensor;
        }
 void Awake()
 {
     _g = gameObject.AddComponent<GestureController>();
     _g.OnGestureStart += OnGestureStart;
     _g.OnGestureEnd += OnGestureEnd;
     Input.multiTouchEnabled = true;
 }
Example #17
0
 //initial manager
 public void Start()
 {
     manager = GestureSourceManager.Instance;
     manager.RemoveDetectors();
     manager.AddDetector("recognize");
     manager.OnGesture += recognize;
     instance           = this;
 }
Example #18
0
 public static GestureController GetInstance()
 {
     if (!_instance)
     {
         _instance = (GestureController)GameObject.FindObjectOfType(typeof(GestureController));
     }
     return(_instance);
 }
Example #19
0
        public void StartKinectServices()
        {
            // initialize the gesture recognizer
            m_gestureController = new GestureController();
            m_gestureController.GestureRecognized += OnGestureRecognized;

            // register the gestures for this demo
            RegisterGestures();
        }
Example #20
0
 void Awake()
 {
     controller = gameObject.GetComponent <GestureController>();
     rigidBody  = gameObject.GetComponent <Rigidbody>();
     box        = gameObject.GetComponent <BoxCollider>();
     if (moveAccelerometer == true && moveSlideDistance == true)
     {
         moveSlideDistance = false;
     }
 }
Example #21
0
        public MainWindow()
        {
            var settings = new CefSettings();

            settings.CefCommandLineArgs.Add("disable-gpu", "1");
            Cef.Initialize(settings);

            InitializeComponent();
            this.PreviewKeyDown += new KeyEventHandler(HandleEsc);

            sensor = KinectSensor.GetDefault();
            //Mouse.OverrideCursor = Cursors.None;

            if (sensor != null)
            {
                sensor.Open();

                reader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
                reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

                //Initialize gestureController
                gestureController = new GestureController();
                gestureController.Start();
                gestureController.GestureRecognized += gestureController_GestureRecognized;

                //Initialize spyGlassController
                mouseController = new MouseController((int)SystemParameters.PrimaryScreenWidth / 2, (int)SystemParameters.PrimaryScreenHeight / 2);   //961,600 for Display / 829,586 for local testing

                playersController              = new PlayersController();
                playersController.BodyEntered += UserReporter_BodyEntered;
                playersController.BodyLeft    += UserReporter_BodyLeft;
                playersController.Start();

                KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread();
                kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved;

                string folder = System.IO.Directory.GetCurrentDirectory().ToString();

                for (int i = 0; i < folder.Length; i++)
                {
                    if (folder[i] == '\\')
                    {
                        base_folder += '\\';
                        base_folder += '\\';
                    }
                    else
                    {
                        base_folder += folder[i];
                    }
                }
                base_folder += "\\Images";

                Console.WriteLine(base_folder);
            }
        }
Example #22
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            sensor = KinectSensor.KinectSensors.FirstOrDefault();
            if (sensor == null)
            {
                MessageBox.Show("This application requires a Kinect sensor.");
                this.Close();
            }

            sensor.Start();

            sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            sensor.ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady);

            sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
            TransformSmoothParameters smoothingParam = new TransformSmoothParameters();

            {
                smoothingParam.Smoothing          = 0.5f;
                smoothingParam.Correction         = 0.5f;
                smoothingParam.Prediction         = 0.5f;
                smoothingParam.JitterRadius       = 0.1f;
                smoothingParam.MaxDeviationRadius = 0.1f;
            }

            sensor.SkeletonStream.Enable(smoothingParam); // Enable skeletal tracking

            sensor.SkeletonStream.Enable();
            if ((bool)cb1.IsChecked)
            {
                sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
                sensor.SkeletonStream.EnableTrackingInNearRange = true;
            }
            else
            {
                sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default;
                sensor.SkeletonStream.EnableTrackingInNearRange = false;
            }

            framecount++;

            sensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady);

            // initialize the gesture recognizer
            gestureController = new GestureController();
            gestureController.GestureRecognized += OnGestureRecognized;

            // register the gestures for this demo
            RegisterGestures();

            Application.Current.Exit += new ExitEventHandler(Current_Exit);

            //Thread speechThread = new Thread(new ThreadStart(InitializeSpeechRecognition));
            InitializeSpeechRecognition();
        }
        /// <summary>
        /// Init Support to process WM_Gesture Messages.
        ///
        /// Has to be run AFTER everything else has been initialized.
        /// </summary>
        private void InitGestureSupport()
        {
            _gc = new GestureController();

            _gc.GestureBegin += OnGestureBegin;
            _gc.GestureEnd   += OnGestureEnd;
            _gc.GesturePan   += OnGesturePan;
            _gc.GestureZoom  += OnGestureZoom;

            //Debug.Print("Gesture Support added");
        }
Example #24
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (this._reader != null)
            {
                //   this._reader.MultiSourceFrameArrived += this.Reader_MultiSourceFrameArrived;

                _gestureController = new GestureController();
                _gestureController.GestureRecognized += GestureController_GestureRecognized;
            }

            //  InitializeImageDataFlow();
        }
    // Use this for initialization
    void Start()
    {
        _gestureController = GetComponent <GestureController>();

        SoundManager.Instance.PlaySoundEffect("summary_loot_item");

        congratsGO.SetActive(false);

        _posTweener = shieldRoot.GetComponent <TweenPosition>();

        _posTweener.onFinished = OnEffectOver;
    }
Example #26
0
        public PersonManager(LocatorInterface locator, GestureController gc, IAIntAirAct intAirAct)
        {
            this.gestureController = gc;
            this.locator           = locator;
            locator.threadLock     = new object();
            this.intAirAct         = intAirAct;

            kinectserver = new MSEKinectServer();

            kinectserver.NewKinectDiscovered += new NewKinectDiscoveredEventSignature(kinectserver_NewKinectDiscovered);
            kinectserver.SkeletonsRecieved   += new SkeletonsReceivedEventSignature(kinectserver_SkeletonsRecieved);
            kinectserver.kinectRemoved       += new KinectRemovedSignature(kinectserver_kinectRemoved);
        }
Example #27
0
        /// <summary>
        /// Kinect enabled apps should customize which Kinect services it initializes here.
        /// </summary>
        /// <param name="kinectSensorManager"></param>
        /// <param name="sensor"></param>
        private void InitializeKinectServices(KinectSensorManager kinectSensorManager, KinectSensor sensor)
        {
            // Application should enable all streams first.

            // configure the color stream
            kinectSensorManager.ColorFormat        = ColorImageFormat.RgbResolution640x480Fps30;
            kinectSensorManager.ColorStreamEnabled = true;

            // configure the depth stream
            kinectSensorManager.DepthStreamEnabled = true;

            kinectSensorManager.TransformSmoothParameters =
                new TransformSmoothParameters
            {
                Smoothing          = 0.7f,     //.5
                Correction         = 0.3f,     //.5
                Prediction         = 1.0f,     //.5
                JitterRadius       = 0.05f,    //.5
                MaxDeviationRadius = 1.0f      //.4
            };

            // configure the skeleton stream
            //sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
            sensor.SkeletonFrameReady += OnSkeletonFrameReady;
            kinectSensorManager.SkeletonStreamEnabled = true;

            audioStream  = sensor.AudioSource.Start();
            audioThread  = new Thread(audioReadingThread);
            audioReading = true;
            speechEngine.SpeechRecognized += speechEngine_SpeechRecognized;
            speechEngine.SpeechDetected   += speechEngine_SpeechDetected;
            loadDictionary();
            speechEngine.SetInputToAudioStream(audioStream, new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
            speechEngine.RecognizeAsync(RecognizeMode.Multiple);

            kinectSensorManager.KinectSensorEnabled = true;

            if (!kinectSensorManager.KinectSensorAppConflict)
            {
                // initialize the gesture recognizer
                gestureController = new GestureController();
                //gestureController.GestureRecognized += OnGestureRecognized;

                // register the gestures for this demo
                //RegisterGestures();
            }

            kinectSensorManager.ElevationAngle = (int)10;
        }
Example #28
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _sensor.Open();

                _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
                _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

                _gestureController = new GestureController();
                _gestureController.GestureRecognized += GestureController_GestureRecognized;
            }
        }
Example #29
0
        /// <summary>
        /// Handle insertion of Kinect sensor.
        /// </summary>
        private void InitializeNui()
        {
            this.UninitializeNui();

            var index = 0;

            while (this.nui == null && index < KinectSensor.KinectSensors.Count)
            {
                try
                {
                    this.nui = KinectSensor.KinectSensors[index];

                    // initialize the gesture recognizer
                    gestureController = new GestureController();
                    gestureController.GestureRecognized += OnGestureRecognized;

                    // register the gestures for this demo
                    RegisterGestures();

                    this.nui.Start();
                    mapper = new CoordinateMapper(nui);

                    this.IsDisconnected     = false;
                    this.DisconnectedReason = null;
                }
                catch (IOException ex)
                {
                    this.nui = null;

                    this.DisconnectedReason = ex.Message;
                }
                catch (InvalidOperationException ex)
                {
                    this.nui = null;

                    this.DisconnectedReason = ex.Message;
                }

                index++;
            }

            if (this.nui != null)
            {
                this.nui.SkeletonStream.Enable();

                this.nui.SkeletonFrameReady += this.OnSkeletonFrameReady;
            }
        }
Example #30
0
        public MSEKinectManager(bool RequireKinect = false)
        {
            if (RequireKinect)
            {
                TestKinectAvailability();
            }


            //Instantiate Components
            intAirAct         = IAIntAirAct.New();
            locator           = new Locator();
            pairingRecognizer = new PairingRecognizer(locator, intAirAct);
            gestureController = new GestureController();
            personManager     = new PersonManager(locator, gestureController, intAirAct);
            deviceManager     = new DeviceManager(locator, intAirAct);
        }
Example #31
0
 private void InitKinect()
 {
     _gestureController = new GestureController();
     _gestureController.SupportedGestures  = "SwipeLeft+SwipeRight+PalmHold+FistHold+TwoPalmsOPen+TouchLeft+TouchRight+TouchMiddle";
     _gestureController.GestureRecognised += _gestureController_GestureRecognised;
     _sensor = KinectSensor.GetDefault();
     if (_sensor != null)
     {
         // open the reader for the body frames
         _bodyFrameReader = this._sensor.BodyFrameSource.OpenReader();
         _sensor.Open();
         if (this._bodyFrameReader != null)
         {
             this._bodyFrameReader.FrameArrived += this.Reader_FrameArrived;
         }
     }
 }
Example #32
0
    public override bool CanUseSpell(GestureController controller)
    {
        if (base.CanUseSpell(controller) && controller.IsFingerPointing.All(b => b) &&
            controller.SwipeVerticalStrength < 0.0f)
        {
            Vector3 palmPos = controller.PalmTracker.MyTransform.position;
            float terrHeight = Terrain.activeTerrain.SampleHeight(palmPos);

            return Mathf.Abs(palmPos.y - terrHeight) <= Consts.GroundPound.MaxDistFromTerrain;
        }

        return false;

        return base.CanUseSpell(controller) &&
               controller.IsFingerPointing.All(b => b) &&
               controller.SwipeVerticalStrength < 0.0f;
    }
Example #33
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            KinectSensor sensor = SensorExtensions.Default();

            if (sensor != null)
            {
                sensor.EnableAllStreams();
                sensor.ColorFrameReady    += Sensor_ColorFrameReady;
                sensor.DepthFrameReady    += Sensor_DepthFrameReady;
                sensor.SkeletonFrameReady += Sensor_SkeletonFrameReady;

                _gestureController = new GestureController(GestureType.All);
                _gestureController.GestureRecognized += GestureController_GestureRecognized;

                sensor.Start();
            }
        }
Example #34
0
    public override void CastSpell(GestureController controller)
    {
        //Find the enemy faction closest to where the player was pointing.
        float closestDist = float.MaxValue;
        Faction closestF = null;
        Vector3 fingerPos = controller.FingerTrackers[1].MyTransform.position,
                palmPos = controller.PalmTracker.MyTransform.position,
                terrPos = CastApproximateRayOnTerrain(fingerPos, (fingerPos - palmPos).normalized);
        Vector2 terrPosHorz = terrPos.Horz();
        foreach (Faction f in Faction.AllFactions[Factions.Enemies])
        {
            float tempDist = terrPosHorz.DistanceSqr(f.AveragePos);
            if (tempDist < closestDist)
            {
                closestDist = tempDist;
                closestF = f;
            }
        }
        if (closestF == null)
            return;

        //Create a lightning object there.
        lightningObject = GameObject.Instantiate(Consts.Lightning.Prefab).GetComponent<LightningController>();
        lightningObject.EnemyFaction = closestF;

        //Start looping lighting audio.
        controller.AudioSrc.clip = Consts.Lightning.AudioLoop;
        controller.AudioSrc.volume = 1.0f;
        controller.AudioSrc.loop = true;
        controller.AudioSrc.Play();

        //Update discovery image.
        if (!Consts.UsedLightningYet)
        {
            Consts.UsedLightningYet = true;
            Consts.CreateDiscoveryImage(Consts.DiscoveryImage_Lightning);
        }

        contr = controller;
    }
        /// <summary>
        /// Kinect enabled apps should customize which Kinect services it initializes here.
        /// </summary>
        /// <param name="kinectSensorManager"></param>
        /// <param name="sensor"></param>
        private void InitializeKinectServices(KinectSensorManager kinectSensorManager, KinectSensor sensor)
        {
            // Application should enable all streams first.

            // configure the color stream
            kinectSensorManager.ColorFormat = ColorImageFormat.RgbResolution640x480Fps30;
            kinectSensorManager.ColorStreamEnabled = true;

            // configure the depth stream
            kinectSensorManager.DepthStreamEnabled = true;

            kinectSensorManager.TransformSmoothParameters =
                new TransformSmoothParameters
                {
                    Smoothing = 0.5f,
                    Correction = 0.5f,
                    Prediction = 0.5f,
                    JitterRadius = 0.05f,
                    MaxDeviationRadius = 0.04f
                };

            // configure the skeleton stream
            sensor.SkeletonFrameReady += OnSkeletonFrameReady;
            kinectSensorManager.SkeletonStreamEnabled = true;

            // initialize the gesture recognizer
            gestureController = new GestureController();
            gestureController.GestureRecognized += OnGestureRecognized;

            kinectSensorManager.KinectSensorEnabled = true;

            if (!kinectSensorManager.KinectSensorAppConflict)
            {
                // addition configuration, as needed
            }
        }
 protected AbstractGesture()
 {
     if (_gc == null) {
         _gc = InputController.Instance().GestureControl;
     }
 }
 public BodyRelativePointConverter(Rect activeRect, GestureController controller)
 {
     this.ActiveRectangle = activeRect;
     controller.SkeletonPreProcessed += new EventHandler<SkeletonPreProcessedEventArgs>(controller_SkeletonPreProcessed);
 }
Example #38
0
 public override bool CanUseSpell(GestureController controller)
 {
     return lightningObject == null && IsCasting(controller);
 }
Example #39
0
 public override void CastSpell(GestureController controller)
 {
     TimeTillUsable = RechargeTime;
 }
Example #40
0
 public override bool CanUseSpell(GestureController controller)
 {
     return (TimeTillUsable <= 0.0f);
 }
Example #41
0
 private static bool IsCasting(GestureController contr)
 {
     return contr.IsFingerPointing[1] &&
            !contr.IsFingerPointing[3] &&
            (contr.PalmTrackerPos.y / contr.MaxPalmForward) >= Consts.Lightning.ActivationDistanceLerp;
 }
Example #42
0
 /// <summary>
 /// Gets whether this spell is ready to be used by the given hand.
 /// </summary>
 public abstract bool CanUseSpell(GestureController controller);
Example #43
0
 /// <summary>
 /// Starts a casting of this spell by the given hand.
 /// </summary>
 public abstract void CastSpell(GestureController controller);