Game Development Reference
In-Depth Information
void RobotRun()
{
Debug.Log("Robot running");
}
}
This means that when the DoRobotWalk method is called, it will set the delegate to the
Walk method, and once updated, it will run the Walk behavior. If you call the DoRo-
botRun public method, it will change the delegate to the Run behavior, and once up-
dated, it will run the Run behavior. This is a very simple kind of state machine with no
conditions around.
The delegation pattern
The delegation pattern is used where a method calls out to a helper library, and on com-
pletion of the required task, continues on back in the main function, as shown in the fol-
lowing diagram:
This is usually used with what you might download from the Web. When the download is
finished, we do something with what we have downloaded.
For instance, refer to the following code:
using System;
using System.Collections.Generic;
public class Delegates
{
public class Worker
{
List<string> WorkCompletedfor = new List<string>();
public void DoSomething(
string ManagerName,
Search WWH ::




Custom Search