Exemplo n.º 1
0
        public override DataObject Copy(Sprite parent)
        {
            var newWhenScript = new WhenScript(parent);
            newWhenScript.action = action;
            if (bricks != null)
                newWhenScript.bricks = bricks.Copy(parent) as BrickList;

            return newWhenScript;
        }
        public void ScriptBrickCollectionAddTest()
        {
            var project = SampleLoader.LoadSampleXML("simple");

              Sprite sprite = project.SpriteList.Sprites[1];
              ScriptBrickCollection collection = new ScriptBrickCollection();
              collection.Update(sprite);

              Script newScript1 = new BroadcastScript(sprite);
              collection.Add(newScript1);

              Brick newBrick1 = new ChangeGhostEffectBrick(sprite);
              collection.Add(newBrick1);
              Brick newBrick2 = new ChangeXByBrick(sprite);
              collection.Add(newBrick2);

              Script newScript2 = new WhenScript(sprite);
              collection.Add(newScript2);

              IEnumerator enumerator = collection.GetEnumerator();

              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is StartScript);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is SetCostumeBrick);

              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is WhenScript);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is SetCostumeBrick);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is WaitBrick);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is SetCostumeBrick);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is WaitBrick);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is SetCostumeBrick);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is BroadcastScript);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is ChangeGhostEffectBrick);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is ChangeXByBrick);
              enumerator.MoveNext();
              Assert.IsTrue(enumerator.Current is WhenScript);

              Assert.IsFalse(enumerator.MoveNext());
        }