public static string GetReferenceString(XmlObjectNode referenceObject)
        {
            if (referenceObject is XmlLookReference)
            {
                return(GetLookReferenceString((referenceObject as XmlLookReference).Look));
            }
            if (referenceObject is XmlSoundReference)
            {
                return(GetSoundReferenceString((referenceObject as XmlSoundReference).Sound));
            }
            if (referenceObject is XmlSpriteReference)
            {
                return(GetSpriteReferenceString((referenceObject as XmlSpriteReference)));
            }
            if (referenceObject is XmlUserVariableReference)
            {
                return(GetVariableReferenceString(referenceObject as XmlUserVariableReference));
            }
            if (referenceObject is XmlLoopBeginBrickReference)
            {
                var loopBeginBrickRef = referenceObject as XmlLoopBeginBrickReference;
                if (loopBeginBrickRef.LoopBeginBrick is XmlForeverBrick)
                {
                    return(GetForeverBrickReferenceString(loopBeginBrickRef.LoopBeginBrick));
                }
                else
                {
                    return(GetRepeatBrickReferenceString(loopBeginBrickRef.LoopBeginBrick));
                }
            }
            if (referenceObject is XmlLoopEndBrickReference)
            {
                var loopEndBrickRef = referenceObject as XmlLoopEndBrickReference;
                if (loopEndBrickRef.LoopEndBrick is XmlForeverLoopEndBrick)
                {
                    return(GetForeverLoopEndBrickReferenceString(loopEndBrickRef.LoopEndBrick));
                }
                else
                {
                    return(GetRepeatLoopEndBrickReferenceString(loopEndBrickRef.LoopEndBrick));
                }
            }
            if (referenceObject is XmlIfLogicBeginBrickReference)
            {
                return(GetIfLogicBeginBrickReferenceString(referenceObject as XmlIfLogicBeginBrickReference));
            }
            if (referenceObject is XmlIfLogicElseBrickReference)
            {
                return(GetIfLogicElseBrickReferenceString(referenceObject as XmlIfLogicElseBrickReference));
            }
            if (referenceObject is XmlIfLogicEndBrickReference)
            {
                return(GetIfLogicEndBrickReferenceString(referenceObject as XmlIfLogicEndBrickReference));
            }

            return("");
        }
        public static XmlObjectNode GetReferenceObject(XmlObjectNode xmlObject, string reference)
        {
            if (reference == null)
            {
                return(null);
            }

            if (xmlObject is XmlLookReference)
            {
                return(GetLookObject(xmlObject as XmlLookReference, reference));
            }
            if (xmlObject is XmlSoundReference)
            {
                return(GetSoundObject(xmlObject as XmlSoundReference, reference));
            }
            if (xmlObject is XmlSpriteReference)
            {
                return(GetSpriteObject(reference));
            }
            if (xmlObject is XmlUserVariableReference)
            {
                return(GetUserVariableObject(xmlObject as XmlUserVariableReference, reference));
            }
            if (xmlObject is XmlLoopBeginBrickReference)
            {
                if (reference.ToLower().Contains("forever"))
                {
                    return(GetForeverBrickObject(xmlObject as XmlLoopBeginBrickReference, reference));
                }
                else
                {
                    return(GetRepeatBrickObject(xmlObject as XmlLoopBeginBrickReference, reference));
                }
            }
            if (xmlObject is XmlLoopEndBrickReference)
            {
                if (reference.ToLower().Contains("endless"))
                {
                    return(GetForeverLoopEndBrickObject(xmlObject as XmlLoopEndBrickReference, reference));
                }
                else
                {
                    return(GetRepeatLoopEndBrickObject(xmlObject as XmlLoopEndBrickReference, reference));
                }
            }
            if (xmlObject is XmlIfLogicBeginBrickReference)
            {
                return(GetIfLogicBeginBrickObject(xmlObject as XmlIfLogicBeginBrickReference, reference));
            }
            if (xmlObject is XmlIfLogicElseBrickReference)
            {
                return(GetIfLogicElseBrickObject(xmlObject as XmlIfLogicElseBrickReference, reference));
            }
            if (xmlObject is XmlIfLogicEndBrickReference)
            {
                return(GetIfLogicEndBrickObject(xmlObject as XmlIfLogicEndBrickReference, reference));
            }


            return(null);
        }