StdPaint.ConsoleBuffer.GetUnitAttributes C# (CSharp) Method

GetUnitAttributes() public method

Returns the attributes for the specified unit.
public GetUnitAttributes ( int x, int y ) : BufferUnitAttributes
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
return BufferUnitAttributes
        public BufferUnitAttributes GetUnitAttributes(int x, int y)
        {
            var attrs = BufferUnitAttributes.None;
            if (InBounds(x,y))
            {
                attrs = (BufferUnitAttributes)_buffer[y, x]._attrs;
            }
            return attrs;
        }

Usage Example

Esempio n. 1
0
 static int CountNeighbors(ConsoleBuffer buffer, int x, int y)
 {
     return (buffer.GetUnitAttributes(x - 1, y) != black ? 1 : 0) +
            (buffer.GetUnitAttributes(x + 1, y) != black ? 1 : 0) +
            (buffer.GetUnitAttributes(x - 1, y + 1) != black ? 1 : 0) +
            (buffer.GetUnitAttributes(x + 1, y + 1) != black ? 1 : 0) +
            (buffer.GetUnitAttributes(x - 1, y - 1) != black ? 1 : 0) +
            (buffer.GetUnitAttributes(x + 1, y - 1) != black ? 1 : 0) +
            (buffer.GetUnitAttributes(x, y + 1) != black ? 1 : 0) +
            (buffer.GetUnitAttributes(x, y - 1) != black ? 1 : 0);
 }