예제 #1
0
        public XmlSprite Convert(Sprite m, XmlModelConvertBackContext c, bool pointerOnly)
        {
            var scriptConverterCollection = new XmlModelConverterCollection <IScriptConverter>();

            // prevents endless loops
            XmlSprite result;

            if (!c.Sprites.TryGetValue(m, out result))
            {
                result = new XmlSprite {
                    Name = m.Name
                };
                c.Sprites[m] = result;
            }
            if (pointerOnly)
            {
                return(result);
            }

            result.Looks = new XmlLookList
            {
                Looks = c.Looks == null ? new List <XmlLook>() : c.Looks.Values.ToList()
            };
            result.Sounds = new XmlSoundList
            {
                Sounds = c.Sounds == null ? new List <XmlSound>() : c.Sounds.Values.ToList()
            };
            result.Scripts = new XmlScriptList
            {
                Scripts = m.Scripts == null
                    ? new List <XmlScript>()
                    : m.Scripts.Select(script => (XmlScript)scriptConverterCollection.Convert(script, c)).ToList()
            };
            return(result);
        }
예제 #2
0
        public override TScript Convert(TXmlScript o, XmlModelConvertContext c)
        {
            var brickConverterCollection = new XmlModelConverterCollection <IBrickConverter>();

            var result = Convert1(o, c);

            result.Bricks = o.Bricks == null || o.Bricks.Bricks == null ? null
                : o.Bricks.Bricks.Select(brick =>
                                         (Brick)brickConverterCollection.Convert(brick, c))
                            .ToObservableCollection();
            return(result);
        }
예제 #3
0
        public override TXmlScript Convert(TScript m, XmlModelConvertBackContext c)
        {
            var brickConverterCollection = new XmlModelConverterCollection <IBrickConverter>();

            var result = Convert1(m, c);

            result.Bricks = new XmlBrickList
            {
                Bricks = m.Bricks == null ? new List <XmlBrick>() :
                         m.Bricks.Select(brick =>
                                         (XmlBrick)brickConverterCollection.Convert(brick, c)).ToList()
            };
            c.Scripts.Add(m, result);
            return(result);
        }
예제 #4
0
        public Sprite Convert(XmlSprite o, XmlModelConvertContext c, bool pointerOnly)
        {
            var scriptConverterCollection = new XmlModelConverterCollection <IScriptConverter>();

            // prevents endless loops
            Sprite result;

            if (!c.Sprites.TryGetValue(o, out result))
            {
                result = new Sprite {
                    Name = o.Name
                };
                c.Sprites[o] = result;
            }
            if (pointerOnly)
            {
                return(result);
            }

            var localVariables = c.Program.VariableList.ObjectVariableList.ObjectVariableEntries.FirstOrDefault(entry => entry.Sprite == o);

            result.Looks = c.Looks == null
                ? new ObservableCollection <Look>()
                : c.Looks.Values.ToObservableCollection();
            result.Sounds = c.Sounds == null
                ? new ObservableCollection <Sound>()
                : c.Sounds.Values.ToObservableCollection();
            result.LocalVariables = localVariables == null || localVariables.VariableList == null || localVariables.VariableList.UserVariables == null
                ? new ObservableCollection <LocalVariable>()
                : localVariables.VariableList.UserVariables.Select(variable => c.LocalVariables[variable]).ToObservableCollection();
            c.Sprites[o]   = result;
            result.Scripts = o.Scripts == null || o.Scripts.Scripts == null
                ? new ObservableCollection <Script>()
                : o.Scripts.Scripts.Select(script => (Script)scriptConverterCollection.Convert(script, c)).ToObservableCollection();
            return(result);
        }