public FoodComponent(Position curPosition, Bitmap bitmap, int points, GameComponentType type) { CurPosition = curPosition; Points = points; Type = type; Bitmap = bitmap; }
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); }
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; }
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); }
public ResType(GameComponentType type, Direction direction) { Type = type; Direction = direction; }
private int GetResourceId(GameComponentType type, Direction direction) { return(_table[new ResType(type, direction)]); }