예제 #1
0
		public void CreateALevel()
		{
			level = new Level(new Size(5, 5));
			level.SetTile(new Vector2D(0, 0), LevelTileType.SpawnPoint);
			level.SetTile(new Vector2D(1, 1), LevelTileType.ExitPoint);
			level.SetTile(new Vector2D(2, 2), LevelTileType.BlockedPlaceable);
			level.SetTile(new Vector2D(0, 1), LevelTileType.Blue);
			level.SetTile(new Vector2D(0, 2), LevelTileType.Brown);
			level.SetTile(new Vector2D(0, 3), LevelTileType.Green);
			level.SetTile(new Vector2D(0, 4), LevelTileType.Gray);
			level.SetTile(new Vector2D(1, 0), LevelTileType.Placeable);
			level.SetTile(new Vector2D(1, 2), LevelTileType.Yellow);
			level.SetTile(new Vector2D(1, 3), LevelTileType.Blocked);
			level.SetTile(new Vector2D(1, 4), LevelTileType.Red);
			level.AddWave(new Wave(2.0f, 1.0f, "Test", "Test", 20.0f));
			var stream = new XmlFile(BuildXmlData()).ToMemoryStream();
			var loadedLevel = new MockLevel(new Size(0, 0));
			loadedLevel.LoadData(stream);
			Assert.AreEqual(loadedLevel.Size, level.Size);
			Assert.AreEqual(loadedLevel.MapData[0], level.MapData[0]);
			Assert.AreEqual(loadedLevel.Waves[0].MaxTime, level.Waves[0].MaxTime);
			Assert.AreEqual(loadedLevel.Waves[0].SpawnInterval, level.Waves[0].SpawnInterval);
			Assert.AreEqual(loadedLevel.Waves[0].SpawnTypeList, level.Waves[0].SpawnTypeList);
			Assert.AreEqual(loadedLevel.Waves[0].WaitTime, level.Waves[0].WaitTime);
			level.Dispose();
		}
예제 #2
0
		public void SaveToServer()
		{
			var bytes = new XmlFile(BuildXmlData()).ToMemoryStream().ToArray();
			var dataAndName = new Dictionary<string, byte[]> { { ContentName + ".xml", bytes } };
			var metaDataCreator = new ContentMetaDataCreator();
			var contentMetaData = metaDataCreator.CreateMetaDataFromLevelData(ContentName, bytes);
			service.UploadContent(contentMetaData, dataAndName);
		}
예제 #3
0
		private void LoadDeviceInfoList()
		{
			AvailableDevices = new List<Device>();
			XmlData devicesXmlData = new XmlFile(GetDevicesXmlStream()).Root;
			foreach (var xmlDevice in devicesXmlData.Children)
				AvailableDevices.Add(new Device(xmlDevice));
			SelectedDevice = AvailableDevices[0];
		}
		private void LoadOrCreateContentMetaDataFile()
		{
			try
			{
				projectMetaDataFile = new XmlFile(ContentMetaDataFilePath);
			}
			catch (Exception)
			{
				CreateContentMetaDataFile();
			}
		}
예제 #5
0
		//ncrunch: no coverage start
		public void SaveInput(CommandList commandList, Service service)
		{
			var root = CreateMainRoot("InputCommands");
			foreach (var command in commandList.GetCommands())
				SetCommand(root, command, commandList.GetAllTriggers(command));
			var bytes = new XmlFile(root).ToMemoryStream().ToArray();
			var fileNameAndBytes = new Dictionary<string, byte[]>();
			fileNameAndBytes.Add("InputCommands.xml", bytes);
			var metaDataCreator = new ContentMetaDataCreator();
			var contentMetaData = metaDataCreator.CreateMetaDataFromInputData(bytes);
			service.UploadContent(contentMetaData, fileNameAndBytes);
		}
예제 #6
0
		//ncrunch: no coverage start (for performance reasons)
		protected override Stream GetContentDataStream(ContentData content)
		{
			var stream = Stream.Null;
			if (content.MetaData.Type == ContentType.Xml && content.Name.Equals("Texts"))
				stream = new XmlFile(new XmlData("Texts").AddChild(GoLocalizationNode)).ToMemoryStream();
			else if (content.Name.Contains("Verdana12") || content.Name.Contains("Tahoma30"))
				stream = CreateFontXml().ToMemoryStream();
			else if (content.MetaData.Type == ContentType.Xml && content.Name != "NonExisting")
				stream = new XmlFile(new XmlData("Root").AddChild(new XmlData("Hi"))).ToMemoryStream();
			else if (content.Name.Equals("EmptyScene"))
				stream = SaveEmptyScene();
			else if (content.Name.Equals("SceneWithAButton"))
				stream = SaveSceneWithAButton();
			else if (content.Name.Equals("SceneWithAButtonWithChangedMaterial"))
				stream = SaveSceneWithAButtonWithMaterial();
			else if (content.Name.Equals("SceneWithAButtonWithDifferentFontText"))
				stream = SaveSceneWithAButtonWithFontText();
			else if (content.Name.Equals("SceneWithASlider"))
				stream = SaveSceneWithASlider();
			else if (content.MetaData.Type == ContentType.Scene)
				stream = SaveEmptyScene();
			else if (content.Name.Contains("Theme"))
				stream = SaveTestTheme();
			else if (content.Name.Equals("TestMenuXml"))
				stream = SaveTestMenu();
			else if (content.Name.Equals("3DMaterial"))
				stream = Save3DMaterial();
			else if (content.Name.Contains("PointEmitter3D"))
				stream = CreateEmitter3D(ParticleEmitterPositionType.Point);
			else if (content.Name.Contains("LineEmitter3D"))
				stream = CreateEmitter3D(ParticleEmitterPositionType.Line);
			else if (content.Name.Contains("BoxEmitter3D"))
				stream = CreateEmitter3D(ParticleEmitterPositionType.Box);
			else if (content.Name.Contains("SphereEmitter3D"))
				stream = CreateEmitter3D(ParticleEmitterPositionType.Sphere);
			else if (content.Name.Contains("SphereBorderEmitter3D"))
				stream = CreateEmitter3D(ParticleEmitterPositionType.SphereBorder);
			else if (content.Name.Contains("CircleAroundCenterEmitter3D"))
				stream = CreateEmitter3D(ParticleEmitterPositionType.CircleAroundCenter);
			else if (content.Name.Contains("CircleEscapingEmitter3D"))
				stream = CreateEmitter3D(ParticleEmitterPositionType.CircleEscaping);
			else if (content.Name.Contains("MeshEmitter3D"))
				stream = CreateEmitter3D(ParticleEmitterPositionType.Mesh);
			else if (content.MetaData.Type == ContentType.ParticleEmitter)
				stream = SaveTestEmitter();
			else if (content.Name == "SpineboyAtlas")
				stream = new MemoryStream(Encoding.Default.GetBytes(MockSpineAtlas.Text));
			else if (content.Name == "SpineboySkeleton")
				stream = new MemoryStream(Encoding.Default.GetBytes(MockSpineSkeleton.Text));
			else if (content.Name.Contains("MyMaterial"))
				stream = SaveMaterial();
			return stream;
		}
예제 #7
0
		private static void CreateContentMetaDataAndRealFiles()
		{
			Directory.CreateDirectory(ContentProjectDirectoryName);
			var root = new XmlData("ContentMetaData");
			root.AddAttribute("Name", "DeltaEngine.Content.Disk.Tests");
			root.AddAttribute("Type", "Scene");
			root.AddChild(CreateImageEntryAndFile("DeltaEngineLogo", new Size(128, 128)));
			root.AddChild(CreateImageEntryAndFile("SmallImage", new Size(32, 32)));
			root.AddChild(CreateAnimationNode());
			root.AddChild(CreateXmlEntryAndFile());
			var contentMetaData = new XmlFile(root);
			contentMetaData.Save(Path.Combine(ContentProjectDirectoryName, "ContentMetaData.xml"));
		}
 private void InitializeProjectMetaDataFile()
 {
     if (File.Exists(ContentMetaDataFilePath))
         projectMetaDataFile = new XmlFile(ContentMetaDataFilePath);
     else
     {
         string activeProject = ProjectName ?? AssemblyExtensions.GetEntryAssemblyForProjectName();
         XmlData root = XmlMetaDataExtensions.CreateProjectMetaData(activeProject, "Windows");
         projectMetaDataFile = new XmlFile(root);
     }
 }
예제 #9
0
		protected override void LoadData(Stream fileData)
		{
			data = new XmlFile(fileData).Root;
			InitializeData();
		}
		private void CreateContentMetaDataFile()
		{
			string activeProject = ProjectName ?? AssemblyExtensions.GetEntryAssemblyForProjectName();
			XmlData root = XmlMetaDataExtensions.CreateProjectMetaData(activeProject, "Windows");
			projectMetaDataFile = new XmlFile(root);
		}