Created
January 14, 2014 12:49
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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