本文整理汇总了C#中RelayTwo.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# RelayTwo.CreateTable方法的具体用法?C# RelayTwo.CreateTable怎么用?C# RelayTwo.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelayTwo
的用法示例。
在下文中一共展示了RelayTwo.CreateTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstantiateFromDatabase
public void InstantiateFromDatabase()
{
RelayTwo relay = new RelayTwo();
TableTwo table = relay.CreateTable(Ting.TABLE_NAME);
relay.CreateTable(Room.TABLE_NAME);
table.AddField<string>(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME);
table.AddField<string>("species");
table.AddField<string>("name");
table.AddField<int>("age");
int row0 = table.CreateRow().row;
int row1 = table.CreateRow().row;
table.SetValue(row0, RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Animal");
table.SetValue(row0, "species", "Monkey");
table.SetValue(row0, "name", "Herr Nilsson");
table.SetValue(row0, "age", 78);
table.SetValue(row1, RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Animal");
table.SetValue(row1, "species", "Horse");
table.SetValue(row1, "name", "Lilla Gubben");
table.SetValue(row1, "age", 50);
TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay));
Animal herrNilsson = tingRunner.GetTing("Herr Nilsson") as Animal;
Animal lillaGubben = tingRunner.GetTing("Lilla Gubben") as Animal;
Assert.IsNotNull(herrNilsson);
Assert.IsNotNull(lillaGubben);
Assert.AreEqual(78, herrNilsson.age);
Assert.AreEqual(50, lillaGubben.age);
}
示例2: AssertCommando
public void AssertCommando()
{
_lines = new List<string>();
s_pooWasCalledCorrectly = false;
RelayTwo relay = new RelayTwo();
relay.CreateTable(DialogueNode.TABLE_NAME);
DialogueRunner dialogueRunner = new DialogueRunner(relay, Language.DEFAULT);
dialogueRunner.AddOnSomeoneSaidSomethingListener(OnSomeoneSaidSomething);
dialogueRunner.AddExpression("Pass", Pass);
dialogueRunner.AddExpression("Fail", Fail);
DialogueScriptLoader scriptLoader = new DialogueScriptLoader(dialogueRunner);
scriptLoader.LoadDialogueNodesFromFile("../conversations/conversation16.dia");
DialogueScriptPrinter scriptPrinter = new DialogueScriptPrinter(dialogueRunner);
scriptPrinter.PrintConversation("conversation16");
Assert.Throws<GrimmAssertException>(() => {
dialogueRunner.StartConversation("conversation16");
for(int i = 0; i < 100; i++)
{
dialogueRunner.Update(1.0f);
}
});
Assert.AreEqual(4, _lines.Count);
Assert.AreEqual("hej1", _lines[0]);
Assert.AreEqual("", _lines[1]);
Assert.AreEqual("hej2", _lines[2]);
Assert.AreEqual("", _lines[3]);
}
示例3: InstantiateDialoguesFromDatabase
public void InstantiateDialoguesFromDatabase()
{
{
RelayTwo relay = new RelayTwo();
relay.CreateTable(DialogueNode.TABLE_NAME);
DialogueRunner runner = new DialogueRunner(relay, Language.SWEDISH);
TimedDialogueNode d1 = runner.Create<TimedDialogueNode>("c", Language.SWEDISH, "d1") as TimedDialogueNode;
d1.speaker = "A";
TimedDialogueNode d2 = runner.Create<TimedDialogueNode>("c", Language.SWEDISH, "d2");
d2.speaker = "B";
relay.SaveAll("conversation.xml");
}
{
RelayTwo relay = new RelayTwo();
relay.LoadAll("conversation.xml");
DialogueRunner runner = new DialogueRunner(relay, Language.SWEDISH);
TimedDialogueNode d1 = runner.GetDialogueNode("c", "d1") as TimedDialogueNode;
TimedDialogueNode d2 = runner.GetDialogueNode("c", "d2") as TimedDialogueNode;
Assert.AreEqual("A", d1.speaker);
Assert.AreEqual("B", d2.speaker);
}
}
示例4: CompileAndRun
public void CompileAndRun()
{
GameTypes.D.onDLog += Console.WriteLine;
output = new List<string>();
RelayTwo relay = new RelayTwo();
TableTwo programsTable = relay.CreateTable(Program.TABLE_NAME);
FunctionDefinition print = new FunctionDefinition("void", "print", new string[] { "string" }, new string[] { "s" }, API_print, FunctionDocumentation.Default());
Program p1 = new Program();
p1.CreateNewRelayEntry(programsTable, "Program");
p1.Init(new ProgramRunner(relay));
p1.sourceCodeContent = "print(42)";
p1.FunctionDefinitions.Add(print);
p1.Compile();
Assert.AreEqual(0, p1.GetErrors().Length);
for(int i = 0; i < 100; i++) {
if(p1.sprakRunner.interpreter != null) {
p1.Update(0.1f);
}
}
Assert.AreEqual(1, output.Count);
Assert.AreEqual("42", output[0]);
}
示例5: Setup
public void Setup()
{
_relay = new RelayTwo();
_table = _relay.CreateTable(Ting.TABLE_NAME);
_relay.CreateTable(Room.TABLE_NAME);
_roomRunner = new RoomRunner(_relay);
Room room = _roomRunner.CreateRoom<Room>(ROOM_NAME);
for (int i = 0; i < 100; i++)
{
room.AddTile(new PointTileNode(new IntPoint(i % 10, i / 10), room));
}
_tingRunner = new TingRunner(_relay, _roomRunner);
_tingRunner.CreateTing<MyTing>("Ting0", new WorldCoordinate(ROOM_NAME, new IntPoint(0, 0)));
_tingRunner.CreateTing<MyTing>("Ting1", new WorldCoordinate(ROOM_NAME, new IntPoint(1, 0)));
}
示例6: DontTriggerEventOnWaitingNodeUnlessEventHappensWhenExpressionIsTrue
public void DontTriggerEventOnWaitingNodeUnlessEventHappensWhenExpressionIsTrue()
{
RelayTwo relay = new RelayTwo();
relay.CreateTable(DialogueNode.TABLE_NAME);
DialogueRunner runner = new DialogueRunner(relay, Language.SWEDISH);
runner.logger.AddListener (msg => Console.WriteLine ("Dialog runner log: " + msg));
bool sunny = false;
runner.AddExpression ("IsSunny", new DialogueRunner.Expression (args => {
return sunny;
}));
var expression = runner.Create<ExpressionDialogueNode>("Conversation1", Language.SWEDISH, "ExpressionNode");
expression.expression = "IsSunny";
expression.args = new string[] { };
var waitNode = runner.Create<WaitDialogueNode>("Conversation1", Language.SWEDISH, "WaitNode");
waitNode.eventName = "bam!";
waitNode.expressions = new ExpressionDialogueNode[] {
expression
};
var start = runner.Create<ConversationStartDialogueNode>("Conversation1", Language.SWEDISH, "Start");
var end = runner.Create<ConversationEndDialogueNode>("Conversation1", Language.SWEDISH, "End");
start.nextNode = waitNode.name;
waitNode.nextNode = end.name;
runner.StartConversation ("Conversation1");
runner.Update (0.1f);
runner.Update (0.1f);
runner.Update (0.1f);
Assert.IsTrue (waitNode.isOn);
Assert.IsTrue (runner.ConversationIsRunning("Conversation1"));
// Event should not occur since it's not sunny yet
runner.EventHappened("bam!");
runner.Update (0.1f);
Assert.IsTrue (waitNode.isOn);
Assert.IsTrue (runner.ConversationIsRunning("Conversation1"));
sunny = true;
// Now, even though it's sunny the event should still not happen since we're not bam!:ing
runner.Update (0.1f);
Assert.IsTrue (waitNode.isOn);
Assert.IsTrue (runner.ConversationIsRunning("Conversation1"));
// But if the bam! event happens while sunny, the conversation should end
runner.EventHappened("bam!");
runner.Update (0.1f);
runner.Update (0.1f);
runner.Update (0.1f);
Assert.IsFalse (waitNode.isOn);
Assert.IsFalse (runner.ConversationIsRunning("Conversation1"));
}
示例7: RunDialogue
static void RunDialogue()
{
string conversationName = "meeting"; // "PixieMeeting1";
RelayTwo relay;
DialogueRunner dialogueRunner;
relay = new RelayTwo();
relay.CreateTable(DialogueNode.TABLE_NAME);
dialogueRunner = new DialogueRunner(relay, Language.DEFAULT);
dialogueRunner.AddExpression("CoinFlip", CoinFlip);
dialogueRunner.AddOnSomeoneSaidSomethingListener(OnSpeech);
dialogueRunner.logger.AddListener(Log);
DialogueScriptLoader scriptLoader = new DialogueScriptLoader(dialogueRunner);
scriptLoader.LoadDialogueNodesFromFile(conversationName + ".dia");
DialogueScriptPrinter printer = new DialogueScriptPrinter(dialogueRunner);
printer.PrintConversation(conversationName);
Console.WriteLine(" - " + conversationName + " - ");
dialogueRunner.StartConversation(conversationName);
while(dialogueRunner.ConversationIsRunning(conversationName))
{
//printer.PrintConversation(conversationName);
dialogueRunner.Update(1.0f);
DialogueNode activeDialogueNode = dialogueRunner.GetActiveBranchingDialogueNode(conversationName);
if(activeDialogueNode is BranchingDialogueNode)
{
BranchingDialogueNode branchingNode = activeDialogueNode as BranchingDialogueNode;
//printer.PrintConversation(conversationName);
int i = 1;
Console.WriteLine("Choose an alternative:");
foreach(string optionNodeName in branchingNode.nextNodes)
{
TimedDialogueNode optionNode = dialogueRunner.GetDialogueNode(conversationName, optionNodeName) as TimedDialogueNode;
Console.WriteLine(i++ + ". " + optionNode.line);
}
int choice = -1;
while(choice < 0 || choice > branchingNode.nextNodes.Length - 1) {
try {
choice = 0; //Convert.ToInt32(Console.ReadLine()) - 1;
}
catch {
choice = -1;
}
}
branchingNode.Choose(choice);
}
}
}
示例8: CompileWithError
public void CompileWithError()
{
RelayTwo relay = new RelayTwo();
TableTwo programsTable = relay.CreateTable(Program.TABLE_NAME);
Program p1 = new Program();
p1.CreateNewRelayEntry(programsTable, "Program");
p1.sourceCodeContent = "var x = ";
p1.Compile();
Assert.AreEqual(1, p1.GetErrors().Length);
}
示例9: CreateTimedDialogueNode
public void CreateTimedDialogueNode()
{
RelayTwo relay = new RelayTwo();
TableTwo table = relay.CreateTable(DialogueNode.TABLE_NAME);
TimedDialogueNode t = new TimedDialogueNode();
t.CreateNewRelayEntry(table, "TimedDialogueNode");
t.timer = 100;
t.Update(1.0f);
Assert.AreEqual(99, t.timer, 0.001f);
}
示例10: BasicUsage
public void BasicUsage()
{
{
RelayTwo relay = new RelayTwo();
relay.CreateTable(Room.TABLE_NAME);
RoomRunner roomRunner = new RoomRunner(relay);
foreach (string s in roomRunner.Preload()) ;
Room r1 = roomRunner.CreateRoom<Room>("r1");
PointTileNode door1 = null;
for(int i = 0; i < 100; i++)
{
int x = i % 10;
int y = i / 10;
if(x == 9 && y == 9) {
door1 = new PointTileNode(new IntPoint(9, 9), r1);
r1.AddTile(door1);
}
else {
r1.AddTile(new PointTileNode(new IntPoint(x, y), r1 ));
}
}
r1.worldPosition = new IntPoint(50, 0);
relay.SaveAll("room_test.json");
}
{
RelayTwo relay = new RelayTwo("room_test.json");
RoomRunner roomRunner = new RoomRunner(relay);
foreach (string s in roomRunner.Preload()) ;
Room r1 = roomRunner.GetRoom("r1");
PointTileNode start = r1.GetTile(new IntPoint(0, 5));
PointTileNode goal = r1.GetTile(new IntPoint(9, 5));
D.isNull(start);
D.isNull(goal);
PathSolver pathSolver = new PathSolver();
Path path = pathSolver.FindPath(start, goal, roomRunner, true);
Console.WriteLine("path resolved using " + path.pathSearchTestCount + " node tests");
Console.WriteLine("path tile count " + path.nodes.Length);
Assert.AreEqual(PathStatus.FOUND_GOAL, path.status);
}
}
示例11: UsingCellId
private static void UsingCellId()
{
RelayTwo relay = new RelayTwo();
relay.CreateTable(Ting.TABLE_NAME);
TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay));
TestTing1UsingCellIdWithConvenienceFunctions t = tingRunner.CreateTing<TestTing1UsingCellIdWithConvenienceFunctions>("TestTing", WorldCoordinate.NONE);
Console.WriteLine("Using class " + t.ToString());
for(int i = 0; i < COUNTER; i++)
{
float a = t.awesome;
a += 1.0f;
t.awesome = a;
}
Console.WriteLine("1. awesome = " + t.awesome);
}
示例12: UsingNormalAccessor
private static void UsingNormalAccessor()
{
RelayTwo relay = new RelayTwo();
relay.CreateTable(Ting.TABLE_NAME);
TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay));
TestTing2UsingNormalAccessor t = tingRunner.CreateTing<TestTing2UsingNormalAccessor>("TestTing", WorldCoordinate.NONE);
Console.WriteLine("Using class " + t.ToString());
for(int i = 0; i < COUNTER; i++)
{
float a = t.awesome;
a += 1.0f;
t.awesome = a;
}
Console.WriteLine("2. awesome = " + t.awesome);
}
示例13: CanNotStartDialogueNodeInAnotherConversation
public void CanNotStartDialogueNodeInAnotherConversation()
{
RelayTwo relay = new RelayTwo();
relay.CreateTable(DialogueNode.TABLE_NAME);
DialogueRunner runner = new DialogueRunner(relay, Language.SWEDISH);
TimedDialogueNode n1 = runner.Create<TimedDialogueNode>("Conversation1", Language.SWEDISH, "DialogueNode1");
n1.nextNode = "DialogueNode2";
n1.timer = 1;
runner.Create<TimedDialogueNode>("Conversation2", Language.SWEDISH, "DialogueNode2");
n1.Start();
Assert.Throws<GrimmException>(() => {
runner.Update(1.0f);
});
}
示例14: BasicUsage
public void BasicUsage()
{
RelayTwo relay = new RelayTwo();
TableTwo table = relay.CreateTable("Stuffs");
table.AddField<string>("name");
table.AddField<string>(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME);
table.CreateRow().Set(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Stuff").Set("name", "first");
table.CreateRow().Set(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Stuff").Set("name", "second");
List<Stuff> objects = InstantiatorTwo.Process<Stuff>(table);
Assert.AreEqual(2, objects.Count);
Stuff first = objects[0];
Stuff second = objects[1];
Assert.AreEqual("first", first.name);
Assert.AreEqual("second", second.name);
}
示例15: CreatingEmptyRoom
public void CreatingEmptyRoom()
{
string saveName = "MyEmptyRoomSave.json";
{
RelayTwo relay = new RelayTwo();
relay.CreateTable(Room.TABLE_NAME);
RoomRunner roomRunner = new RoomRunner(relay);
roomRunner.CreateRoom<Room>("MyRoom");
relay.SaveAll(saveName);
}
{
RelayTwo relay = new RelayTwo(saveName);
RoomRunner roomRunner = new RoomRunner(relay);
Room room = roomRunner.GetRoom("MyRoom");
Assert.IsNotNull(room);
Assert.AreEqual("MyRoom", room.name);
Assert.AreEqual(new PointTileNode[] {}, room.tiles);
}
}