Exemple #1
0
 public static void Initialize()
 {
     foreach (string file in Content.GetFiles("Content/titles"))
     {
         IEnumerable <XElement> source = XDocument.Load(TitleContainer.OpenStream(file)).Elements((XName)"Title");
         if (source != null)
         {
             XAttribute xattribute1 = source.Attributes((XName)"name").FirstOrDefault <XAttribute>();
             if (xattribute1 != null)
             {
                 DuckTitle duckTitle = new DuckTitle();
                 duckTitle._name = xattribute1.Value;
                 bool flag = false;
                 foreach (XElement element in source.Elements <XElement>())
                 {
                     if (element.Name == (XName)"StatRequirement")
                     {
                         XAttribute statNameAttrib = element.Attributes((XName)"name").FirstOrDefault <XAttribute>();
                         XAttribute xattribute2    = element.Attributes((XName)"value").FirstOrDefault <XAttribute>();
                         if (statNameAttrib != null && xattribute2 != null)
                         {
                             PropertyInfo key = ((IEnumerable <PropertyInfo>) typeof(ProfileStats).GetProperties()).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(x => x.Name == statNameAttrib.Value));
                             if (key != (PropertyInfo)null)
                             {
                                 if (key.GetType() == typeof(float))
                                 {
                                     duckTitle._requirementsFloat.Add(key, Change.ToSingle((object)xattribute2.Value));
                                 }
                                 else if (key.GetType() == typeof(int))
                                 {
                                     duckTitle._requirementsFloat.Add(key, (float)Convert.ToInt32(xattribute2.Value));
                                 }
                                 else
                                 {
                                     duckTitle._requirementsString.Add(key, xattribute2.Value);
                                 }
                             }
                             else
                             {
                                 flag = true;
                                 break;
                             }
                         }
                         else
                         {
                             flag = true;
                             break;
                         }
                     }
                 }
                 if (!flag)
                 {
                     DuckTitle._titles.Add(duckTitle);
                 }
             }
         }
     }
 }
Exemple #2
0
 private static void SearchDirLevels(string dir, LevelLocation location)
 {
     foreach (string path in location == LevelLocation.Content ? Content.GetFiles(dir) : DuckFile.GetFiles(dir))
     {
         RandomLevelDownloader.ProcessLevel(path, location);
     }
     foreach (string dir1 in location == LevelLocation.Content ? Content.GetDirectories(dir) : DuckFile.GetDirectories(dir))
     {
         RandomLevelDownloader.SearchDirLevels(dir1, location);
     }
 }
Exemple #3
0
 public static void Initialize()
 {
     foreach (string file in Content.GetFiles("Content/news"))
     {
         IEnumerable <XElement> source1 = XDocument.Load(TitleContainer.OpenStream(file)).Elements((XName)"NewsStory");
         if (source1 != null)
         {
             if (DG.isHalloween)
             {
                 IEnumerable <XElement> source2 = source1.Elements <XElement>((XName)"NewsStoryHalloween");
                 if (source2 != null && source2.Count <XElement>() > 0)
                 {
                     source1 = source2;
                 }
             }
             DuckNews duckNews = DuckNews.Parse(source1.ElementAt <XElement>(0));
             if (duckNews != null)
             {
                 DuckNews._stories.Add(duckNews);
             }
         }
     }
     DuckNews._stories = DuckNews._stories.OrderBy <DuckNews, int>((Func <DuckNews, int>)(x => (int)x._section)).ToList <DuckNews>();
 }