public Texture2D Create(Square tile) { if (_cachedTexture != null) return _cachedTexture; var texture = new Texture2D(RotationGame.CurrentGraphicsDevice, DrawingConstants.Tiles.TILE_WIDTH, DrawingConstants.Tiles.TILE_HEIGHT, false, SurfaceFormat.Color); var colours = new Color[DrawingConstants.Tiles.TILE_HEIGHT*DrawingConstants.Tiles.TILE_WIDTH]; const int boarderWidth = 4; for (int x = 0; x < DrawingConstants.Tiles.TILE_WIDTH; x++) { for (int y = 0; y < DrawingConstants.Tiles.TILE_HEIGHT; y++) { if (x <= boarderWidth || x >= DrawingConstants.Tiles.TILE_WIDTH - boarderWidth || y <= boarderWidth || y >= DrawingConstants.Tiles.TILE_HEIGHT - boarderWidth) { colours[x + y * DrawingConstants.Tiles.TILE_WIDTH] = Color.Black; } else { colours[x + y * DrawingConstants.Tiles.TILE_WIDTH] = Color.White; } } } texture.SetData(colours); _cachedTexture = texture; return _cachedTexture; }
public Texture2D Create(Square tile) { if (_cachedTexture != null) return _cachedTexture; var texture = new Texture2D(RotationGame.CurrentGraphicsDevice, DrawingConstants.Tiles.TILE_WIDTH, DrawingConstants.Tiles.TILE_HEIGHT, false, SurfaceFormat.Color); var colours = new Color[DrawingConstants.Tiles.TILE_HEIGHT * DrawingConstants.Tiles.TILE_WIDTH]; for (int i = 0; i < colours.Length; i++) colours[i] = Color.White; texture.SetData(colours); _cachedTexture = texture; return _cachedTexture; }
public ISquareTextureCreator Create(Square tile) { return _tileTextureCreators.First(t => t.CanCreateTexture(tile)); }
public SquareBuilder(bool isSelectable, int x, int y) { _square = new Square(isSelectable, x, y); }
public float Calculate(Square square) { return square.Angle == 0 ? 0.2f : 0.1f; }
public bool CanCreateTexture(Square square) { return !square.HasTile; }
public bool CanCreateTexture(Square square) { return square.HasTile && !square.IsSelected; }
public bool CanCreateTexture(Square square) { return square.HasTile && (square.IsSelected || square.IsMainSelection); }