Please make sure you’re using code tags Using code tags properly
The inline code tags are better than nothing, but inserting the code makes it a lot easier to read.
Let me know if you have any questions.
public MainClass : MonoBehaviour
{
List<Unit> units = new List<Unit>(); //https://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.90).aspx
//http://www.tutorialsteacher.com/csharp/csharp-list
Awake()//Or Start() https://unity3d.com/learn/tutorials/topics/scripting/awake-and-start
{
units.Add(new Haverster());
units.Add(new Fighter());
}
Update()
{
foreach(Unit u in units)
{
u.PerformAction();
}
}
}
public class Unit
{
abstract public void PerformAction();
//https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/abstract
}
public class Harvester : Unit
{
override public void PerformAction()
{
//DO HARVESTER STUFF
//Walk 3 tiles
//collect resource
}
}
public class Fighter : Unit
{
override public void PerformAction()
{
//DO FIGHTER STUFF
//walk 10 tiles
//fight enemy
}
}
Quick mock code may or may not have the correct capitlization and spelling