Game Development Reference
In-Depth Information
private void DoJob1()
{
//Do some filing
}
private void DoJob2()
{
//Make coffee for the office
}
private void DoJob3()
{
//Stick it to the man
}
}
You can achieve the same output but with more flexibility by using the following code:
//A more intelligent WorkerManager
public class WorkerManager2
{
//WorkerManager delegate
delegate void MyDelegateHook();
MyDelegateHook ActionsToDo;
public string WorkerType = "Peon";
//On Startup, assign jobs to the worker; note this is
//configurable instead of fixed
void Start()
{
//Peons get lots of work to do
if (WorkerType == "Peon")
{
ActionsToDo += DoJob1;
ActionsToDo += DoJob2;
}
//Everyone else plays golf
else
Search WWH ::




Custom Search