Esempio n. 1
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);
        }
Esempio n. 2
0
        private Tile addToBestPath(List<Tile> bestpath, Tile toadd, Tile prev)
        {
            int x = toadd.getX();
            int y = toadd.getY();
            int mapx = toadd.getMapX();
            int mapy = toadd.getMapY();
            int len = toadd.getLength();

            if(DEBUG)
            Console.WriteLine("Adding tile at (" + mapx + "," + mapy + ") to bestpath! Cost is " + toadd.getTotalCost());

            Tile newadd = new Tile(mapx, mapy, x, y, len, astarwaypoint, Color.White);
            newadd.setPrevious(prev);
            bestpath.Add(newadd);
            return newadd;
        }