public ToolMap(int x, int y, Texture2D pixel, Dictionary<String,Texture2D> texmap, WorldTile[] tiles, SpriteFont font, IntPtr handle) { this.handle = handle; combobox = new System.Windows.Forms.ComboBox(); combobox.Location = new System.Drawing.Point(542, 50); combobox.Size = new System.Drawing.Size(200, 25); combobox.BackColor = System.Drawing.Color.White; combobox.ForeColor = System.Drawing.Color.Black; combobox.SelectedIndexChanged += new System.EventHandler(ComboBox1_SelectedIndexChanged); this.texmap = texmap; 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; toolmap = new Dictionary<WorldTile, Tool>(); for (int i = 0; i < tiles.Length; i++) { if (tiles[i] != WorldTile.SELECT) { try { toolmap.Add(tiles[i], new Tool(tiles[i], texmap[tiles[i].GetTexture()])); } catch (KeyNotFoundException e) { } } } for (int i = 0; i < tiles.Length; i++) combobox.Items.Add(tiles[i]); /*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 = null; 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()); addeventbutton = new Rectangle(xmin, ymax, 142, 30); editbutton = new Rectangle(xmin, ymax + 10, 122, 30); astarbutton = new Rectangle(xmin, ymax + 60, 122, 30); playbutton = new Rectangle(xmin, ymax + 110, 122, 30); savebutton = new Rectangle(xmin, ymax + 160, 122, 30); loadbutton = new Rectangle(xmin, ymax + 210, 122, 30); }
public void addNPC(String id, int x, int y, Tool tool) { if(!npctiles.ContainsKey(id)) npctiles.Add(id, new Tile(x, y, 0, 0, 0, tool)); }
public GameState Update(GameState current) { GameState ret = current; if (enabled) { MouseState mouseState = Mouse.GetState(); int mousex = mouseState.X; int mousey = mouseState.Y; Object selectedobj = combobox.SelectedItem; if (selectedobj != null) { WorldTile select = (WorldTile)selectedobj; if (select != WorldTile.SELECT) { Texture2D seltex = texmap[select.GetTexture()]; selected = new Tool(select, seltex); } else selected = new Tool(select, null); } if (selectedtile != null && (mousex >= addeventbutton.X && mousex <= (addeventbutton.X + addeventbutton.Width)) && (mousey >= addeventbutton.Y && mousey <= (addeventbutton.Y + addeventbutton.Height)) && (mouseState.LeftButton == ButtonState.Pressed)) { updateSelected(addeventbutton.X, addeventbutton.Y, addeventbutton.Width, addeventbutton.Height); ret = GameState.ADDEVENT; } if ((mousex >= editbutton.X && mousex <= (editbutton.X + editbutton.Width)) && (mousey >= editbutton.Y && mousey <= (editbutton.Y + editbutton.Height)) && (mouseState.LeftButton == ButtonState.Pressed)) { updateSelected(editbutton.X, editbutton.Y, editbutton.Width, editbutton.Height); ret = GameState.EDIT; } if ((mousex >= astarbutton.X && mousex <= (astarbutton.X + astarbutton.Width)) && (mousey >= astarbutton.Y && mousey <= (astarbutton.Y + astarbutton.Height)) && (mouseState.LeftButton == ButtonState.Pressed)) { updateSelected(astarbutton.X, astarbutton.Y, astarbutton.Width, astarbutton.Height); ret = GameState.ASTAR; } if ((mousex >= playbutton.X && mousex <= (playbutton.X + playbutton.Width)) && (mousey >= playbutton.Y && mousey <= (playbutton.Y + playbutton.Height)) && (mouseState.LeftButton == ButtonState.Pressed)) { updateSelected(playbutton.X, playbutton.Y, playbutton.Width, playbutton.Height); disable(); Game1.playstate = PlayState.WORLD; ret = GameState.RUNNING; } if ((mousex >= savebutton.X && mousex <= (savebutton.X + savebutton.Width)) && (mousey >= savebutton.Y && mousey <= (savebutton.Y + savebutton.Height)) && (mouseState.LeftButton == ButtonState.Pressed)) { updateSelected(savebutton.X, savebutton.Y, savebutton.Width, savebutton.Height); ret = GameState.SAVEMAP; } if ((mousex >= loadbutton.X && mousex <= (loadbutton.X + loadbutton.Width)) && (mousey >= loadbutton.Y && mousey <= (loadbutton.Y + loadbutton.Height)) && (mouseState.LeftButton == ButtonState.Pressed)) { updateSelected(loadbutton.X, loadbutton.Y, loadbutton.Width, loadbutton.Height); ret = GameState.LOADMAP; } if (ret != current) Console.WriteLine("Game state set to " + ret); } return ret; }