// When you use an interface, you can use two diferent objects to perform one
// action in common that executes diferently in each of theme.
Interface IDrivable {
void Drive(); //just the sentence
//....
}
// Examples of uses:
class Car1 : IDrivable
{
void Drive() {
//actions to drive the first Car
}
}
class Car2 : IDrivable
{
void Drive() {
//actions to drive the second Car
}
}
// In this example Car1 and Car2 are diferent classes and each of theme
// drives diferently, but can be used in something like this:
public IDrivable CarToDrive;
CarToDrive.Drive() // this executes Drive() in the selected car, no methers
// what car is.
using System.Linq;
...
var ss = FindObjectsOfType<MonoBehaviour>().OfType<IStats>();
foreach (IStats s in ss) {
enemies.Add (s);
}