/// <summary> /// Object-valued matrix. /// </summary> /// <param name="Values">Object value.</param> public ObjectMatrix(IElement[,] Values) { this.values = Values; this.elements = null; this.rows = Values.GetLength(0); this.columns = Values.GetLength(1); }
public bool VerificaParede(IElement[,] terreno, Veiculo motinha, int[,] sentido) { bool teste = true;; if (sentido[0, 1] > 0) // E { if (motinha.XPos + sentido[0, 1] * QuantidadeMov >= terreno.GetLength(1) - 1) { if (motinha is Escavadora) { terreno[YPos, XPos] = null; XPos = 1; terreno[YPos, XPos] = motinha; } teste = false; } } else if (sentido[0, 1] < 0) //W { if (motinha.XPos + sentido[0, 1] * QuantidadeMov <= 0) { if (motinha is Escavadora) { terreno[YPos, XPos] = null; XPos = terreno.GetLength(1) - 2; terreno[YPos, XPos] = motinha; } teste = false; } } if (sentido[1, 0] > 0) // S { if (motinha.YPos + sentido[1, 0] * QuantidadeMov >= terreno.GetLength(0) - 1) { if (motinha is Escavadora) { terreno[YPos, XPos] = null; YPos = 1; terreno[YPos, XPos] = motinha; } teste = false; } } else if (sentido[1, 0] < 0) // N { if (motinha.YPos + sentido[1, 0] * QuantidadeMov <= 0) { if (motinha is Escavadora) { terreno[YPos, XPos] = null; YPos = terreno.GetLength(0) - 2; terreno[YPos, XPos] = motinha; } teste = false; } } return(teste); }
public void SetVeiculo(IElement[,] terreno, Veiculo motinha) { rnd = new Random(); do { YPos = rnd.Next(1, terreno.GetLength(0) - 1); XPos = rnd.Next(1, terreno.GetLength(1) - 1); } while (terreno[YPos, XPos] != null); terreno[YPos, XPos] = motinha; }
public override string ToString() { var sb = new StringBuilder(); sb.Append("<" + this.Name + ">"); for (var i = 0; i < table.GetLength(0); i++) { sb.Append("<tr>"); for (var j = 0; j < table.GetLength(1); j++) { var elem = table[i, j]; sb.Append("<td>"); sb.Append(elem.ToString()); sb.Append("</td>"); } sb.Append("</tr>"); } sb.Append("</" + this.Name + ">"); return(sb.ToString()); }
public override void Render(StringBuilder output) { output.Append("<table>"); for (int row = 0; row < this.arr.GetLength(0); row++) { output.Append("<tr>"); for (int col = 0; col < arr.GetLength(1); col++) { output.AppendFormat("<td>{0}</td>", this.arr[row, col].ToString()); } output.Append("</tr>"); } output.Append("</table>"); }