Пример #1
0
    void Update()
    {
        if (viewingHighScores)
        {
            ///Gather the data from the sourceManager
            Kinect.Body[] data = BodySourceManager.instance.GetData();

            /// if there is no data don't do anything
            if (data == null)
            {
                return;
            }

            /// instantiate an empty list of tracked IDs
            /// This list is necessary in the event that we make multiplayer
            List <ulong> trackedIds = new List <ulong>();

            /// Make sure you only have 1 player
            Kinect.Body player = bsm.GetActiveBody(data, currTrackingId);

            ///if you have a player then add -
            ///it to the list of trackedIds
            if (player != null)
            {
                trackedIds.Add(player.TrackingId);
            }

            List <ulong> knownIds = new List <ulong>(bodies.Keys);

            /// First delete untracked bodies
            foreach (ulong trackingId in knownIds)
            {
                if (!trackedIds.Contains(trackingId))
                {
                    Destroy(bodies[trackingId]);
                    bodies.Remove(trackingId);
                }
            }

            /// If body doesn't exist create it
            if (player != null)
            {
                if (!bodies.ContainsKey(player.TrackingId))
                {
                    Debug.Log("Didnt have the key in bodies disctionary");
                    bodies[player.TrackingId] = bsm.CreateBodyObject(player.TrackingId, transform);
                }

                Debug.Log(bodies[player.TrackingId].gameObject.name);

                RefreshBodyObject(player, bodies[player.TrackingId]);
                //DrawBodyLines(player, bodies[player.TrackingId]);
            }
        }
    }
Пример #2
0
    void Update()
    {
        if (!leftMenu)
        {
            ///Gather the data from the sourceManager
            Kinect.Body[] data = bsm.GetData();

            /// if there is no data don't do anything
            if (data == null)
            {
                return;
            }

            /// instantiate an empty list of tracked IDs
            /// This list is necessary in the event that we make multiplayer
            List <ulong> trackedIds = new List <ulong>();

            /// Make sure you only have 1 player
            Kinect.Body player = bsm.GetActiveBody(data, currTrackingId);

            ///if you have a player then add -
            ///it to the list of trackedIds
            if (player != null)
            {
                trackedIds.Add(player.TrackingId);
            }

            List <ulong> knownIds = new List <ulong>(bodies.Keys);

            /// First delete untracked bodies
            foreach (ulong trackingId in knownIds)
            {
                if (!trackedIds.Contains(trackingId))
                {
                    Destroy(bodies[trackingId]);
                    bodies.Remove(trackingId);
                }
            }

            /// If you have a player
            if (player != null)
            {
                if (!playerInteracting)
                {
                    Debug.Log("Found player setting interaction to true");
                    playerInteracting = true;
                }

                if (!bodies.ContainsKey(player.TrackingId))
                {
                    bodies[player.TrackingId] = bsm.CreateBodyObject(player.TrackingId, playerSpawnPosition);
                    initialized = false;
                }

                UpdateHandInput(player, bodies[player.TrackingId]);
            }

            /// If you do not have a player
            if (player == null && playerInteracting)
            {
                Debug.Log("Can no longer find player!");
                ClearMenuElements(false);
                playerInteracting = false;
            }
        }
    }
Пример #3
0
    void Update()
    {
        if (enteringName)
        {
            ///Gather the data from the sourceManager
            Kinect.Body[] data = bsm.GetData();

            /// if there is no data don't do anything
            if (data == null)
            {
                return;
            }

            /// instantiate an empty list of tracked IDs
            /// This list is necessary in the event that we make multiplayer
            List <ulong> trackedIds = new List <ulong>();

            /// Make sure you only have 1 player
            Kinect.Body player = bsm.GetActiveBody(data, currTrackingId);

            ///if you have a player then add -
            ///it to the list of trackedIds
            if (player != null)
            {
                trackedIds.Add(player.TrackingId);
            }

            List <ulong> knownIds = new List <ulong>(bodies.Keys);

            /// First delete untracked bodies
            foreach (ulong trackingId in knownIds)
            {
                if (!trackedIds.Contains(trackingId))
                {
                    Destroy(bodies[trackingId]);
                    bodies.Remove(trackingId);
                }
            }

            /// If there is a player
            if (player != null)
            {
                if (!playerInteracting)
                {
                    Debug.Log("Found player setting interaction to true");
                    playerInteracting = true;
                }

                /// if the list of bodies doesnt contain this player then create them
                if (!bodies.ContainsKey(player.TrackingId))
                {
                    bodies[player.TrackingId] = bsm.CreateBodyObject(player.TrackingId, playerSpawnPosition);
                    initialized = false;
                }

                /// Update the position of the players hands every third frame
                if (Time.frameCount % 3 == 0)
                {
                    RefreshHandPosition(player, bodies[player.TrackingId]);
                }

                /// Update the state of the players hand in every frame
                RefreshHandState(player);
            }

            if (handCursor != null)
            {
                handCursor.transform.position = Vector3.MoveTowards(handCursor.transform.position, des, speed * Time.deltaTime);
            }

            if (Time.frameCount % 15 == 0)
            {
                RefreshLetters();
            }

            /// If you do not have a player
            if (player == null && playerInteracting)
            {
                Debug.Log("Can no longer find player!");
                ResetEnterNameArea(false);
                playerInteracting = false;
            }
        }
    }