Esempio n. 1
0
 public void SetTileInfoAtWorldPos(Vector2 worldPosition, TileInfo tileInfo)
 {
     Vector2 tilePos = WorldPosToTilePos(worldPosition);
     SetTileInfoAtTilePos((int)tilePos.Y, (int)tilePos.X, tileInfo);
 }
Esempio n. 2
0
        private void createTiles(int[] tileTypeIndices)
        {
            for (int i = 0; i < TilesDown; i++)
            {
                for (int j = 0; j < TilesAcross; j++)
                {
                    TileInfo curTileInfo = new TileInfo();
                    curTileInfo.Position = new Vector2(j * TileSize.X, i * TileSize.Y);

                    int curIdx = (i * TilesAcross) + j;
                    TileType curTileType = (TileType)tileTypeIndices[curIdx];

                    if (curTileType == TileType.Wall)
                    {
                        // Create a Wall and register it with the WallManager.
                        Wall curWall = new Wall();
                        curWall.TopLeftPixel = curTileInfo.Position;
                        curWall.BottomRightPixel = curTileInfo.Position + TileSize;
                        WallManager.Instance.AddWall(curWall);

                        curTileInfo.Type = TileType.Wall;
                    }
                    else if (curTileType == TileType.Bush)
                    {
                        Vector2 bushPos = curTileInfo.Position + TileSize / 2;
                        bushes.Add(bushPos);

                        curTileInfo.Type = TileType.Bush;
                    }
                    else
                        curTileInfo.Type = TileType.Ground;

                    mapTiles.Add(curTileInfo);
                }
            }
        }
Esempio n. 3
0
        public void SetTileInfoAtTilePos(int row, int col, TileInfo tileInfo)
        {
            if (col < 0 || col >= TilesAcross)
                throw new System.InvalidOperationException("There are "
                    + TilesAcross + " tiles across and " + col + " was "
                    + " passed in for col.");

            if (row < 0 || row >= TilesDown)
                throw new System.InvalidOperationException("There are "
                    + TilesDown + " tiles down and " + row + " was "
                    + " passed in for row.");

            int tileIdx = (row * TilesAcross) + col;
            mapTiles[tileIdx] = tileInfo;
        }