public void Offset(OffsetTypes offsetType, params float[] offsets) { var result = Transformer2D.Offset(offsets, new IDot[] { StartPoint, EndPoint }); StartPoint = result[0]; EndPoint = result[1]; }
protected CentreLineOffset(double distance, SidesOfCentre side, OffsetTypes type) { DistanceFromCentre = distance; Side = side; OffsetType = type; Curves = new PersistentObjectIdCollection(); }
public void Offset(OffsetTypes offsetType, params float[] offsets) { var result = new IDot[2]; switch (offsetType) { case OffsetTypes.Usual: { result = Transformer3D.Offset(offsets, new IDot[] { StartPoint, EndPoint }); break; } case OffsetTypes.MatrixOffset: { result = Transformer3D.Action(offsets, new IDot[] { StartPoint, EndPoint }); break; } case OffsetTypes.HouseOffset: { result = Transformer3D.HomeMoving(offsets[0], offsets[1], offsets[2], new IDot[] { StartPoint, EndPoint }); break; } } StartPoint = result[0]; EndPoint = result[1]; StartPoint.Normalise(); EndPoint.Normalise(); }
public void Offset(OffsetTypes offsetType, params float[] offsets) { foreach (var i in Data) { i.Offset(offsetType, offsets); } }
public Coordinate2D To2D(OffsetTypes offsetType) { int col, row; switch (offsetType) { case OffsetTypes.OddRowsRight: col = X + (Z - Z % 2) / 2; row = Z; return(new Coordinate2D(col, row, offsetType)); case OffsetTypes.EvenRowsRight: col = X + (Z + Z % 2) / 2; row = Z; return(new Coordinate2D(col, row, offsetType)); case OffsetTypes.OddColumnsDown: col = X; row = Z + (Z - Z % 2) / 2; return(new Coordinate2D(col, row, offsetType)); case OffsetTypes.EvenColumnsDown: col = X; row = Z + (Z + Z % 2) / 2; return(new Coordinate2D(col, row, offsetType)); default: throw new ArgumentOutOfRangeException(nameof(offsetType), offsetType, null); } }
public static void ResizeSquareGraph(Graph graph, OffsetTypes offsetType, int newWidth, int newHeight, TerrainType defaultTerrainType) { var offsetCoordinates = Coordinate3D.To2D(graph.GetAllCellsCoordinates(), offsetType); var areCoordinatesInitialized = offsetCoordinates.Any(); var width = areCoordinatesInitialized ? offsetCoordinates.Select(item => item.X).Max() + 1 : 0; var height = areCoordinatesInitialized ? offsetCoordinates.Select(item => item.Y).Max() + 1 : 0; if (width > newWidth) { offsetCoordinates = Coordinate3D.To2D(graph.GetAllCellsCoordinates(), offsetType); var coordinatesToRemove = Coordinate2D.To3D(offsetCoordinates.Where(coordinate => coordinate.X >= newWidth).ToList()); graph.RemoveCells(coordinatesToRemove); } if (height > newHeight) { offsetCoordinates = Coordinate3D.To2D(graph.GetAllCellsCoordinates(), offsetType); var coordinatesToRemove = Coordinate2D.To3D(offsetCoordinates.Where(coordinate => coordinate.Y >= newHeight).ToList()); graph.RemoveCells(coordinatesToRemove); } if (newWidth > width) { var cellsToAdd = new List <CellState>(); // We'll add new columns width already updated height for (var x = width; x < newWidth; x++) { cellsToAdd.AddRange(CreateNewCellsForColumn(x, 0, newHeight, defaultTerrainType, offsetType)); } graph.AddCells(cellsToAdd); } if (newHeight <= height) { return; } { var cellsToAdd = new List <CellState>(); // New columns already will have correct height; So only old needs to be resized. for (var x = 0; x < width; x++) { cellsToAdd.AddRange(CreateNewCellsForColumn(x, height, newHeight, defaultTerrainType, offsetType)); } graph.AddCells(cellsToAdd); } }
public List <Coordinate2D> GetAllCellsCoordinates(OffsetTypes offsetType) { var result = PoolProvider.OffsetCoordinateListPool.Get(); var cells = GetAllCellsCoordinates(); Coordinate3D.To2D(cells, offsetType, result); ReturnListToPool(cells); return(result); }
public static Graph CreateRectangularGraph(int width, int height, MovementTypes movementTypes, TerrainType defaultTerrainType, OffsetTypes offsetType = OffsetTypes.OddRowsRight) { var graph = new Graph(new CellState[] { }.ToList(), movementTypes); GraphUtils.ResizeSquareGraph(graph, offsetType, width, height, defaultTerrainType); return(graph); }
public static List <Coordinate2D> To2D(List <Coordinate3D> coordinate3Ds, OffsetTypes offsetType, List <Coordinate2D> listToWriteTo = null) { if (listToWriteTo == null) { listToWriteTo = new List <Coordinate2D>(); } foreach (var coordinate3D in coordinate3Ds) { listToWriteTo.Add(coordinate3D.To2D(offsetType)); } return(listToWriteTo); }
public override void OnGUI(float width) { Vector2Int offset = m_Offset; GUILayout.Label("Offset :", GUILayout.Width(width)); GUILayout.BeginHorizontal(GUILayout.Width(width)); { m_Offset.x = EditorGUILayout.IntField("", m_Offset.x, GUILayout.Width(width / 2.0f - 2.0f)); GUILayout.FlexibleSpace(); m_Offset.y = EditorGUILayout.IntField("", m_Offset.y, GUILayout.Width(width / 2.0f - 2.0f)); } GUILayout.EndHorizontal(); GUILayout.Space(8.0f); OffsetTypes type = m_OffsetType; GUILayout.Label("Offset Type :"); m_OffsetType = (OffsetTypes)EditorGUILayout.EnumPopup(m_OffsetType, GUILayout.Width(width)); GUILayout.Space(8.0f); GUILayout.Label("Margin between repeats :"); Vector2Int margin = m_Margin; GUILayout.BeginHorizontal(GUILayout.Width(width)); { m_Margin.x = EditorGUILayout.IntField("", m_Margin.x, GUILayout.Width(width / 2.0f - 2.0f)); GUILayout.FlexibleSpace(); m_Margin.y = EditorGUILayout.IntField("", m_Margin.y, GUILayout.Width(width / 2.0f - 2.0f)); } GUILayout.EndHorizontal(); IsDirty = offset != m_Offset || type != m_OffsetType || margin != m_Margin; }
private byte[] CreateIndexedAddressingPostByte(OffsetTypes offsetType, char register, int incrementCount, bool negate, ushort offsetValue) { byte operand = 128; bool hasByteOperand = false; bool hasWordOperand = false; ushort wordOperand = 0; byte byteOperand = 0; ushort indexValue = 0; if (indexValue == 0) { operand = 132; } else if (indexValue > 0 && indexValue <= 16) { operand = (byte)indexValue; if (negate) { operand = ConvertToTwosCompliment(operand); operand = (byte)(operand & 0x1f); } } else if (indexValue >= 17 && indexValue <= 128) { operand = (byte)(operand | 8); byteOperand = (byte)(negate ? ConvertToTwosCompliment((byte)indexValue) : indexValue); hasByteOperand = true; } else if (indexValue >= 129) { operand = (byte)(operand | 9); wordOperand = negate ? ConvertToTwosCompliment(indexValue) : indexValue; hasWordOperand = true; } switch (register) { case 'X': operand = (byte)(operand & 0x9f); break; case 'Y': operand = (byte)(operand & 0xbf); break; case 'U': operand = (byte)(operand & 0xdf); break; case 'S': operand = (byte)(operand & 0xff); break; } if (incrementCount == 1) { operand = (byte)(operand & 0xe0); } else if (incrementCount == 2) { operand = (byte)(operand & 0xe0); operand = (byte)(operand | 0x01); } var retval = new byte[hasByteOperand ? 2 : hasWordOperand ? 3 : 1]; retval[0] = operand; if (hasByteOperand) { retval[1] = byteOperand; } if (hasWordOperand) { retval[1] = (byte)((wordOperand >> 8) & 0xFFu); retval[2] = (byte)(wordOperand & 0xFFu); } return retval; }
private static List <CellState> CreateNewCellsForColumn(int x, int oldY, int newY, TerrainType defaultTerrainType, OffsetTypes offsetType) { var newCells = new List <CellState>(); for (var y = oldY; y < newY; y++) { var position = new Coordinate2D(x, y, offsetType); var cubeCoordinate = position.To3D(); newCells.Add(new CellState(false, cubeCoordinate, defaultTerrainType)); } return(newCells); }
public Coordinate2D(int x, int y, OffsetTypes offsetType) { X = x; Y = y; OffsetType = offsetType; }