예제 #1
0
    public int RawIndexFor(int rawIndex, CellOffset offset)
    {
        int currentX = XForRawIndex(rawIndex);
        int currentY = YForRawIndex(rawIndex);

        int adjacentOffsetX = offset.XFrom(currentX);
        int adjacentOffsetY = offset.YFrom(currentY);

        int adjustedX = WrappedIndexFor(adjacentOffsetX, columnCount);
        int adjustedY = WrappedIndexFor(adjacentOffsetY, rowCount);

        // Debug.Log("RawIndexFor:");
        //Debug.Log("index: " + rawIndex + " currentX: " + currentX + " currentY: "+ currentY +" xOffset: " + offset.xOffset + " yOffset: " + offset.yOffset + " adjustedX: " + adjustedX + " adjustedY: " + adjustedY);

        return(RawIndexFor(adjustedX, adjustedY));
    }
    public void SetBrushAt(int x, int y, CellOffset[] brush)
    {
        for (int i = 0; i < brush.Length; i++)
        {
            CellOffset tempOffset = brush[i];

            int newX = tempOffset.XFrom(x);
            int newY = tempOffset.YFrom(y);

            int newRawIndex = _indexer.RawIndexFor(newX, newY);
            if (newRawIndex < _conwayState.Length)
            {
                _conwayState[newRawIndex] = true;
            }
        }
    }