private ExplosionDirection ComputeExplosionSpriteDirections(Point cell)
{
int downCell = cell.Y + 1, leftCell = cell.X - 1, rightCell = cell.X + 1, upCell = cell.Y - 1;
// The middle
if (cell.X == CellPosition.X && cell.Y == CellPosition.Y)
return ExplosionDirection.Middle;
// ~ Vertical axis ~ //
if ((ActionField.Any(c => c.X == cell.X && c.Y == downCell)) ||
(ActionField.Any(c => c.X == cell.X && c.Y == upCell)))
{
// Top extremity
if (!ActionField.Any(c => c.X == cell.X && c.Y == upCell))
return ExplosionDirection.Up;
// Bottom extremity
if (!ActionField.Any(c => c.X == cell.X && c.Y == downCell))
return ExplosionDirection.Down;
// Vertical
return ExplosionDirection.Vertical;
}
// ~ Horizontal axis ~ //
if ((ActionField.Any(c => c.X == rightCell && c.Y == cell.Y)) ||
(ActionField.Any(c => c.X == leftCell && c.Y == cell.Y)))
{
// Left extremity
if (!ActionField.Any(c => c.X == leftCell && c.Y == cell.Y))
return ExplosionDirection.Left;
// Right extremity
if (!ActionField.Any(c => c.X == rightCell && c.Y == cell.Y))
return ExplosionDirection.Right;
// Left - Right
return ExplosionDirection.Horizontal;
}
Debug.Print("No sprite found for this case ! (" + cell.X + "," + cell.Y + ")");
// Error case
return ExplosionDirection.Middle;
}