Ejemplo n.º 1
0
        public async Task StartAsync(Uri hubUri)
        {
            _hubConnection = new HubConnectionBuilder()
                             .WithUrl(hubUri)
                             .Build();

            _hubConnection.On(LobbyMessage.UserEntered, (string userId) =>
            {
                OnUserEnter?.Invoke(userId);
            });

            _hubConnection.On(LobbyMessage.UserConnected, (string userId) =>
            {
                OnUserConnected?.Invoke(userId);
            });

            _hubConnection.On(LobbyMessage.UserAdmitted, (string userId) =>
            {
                OnUserAdmitted?.Invoke(userId);
            });

            _hubConnection.On(LobbyMessage.RefreshGroupsAhead, (string lobbyId) =>
            {
                OnGroupsAheadRefreshed?.Invoke(lobbyId);
            });

            await _hubConnection.StartAsync();
        }
        private void EvaluateCollisionEvent(Collision collision, CollisionEvent eventType)
        {
            GameObject other = collision.gameObject;

            if (other.tag == "Untagged" || string.IsNullOrEmpty(other.tag))
            {
                return;
            }
            if (OnUserEnter == null)
            {
                return;
            }

            OnUserEnter?.Invoke(other, eventType);
        }
Ejemplo n.º 3
0
        internal void UpdateData(SkeletonData skeletonData, HandTrackerData handTrackerData, GestureData gestureData, JsonInfo jsonInfo)
        {
            foreach (UserData user in this)
            {
                user.Reset();
            }

            List <int> oldUsersIDs = new List <int>(users.Keys);
            List <int> newUsersIDs = new List <int>();

            if (skeletonData != null)
            {
                foreach (Skeleton skeleton in skeletonData.Skeletons)
                {
                    TryGetUser(skeleton.ID, ref newUsersIDs).AddData(skeleton);
                }
            }

            if (handTrackerData != null)
            {
                foreach (UserHands hands in handTrackerData.UsersHands)
                {
                    TryGetUser(hands.UserId, ref newUsersIDs).AddData(hands);
                }
            }

            if (gestureData != null)
            {
                foreach (Gesture gesture in gestureData.Gestures)
                {
                    TryGetUser(gesture.UserID, ref newUsersIDs).AddData(gesture);
                }
            }

            if (jsonInfo != null && jsonInfo.Instances != null)
            {
                foreach (Instances instances in jsonInfo.Instances)
                {
                    if (!instances.face.IsEmpty)
                    {
                        TryGetUser(instances.id, ref newUsersIDs).AddData(instances.face);
                    }
                }
            }

            foreach (int userID in newUsersIDs)
            {
                if (!oldUsersIDs.Contains(userID))
                {
                    OnUserEnter?.Invoke(users[userID]);
                }
            }

            foreach (int userID in oldUsersIDs)
            {
                if (!newUsersIDs.Contains(userID))
                {
                    OnUserExit?.Invoke(users[userID]);

                    users[userID].Dispose();
                    users.Remove(userID);
                }
            }

            if (users.Count == 0)
            {
                CurrentUserID = 0;
            }
            else
            {
                if (CurrentUserID != 0 && !users.ContainsKey(CurrentUserID))
                {
                    CurrentUserID = 0;
                }

                if (CurrentUserID == 0)
                {
                    CurrentUserID = users.Keys.First();
                }
            }
        }