Esempio n. 1
0
        public void GetAndRemoveTest()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(9, 0))
            {
                Assert.Ignore("Ignoring GameplayKit tests: Requires iOS9+");
            }

            var entity = GKEntity.GetEntity();

            entity.AddComponent(new NumberComponent(10));
            entity.AddComponent(new NameComponent("Ten"));
            Assert.IsTrue(entity.Components.Length == 2, "entity.Components length must be 2");

            // Test component retrieval by type
            var component = entity.GetComponent(typeof(NumberComponent)) as NumberComponent;

            Assert.NotNull(component, "Component must not be null");
            Assert.IsTrue(component.Id == 10, "Component Id must be 10");

            // Test component removal by type
            Assert.NotNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must not be null");
            entity.RemoveComponent(typeof(NameComponent));
            Assert.IsTrue(entity.Components.Length == 1, "entity.Components length must be 1");
            Assert.IsNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must be null");
        }
        public void BadRemoval()
        {
            TestRuntime.AssertXcodeVersion(7, 0);

            var entity = GKEntity.GetEntity();

            Assert.Throws <ArgumentNullException> (() => entity.RemoveComponent(null));
        }
Esempio n. 3
0
        public void BadRemoval()
        {
            TestRuntime.AssertXcodeVersion(7, 0);

            var entity = GKEntity.GetEntity();

            entity.RemoveComponent(null);
        }
Esempio n. 4
0
 public ItemSpriteComponent(SKTexture texture, GKEntity entity)
 {
     Sprite                        = new EntityNode();
     Sprite.Texture                = texture;
     Sprite.Size                   = new CoreGraphics.CGSize(64f, 64f);
     Sprite.AnchorPoint            = new CoreGraphics.CGPoint(0.5f, 0.0f);
     Sprite.UserInteractionEnabled = true;
     ((EntityNode)Sprite).Entity   = entity;
 }
Esempio n. 5
0
        public void BadRemoval()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(9, 0))
            {
                Assert.Ignore("Ignoring GameplayKit tests: Requires iOS9+");
            }

            var entity = GKEntity.GetEntity();

            entity.RemoveComponent(null);
        }
Esempio n. 6
0
        public CharacterSpriteComponent(string spriteAtlasFilename, GKEntity entity)
        {
            // Setup the idle actions
            SKTextureAtlas atlas = SKTextureAtlas.FromName(spriteAtlasFilename);

            idleNorthWestAction = SKAction.AnimateWithTextures(new SKTexture[] { atlas.TextureNamed(spriteAtlasFilename + "-1-0") }, 1.0);
            idleSouthEastAction = SKAction.AnimateWithTextures(new SKTexture[] { atlas.TextureNamed(spriteAtlasFilename + "-3-0") }, 1.0);

            // Setup the walking action
            SKTexture[] textArray = TextureArrayFromAtlas(atlas, spriteAtlasFilename, 1);
            walkNorthWestAction = SKAction.AnimateWithTextures(textArray, 0.1);
            textArray           = TextureArrayFromAtlas(atlas, spriteAtlasFilename, 3);
            walkSouthEastAction = SKAction.AnimateWithTextures(textArray, 0.1);

            Sprite                        = new EntityNode();
            Sprite.Texture                = atlas.TextureNamed(spriteAtlasFilename + "-1-0");
            Sprite.Size                   = new CoreGraphics.CGSize(64f, 64f);
            Sprite.AnchorPoint            = new CoreGraphics.CGPoint(0.5f, 0.0f);
            Sprite.UserInteractionEnabled = true;
            ((EntityNode)Sprite).Entity   = entity;
        }
        public void GetAndRemoveTest()
        {
            TestRuntime.AssertXcodeVersion(7, 0);

            var entity = GKEntity.GetEntity();

            entity.AddComponent(new NumberComponent(10));
            entity.AddComponent(new NameComponent("Ten"));
            Assert.IsTrue(entity.Components.Length == 2, "entity.Components length must be 2");

            // Test component retrieval by type
            var component = entity.GetComponent(typeof(NumberComponent)) as NumberComponent;

            Assert.NotNull(component, "Component must not be null");
            Assert.IsTrue(component.Id == 10, "Component Id must be 10");

            // Test component removal by type
            Assert.NotNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must not be null");
            entity.RemoveComponent(typeof(NameComponent));
            Assert.IsTrue(entity.Components.Length == 1, "entity.Components length must be 1");
            Assert.IsNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must be null");
        }
Esempio n. 8
0
 public static T GetComponent <T> (this GKEntity entity) where T : GKComponent
 {
     return((T)entity.GetComponent(typeof(T)));
 }