Skip to content

Instantly share code, notes, and snippets.

@FabienArcellier
Created January 14, 2014 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabienArcellier/8417801 to your computer and use it in GitHub Desktop.
Save FabienArcellier/8417801 to your computer and use it in GitHub Desktop.
This exemple not working. I try to implement a BOT engine in C# to understand what are good points and negative points. http://www.chris-granger.com/2012/12/11/anatomy-of-a-knockout/
Class Element : BotObject
{
Behavior={":black", ":next_click_white"}
}
class BlackBehavior
{
Trigger = {":click"},
Reaction( (o) => {
System.WriteLine("Noir")
})
}
class WhiteBehavior() {
Trigger = {":click"},
Reaction( (o) => {
System.WriteLine("Blanc")
})
}
class NextClickWhiteBehavior() {
Trigger = {":click"},
Reaction( (o) => {
o.RemoveBehavior(":black");
o.AddBehavior(":white");
o.RemoveBehavior(":next_click_white");
o.AddBehavior(":next_click_black");
})
}
class NextClickBlackBehavior() {
Trigger = {":click"},
Reaction( (o) => {
o.RemoveBehavior(":black");
o.AddBehavior(":white");
o.RemoveBehavior(":next_click_black");
o.AddBehavior(":next_click_white");
})
}
Behaviors behaviors = new Behaviors()
{
{":black", new BlackBehavior()},
{":white", new WhiteBehavior()},
{":next_click_white", new NextClickWhiteBehavior()},
{":next_click_black", new NextClickBlackBehavior()}
}
Component component = new BotObject()
{
Id=":app",
Components = new List<BotObject>() {
new BotObject() {
Id=":elt",
Trigger={":click"},
Behavior={":black", ":next_click_white"}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment