コード例 #1
0
 public FrameAnimationSystem(SpriteMapper spriteMapper)
     : base(SystemOrders.Update.FrameAnimation, new int[] { ComponentTypeIds.FrameAnimation, ComponentTypeIds.Aspect },
            null)
 {
     this.spriteMapper = spriteMapper;
     DrawOrder         = SystemOrders.Draw.FrameAnimation;
 }
コード例 #2
0
ファイル: RenderSystem.cs プロジェクト: mdwheele/bomberman
        public RenderSystem(Game game, Camera camera, SpriteBatch spriteBatch, SpriteMapper spriteMapper)
            : base(SystemOrders.Update.Render,
                   new int[] { ComponentTypeIds.Aspect, ComponentTypeIds.Placement }
                   )
        {
            this.spriteMapper = spriteMapper;
            this.spriteBatch  = spriteBatch;
            DrawOrder         = SystemOrders.Draw.Render;
            this.camera       = camera;

            for (int i = 0; i < textures.Length; i++)
            {
                textures[i] = new List <TexAndPos>();
            }
        }
コード例 #3
0
        public void FasterCached()
        {
            var stopwatch    = new Stopwatch();
            var spriteMapper = new SpriteMapper(WorldObjects.Blocks.BlockTypes.Dirt, SAMPLE_TEXTURE);

            stopwatch.Start();
            for (var x = -160; x < 160; x++)
            {
                for (var y = -160; y < 160; y++)
                {
                    var pixelPositionX = (x * 64) % SAMPLE_TEXTURE.width;
                    var pixelPositionY = (y * 64) % SAMPLE_TEXTURE.height;

                    var pixelPosition = new Vector2(pixelPositionX, pixelPositionY);

                    Sprite.Create(SAMPLE_TEXTURE, new Rect(pixelPosition, SPRITE_SIZE), SPRITE_ANCHOR, 64);
                }
            }
            stopwatch.Stop();

            var uncachedTime = stopwatch.Elapsed;

            stopwatch.Reset();

            stopwatch.Start();
            for (var x = -160; x < 160; x++)
            {
                for (var y = -160; y < 160; y++)
                {
                    spriteMapper.Fetch(new IntVector2(x, y));
                }
            }
            stopwatch.Stop();

            var mapperCachedTime = stopwatch.Elapsed;

            Assert.LessOrEqual(mapperCachedTime, uncachedTime);

            _log.Info($"Raw Time : {uncachedTime}, Cached Time: {mapperCachedTime}.");
        }
コード例 #4
0
        public void NotSlowerUncachedTest()
        {
            var stopwatch = new Stopwatch();

            var spriteMapper = new SpriteMapper(WorldObjects.Blocks.BlockTypes.Dirt, SAMPLE_TEXTURE);

            stopwatch.Start();
            for (var x = -16; x < 16; x++)
            {
                for (var y = -16; y < 16; y++)
                {
                    var pixelPositionX = (x * 64) % SAMPLE_TEXTURE.width;
                    var pixelPositionY = (y * 64) % SAMPLE_TEXTURE.height;

                    var pixelPosition = new Vector2(pixelPositionX, pixelPositionY);

                    Sprite.Create(SAMPLE_TEXTURE, new Rect(pixelPosition, SPRITE_SIZE), SPRITE_ANCHOR, 64);
                }
            }
            stopwatch.Stop();

            var rawUncachedTime = stopwatch.Elapsed;

            stopwatch.Reset();

            stopwatch.Start();
            for (var x = -16; x < 16; x++)
            {
                for (var y = -16; y < 16; y++)
                {
                    spriteMapper.Fetch(new IntVector2(x, y));
                }
            }
            stopwatch.Stop();

            var mapperUncachedTime = stopwatch.Elapsed;

            Assert.LessOrEqual((mapperUncachedTime - rawUncachedTime).TotalSeconds, 3);
        }
コード例 #5
0
 private void Awake()
 {
     SpriteStore = SpriteStoreProvider;
 }
コード例 #6
0
 // SpriteMapper initialization
 void initSpriteMapper()
 {
     spriteMapper = new SpriteMapper();
     spriteMapper.init(SceneryObject_Prefab.GetComponent <tk2dSprite> ());
 }