示例#1
0
        public bool CheckCollision(Vector2Int position, Matrix4x4Bool blockStruct, out bool byBoundsHorizontal)
        {
            var bounds = blockStruct.GetBounds();

            byBoundsHorizontal = true;

            if (position.x < 0 || position.x + bounds.x > size.x)
            {
                return(true);
            }

            byBoundsHorizontal = false;

            if (position.y - bounds.y + 1 < 0)
            {
                return(true);
            }

            for (int i = 0; i < bounds.x; i++)
            {
                var currentColumnSize = blockStruct.GetRow(i).Max;

                for (int j = 0; j < currentColumnSize; j++)
                {
                    if (position.y - j >= size.y)
                    {
                        continue;
                    }

                    if (grid[position.x + i, position.y - j] && blockStruct[i, j])
                    {
                        return(true);
                    }
                }
            }


            return(false);
        }