コード例 #1
0
ファイル: StaticObject.cs プロジェクト: reddogyy/Learning
 public StaticObject(int height, int width, Position position)
     : base(height, width, position)
 {
     this.Height = height;
     this.Width = width;
     this.Position = position;
 }
コード例 #2
0
ファイル: Tank.cs プロジェクト: reddogyy/Learning
 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();
 }
コード例 #3
0
ファイル: Map.cs プロジェクト: reddogyy/Learning
 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);
 }
コード例 #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';
         }
     }
 }
コード例 #5
0
 private static void MoveObject(char[,] obj, Position position, Position newPos)
 {
     PlaceObjectOnField(obj, newPos);
 }
コード例 #6
0
        private static bool IsFreeSpace (Position position)
        {
            bool free = true;


            return free;
        }
コード例 #7
0
 private static bool isInField (Position position)
 {
     return (position.X >= 0 && position.Y >= 0 && position.X <= CONSOLE_HEIGHT && position.Y <= CONSOLE_WIDTH);            
 }
コード例 #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);
        }