public Tile addTile(string tileName) { Tile t = new Tile(tileName, content); tiles.Add(t); return t; }
private void duplicateTile() { if (getTileAtMouse() != null) { xnaContext.placeTile(currTile); currTile = xnaContext.addTile(currTile.type); } }
//This function should be called when placing a tile. It will overwrite // Anything that currently occupies that position. public void placeTile(Tile entry) { int latestIndex = tiles.IndexOf(entry); if (entry == null) { return; } /* for (int i = currentState; i < 11; i++) { states[i].Clear(); }*/ if (currentState == 11) { states.RemoveAt(0); states.Add(new List<Tile>()); currentState--; } else if (currentState == states.Count) { states.Add(new List<Tile>()); } states[currentState].Clear(); foreach (Tile t in tiles) { if (tiles.IndexOf(t) != latestIndex) { states[currentState].Add(t); } } currentState++; foreach (Tile current in tiles) { if (current.pos == entry.pos && tiles.IndexOf(current) != latestIndex) { tiles.Remove(current); break; } } }
public void removeTile(Tile currTile) { foreach (Tile t in tiles) { if (t.Equals(currTile)) { tiles.Remove(currTile); break; } } }
private void frownyButton_Click(object sender, EventArgs e) { currTile = xnaContext.addTile("frowny"); // xnaContext.undo(); // Set XNA context to focus so that duplication works this.xnaContext.Focus(); }
void xnaContext_KeyUp(object sender, KeyEventArgs e) { int DELETE_KEY = 46; if (e.KeyValue == DELETE_KEY) { xnaContext.removeTile(currTile); currTile = null; } }
private void xnaContext_Click(object sender, System.EventArgs e) { if (currTile == null) { currTile = getTileAtMouse(); } else { xnaContext.placeTile(currTile); currTile = null; } this.xnaContext.Focus(); }
private void tileSelector_SelectedIndexChanged(object sender, EventArgs e) { if (this.tileSelection.SelectedIndex != -1) { String selected = ((TileTypes)this.tileSelection.SelectedItem).FileName; currTile = this.xnaContext.addTile(selected); } }