Example #1
0
 /// <summary>
 /// Draw the GameObject at its isometric location
 /// </summary>
 public void DrawIsometric(GameTime gameTime, SpriteBatchIsometric spriteBatch)
 {
     spriteBatch.DrawIsometric(
         _texture,
         _parent.Displacement,
         _drawColor);
 }
Example #2
0
        public void Draw(GameTime gameTime, SpriteBatchIsometric spriteBatch)
        {
            // ---------- Draw all tiles ----------
            for (int i = 0; i < _numRows; i++)
                for (int j = 0; j < _numCols; j++)
                {
                    TileRef currTile = _tiles[i, j];

                    Vector3 tilePosition;
                    tilePosition.X = i * TILE_SIZE;
                    tilePosition.Y = currTile.Elevation * TILE_SIZE;
                    tilePosition.Z = j * TILE_SIZE;

                    spriteBatch.DrawIsometric(
                        TileTypes[currTile.ReferenceID].Texture,
                        tilePosition,
                        Color.White);
                }

            // ---------- Draw selection indicators ----------
            if (_selectedIndices.Count != 0)
            {
                foreach (Vector2 index in _selectedIndices)
                {
                    int x = (int)index.X;
                    int y = (int)index.Y;
                    TileRef currTile = _tiles[x, y];

                    Vector3 drawPosition;
                    drawPosition.X = x * TILE_SIZE;
                    drawPosition.Y = currTile.Elevation * TILE_SIZE;
                    drawPosition.Z = y * TILE_SIZE;

                    spriteBatch.DrawIsometric(
                        _selectionTextureDraw,
                        drawPosition,
                        _selectionColorDraw);
                }
            }
            else
            {
                if (VerifyIndexWithinRange(_currentMouseTileIndex))
                {
                    TileRef mouseTile = _tiles[(int)_currentMouseTileIndex.X, (int)_currentMouseTileIndex.Y];
                    Vector3 drawPosition;
                    drawPosition.X = _currentMouseTileIndex.X * TILE_SIZE;
                    drawPosition.Y = mouseTile.Elevation * TILE_SIZE;
                    drawPosition.Z = _currentMouseTileIndex.Y * TILE_SIZE;

                    spriteBatch.DrawIsometric(
                        _selectionTextureDraw,
                        drawPosition,
                        _selectionColorDraw);
                }
            }
        }