using System;
using RidR;
namespace RidR.Extensions
{
///
/// This class contains extension methods for types used in the RidR game.
///
public static class RidRExtensions
{
///
/// Removes an element from an array at the speciefied index.
///
/// The type of the array.
/// The array to remove an element from.
/// The index of the element to remove.
public static T[] RemoveAt(this T[] source, int index)
{
T[] dest = new T[source.Length - 1];
if (index > 0)
Array.Copy(source, 0, dest, 0, index);
if (index < source.Length - 1)
Array.Copy(source, index + 1, dest, index, source.Length - index - 1);
return dest;
}
///
/// Converts the value of this instance to its equivalent character representation.
///
public static char toChar(this TileType tile)
{
switch (tile)
{
case TileType.Floor:
return 'F';
case TileType.Rift:
return 'R';
case TileType.Wall:
return 'W';
case TileType.Crystal:
return 'C';
default:
throw new ArgumentException("No valid TileType was provided.");
}
}
}
}