当前位置: 首页>>代码示例>>C#>>正文


C# RelayTwo类代码示例

本文整理汇总了C#中RelayTwo的典型用法代码示例。如果您正苦于以下问题:C# RelayTwo类的具体用法?C# RelayTwo怎么用?C# RelayTwo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RelayTwo类属于命名空间,在下文中一共展示了RelayTwo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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]);
        }
开发者ID:KarmaLaBelle,项目名称:GameWorld2,代码行数:28,代码来源:ProgramTest.cs

示例2: 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);
            }
        }
开发者ID:substans,项目名称:Grimm,代码行数:28,代码来源:DialogueRunnerTest.cs

示例3: 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);
        }
开发者ID:substans,项目名称:TingTing,代码行数:32,代码来源:TingRunnerTest.cs

示例4: 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]);
        }
开发者ID:substans,项目名称:Grimm,代码行数:34,代码来源:LoadConversationsFromScriptFilesTest.cs

示例5: TimetableRunner

        //, TingRunner pTingRunner)
        public TimetableRunner(RelayTwo pRelay)
        {
            _timetableTable = pRelay.GetTable(Timetable.TABLE_NAME);

            foreach(var timetable in InstantiatorTwo.Process<Timetable>(_timetableTable)) {
                _timetables[timetable.name] = timetable;
            }
        }
开发者ID:KarmaLaBelle,项目名称:GameWorld2,代码行数:9,代码来源:TimetableRunner.cs

示例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"));
        }
开发者ID:eriksvedang,项目名称:Grimm,代码行数:58,代码来源:DialogueRunnerTest.cs

示例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);
                }
            }
        }
开发者ID:eriksvedang,项目名称:Grimm,代码行数:58,代码来源:Main.cs

示例8: AssertThatCanFindAllTables

 void AssertThatCanFindAllTables(RelayTwo pRelay)
 {
     Assert.IsNotNull(pRelay.GetTable(Ting.TABLE_NAME));
     Assert.IsNotNull(pRelay.GetTable(Room.TABLE_NAME));
     Assert.IsNotNull(pRelay.GetTable(DialogueNode.TABLE_NAME));
     Assert.IsNotNull(pRelay.GetTable(SourceCode.TABLE_NAME));
     Assert.IsNotNull(pRelay.GetTable(Program.TABLE_NAME));
     Assert.IsNotNull(pRelay.GetTable(WorldSettings.TABLE_NAME));
 }
开发者ID:KarmaLaBelle,项目名称:GameWorld2,代码行数:9,代码来源:InitialSaveFileCreatorTests.cs

示例9: ProgramRunner

 public ProgramRunner(RelayTwo pRelay)
 {
     D.isNull(pRelay);
     _programTable = pRelay.GetTable(Program.TABLE_NAME);
     _programsList = InstantiatorTwo.Process<Program>(_programTable);
     foreach (var program in _programsList) {
         program.Init(this);
         _programsDictionary.Add(program.objectId, program);
     }
 }
开发者ID:KarmaLaBelle,项目名称:GameWorld2,代码行数:10,代码来源:ProgramRunner.cs

示例10: SourceCodeDispenser

 public SourceCodeDispenser(RelayTwo pRelay)
 {
     _sourceCodeTable = pRelay.GetTable(SourceCode.TABLE_NAME);
     //Console.WriteLine("Getting source code from " + _sourceCodeTable.name);
     _sourceCodes = InstantiatorTwo.Process<SourceCode>(_sourceCodeTable);
     foreach (SourceCode sc in _sourceCodes)
     {
         //Console.WriteLine("found source code " + sc.name);
     }
 }
开发者ID:KarmaLaBelle,项目名称:GameWorld2,代码行数:10,代码来源:SourceCodeDispenser.cs

示例11: 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);
        }
开发者ID:KarmaLaBelle,项目名称:GameWorld2,代码行数:11,代码来源:ProgramTest.cs

示例12: 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);
        }
开发者ID:cyberis,项目名称:Grimm,代码行数:12,代码来源:DialogueRunnerTest.cs

示例13: 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);
			}
		}
开发者ID:eriksvedang,项目名称:TingTing,代码行数:52,代码来源:RoomTest.cs

示例14: 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);
 }
开发者ID:substans,项目名称:TingTing,代码行数:15,代码来源:Main.cs

示例15: 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);
 }
开发者ID:substans,项目名称:TingTing,代码行数:15,代码来源:Main.cs


注:本文中的RelayTwo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。