예제 #1
0
        public Tile[,] tileMap(int[,] thisMap)
        {
            Tile[,] tiledMap = new Tile[thisMap.GetUpperBound(0), thisMap.GetUpperBound(1)];
            Rectangle tileTemplate = new Rectangle(0, 0, (int)GlobalDictionaries.standardTileSize.X, (int)GlobalDictionaries.standardTileSize.Y);

            for (int controlVar1 = 0; controlVar1 <= thisMap.GetUpperBound(0); controlVar1++)
            {
                for (int controlVar2 = 0; controlVar2 <= thisMap.GetUpperBound(1); controlVar2++)
                {
                    int tileTextureID = thisMap[controlVar1, controlVar2];
                    bool? isTileOpaque = null;
                    if (!GlobalDictionaries.tilesYouCanWalkOn.Contains(tileTextureID))
                    {
                        isTileOpaque = true;
                    }
                    else
                    {
                        isTileOpaque = false;
                    }
                    Tile tempTile = new Tile(tileTemplate, tileTextureID, isTileOpaque);
                    tiledMap[controlVar1, controlVar2] = tempTile;
                    tileTemplate.X += 32;
                    Debug.WriteLine("Tile value " + tileTextureID + " loaded at " + tileTemplate.X + ", " + tileTemplate.Y + ".");
                }
                tileTemplate.X = 0;
                tileTemplate.Y += 32;
            }
            return tiledMap;
        }
예제 #2
0
        public List<Tile> tileMap(Dictionary<int, Texture2D> tileCatalogue, Dictionary<int, Texture2D> itemCatalogue)
        {
            Rectangle tempRect = new Rectangle(0, 0, 32, 32);

            for (int controlVar1 = 0; controlVar1 <= masterMapArray.GetUpperBound(0); controlVar1++)
            {
                for (int controlVar2 = 0; controlVar2 <= masterMapArray.GetUpperBound(1); controlVar2++)
                {
                    int tempValue = masterMapArray[controlVar1, controlVar2];
                    Tile tempTile = new Tile(tempRect, tempValue, false);
                    this.masterTiledMapArray[controlVar1, controlVar2] = tempTile;
                    this.thisMap.Add(tempTile);
                    if (!tilesThatCanBeWalkedOn.Contains(tempValue))
                    {
                        wallTilesInMap.Add(tempRect);
                    }
                    else
                    {
                        floorTilesInMap.Add(tempRect);
                        tempTile.tileItemPosition = new Rectangle(tempTile.tilePosition.X + 4, tempTile.tilePosition.Y + 4, 24, 24);
                        //tempTile.addItemToTile(99902);
                    }
                    tempRect.X += 32;
                    Debug.WriteLine("Tile value " + tempValue + " loaded at " + tempRect.X + ", " + tempRect.Y + ".");
                }

                tempRect.X = 0;
                tempRect.Y += 32;
            }

            return thisMap;
        }