Beispiel #1
0
        public TileMap(int x, int y, int size, Texture2D pixel, Tool initial)
        {
            this.size = size;
            double tss = MAP_HEIGHT / size;
            int tilesidesize = (int)Math.Floor(tss);
            pixelsperside = tilesidesize;

            map = new Tile[size][];

            for (int i = 0; i < size; i++)
            {
                map[i] = new Tile[size];
                for (int j = 0; j < size; j++)
                {
                    map[i][j] = new Tile(i, j, (x + i * tilesidesize), (y + j * tilesidesize), tilesidesize, initial);
                }
            }
        }
Beispiel #2
0
        public ToolMap(int x, int y, Texture2D pixel, Tool[][] tooltextures, SpriteFont font)
        {
            this.pixel = pixel;
            this.font = font;
            /*Color[] colors = new Color[]{Color.White, Color.Red, Color.Goldenrod,
                Color.Green, Color.Blue, Color.Chocolate, Color.Orange, Color.DarkGray,
            Color.Purple, Color.Black};
            */
            xmin = x;
            ymin = y;

            int[] col = {x,x+90};
            xmax = col[1] + 32;
            int yinterval = 44;
            ymax = y + 3 * yinterval + 32;

            xcolwidth = (xmax - xmin) / 2;
            yrowheight = (ymax - ymin) / 4;

            tools = new Tile[2][];
            for(int j = 0; j < col.Length; j++)
            {
                tools[j] = new Tile[4];
                for (int i = 0; i < 4; i++)
                {
                    tools[j][i] = new Tile(j, i, col[j] + 1, 1 + y + yinterval * i, 32, tooltextures[j][i]);
                }

            }
            selected = tools[0][0];
            selectedtop = new Rectangle(-40,-40,36,2);
            selectedbottom = new Rectangle(-40,-40,36,2);
            selectedleft = new Rectangle(-40,-40,2,36);
            selectedright = new Rectangle(-40,-40,2,36);
            updateSelected(selected.getX(), selected.getY(), selected.getLength(), selected.getLength());

            astarbutton = new Rectangle(xmin, ymax + 40, 122, 30);
            playbutton = new Rectangle(xmin, ymax + 90, 122, 30);
        }
Beispiel #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            whitepixel  = new Texture2D(GraphicsDevice, 1, 1);
            whitepixel.SetData(new Color[] { Color.White });

            astarwaypoint = Content.Load<Texture2D>("AStarWayPoint");
            edited = true;

            font = Content.Load<SpriteFont>("gameFont");

            tools = new Tool[2][];
            tools[0] = new Tool[4];
            tools[1] = new Tool[4];

            tools[0][0] = new Tool(TileType.GRASS, Content.Load<Texture2D>("Grass"), false, 1);
            tools[0][1] = new Tool(TileType.TREES, Content.Load<Texture2D>("Trees"), false, 2);
            tools[0][2] = new Tool(TileType.SWAMP, Content.Load<Texture2D>("Swamp"), false, 4);
            tools[0][3] = new Tool(TileType.PLAYER, Content.Load<Texture2D>("Player"), false, 0);
            tools[1][0] = new Tool(TileType.WATER, Content.Load<Texture2D>("Water"), false, 6);
            tools[1][1] = new Tool(TileType.ROCKS, Content.Load<Texture2D>("LavaRocks"), false, 8);
            tools[1][2] = new Tool(TileType.WALL, Content.Load<Texture2D>("Wall"), true, 0);
            tools[1][3] = new Tool(TileType.MONSTER, Content.Load<Texture2D>("Monster"), false, 0);

            map = new TileMap(10, 10, 16, whitepixel, tools[0][0]);
            toolmap = new ToolMap(578, 100, whitepixel, tools, font);
            // TODO: use this.Content to load your game content here
        }