Пример #1
0
    /// <summary>
    /// checks the event state and resumes or pauzes accordingly.
    /// </summary>
    /// <param name="evt">event sent</param>
    public void OnCursorEvent(CursorEvent evt)
    {
        switch (evt.currentcursorstate)
        {
        case CursorState.Door:
            Cursor.SetCursor(doorTexture, Vector2.zero, CursorMode.Auto);
            break;

        case CursorState.Grab:
            Cursor.SetCursor(grabTexture, Vector2.zero, CursorMode.Auto);
            break;

        case CursorState.Magnify:
            Cursor.SetCursor(magnifyTexture, Vector2.zero, CursorMode.Auto);
            break;

        case CursorState.Normal:
            Cursor.SetCursor(normalTexture, Vector2.zero, CursorMode.Auto);
            break;

        default:
            Cursor.SetCursor(normalTexture, Vector2.zero, CursorMode.Auto);
            break;
        }
    }
Пример #2
0
        //user U can take cursor on shape S <=> (U doesn't have other cursors && S is free)
        public void HandleCursorRequest(LitePeer peer,
                                        OperationRequest operationRequest,
                                        SendParameters sendParameters)
        {
            var req = CursorRequest.Read(operationRequest.Parameters);

            var changes = false;

            if (req.doSet)
            {
                if (_doc.UserHasCursor(req.ownerId))
                {
                    return; //already holds another cursor
                }
                var sh = _doc.TryGetShape(req.shapeId);
                if (sh == null)
                {
                    return; //no such shape
                }
                if (sh.GetCursor() != null)
                {
                    return; // shape is busy
                }
                //ok, lock shape
                _doc.LockShape(sh, req.ownerId);
                changes = true;
            }
            else
            {
                //cursor remove operation is always ok
                var sh = _doc.TryGetShape(req.shapeId);
                if (sh == null)
                {
                    return; //no such shape
                }
                _doc.UnlockShape(sh, req.ownerId);
                changes = true;
            }

            if (changes)
            {
                _room.Broadcast(peer,
                                CursorEvent.Write(req.doSet, req.ownerId, req.shapeId, _topicId),
                                sendParameters,
                                (byte)DiscussionEventCode.CursorEvent,
                                BroadcastTo.RoomAll); //include self
            }
        }
Пример #3
0
        void cursorEvent(CursorEvent ev)
        {
            if (ev.topicId != _doc.TopicId)
            {
                return;
            }

            if (ev.doSet)
            {
                PlayTakeCursor(ev.ownerId, ev.shapeId);
            }
            else
            {
                PlayFreeCursor(ev.ownerId, ev.shapeId);
            }
        }
	/// <summary>
	/// checks the event state and resumes or pauzes accordingly.
	/// </summary>
	/// <param name="evt">event sent</param>
	public void OnCursorEvent(CursorEvent evt)
	{
		switch (evt.currentcursorstate)
		{
			case CursorState.Door:
				Cursor.SetCursor(doorTexture , Vector2.zero , CursorMode.Auto);
				break;
			case CursorState.Grab:
				Cursor.SetCursor(grabTexture , Vector2.zero , CursorMode.Auto);
				break;
			case CursorState.Magnify:
				Cursor.SetCursor(magnifyTexture , Vector2.zero , CursorMode.Auto);
				break;
			case CursorState.Normal:
				Cursor.SetCursor(normalTexture , Vector2.zero , CursorMode.Auto);
				break;
			default:
				Cursor.SetCursor(normalTexture , Vector2.zero , CursorMode.Auto);
				break;
		}
	}
Пример #5
0
 private void CursorHandle(CursorEvent e)
 {
     observable.Publish(new SoldierLookingEvent(PlayerGuid, e.WorldPosition));
 }
Пример #6
0
 private void CursorHandle(CursorEvent e)
 {
     inputData.LookingPosition = e.WorldPosition;
 }
Пример #7
0
 private void OnCursorEvent(object sender, CursorEvent e)
 {
     m_model.m_isInteractButtonVisiable = true;
 }
Пример #8
0
 private void CursorHandle(CursorEvent e)
 {
     data.LookAt = e.WorldPosition;
 }
Пример #9
0
 private void CursorHandle(CursorEvent e)
 {
     UpdatePlayerIfExist(player => player.LookAt = e.WorldPosition);
 }
Пример #10
0
        public void HandleInitialSceneLoad(LitePeer peer,
                                           OperationRequest operationRequest,
                                           SendParameters sendParameters)
        {
            //// var req = InitialSceneLoadRequest.Read(operationRequest);
            /// req.topicId
            _log.Debug("scene load request");

            CleanupEmptyClusters();

            //1st phase, send creation events for simple shapes (+cluster)  in the scene
            var simpleShapes = _doc.GetShapes().Where(sh => sh.ShapeCode() != VdShapeType.ClusterLink).ToArray();

            foreach (var sh in simpleShapes)
            {
                _room.PublishEventToSingle(peer,
                                           CreateShape.Write(sh.InitialOwner(), sh.Id(),
                                                             sh.ShapeCode(), 400, 400, false, sh.Tag(),
                                                             _topicId),
                                           sendParameters,
                                           (byte)DiscussionEventCode.CreateShapeEvent);
            }

            //2nd phase, send state update packets
            foreach (var sh in simpleShapes)
            {
                var st = sh.GetState();
                if (st == null)
                {
                    continue;
                }
                _room.PublishEventToSingle(peer,
                                           st.ToDict(),
                                           sendParameters,
                                           (byte)DiscussionEventCode.StateSyncEvent);
            }

            //3rd phase, sequence of cluster-add operations (enumerate contents of all existing clusters)
            var clusterShapes = _doc.GetShapes().Where(sh => sh.ShapeCode() == VdShapeType.Cluster);

            foreach (var clShape in clusterShapes)
            {
                var cluster = _topology.GetCluster(clShape.Id());
                _log.Info("scene load, cluster updates, num badges =" + cluster.GetClusterables());
                foreach (var badge in cluster.GetClusterables())
                {
                    var clustMsg = ClusterBadgeMessage.Write(badge.GetId(),
                                                             _doc.TryGetShape(badge.GetId()).InitialOwner(),
                                                             badge == cluster.GetClusterables().Last(),
                                                             cluster.GetId(),
                                                             _topicId,
                                                             -1);
                    _room.PublishEventToSingle(peer,
                                               clustMsg,
                                               sendParameters,
                                               (byte)DiscussionEventCode.ClusterBadgeEvent);
                }
            }

            //4rd phase, create links
            var linkShapes = _doc.GetShapes().Where(sh => sh.ShapeCode() == VdShapeType.ClusterLink);

            foreach (var lnk in linkShapes)
            {
                var edge = _topology.GetForwardEdge(lnk.Id());

                var ev = LinkCreateMessage.Write(edge.curr.GetId(),
                                                 edge.next.GetId(),
                                                 lnk.InitialOwner(),
                                                 lnk.Id(),
                                                 _topicId,
                                                 false,
                                                 (LinkHeadType)lnk.Tag());
                _room.PublishEventToSingle(peer, ev, sendParameters, (byte)DiscussionEventCode.LinkCreateEvent);

                //send link state update
                var st = lnk.GetState();
                if (st != null)
                {
                    _room.PublishEventToSingle(peer,
                                               st.ToDict(),
                                               sendParameters,
                                               (byte)DiscussionEventCode.StateSyncEvent);
                }
            }

            //5th phase, send cursor events
            foreach (var sh in _doc.GetShapes())
            {
                if (sh.GetCursor() == null)
                {
                    continue; //cursors are unset by default for all shapes
                }
                _room.PublishEventToSingle(peer,
                                           CursorEvent.Write(true,
                                                             sh.GetCursor().OwnerId,
                                                             sh.Id(),
                                                             _topicId),
                                           sendParameters,
                                           (byte)DiscussionEventCode.CursorEvent);
            }

            //6th phase, send ink
            if (_doc.inkData != null)
            {
                _room.PublishEventToSingle(peer,
                                           InkMessage.Write(-1,
                                                            _topicId,
                                                            _doc.inkData),
                                           sendParameters,
                                           (byte)DiscussionEventCode.InkEvent);
            }

            //7th phase, send laser pointers
            foreach (var laserPointer in _doc.LaserPointers)
            {
                _room.PublishEventToSingle(peer,
                                           laserPointer.ToDict(),
                                           sendParameters,
                                           (byte)DiscussionEventCode.AttachLaserPointerEvent);
            }

            //notify client loading sequence complete
            _room.PublishEventToSingle(peer,
                                       null,
                                       sendParameters,
                                       (byte)DiscussionEventCode.SceneLoadingDone);
        }
Пример #11
0
 private void CursorHandle(CursorEvent e)
 {
     rotation.LookAt(e.WorldPosition);
 }
Пример #12
0
        public void OnEvent(EventData eventData)
        {
            switch (eventData.Code)
            {
            case (byte)LiteEventCode.Join:
                int[] actNrs   = (int[])eventData.Parameters[(byte)ParameterKey.Actors];
                int   ActorNr  = (int)eventData.Parameters[(byte)ParameterKey.ActorNr];
                var   actProps = (Hashtable)eventData.Parameters[(byte)ParameterKey.ActorProperties];

                Console.WriteLine("Join event actors.len={0}", actNrs.Length);
                List <int> unknownPeersNrs = new List <int>();
                for (int i = 0; i < actNrs.Length; i++)
                {
                    if (!usersOnline.ContainsKey(actNrs[i]))
                    {
                        if (!unknownPeersNrs.Contains(actNrs[i]))
                        {
                            unknownPeersNrs.Add(actNrs[i]);
                        }
                    }
                }
                requestPeersInfo(unknownPeersNrs.ToArray());
                DbgPrintOnlineList();
                break;

            case (byte)EventCode.Leave:
                actNrs = (int[])eventData.Parameters[(byte)ParameterKey.Actors];
                int leftActNr = (int)eventData.Parameters[(byte)ParameterKey.ActorNr];
                Console.WriteLine("Leave event, actors.len={0}", actNrs.Length);
                if (usersOnline.ContainsKey(leftActNr))
                {
                    if (userLeaves != null)
                    {
                        DiscUser leaving = usersOnline[leftActNr];
                        userLeaves(leaving);
                    }
                    usersOnline.Remove(leftActNr);
                }
                DbgPrintOnlineList();
                break;

            case (byte)DiscussionEventCode.InstantUserPlusMinus:
                if (smbdLeaved != null)
                {
                    smbdLeaved();
                }
                break;

            case (byte)DiscussionEventCode.StructureChanged:
                int initiater = (int)eventData.Parameters[(byte)DiscussionParamKey.UserId];
                int devType   = (int)eventData.Parameters[(byte)DiscussionParamKey.DeviceType];
                if (eventData.Parameters.ContainsKey((byte)DiscussionParamKey.ForceSelfNotification))
                {
                    //topic updated
                    if (onStructChanged != null)
                    {
                        onStructChanged(Serializers.ReadChangedTopicId(eventData.Parameters),
                                        initiater, (DeviceType)devType);
                    }
                }
                else if (initiater != -1 && initiater != localUsr.ActNr)
                {
                    if (onStructChanged != null)
                    {
                        onStructChanged(Serializers.ReadChangedTopicId(eventData.Parameters),
                                        initiater, (DeviceType)devType);
                    }
                }
                break;

            case (byte)DiscussionEventCode.ArgPointChanged:
                var changeType = PointChangedType.Modified;
                int topicId;
                int personId;
                int argPointId = Serializers.ReadChangedArgPoint(eventData.Parameters, out changeType, out topicId, out personId);
                if (argPointChanged != null)
                {
                    argPointChanged(argPointId, topicId, changeType, personId);
                }
                break;

            case (byte)DiscussionEventCode.UserAccPlusMinus:
                if (userAccPlusMinus != null)
                {
                    userAccPlusMinus();
                }
                break;

            case (byte)DiscussionEventCode.StatsEvent:
                if (onStatsEvent != null)
                {
                    StEvent    e;
                    int        userId       = -1;
                    int        discussionId = -1;
                    int        statsTopicId = -1;
                    DeviceType devTyp;
                    Serializers.ReadStatEventParams(eventData.Parameters, out e, out userId, out discussionId,
                                                    out statsTopicId, out devTyp);
                    onStatsEvent(e, userId, discussionId, statsTopicId, devTyp);
                }
                break;

            case (byte)DiscussionEventCode.CursorEvent:
                if (cursorEvent != null)
                {
                    cursorEvent(CursorEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.CreateShapeEvent:
                if (createShapeEvent != null)
                {
                    createShapeEvent(CreateShape.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.UnselectAllEvent:
                if (unselectAll != null)
                {
                    unselectAll(UnselectAllEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.DeleteSingleShapeEvent:
                if (deleteSingleShape != null)
                {
                    deleteSingleShape(DeleteSingleShapeEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ApplyPointEvent:
                if (applyPoint != null)
                {
                    applyPoint(PointMove.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.StateSyncEvent:
                if (syncStateEvent != null)
                {
                    syncStateEvent(ShapeState.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.LinkCreateEvent:
                if (onLinkCreateEvent != null)
                {
                    onLinkCreateEvent(LinkCreateMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.UnclusterBadgeEvent:
                if (onUnclusterBadgeEvent != null)
                {
                    onUnclusterBadgeEvent(UnclusterBadgeMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ClusterBadgeEvent:
                if (onClusterBadgeEvent != null)
                {
                    onClusterBadgeEvent(ClusterBadgeMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.InkEvent:
                if (inkEvent != null)
                {
                    inkEvent(InkMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.SceneLoadingDone:
                if (loadingDoneEvent != null)
                {
                    loadingDoneEvent();
                }
                break;

            case (byte)DiscussionEventCode.DEditorReportEvent:
                if (dEditorReportResponse != null)
                {
                    dEditorReportResponse(DEditorStatsResponse.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ClusterStatsEvent:
                if (clusterStatsResponse != null)
                {
                    if (eventData.Parameters == null || eventData.Parameters.Count() == 0)
                    {
                        clusterStatsResponse(default(ClusterStatsResponse), false);
                    }
                    else
                    {
                        clusterStatsResponse(ClusterStatsResponse.Read(eventData.Parameters), true);
                    }
                }
                break;

            case (byte)DiscussionEventCode.LinkStatsEvent:
                if (linkStatsResponseEvent != null)
                {
                    if (eventData.Parameters == null || eventData.Parameters.Count() == 0)
                    {
                        linkStatsResponseEvent(default(LinkReportResponse), false);
                    }
                    else
                    {
                        linkStatsResponseEvent(LinkReportResponse.Read(eventData.Parameters), true);
                    }
                }
                break;

            case (byte)DiscussionEventCode.BadgeViewEvent:
                if (onBadgeViewRequest != null)
                {
                    onBadgeViewRequest(BadgeViewMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.SourceViewEvent:
                if (onSourceViewRequest != null)
                {
                    onSourceViewRequest(ExplanationModeSyncMsg.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.CommentReadEvent:
                if (onCommentRead != null)
                {
                    onCommentRead(CommentsReadEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.AttachLaserPointerEvent:
                if (onAttachLaserPointer != null)
                {
                    onAttachLaserPointer(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.DetachLaserPointerEvent:
                if (onDetachLaserPointer != null)
                {
                    onDetachLaserPointer(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.LaserPointerMovedEvent:
                if (onLaserPointerMoved != null)
                {
                    onLaserPointerMoved(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ImageViewerManipulatedEvent:
                if (onImageViewerManipulated != null)
                {
                    onImageViewerManipulated(ImageViewerMatrix.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.BrowserScrollChangedEvent:
                if (onBrowserScroll != null)
                {
                    onBrowserScroll(BrowserScrollPosition.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.PdfScrollChangedEvent:
                if (onPdfScroll != null)
                {
                    onPdfScroll(PdfScrollPosition.Read(eventData.Parameters));
                }
                break;

            default:
                Console.WriteLine("Unhandled event " + eventData.Code);
                break;
            }
        }