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


C# RelayTwo.SaveAll方法代码示例

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


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

示例1: 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

示例2: 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

示例3: BasicUsage

        public void BasicUsage()
        {
            const string saveName = "SourceCodeDispenserTest.json";

            {
                RelayTwo relay = new RelayTwo();
                relay.CreateTable(SourceCode.TABLE_NAME);

                SourceCodeDispenser sourceCodeDispenser = new SourceCodeDispenser(relay);
                sourceCodeDispenser.LoadSourceCode(WorldTestHelper.INIT_DATA_PATH + "Sprak/helloworld.sprak");

                SourceCode s = sourceCodeDispenser.GetSourceCode("helloworld");
                Assert.AreEqual("print(\"Hello World!\")", s.content);

                relay.SaveAll(saveName);
            }

            {
                RelayTwo relay = new RelayTwo(saveName);
                SourceCodeDispenser sourceCodeDispenser = new SourceCodeDispenser(relay);
                SourceCode s = sourceCodeDispenser.GetSourceCode("helloworld");
                Assert.AreEqual("print(\"Hello World!\")", s.content);
            }
        }
开发者ID:KarmaLaBelle,项目名称:GameWorld2,代码行数:24,代码来源:SourceCodeDispenserTest.cs

示例4: LoadFromSeveralPartialDatabases

		public void LoadFromSeveralPartialDatabases()
        {
			{
				RelayTwo r1 = new RelayTwo();
				TableTwo t = r1.CreateTable("Table");
				
				t.AddField<string>("animal");
				t.AddField<int>("age");
				
				TableRow row0 = t.CreateRow();
				row0.Set("animal", "rabbit");
				row0.Set("age", 5);
				
				TableRow row1 = t.CreateRow();
				row1.Set("animal", "salmon");
				row1.Set("age", 10);
				
				TableRow row2 = t.CreateRow();
				row2.Set("animal", "spider");
				row2.Set("age", 1);
				
				r1.SaveAll("r1.json");
			}
			
			{
				RelayTwo r2 = new RelayTwo();
				TableTwo t = r2.CreateTable("Table");
				
				t.AddField<string>("animal");
				t.AddField<bool>("carnivore");
				
				TableRow row0 = t.CreateRow();
				row0.Set("animal", "mouse");
				row0.Set("carnivore", false);
				
				TableRow row1 = t.CreateRow();
				row1.Set("animal", "fox");
				row1.Set("carnivore", true);
				
				r2.SaveAll("r2.json");
			}
		
			{
				RelayTwo combined = new RelayTwo();
				combined.AppendTables("r1.json");
                combined.AppendTables("r2.json");
				
				Assert.AreEqual(1, combined.tables.Count);
				
				TableTwo t = combined.GetTable("Table");
				Assert.AreEqual(3, t.fieldNames.Length);
				
				Console.WriteLine("The merged table contains the following rows: ");
				foreach(int rowIndex in t.GetIndexesOfPopulatedRows())
				{
					TableRow row = t[rowIndex];
					Console.WriteLine("Values in row " + rowIndex);
					foreach(string s in row.valuesAsStrings) {
						Console.Write(s + ", ");
					}
                    Console.WriteLine("\n");
				}
				Assert.AreEqual(5, t.GetIndexesOfPopulatedRows().Length);
				
				TableRow rabbit = t[0];
				TableRow salmon = t[1];
				TableRow spider = t[2];
				TableRow mouse = t[3];
				TableRow fox = t[4];
				
				Assert.AreEqual("rabbit", rabbit.Get<string>("animal"));
				Assert.AreEqual("salmon", salmon.Get<string>("animal"));
				Assert.AreEqual("spider", spider.Get<string>("animal"));
				Assert.AreEqual("mouse", mouse.Get<string>("animal"));
				Assert.AreEqual("fox", fox.Get<string>("animal"));
				
				Assert.AreEqual(5, rabbit.Get<int>("age"));
				Assert.AreEqual(10, salmon.Get<int>("age"));
				Assert.AreEqual(1, spider.Get<int>("age"));
                Assert.Throws<RelayException>(() =>
                {
                    Assert.AreEqual(0, mouse.Get<int>("age"));
                });
                Assert.Throws<RelayException>(() =>
                {
                    Assert.AreEqual(0, fox.Get<int>("age"));
                });
				Assert.AreEqual(true, fox.Get<bool>("carnivore"));
			}
		}
开发者ID:substans,项目名称:Relay,代码行数:90,代码来源:RelayTwoTests.cs

示例5: SaveAndLoad

        public void SaveAndLoad()
        {
			int rowNr0, rowNr1, rowNr2;
			
			{
				RelayTwo r1 = new RelayTwo();
				
	            r1.CreateTable("Table1");
	            TableTwo table = r1.GetTable("Table1");
				
				rowNr0 = table.CreateRow().row;
				rowNr1 = table.CreateRow().row;
				rowNr2 = table.CreateRow().row;
				
				table.GetValueEntryEnsureDefault<float>(rowNr0, "a", 3.5f);
				table.GetValueEntryEnsureDefault<float>(rowNr0, "b", 7.0f);
				table.GetValueEntryEnsureDefault<float>(rowNr1, "a", 2.0f);
                table.SetValue<float>(rowNr0, "a", 5.0f);
                table.GetValueEntryEnsureDefault<string>(rowNr2, "blehu", "ap\na");
                Assert.AreEqual(5.0f, table[rowNr0].Get<float>("a"));
                Assert.AreEqual(7.0f, table[rowNr0].Get<float>("b"));
                Assert.AreEqual(2.0f, table[rowNr1].Get<float>("a"));
                Assert.AreEqual("ap\na", table[rowNr2].Get<string>("blehu"));

				r1.SaveAll("sdfsdf.json");
			}
			{
                
	            RelayTwo r2 = new RelayTwo("sdfsdf.json");
	
	            TableTwo table = r2.GetTable("Table1");

                Assert.AreEqual(5.0f, table[rowNr0].Get<float>("a"));
                Assert.AreEqual(7.0f, table[rowNr0].Get<float>("b"));
                Assert.AreEqual(2.0f, table[rowNr1].Get<float>("a"));
                Assert.AreEqual("ap\na", table[rowNr2].Get<string>("blehu"));
			}
        }
开发者ID:substans,项目名称:Relay,代码行数:38,代码来源:RelayTwoTests.cs

示例6: ListeningForEventAndSaveInBetween

        public void ListeningForEventAndSaveInBetween()
        {
            _lines = new List<string>();

            {
                RelayTwo relay = new RelayTwo();
                relay.CreateTable(DialogueNode.TABLE_NAME);

                DialogueRunner dialogueRunner = new DialogueRunner(relay, Language.DEFAULT);
                dialogueRunner.AddOnSomeoneSaidSomethingListener(OnSomeoneSaidSomething);
                dialogueRunner.logger.AddListener(LogDialogueRunner);

                DialogueScriptLoader scriptLoader = new DialogueScriptLoader(dialogueRunner);
                scriptLoader.LoadDialogueNodesFromFile("../conversations/conversation19.dia");

                DialogueScriptPrinter scriptPrinter = new DialogueScriptPrinter(dialogueRunner);
                scriptPrinter.PrintConversation("conversation19");

                dialogueRunner.StartConversation("conversation19");

                for(int i = 0; i < 10; i++) {
                    dialogueRunner.Update(0.1f);
                }

                Assert.AreEqual(1, _lines.Count);
                Assert.AreEqual("Blah blah blah",  _lines[0]);
                relay.SaveAll("save.xml");
            }

            {
                RelayTwo relay = new RelayTwo("save.xml");
                DialogueRunner dialogueRunner = new DialogueRunner(relay, Language.DEFAULT);
                dialogueRunner.AddOnSomeoneSaidSomethingListener(OnSomeoneSaidSomething);
                dialogueRunner.logger.AddListener(LogDialogueRunner);

                dialogueRunner.EventHappened("TensionWentUp");

                for(int i = 0; i < 500; i++)
                {
                    dialogueRunner.Update(1.0f);
                }

                Assert.AreEqual(4, _lines.Count);
                Assert.AreEqual("Oh!",  _lines[1]);
                Assert.AreEqual("",  _lines[2]);
                Assert.AreEqual("",  _lines[3]);

                Assert.IsFalse(dialogueRunner.ConversationIsRunning("conversation19"));

                dialogueRunner.EventHappened("SomethingElse"); // this is not supposed to do anything since the story is over

                for(int i = 0; i < 500; i++)
                {
                    dialogueRunner.Update(1.0f);
                }

                Assert.AreEqual(4, _lines.Count);
            }
        }
开发者ID:eriksvedang,项目名称:Grimm,代码行数:59,代码来源:LoadConversationsFromScriptFilesTest.cs

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


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