Beispiel #1
0
        public AGT_SpriteId AddResource(string id, System.Drawing.Bitmap bitmap, float x, float y, float z, bool rotate)
        {
            if (bitmap != null)
            {
                AGT_SpriteResource t = new AGT_SpriteResource();
                t.TextureId    = id;
                t.CanRotate    = rotate;
                t.Texture      = Texture.FromBitmap(_device_, bitmap, Usage.None, Pool.Managed);
                t.Position.X   = x;
                t.Position.Y   = y;
                t.Position.Z   = z;
                t.Aspect.X     = ((float)bitmap.Width / (float)bitmap.Height);
                t.Aspect.Y     = ((float)bitmap.Width / (float)bitmap.Height);
                t.BitmapHeight = bitmap.Height;
                t.BitmapWidth  = bitmap.Width;
                using (Surface s = t.Texture.GetSurfaceLevel(0))
                {
                    t.Width  = s.Description.Width;
                    t.Height = s.Description.Height;
                }

                lock (this)
                {
                    if (!_texture_list.ContainsKey(id))
                    {
                        _texture_list.Add(id, t);
                    }
                }
                return(new AGT_SpriteId(id));
            }
            else
            {
                throw new ArgumentNullException("Null bitmap passed");
            }
        }
Beispiel #2
0
        public AGT_SpriteResource(AGT_SpriteResource t)
        {
            TextureId = t.TextureId;
            Texture   = t.Texture;
            Position  = t.Position;
            Rotation  = t.Rotation;
            Scaling   = t.Scaling;
            Center    = t.Center;
            Width     = t.Width;
            Height    = t.Height;

            CanRotate = t.CanRotate;
            Aspect    = t.Aspect;
        }
Beispiel #3
0
 public AGT_SpriteResource(AGT_SpriteResource t)
 {
     TextureId = t.TextureId;
     Texture = t.Texture;
     Position = t.Position;
     Rotation = t.Rotation;
     Scaling = t.Scaling;
     Center = t.Center;
     Width = t.Width;
     Height = t.Height;
    
     CanRotate = t.CanRotate;
     Aspect = t.Aspect;
 }
Beispiel #4
0
 public AGT_SpriteId AddResource(string id, string file, float x, float y, float z, bool rotate)
 {
     if (System.IO.File.Exists(file))
     {
         AGT_SpriteResource t = new AGT_SpriteResource();
         t.TextureId  = id;
         t.CanRotate  = rotate;
         t.Texture    = TextureLoader.FromFile(_device_, file);
         t.Position.X = x;
         t.Position.Y = y;
         t.Position.Z = z;
         using (Surface s = t.Texture.GetSurfaceLevel(0))
         {
             t.Width  = s.Description.Width;
             t.Height = s.Description.Height;
         }
         using (Image b = Bitmap.FromFile(file))
         {
             t.Aspect.X     = (float)b.Width / (float)t.Width;
             t.Aspect.Y     = (float)b.Height / (float)t.Height;
             t.BitmapWidth  = b.Width;
             t.BitmapHeight = b.Height;
         }
         lock (this)
         {
             if (!_texture_list.ContainsKey(id))
             {
                 _texture_list.Add(id, t);
             }
         }
         return(new AGT_SpriteId(id));
     }
     else
     {
         throw new ArgumentNullException("Null bitmap passed");
     }
 }
Beispiel #5
0
 public AGT_SpriteId AddResource(string id, string file, float x, float y, float z, bool rotate)
 {
     if (System.IO.File.Exists(file))
     {
         AGT_SpriteResource t = new AGT_SpriteResource();
         t.TextureId = id;
         t.CanRotate = rotate;
         t.Texture = TextureLoader.FromFile(_device_, file);
         t.Position.X = x;
         t.Position.Y = y;
         t.Position.Z = z;
         using (Surface s = t.Texture.GetSurfaceLevel(0))
         {
             t.Width = s.Description.Width;
             t.Height = s.Description.Height;
         }
         using (Image b = Bitmap.FromFile(file))
         {
             t.Aspect.X = (float)b.Width / (float)t.Width;
             t.Aspect.Y = (float)b.Height / (float)t.Height;
             t.BitmapWidth = b.Width;
             t.BitmapHeight = b.Height;
         }
         lock (this)
         {
             if (!_texture_list.ContainsKey(id))
             {
                 _texture_list.Add(id, t);
             }
         }
         return new AGT_SpriteId(id);
     }
     else
     {
         throw new ArgumentNullException("Null bitmap passed");
     }
 }
Beispiel #6
0
        public AGT_SpriteId AddResource(string id, System.Drawing.Bitmap bitmap, float x, float y, float z, bool rotate)
        {
            if (bitmap != null)
            {
                AGT_SpriteResource t = new AGT_SpriteResource();
                t.TextureId = id;
                t.CanRotate = rotate;
                t.Texture = Texture.FromBitmap(_device_, bitmap, Usage.None, Pool.Managed);
                t.Position.X = x;
                t.Position.Y = y;
                t.Position.Z = z;
                t.Aspect.X = ((float)bitmap.Width / (float)bitmap.Height);
                t.Aspect.Y = ((float)bitmap.Width / (float)bitmap.Height);
                t.BitmapHeight = bitmap.Height;
                t.BitmapWidth = bitmap.Width;
                using (Surface s = t.Texture.GetSurfaceLevel(0))
                {
                    t.Width = s.Description.Width;
                    t.Height = s.Description.Height;
                }

                lock (this)
                {
                    if (!_texture_list.ContainsKey(id))
                    {
                        _texture_list.Add(id, t);
                    }
                }
                return new AGT_SpriteId(id);
            }
            else
            {
                throw new ArgumentNullException("Null bitmap passed");
            }
        }
Beispiel #7
0
 public void SetSpriteReference(AGT_SpriteResource texture)
 {
     _sprite_id.Id = texture.TextureId;
     _collision_rect.Height = _texture_height = texture.Height;
     _collision_rect.Width = _texture_width = texture.Width;
 }
Beispiel #8
0
 public AGT_Pawn(string pawn_id, AGT_SpriteResource texture)
 {
     _position = new Vector3(0, 0, 0);
     _rotation = new Vector3(0, 0, 0);
     _scaling = new Vector3(1, 1, 1);
     _pawn_id = pawn_id;
     _sprite_id.Id = texture.TextureId;
     _collision_rect.Height = _texture_height = texture.Height;
     _collision_rect.Width = _texture_width = texture.Width;
 }