예제 #1
0
    public MyArea(MyVector2 dimensions, int spriteIndex, MyRect spriteRect, params MyColor[] colors)
    {
        _colors         = colors;
        Dimensions      = dimensions;
        Correlations    = new ConcurrentDictionary <int, MyAreaCoordinates>();
        CorrelationsBag = new ConcurrentBag <MyAreaCoordinates>();

        OpaquePixelsCount = 0;
        _hash             = 0;
        for (int i = 0; i < _colors.Length; i++)
        {
            if (_colors[i].A > 0f)
            {
                OpaquePixelsCount++;
            }
            _hash += (i + 1) * _colors[i].GetHashCode() * short.MaxValue;
        }
        _hash += dimensions.GetHashCode();
        _hash += spriteIndex.GetHashCode();
        _hash += spriteRect.GetHashCode();
        _hash += OpaquePixelsCount.GetHashCode();

        Score = (long)(Mathf.Pow(OpaquePixelsCount, 3f) / Dimensions.Square);

        SpriteIndex = spriteIndex;
        SpriteRect  = spriteRect;

        UniqueString = _hash.ToString();
    }