/// <summary>
/// Click the box at the index.
/// </summary>
/// <param name="index">The index.</param>
protected override void ViewClicked(int index)
{
m_ViewDrawer.Click(index);
if (m_Elements.Count <= StartIndex + index) {
NotifyEmptyClicked(index);
return;
}
var selectedElements = GetElementAt(StartIndex + index);
NotifyElementClicked(index, selectedElements);
}
/// <summary>
/// Notifies that an element has been clicked in the grid.
/// </summary>
/// <param name="index">The index of the clicked element.</param>
/// <param name="selectedElements">The clicked element of type T.</param>
protected virtual void NotifyElementClicked(int index, T selectedElements)
{
OnElementClicked?.Invoke(selectedElements, index);
}
/// <summary>
/// Notifies that an empty grid slot has been clicked.
/// </summary>
/// <param name="index">The index of the empty slot that was clicked.</param>
protected virtual void NotifyEmptyClicked(int index)
{
OnEmptyClicked?.Invoke(index);
}