Ejemplo n.º 1
0
 public StaticObject(int height, int width, Position position)
     : base(height, width, position)
 {
     this.Height = height;
     this.Width = width;
     this.Position = position;
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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';
         }
     }
 }
Ejemplo n.º 5
0
 private static void MoveObject(char[,] obj, Position position, Position newPos)
 {
     PlaceObjectOnField(obj, newPos);
 }
Ejemplo n.º 6
0
        private static bool IsFreeSpace (Position position)
        {
            bool free = true;


            return free;
        }
Ejemplo n.º 7
0
 private static bool isInField (Position position)
 {
     return (position.X >= 0 && position.Y >= 0 && position.X <= CONSOLE_HEIGHT && position.Y <= CONSOLE_WIDTH);            
 }
Ejemplo n.º 8
0
        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);
        }