public bool update(BGField field) { if (field.GetValueByPosition(left, top) != 3) { return(true); } field.SetValueAtPosition(left, top, 0); if (dir == 1) { top--; } if (dir == 2) { top++; } if (dir == 3) { left--; } if (dir == 4) { left++; } if (top == 20 || top == -1 || left == 10 || left == -1) { return(true); } field.SetValueAtPosition(left, top, 3); return(false); }
public bool IsCorrupted(BGField field) { if (field.GetValueByPosition(left, top) == 3) { return(true); } if (field.GetValueByPosition(left, top + 1) == 3) { return(true); } if (field.GetValueByPosition(left, top - 1) == 3) { return(true); } if (field.GetValueByPosition(left + 1, top) == 3) { return(true); } if (field.GetValueByPosition(left + 1, top + 1) == 3) { return(true); } if (field.GetValueByPosition(left + 1, top - 1) == 3) { return(true); } if (field.GetValueByPosition(left - 1, top) == 3) { return(true); } if (field.GetValueByPosition(left - 1, top + 1) == 3) { return(true); } if (field.GetValueByPosition(left - 1, top - 1) == 3) { return(true); } //for(int i = top - 1;i<=top+1;i++) //{ // for(int j = left - 1;j<=left+1;j++) // { // if (field.GetValueByPosition(left, top) == 3) // return true; // } //} return(false); }
private void Move(BGField field) { Draw(field, olddir, 0); if (dir == olddir) { if (dir == 1 && top - 1 != 0) { if (top - 1 >= 1 && field.GetValueByPosition(left, top - 2) != 1 && field.GetValueByPosition(left + 1, top - 2) != 1 && field.GetValueByPosition(left - 1, top - 2) != 1) { top--; } } if (dir == 2 && top + 1 != 19) { if (top + 1 <= 18 && field.GetValueByPosition(left, top + 2) != 1 && field.GetValueByPosition(left + 1, top + 2) != 1 && field.GetValueByPosition(left - 1, top + 2) != 1) { top++; } } if (dir == 3 && left - 1 != 0) { if (left - 1 >= 1 && field.GetValueByPosition(left - 2, top) != 1 && field.GetValueByPosition(left - 2, top + 1) != 1 && field.GetValueByPosition(left - 2, top - 1) != 1) { left--; } } if (dir == 4 && left + 1 != 9) { if (left + 1 <= 18 && field.GetValueByPosition(left + 2, top) != 1 && field.GetValueByPosition(left + 2, top + 1) != 1 && field.GetValueByPosition(left + 2, top - 1) != 1) { left++; } } Draw(field, dir, 1); } if (dir == 5) { Draw(field, olddir, 1); return; } Draw(field, dir, 1); }
private void PrintWall(BGField field) { int left = buffer[buffer.Count - 1], top = 0; buffer.RemoveAt(buffer.Count - 1); while (field.GetValueByPosition(left, top) == 2) { top++; } field.SetValueAtPosition(left, top, 2); }
static public bool IsCreateble(BGField field, int left, int top) { for (int i = left; i < left + 5; i++) { for (int j = top; j < top + 5; j++) { if (field.GetValueByPosition(i, j) != 0) { return(false); } } } return(true); }
public bool update(ConsoleKey key, BGField field, List <Arrow> Arrows) { int direction = 0; if (key == ConsoleKey.LeftArrow) { direction = 1; } if (key == ConsoleKey.RightArrow) { direction = 2; } if (direction == 1 && field.GetValueByPosition(left, top - 1) == 2) { return(true); } Move(direction, field, Arrows); return(false); }
public bool update(BGField field) { if (top == 0) { field.SetValueAtPosition(left, top, 0); return(true); } if (field.GetValueByPosition(left, top - 1) == 2) { field.SetValueAtPosition(left, top - 1, 0); field.SetValueAtPosition(left, top, 0); return(true); } else { field.SetValueAtPosition(left, top, 0); top--; field.SetValueAtPosition(left, top, 1); return(false); } }