Esempio n. 1
0
        public Sprite(GameObject baseObject, Vector3 position, int spriteIndex, Texture2D texture, IDictionary<int, SpriteItem> spriteDictionary)
        {
            var item = new SpriteItem(SpriteType.Car);

            //Bus
            //item.Sprite = 10;
            //item.Model = 11;
            //item.Remap = 4;

            //Cop
            //item.Sprite = 11;
            //item.Model = 12;
            //item.Remap = 36;

            item.SpriteId = 10;
            //item.Model = 10;
            //item.Remap = -1;

            var sourceRectangle = spriteDictionary[item.SpriteId].Rectangle;
            Width = sourceRectangle.Width / 64f; //1 Unit = 64px
            Height = sourceRectangle.Height / 64f;
            _widthHalf = Width / 2;
            _heightHalf = Height / 2;

            SetNeutralPosition(position);


            SpriteIndex = spriteIndex;

            //Texture
            double pixelPerWidth = 1f / texture.Width;
            double pixelPerHeight = 1f / texture.Height;

            TexturePositionTopLeft = new Vector2((float)((sourceRectangle.X + 1) * pixelPerWidth), (float)((sourceRectangle.Y + 1) * pixelPerHeight));
            TexturePositionTopRight = new Vector2((float)((sourceRectangle.X + sourceRectangle.Width - 1) * pixelPerWidth), (float)((sourceRectangle.Y + 1) * pixelPerHeight));
            TexturePositionBottomRight = new Vector2((float)((sourceRectangle.X + sourceRectangle.Width - 1) * pixelPerWidth), (float)((sourceRectangle.Y + sourceRectangle.Height - 1) * pixelPerHeight));
            TexturePositionBottomLeft = new Vector2((float)((sourceRectangle.X + 1) * pixelPerWidth), (float)((sourceRectangle.Y + sourceRectangle.Height - 1) * pixelPerHeight));
        }
Esempio n. 2
0
 public SpriteEventArgs(SpriteItem sprite)
 {
     Sprite = sprite;
 }