예제 #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;
        }