Data class for maps.
Ejemplo n.º 1
0
        public TileMap(int x, int y, int size, int xtiles, int ytiles, Texture2D pixel, ToolMap tools, SpriteFont font, String filename)
        {
            this.hasmonsters = false;
            this.lastspawnedmonster = 0;
            this.filename = filename;
            this.toolmap = tools;
            this.size = size;
            this.xtiles = xtiles;
            this.ytiles = ytiles;
            this.font = font;
            double tss = VIEW_HEIGHT / size;
            int tilesidesize = (int)Math.Floor(tss);
            totalmapsize = tilesidesize * size;
            curxtilemin = 0;
            curytilemin = 0;
            battlemap = Map.BATTLE_GENERIC;

            //int curtoolx = tools.Length-1;
            //int curtooly = tools[0].Length-1;

            pixelsperside = tilesidesize;
            center = (int)Math.Ceiling(size / 2.0);
            displaytiles = new Rectangle[size][];
            monstertiles = new List<Tile>();
            npctiles = new Dictionary<String, Tile>();
            for (int i = 0; i < size; i++)
            {
                displaytiles[i] = new Rectangle[size];
                for (int j = 0; j < size; j++)
                {
                    displaytiles[i][j] = new Rectangle(x + i*tilesidesize, y + j*tilesidesize, pixelsperside, pixelsperside);
                }
            }

            //Random randval = new Random();

            map = new Tile[xtiles][];

            for (int i = 0; i < xtiles; i++)
            {
                map[i] = new Tile[ytiles];
                for (int j = 0; j < ytiles; j++)
                {
                    //int currandx = randval.Next(0, 2);
                    //int currandy = randval.Next(0, 3);
                    map[i][j] = new Tile(i, j, (x + i * tilesidesize), (y + j * tilesidesize), tilesidesize, toolmap.getDefaultTool());
                }
            }
        }
Ejemplo n.º 2
0
 private static MapAttribute GetAttribute(Map p)
 {
     return (MapAttribute)Attribute.GetCustomAttribute(ForValue(p), typeof(MapAttribute));
 }
Ejemplo n.º 3
0
 private static MemberInfo ForValue(Map p)
 {
     return typeof(Map).GetField(Enum.GetName(typeof(Map), p));
 }