public Map(int dimX, int dimY, Cell defaultCell) { map = new Cell[dimX, dimY]; for (int i = 0; i < dimX; i++) { for (int j = 0; j < dimY; j++) { map[i, j] = (Cell)defaultCell.Clone(); } } }
private void btnOK_Click(object sender, EventArgs e) { string name = txtName.Text; int temp = (int)nudTemp.Value; Image image = pboxImage.Image; bool isHole = chkHole.Checked; bool isLiquid = chkLiquid.Checked; Cell cell = new Cell(name, temp, image, isHole, isLiquid); if (cellEditing == null) { cellList.Add(cell); } else { cellEditing.Name = cell.Name; cellEditing.Image = cell.Image; cellEditing.IsHole = cell.IsHole; cellEditing.Temperature = cell.Temperature; cellEditing.IsLiquid = cell.IsLiquid; } }
public InteractionEventArgs(Cell happenedAt, Item happenedTo) { if (happenedTo != null) { string who = happenedTo.Name; string action = ""; string where = happenedAt.Name; if (happenedAt.IsHole) { if (happenedTo.CanFillHoles) action = "fills"; else action = "falls in"; } else if (happenedAt.Temperature >= happenedTo.TempToMelt) action = "melts in"; else if (happenedAt.IsLiquid && !happenedTo.Floats){ action = "sinks in"; } if (action != "") this.EventDescription = string.Format("{0} {1} {2}", who, action, where); else this.EventDescription = InteractionEventArgs.NothingHappened; } else { this.EventDescription = InteractionEventArgs.NothingHappened; } }
// Para modificar una celda del mapa public DlgEditCell(Cell cellToEdit) { cellEditing = cellToEdit; InitializeComponent(); }