Esempio n. 1
0
        public override DataObject Copy(Sprite parent)
        {
            var newBroadcastScript = new BroadcastScript(parent);
            newBroadcastScript.receivedMessage = receivedMessage;
            if (bricks != null)
                newBroadcastScript.bricks = bricks.Copy(parent) as BrickList;

            return newBroadcastScript;
        }
        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());
        }
        public void ScriptBrickCollectionIndexIfTest()
        {
            var project = SampleLoader.LoadSampleXML("simple");

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

              int referenceIndex = 0;
              while (enumerator.MoveNext())
              {
            Assert.AreEqual(collection.IndexOf(enumerator.Current), referenceIndex);
            referenceIndex++;
              }

              Brick notContainedBrick = new BroadcastBrick(sprite);
              Assert.AreEqual(collection.IndexOf(notContainedBrick), -1);

              Script notContainedScript = new BroadcastScript(sprite);
              Assert.AreEqual(collection.IndexOf(notContainedScript), -1);
        }
        public void ScriptBrickCollectionContainsTest()
        {
            var project = SampleLoader.LoadSampleXML("simple");

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

              while (enumerator.MoveNext())
            Assert.IsTrue(collection.Contains(enumerator.Current));

              Brick notContainedBrick = new BroadcastBrick(sprite);
              Assert.IsFalse(collection.Contains(notContainedBrick));

              Script notContainedScript = new BroadcastScript(sprite);
              Assert.IsFalse(collection.Contains(notContainedScript));
        }