public FoodComponent(Position curPosition, Bitmap bitmap, int points, GameComponentType type)
 {
     CurPosition = curPosition;
     Points      = points;
     Type        = type;
     Bitmap      = bitmap;
 }
Example #2
0
        private Bitmap GetBitmap(GameComponentType type, Direction direction, int width, int height)
        {
            var    img          = _resources.GetDrawable(GetResourceId(type, direction));
            Bitmap bitmap       = ((BitmapDrawable)img).Bitmap;
            Bitmap scaledBitmap = Bitmap.CreateScaledBitmap(bitmap, width, height, true);

            return(scaledBitmap);
        }
Example #3
0
 public ImgComponent(Position curPosition, GameComponentType type, Bitmap leftBitmap, Bitmap rightBitmap, Bitmap upBitmap, Bitmap downBitmap)
 {
     CurPosition = curPosition;
     Type        = type;
     LeftBitmap  = leftBitmap;
     RightBitmap = rightBitmap;
     UpBitmap    = upBitmap;
     DownBitmap  = downBitmap;
 }
Example #4
0
        public ISnakeComponent Create(Position position, GameComponentType type, Direction direction, int width, int height)
        {
            //System.Diagnostics.Debug.WriteLine(type);
            //var img = _resources.ObtainTypedArray(GetResourceId(type)).GetDrawable(GetResourceId(type));

            var imgSnakeComponent = new ImgComponent(position, type,
                                                     GetBitmap(type, Direction.Left, width, height),
                                                     GetBitmap(type, Direction.Right, width, height),
                                                     GetBitmap(type, Direction.Up, width, height),
                                                     GetBitmap(type, Direction.Down, width, height));

            imgSnakeComponent.Direction = direction;

            return(imgSnakeComponent);
        }
Example #5
0
 public ResType(GameComponentType type, Direction direction)
 {
     Type      = type;
     Direction = direction;
 }
Example #6
0
 private int GetResourceId(GameComponentType type, Direction direction)
 {
     return(_table[new ResType(type, direction)]);
 }