private static void AssertBasicContentMetaData(XmlData xmlMetaData, ContentMetaData metaData)
 {
     AssertMinimumContentMetaData(xmlMetaData, metaData.Name, metaData.Type.ToString(),
         metaData.LastTimeUpdated);
     Assert.AreEqual(metaData.LocalFilePath, xmlMetaData.GetAttributeValue("LocalFilePath"));
     Assert.AreEqual(metaData.FileSize.ToString(), xmlMetaData.GetAttributeValue("FileSize"));
 }
Example #2
0
 private static void AssertBasicContentMetaData(XmlData xmlMetaData, ContentMetaData metaData)
 {
     AssertMinimumContentMetaData(xmlMetaData, metaData.Name, metaData.Type.ToString(),
                                  metaData.LastTimeUpdated);
     Assert.AreEqual(metaData.LocalFilePath, xmlMetaData.GetAttributeValue("LocalFilePath"));
     Assert.AreEqual(metaData.FileSize.ToString(), xmlMetaData.GetAttributeValue("FileSize"));
 }
Example #3
0
        public void GetAttributeValueAsInteger()
        {
            var root = new XmlData("root");

            root.AddAttribute("number", "123");
            Assert.AreEqual(123, root.GetAttributeValue("number", 0));
            Assert.AreEqual("", root.GetAttributeValue("nonexistant", ""));
        }
Example #4
0
        public void GetAttributeValue()
        {
            var root = new XmlData("root");

            root.AddAttribute("attribute", "value");
            Assert.AreEqual("value", root.GetAttributeValue("attribute"));
            Assert.AreEqual("", root.GetAttributeValue("attribute2"));
        }
		private static void AssertMinimumContentMetaData(XmlData xmlMetaData,
			string nameAttributeValue, string typeAttributeValue, DateTime lastUpdatedAttributeValue)
		{
			Assert.AreEqual("ContentMetaData", xmlMetaData.Name);
			Assert.AreEqual(nameAttributeValue, xmlMetaData.GetAttributeValue("Name"));
			Assert.AreEqual(typeAttributeValue, xmlMetaData.GetAttributeValue("Type"));
			Assert.AreEqual(lastUpdatedAttributeValue.GetIsoDateTime(),
				xmlMetaData.GetAttributeValue("LastTimeUpdated"));
		}
Example #6
0
 private static void AssertMinimumContentMetaData(XmlData xmlMetaData,
                                                  string nameAttributeValue, string typeAttributeValue, DateTime lastUpdatedAttributeValue)
 {
     Assert.AreEqual("ContentMetaData", xmlMetaData.Name);
     Assert.AreEqual(nameAttributeValue, xmlMetaData.GetAttributeValue("Name"));
     Assert.AreEqual(typeAttributeValue, xmlMetaData.GetAttributeValue("Type"));
     Assert.AreEqual(lastUpdatedAttributeValue.GetIsoDateTime(),
                     xmlMetaData.GetAttributeValue("LastTimeUpdated"));
 }
Example #7
0
		//ncrunch: no coverage start
		public void LoadKerning(XmlData kerningData)
		{
			char firstChar = kerningData.GetAttributeValue("First", '\0');
			char secondChar = kerningData.GetAttributeValue("Second", '\0');
			int kerningDistance = kerningData.GetAttributeValue("Distance", 0);
			if (firstChar == '\0' || secondChar == '\0' || kerningDistance == 0)
				throw new InvalidDataException("Unable to add kerning " + firstChar + " and " + secondChar +
					" with distance=" + kerningDistance);
			Glyph glyph;
			if (GlyphDictionary.TryGetValue(firstChar, out glyph))
				glyph.Kernings.Add(secondChar, kerningDistance);
		} //ncrunch: no coverage end
Example #8
0
		private void LoadGlyph(XmlData glyphData, Size fontMapSize)
		{
			char character = glyphData.GetAttributeValue("Character", ' ');
			var glyph = new Glyph
			{
				UV = new Rectangle(glyphData.GetAttributeValue("UV")),
				LeftSideBearing = glyphData.GetAttributeValue("LeftBearing", 0.0f),
				RightSideBearing = glyphData.GetAttributeValue("RightBearing", 0.0f)
			};
			glyph.AdvanceWidth = glyphData.GetAttributeValue("AdvanceWidth", glyph.UV.Width - 2.0f);
			glyph.PrecomputedFontMapUV = Rectangle.BuildUVRectangle(glyph.UV, fontMapSize);
			GlyphDictionary.Add(character, glyph);
		}
Example #9
0
        private void LoadGlyph(XmlData glyphData, Size fontMapSize)
        {
            char character = glyphData.GetAttributeValue("Character", ' ');
            var  glyph     = new Glyph
            {
                UV = new Rectangle(glyphData.GetAttributeValue("UV")),
                LeftSideBearing  = glyphData.GetAttributeValue("LeftBearing", 0.0f),
                RightSideBearing = glyphData.GetAttributeValue("RightBearing", 0.0f)
            };

            glyph.AdvanceWidth         = glyphData.GetAttributeValue("AdvanceWidth", glyph.UV.Width - 2.0f);
            glyph.PrecomputedFontMapUV = Rectangle.BuildUVRectangle(glyph.UV, fontMapSize);
            GlyphDictionary.Add(character, glyph);
        }
Example #10
0
        public void UpdateNonExistingAttribute()
        {
            var root = new XmlData("root");

            root.UpdateAttribute("number", "312");
            Assert.AreEqual("312", root.GetAttributeValue("number"));
        }
Example #11
0
		private string GetAppPackageFilePath(XmlData appInfoData)
		{
			string fileName = appInfoData.GetAttributeValue(XmlAttributeNameOfFileName);
			if (String.IsNullOrEmpty(fileName))
				throw new AppInfoDataMissing(XmlAttributeNameOfFileName); // ncrunch: no coverage
			return Path.Combine(StorageDirectory, fileName);
		}
Example #12
0
 private static Guid GetAppGuid(XmlData appInfoData)
 {
     string appGuidString = appInfoData.GetAttributeValue(XmlAttributeNameOfAppGuid);
     if (String.IsNullOrEmpty(appGuidString))
         throw new AppInfoDataMissing(XmlAttributeNameOfAppGuid);
     return new Guid(appGuidString);
 }
Example #13
0
        public void UpdateExistingAttributeWithSameValue()
        {
            var root = new XmlData("root");

            root.AddAttribute("number", "123");
            root.UpdateAttribute("number", "123");
            Assert.AreEqual("123", root.GetAttributeValue("number"));
        }
Example #14
0
 private static DateTime GetAppBuildData(XmlData appInfoData)
 {
     var noBuildDate = DateTime.MinValue;
     DateTime buildDate = appInfoData.GetAttributeValue(XmlAttributeNameOfBuildDate, noBuildDate);
     if (buildDate == noBuildDate)
         throw new AppInfoDataMissing(XmlAttributeNameOfBuildDate);
     return buildDate;
 }
Example #15
0
        //ncrunch: no coverage start
        public void LoadKerning(XmlData kerningData)
        {
            char firstChar       = kerningData.GetAttributeValue("First", '\0');
            char secondChar      = kerningData.GetAttributeValue("Second", '\0');
            int  kerningDistance = kerningData.GetAttributeValue("Distance", 0);

            if (firstChar == '\0' || secondChar == '\0' || kerningDistance == 0)
            {
                throw new InvalidDataException("Unable to add kerning " + firstChar + " and " + secondChar +
                                               " with distance=" + kerningDistance);
            }
            Glyph glyph;

            if (GlyphDictionary.TryGetValue(firstChar, out glyph))
            {
                glyph.Kernings.Add(secondChar, kerningDistance);
            }
        }         //ncrunch: no coverage end
Example #16
0
        public void InitializeData()
        {
            var mapXml = data.GetChild("Map");

            if (mapXml == null || string.IsNullOrEmpty(mapXml.Value))
            {
                throw new InvalidTileMapData();                 //ncrunch: no coverage
            }
            Size      = new Size(data.GetAttributeValue("Size"));
            ModelName = data.GetAttributeValue("ModelName");
            InitializeLists();
            StoreSpawnAndGoalPoints();
            StoreWaves();
            StoreGameTriggers();
            InitializeMapFromXml(mapXml.Value);
            LoadCustomLevelData(data);
            Current = this;
        }
Example #17
0
        private string GetAppPackageFilePath(XmlData appInfoData)
        {
            string fileName = appInfoData.GetAttributeValue(XmlAttributeNameOfFileName);

            if (String.IsNullOrEmpty(fileName))
            {
                throw new AppInfoDataMissing(XmlAttributeNameOfFileName);                 // ncrunch: no coverage
            }
            return(Path.Combine(StorageDirectory, fileName));
        }
Example #18
0
        private static Guid GetAppGuid(XmlData appInfoData)
        {
            string appGuidString = appInfoData.GetAttributeValue(XmlAttributeNameOfAppGuid);

            if (String.IsNullOrEmpty(appGuidString))
            {
                throw new AppInfoDataMissing(XmlAttributeNameOfAppGuid);                 // ncrunch: no coverage
            }
            return(new Guid(appGuidString));
        }
Example #19
0
        private static string GetAppSolutionFilePath(XmlData appInfoData)
        {
            string solutionFilePath = appInfoData.GetAttributeValue(XmlAttributeNameOfSolutionFilePath);

            if (String.IsNullOrEmpty(solutionFilePath))
            {
                throw new AppInfoDataMissing(XmlAttributeNameOfSolutionFilePath);                 // ncrunch: no coverage
            }
            return(solutionFilePath);
        }
 private static void AssertFullContentMetaDataEntry(XmlData xmlMetaData,
     ContentMetaData metaData)
 {
     AssertBasicContentMetaData(xmlMetaData, metaData);
     AssertLanguageInMetaData(xmlMetaData, metaData);
     AssertPlatformFileIdInMetaData(xmlMetaData, metaData);
     foreach (KeyValuePair<string, string> valuePair in metaData.Values)
         Assert.AreEqual(metaData.Values[valuePair.Key],
             xmlMetaData.GetAttributeValue(valuePair.Key));
 }
Example #21
0
 protected override AgentData ParseData(XmlData tower)
 {
     return
         (new TowerData((TowerType)Enum.Parse(typeof(TowerType), tower.GetAttributeValue("Type")),
                        tower.GetAttributeValue("Name"),
                        (AttackType)Enum.Parse(typeof(AttackType), tower.GetAttributeValue("AttackType")),
                        tower.GetAttributeValue("Range", 0.0f), tower.GetAttributeValue("AttackFrequency", 0.0f),
                        tower.GetAttributeValue("AttackDamage", 0.0f), tower.GetAttributeValue("Cost", 0)));
 }
Example #22
0
		protected override AgentData ParseData(XmlData tower)
		{
			return
				new TowerData((TowerType)Enum.Parse(typeof(TowerType), tower.GetAttributeValue("Type")),
					tower.GetAttributeValue("Name"),
					(AttackType)Enum.Parse(typeof(AttackType), tower.GetAttributeValue("AttackType")),
					tower.GetAttributeValue("Range", 0.0f), tower.GetAttributeValue("AttackFrequency", 0.0f),
					tower.GetAttributeValue("AttackDamage", 0.0f), tower.GetAttributeValue("Cost", 0));
		}
Example #23
0
        private static DateTime GetAppBuildData(XmlData appInfoData)
        {
            var      noBuildDate = DateTime.MinValue;
            DateTime buildDate   = appInfoData.GetAttributeValue(XmlAttributeNameOfBuildDate, noBuildDate);

            if (buildDate == noBuildDate)
            {
                throw new AppInfoDataMissing(XmlAttributeNameOfBuildDate);                 // ncrunch: no coverage
            }
            return(buildDate);
        }
Example #24
0
 private static void AssertLanguageInMetaData(XmlData xmlMetaData, ContentMetaData metaData)
 {
     if (metaData.Language == null)
     {
         Assert.IsFalse(IsAttributeAvailable(xmlMetaData, "Language"));
     }
     else
     {
         Assert.AreEqual(metaData.Language, xmlMetaData.GetAttributeValue("Language"));
     }
 }
Example #25
0
        // ncrunch: no coverage end

        private static PlatformName GetAppPlatform(XmlData appInfoData)
        {
            const PlatformName NoPlatform = (PlatformName)0;
            PlatformName       platform   = appInfoData.GetAttributeValue(XmlAttributeNameOfPlatform, NoPlatform);

            if (platform == NoPlatform)
            {
                throw new AppInfoDataMissing(XmlAttributeNameOfPlatform);                 // ncrunch: no coverage
            }
            return(platform);
        }
Example #26
0
 private static void AssertFullContentMetaDataEntry(XmlData xmlMetaData,
                                                    ContentMetaData metaData)
 {
     AssertBasicContentMetaData(xmlMetaData, metaData);
     AssertLanguageInMetaData(xmlMetaData, metaData);
     AssertPlatformFileIdInMetaData(xmlMetaData, metaData);
     foreach (KeyValuePair <string, string> valuePair in metaData.Values)
     {
         Assert.AreEqual(metaData.Values[valuePair.Key],
                         xmlMetaData.GetAttributeValue(valuePair.Key));
     }
 }
Example #27
0
 private static void AssertPlatformFileIdInMetaData(XmlData xmlMetaData, ContentMetaData metaData)
 {
     if (metaData.PlatformFileId == 0)
     {
         Assert.IsFalse(IsAttributeAvailable(xmlMetaData, "PlatformFileId"));
     }
     else
     {
         Assert.AreEqual(metaData.PlatformFileId.ToString(),
                         xmlMetaData.GetAttributeValue("PlatformFileId"));
     }
 }
 protected override AgentData ParseData(XmlData boss)
 {
     return(new BossData((BossType)Enum.Parse(typeof(BossType), boss.GetAttributeValue("Type")),
                         boss.GetAttributeValue("Name"), boss.GetAttributeValue("MaxHp", 0.0f),
                         boss.GetAttributeValue("Speed", 0.0f), boss.GetAttributeValue("Resistance", 0.0f),
                         boss.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(boss)));
 }
Example #29
0
		protected override AgentData ParseData(XmlData boss)
		{
			return new BossData((BossType)Enum.Parse(typeof(BossType), boss.GetAttributeValue("Type")),
				boss.GetAttributeValue("Name"), boss.GetAttributeValue("MaxHp", 0.0f),
				boss.GetAttributeValue("Speed", 0.0f), boss.GetAttributeValue("Resistance", 0.0f),
				boss.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(boss));
		}
Example #30
0
        private void DeleteFiles(XmlData entry)
        {
            var localFilePath = entry.GetAttributeValue("LocalFilePath");

            if (string.IsNullOrEmpty(localFilePath))
            {
                return;
            }
            if (NoContentEntryUsesFile(entry, localFilePath))
            {
                File.Delete(Path.Combine(ContentProjectPath, localFilePath));
            }
        }
Example #31
0
		protected override AgentData ParseData(XmlData creep)
		{
			return
				new CreepData((CreepType)Enum.Parse(typeof(CreepType), creep.GetAttributeValue("Type")),
					creep.GetAttributeValue("Name"), creep.GetAttributeValue("MaxHp", 0.0f),
					creep.GetAttributeValue("Speed", 0.0f), creep.GetAttributeValue("Resistance", 0.0f),
					creep.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(creep));
		}
 protected override AgentData ParseData(XmlData creep)
 {
     return
         (new CreepData((CreepType)Enum.Parse(typeof(CreepType), creep.GetAttributeValue("Type")),
                        creep.GetAttributeValue("Name"), creep.GetAttributeValue("MaxHp", 0.0f),
                        creep.GetAttributeValue("Speed", 0.0f), creep.GetAttributeValue("Resistance", 0.0f),
                        creep.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(creep)));
 }
Example #33
0
        private void ParseXmlNode(XmlData currentNode)
        {
            var currentElement = ParseContentMetaData(currentNode.Attributes);
            var name           = currentNode.GetAttributeValue("Name");

            if (!metaData.ContainsKey(name) && currentNode.Parent != null)
            {
                lock (metaData)
                    metaData.Add(name, currentElement);
            }
            foreach (var node in currentNode.Children)
            {
                ParseXmlNode(node);
            }
        }
Example #34
0
		// ncrunch: no coverage end

		private static PlatformName GetAppPlatform(XmlData appInfoData)
		{
			const PlatformName NoPlatform = (PlatformName)0;
			PlatformName platform = appInfoData.GetAttributeValue(XmlAttributeNameOfPlatform, NoPlatform);
			if (platform == NoPlatform)
				throw new AppInfoDataMissing(XmlAttributeNameOfPlatform); // ncrunch: no coverage
			return platform;
		}
 private static void AssertLanguageInMetaData(XmlData xmlMetaData, ContentMetaData metaData)
 {
     if (metaData.Language == null)
         Assert.IsFalse(IsAttributeAvailable(xmlMetaData, "Language"));
     else
         Assert.AreEqual(metaData.Language, xmlMetaData.GetAttributeValue("Language"));
 }
 private static GroupData ParseGroupData(XmlData group)
 {
     return(new GroupData(group.GetAttributeValue("Name"),
                          group.GetAttributeValue("CreepTypeList").SplitAndTrim(',').ToList(),
                          group.GetAttributeValue("SpawnIntervalList", 0.0f)));
 }
Example #37
0
		private static GroupData ParseGroupData(XmlData group)
		{
			return new GroupData(group.GetAttributeValue("Name"),
				group.GetAttributeValue("CreepTypeList").SplitAndTrim(',').ToList(),
				group.GetAttributeValue("SpawnIntervalList", 0.0f));
		}
 private static void AssertPlatformFileIdInMetaData(XmlData xmlMetaData, ContentMetaData metaData)
 {
     if (metaData.PlatformFileId == 0)
         Assert.IsFalse(IsAttributeAvailable(xmlMetaData, "PlatformFileId"));
     else
         Assert.AreEqual(metaData.PlatformFileId.ToString(),
             xmlMetaData.GetAttributeValue("PlatformFileId"));
 }
Example #39
0
		public void UpdateExistingAttributeWithSameValue()
		{
			var root = new XmlData("root");
			root.AddAttribute("number", "123");
			root.UpdateAttribute("number", "123");
			Assert.AreEqual("123", root.GetAttributeValue("number"));
		}
Example #40
0
		public void UpdateNonExistingAttribute()
		{
			var root = new XmlData("root");
			root.UpdateAttribute("number", "312");
			Assert.AreEqual("312", root.GetAttributeValue("number"));
		}
Example #41
0
		public void GetAttributeValueAsInteger()
		{
			var root = new XmlData("root");
			root.AddAttribute("number", "123");
			Assert.AreEqual(123, root.GetAttributeValue("number", 0));
			Assert.AreEqual("", root.GetAttributeValue("nonexistant", ""));
		}
Example #42
0
		public void GetAttributeValue()
		{
			var root = new XmlData("root");
			root.AddAttribute("attribute", "value");
			Assert.AreEqual("value", root.GetAttributeValue("attribute"));
			Assert.AreEqual("", root.GetAttributeValue("attribute2"));
		}
Example #43
0
		private static string GetAppSolutionFilePath(XmlData appInfoData)
		{
			string solutionFilePath = appInfoData.GetAttributeValue(XmlAttributeNameOfSolutionFilePath);
			if (String.IsNullOrEmpty(solutionFilePath))
				throw new AppInfoDataMissing(XmlAttributeNameOfSolutionFilePath); // ncrunch: no coverage
			return solutionFilePath;
		}
 private void DeleteFiles(XmlData entry)
 {
     var localFilePath = entry.GetAttributeValue("LocalFilePath");
     if (string.IsNullOrEmpty(localFilePath))
         return;
     if (NoContentEntryUsesFile(entry, localFilePath))
         File.Delete(Path.Combine(contentPath, localFilePath));
 }
Example #45
0
 private void LoadAlreadyBuiltApps()
 {
     storageData = settings.GetValue(XmlNodeNameOfStorageData,
         new XmlData(XmlNodeNameOfStorageData));
     if (String.IsNullOrEmpty(storageData.GetAttributeValue("StoragePath")))
         CreateNewBuiltAppsListData();
     StorageDirectory = storageData.GetAttributeValue("StoragePath");
     foreach (XmlData appInfoData in storageData.Children)
         TryLoadAppFromStorageData(appInfoData);
 }
 private void ParseXmlNode(XmlData currentNode)
 {
     var currentElement = ParseContentMetaData(currentNode.Attributes);
     var name = currentNode.GetAttributeValue("Name");
     if (!metaData.ContainsKey(name) && currentNode.Parent != null)
         metaData.Add(name, currentElement);
     foreach (var node in currentNode.Children)
         ParseXmlNode(node);
 }
Example #47
0
 public void CreateProjectMetaData()
 {
     AssertMinimumContentMetaData(projectMetaData, ProjectName, "Scene", DateTime.Now);
     Assert.AreEqual(Platform, projectMetaData.GetAttributeValue("ContentDeviceName"));
 }