public void TestHashCode()
        {
            var o1 = new Origin2d(Anchor2d.Center, new Vector2d(8, 9));
            var o2 = new Origin2d(Anchor2d.Center, new Vector2d(8, 9));

            Assert.Equal(o1.GetHashCode(), o2.GetHashCode());

            o2.Offset.X += 1;

            Assert.NotEqual(o1.GetHashCode(), o2.GetHashCode());
        }
        public void TestEquality(Anchor2d anchor, float x, float y)
        {
            var o1 = new Origin2d(anchor, new Vector2d(x, y));
            var o2 = new Origin2d(anchor, new Vector2d(x, y));

            Assert.True(o1 == o2);
            Assert.True(o1.Equals(o2));

            o1.Offset.X += Constants.FloatTolerance / 10;

            Assert.True(o1 == o2);
            Assert.True(o1.Equals(o2));

            o1.Offset.X += Constants.FloatTolerance * 10;

            Assert.False(o1 == o2);
            Assert.False(o1.Equals(o2));
        }
        private void LoadMap()
        {
            var tileSize = Sprites.Tiles.Frames[0].GetSize();
            var start    = Position2d.Zero;
            var origin   = new Origin2d(Anchor2d.TopCenter);

            int xShift = 32;
            int yShift = 16;

            var i        = 0;
            var row      = 0;
            var entities = new List <Entity>();

            foreach (var tilerow in this.TestBoard)
            {
                var row_x = start.X - row * xShift;
                var row_y = start.Y + row * yShift;

                var col = 0;
                foreach (var tilevalue in tilerow)
                {
                    var x = row_x + col * xShift;
                    var y = row_y + col * yShift;

                    var tileEntity = new Entity(new Rect2d(x, y, tileSize.Width, tileSize.Height, origin));
                    tileEntity.AddComponent(new SpriteComponent {
                        SpriteSheet = Sprites.Tiles, Index = tilevalue
                    });
                    entities.Add(tileEntity);

                    col++;
                }

                row++;
            }

            this.Ecosystem.AddEntities(n => $"Tile_{n}", entities);
        }
Exemple #4
0
 public RotationAnimation SetOrigin(Origin2d origin)
 {
     this.Origin = origin;
     return(this);
 }
Exemple #5
0
 public RotationAnimation SetOrigin(Anchor2d anchor)
 {
     this.Origin = new Origin2d(anchor);
     return(this);
 }
 public ScaleAnimation SetOrigin(Origin2d origin)
 {
     this.Origin = origin;
     return(this);
 }