Esempio n. 1
0
        public void ConnectNodeToAvatar(string ownerRoom, string targetRoom, string nodeDirection)
        {
            ImageBox target = null;
            ImageBox owner  = null;

            if (ownerRoom == null || ownerRoom == "" || targetRoom == "" || nodeDirection == null || nodeDirection == "")
            {
                return;
            }

            if (targetRoom == null)
            {
                target = null;
            }
            else
            {
                if (AvatarMap.ContainsKey(targetRoom))
                {
                    target = AvatarMap[targetRoom];
                }
            }
            if (AvatarMap.ContainsKey(ownerRoom))
            {
                owner = AvatarMap[ownerRoom];
            }


            //hack alert! we are setting this up for static item based exits/enters
            if (!Globals.NodeProperties.NodeLocations.ContainsKey(nodeDirection))
            {
                nodeDirection = "other";
            }

            if (targetRoom != null && targetRoom.Length > 0 && target == null && owner != null)
            {
                //failed connection

                ConnectionNode node = owner.GetNode(nodeDirection);
                if (node != null)
                {
                    node.FailedConnection = true;
                    node.SetTarget(target);
                }
            }
            else
            {
                //connect / disconnect
                if (owner != null)
                {
                    ConnectionNode node = owner.GetNode(nodeDirection);
                    if (node != null)
                    {
                        node.FailedConnection = false;
                        node.SetTarget(target);
                    }
                    return;
                }
            }
            return;
        }
        public void ConnectRoom(MouseMoveArgs mma)
        {
            if (DeactivateDragLine != null)
            {
                DeactivateDragLine(this, null);
            }

            //if we are over another image, attach the connection to that
            if (HilightMouseover(mma))
            {
                //connect
                State = MouseStates.Hover;

                refHoveredNode.SetTarget(refHoveredImage);
                RoomConnectionArgs args = new RoomConnectionArgs(refHoveredNode.Source.RoomName,
                                                                 refHoveredImage.RoomName,
                                                                 refHoveredNode.Direction,
                                                                 ConnectionType.Connect);

                if (SetConnection != null)
                {
                    SetConnection(this, args);
                }
            }
            else
            {
                //disconnect
                State = MouseStates.Normal;
                RoomConnectionArgs args = new RoomConnectionArgs(refHoveredNode.Source.RoomName,
                                                                 refHoveredNode.Target.RoomName,
                                                                 refHoveredNode.Direction,
                                                                 ConnectionType.Disconnect);
                refHoveredNode.SetTarget(null);
                if (RemoveConnection != null)
                {
                    RemoveConnection(this, args);
                }
            }
        }