public override XmlUserVariable Convert(TVariable m, XmlModelConvertBackContext c)
 {
     return(new XmlUserVariable
     {
         Name = m.Name
     });
 }
 public override XmlNoteBrick Convert1(CommentBrick m, XmlModelConvertBackContext c)
 {
     return(new XmlNoteBrick
     {
         Note = m.Value
     });
 }
 public override XmlNxtMotorStopBrick Convert1(StopNxtMotorBrick m, XmlModelConvertBackContext c)
 {
     return(new XmlNxtMotorStopBrick
     {
         Motor = m.Motor
     });
 }
Пример #4
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);
        }
Пример #5
0
 public override XmlSpeakBrick Convert1(SpeakBrick m, XmlModelConvertBackContext c)
 {
     return(new XmlSpeakBrick
     {
         Text = m.Value
     });
 }
 public override XmlBroadcastBrick Convert1(BroadcastSendBrick m, XmlModelConvertBackContext c)
 {
     return(new XmlBroadcastBrick
     {
         BroadcastMessage = m.Message == null ? null : m.Message.Content
     });
 }
 public override XmlWhenScript Convert1(TappedScript m, XmlModelConvertBackContext c)
 {
     return(new XmlWhenScript
     {
         Action = XmlWhenScript.WhenScriptAction.Tapped
     });
 }
Пример #8
0
 public override XmlBroadcastScript Convert1(BroadcastReceivedScript m, XmlModelConvertBackContext c)
 {
     return(new XmlBroadcastScript
     {
         ReceivedMessage = m.Message == null ? null : m.Message.Content
     });
 }
 public override XmlLook Convert(Look m, XmlModelConvertBackContext c)
 {
     return(new XmlLook
     {
         Name = m.Name,
         FileName = m.FileName
     });
 }
Пример #10
0
 public override XmlSound Convert(Sound m, XmlModelConvertBackContext c)
 {
     return(new XmlSound
     {
         Name = m.Name,
         FileName = m.FileName
     });
 }
        public override XmlChangeSizeByNBrick Convert1(ChangeSizeBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlChangeSizeByNBrick
            {
                Size = m.RelativePercentage == null ? new XmlFormula() : formulaConverter.Convert(m.RelativePercentage, c)
            });
        }
Пример #12
0
        public override XmlPointInDirectionBrick Convert1(SetRotationBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlPointInDirectionBrick
            {
                Degrees = m.Value == null ? new XmlFormula() : formulaConverter.Convert(m.Value, c)
            });
        }
Пример #13
0
        public override XmlWaitBrick Convert1(DelayBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlWaitBrick
            {
                TimeToWaitInSeconds = m.Duration == null ? new XmlFormula() : formulaConverter.Convert(m.Duration, c)
            });
        }
        public override XmlRepeatLoopEndBrick Convert1(EndRepeatBrick m, XmlModelConvertBackContext c)
        {
            var repeatBrickConverter = new RepeatBrickConverter();

            var result = new XmlRepeatLoopEndBrick();

            c.Bricks[m] = result;
            return(result);
        }
Пример #15
0
        public override XmlPointToBrick Convert1(LookAtBrick m, XmlModelConvertBackContext c)
        {
            var spriteConverter = new SpriteConverter();

            return(new XmlPointToBrick
            {
                PointedSprite = m.Target == null ? null : (XmlSprite)spriteConverter.Convert(m.Target, c, pointerOnly: true)
            });
        }
        public override XmlSetXBrick Convert1(SetPositionXBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlSetXBrick
            {
                XPosition = m.Value == null ? new XmlFormula() : formulaConverter.Convert(m.Value, c)
            });
        }
        public override XmlMoveNStepsBrick Convert1(MoveBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlMoveNStepsBrick
            {
                Steps = m.Steps == null ? new XmlFormula() : formulaConverter.Convert(m.Steps, c)
            });
        }
Пример #18
0
        public override XmlTurnLeftBrick Convert1(TurnLeftBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlTurnLeftBrick
            {
                Degrees = m.RelativeValue == null ? new XmlFormula() : formulaConverter.Convert(m.RelativeValue, c)
            });
        }
Пример #19
0
        public override XmlChangeYByBrick Convert1(ChangePositionYBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlChangeYByBrick
            {
                YMovement = m.RelativeValue == null ? new XmlFormula() : formulaConverter.Convert(m.RelativeValue, c)
            });
        }
        public override XmlSetBrightnessBrick Convert1(SetBrightnessBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlSetBrightnessBrick
            {
                Brightness = m.Percentage == null ? new XmlFormula() : formulaConverter.Convert(m.Percentage, c)
            });
        }
Пример #21
0
        public override XmlSetGhostEffectBrick Convert1(SetTransparencyBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlSetGhostEffectBrick
            {
                Transparency = m.Percentage == null ? new XmlFormula() : formulaConverter.Convert(m.Percentage, c)
            });
        }
Пример #22
0
        public override XmlSetVolumeToBrick Convert1(SetVolumeBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlSetVolumeToBrick
            {
                Volume = m.Percentage == null ? null : formulaConverter.Convert(m.Percentage, c)
            });
        }
        public override XmlForeverBrick Convert1(ForeverBrick m, XmlModelConvertBackContext c)
        {
            var foreverEndBrickConverter = new ForeverEndBrickConverter();

            var result = new XmlForeverBrick();

            c.Bricks[m] = result;
            return(result);
        }
Пример #24
0
        public override XmlGoNStepsBackBrick Convert1(DecreaseZOrderBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlGoNStepsBackBrick
            {
                Steps = m.RelativeValue == null ? new XmlFormula() : formulaConverter.Convert(m.RelativeValue, c)
            });
        }
        public override XmlNxtPlayToneBrick Convert1(PlayNxtToneBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlNxtPlayToneBrick
            {
                Frequency = m.Frequency == null ? new XmlFormula() : formulaConverter.Convert(m.Frequency, c),
                DurationInSeconds = m.Duration == null ? new XmlFormula() : formulaConverter.Convert(m.Duration, c)
            });
        }
Пример #26
0
        public override XmlPlaceAtBrick Convert1(SetPositionBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlPlaceAtBrick
            {
                XPosition = m.ValueX == null ? new XmlFormula() : formulaConverter.Convert(m.ValueX, c),
                YPosition = m.ValueY == null ? new XmlFormula() : formulaConverter.Convert(m.ValueY, c)
            });
        }
Пример #27
0
        public override XmlNxtMotorActionBrick Convert1(SetNxtMotorSpeedBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlNxtMotorActionBrick
            {
                Motor = m.Motor,
                Speed = m.Percentage == null ? new XmlFormula() : formulaConverter.Convert(m.Percentage, c)
            });
        }
Пример #28
0
        public override XmlGlideToBrick Convert1(AnimatePositionBrick m, XmlModelConvertBackContext c)
        {
            var formulaConverter = new FormulaConverter();

            return(new XmlGlideToBrick
            {
                DurationInSeconds = m.Duration == null ? new XmlFormula() : formulaConverter.Convert(m.Duration, c),
                XDestination = m.ToX == null ? new XmlFormula() : formulaConverter.Convert(m.ToX, c),
                YDestination = m.ToY == null ? new XmlFormula() : formulaConverter.Convert(m.ToY, c)
            });
        }
Пример #29
0
        public override XmlIfLogicEndBrick Convert1(EndIfBrick m, XmlModelConvertBackContext c)
        {
            var ifBrickConverter   = new IfLogicBrickConverter();
            var elseBrickConverter = new IfLogicElseBrickConverter();

            var result = new XmlIfLogicEndBrick();

            c.Bricks[m] = result;
            result.IfLogicBeginBrick = m.Begin == null ? null : (XmlIfLogicBeginBrick)ifBrickConverter.Convert(m.Begin, c);
            result.IfLogicElseBrick  = m.Else == null ? null : (XmlIfLogicElseBrick)elseBrickConverter.Convert(m.Else, c);
            return(result);
        }
Пример #30
0
        public override XmlSetLookBrick Convert1(SetLookBrick m, XmlModelConvertBackContext c)
        {
            XmlLook look = null;

            if (m.Value != null)
            {
                c.Looks.TryGetValue(m.Value, out look);
            }
            return(new XmlSetLookBrick
            {
                Look = look
            });
        }