public StaticObject(int height, int width, Position position) : base(height, width, position) { this.Height = height; this.Width = width; this.Position = position; }
public Tank(int height, int width, Position position, TankTypes type) : base(height, width, position) { this.Height = height; this.Width = width; this.Position = position; this.Type = type; MakeSuit(); }
public void PlaceObject(Position position, WorldObject obj) { UI.ConsoleHelper.ClearAndResetConsole(); UI.ConsoleHelper.WriteOnPosition(obj.Suit.StringRepresentation, position.X, position.Y, obj.Suit.ForegroundColor, obj.Suit.BackgroundColor); }
private static void RemoveObject(Position position, int height, int width) { int currentX = position.X; int currentY = position.Y; for (int i = currentX; i < currentX + height; i++) { for (int j = currentY; j < currentY + width; j++) { field[i, j] = '\0'; } } }
private static void MoveObject(char[,] obj, Position position, Position newPos) { PlaceObjectOnField(obj, newPos); }
private static bool IsFreeSpace (Position position) { bool free = true; return free; }
private static bool isInField (Position position) { return (position.X >= 0 && position.Y >= 0 && position.X <= CONSOLE_HEIGHT && position.Y <= CONSOLE_WIDTH); }
private static void PlaceObjectOnField(char[,] obj, Position position) { if (!isInField(position)) throw new Exception("Trying to place object outside field: " + position.X + " " + position.Y); //if (!IsFreeSpace(position)) throw new Exception("Trying to place object on occupied space: " + position.X + " " + position.Y); // This may not be needed cause there is CollisionDetection int rows = obj.GetLength(0); int cols = obj.GetLength(1); int currentX = position.X; int currentY = position.Y; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { field[currentX, currentY] = obj[i, j]; currentY++; } currentY = position.Y; currentX++; } //Basic.UI.ConsoleHelper.WriteOnPosition(obj, position.X, position.Y); if (!movableObjectsOnField.ContainsKey(obj)) movableObjectsOnField.Add(obj, new Position(position.X, position.Y)); else movableObjectsOnField[obj] = new Position(position.X, position.Y); }