예제 #1
0
 protected override void OnExiting(object sender, EventArgs args)
 {
     if (playerData.ReportingEnabled)
     {
         foreach (KeyValuePair<string, Menu> menu in Manager.Menues)
         {
             VelesConflict.VelesConflictReporting.MenuUsageStatistic mus = new VelesConflictReporting.MenuUsageStatistic();
             mus.Actions = menu.Value.Actions;
             mus.Menu = menu.Key;
             mus.TimeSpent = menu.Value.TimeSpent;
             mus.DeviceID = DeviceID;
             lock (MenuUsage)
             {
                 MenuUsage.Add(mus);
             }
         }
     }
     playerData.Save();
     base.OnExiting(sender, args);
 }
예제 #2
0
        public void Load()
        {
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            if (isf.FileExists("PlayerData.dat"))
            {
                IsolatedStorageFileStream stream = isf.OpenFile("PlayerData.dat", System.IO.FileMode.Open);
                XmlReader reader = XmlReader.Create(stream);
                reader.ReadToFollowing("IsStored");
                IsStored = reader.ReadElementContentAsBoolean();
                if (IsStored)
                {
                    reader.ReadToFollowing("OGI");
                    OGI = reader.ReadElementContentAsString();
                    reader.ReadToFollowing("Hash");
                    Hash = reader.ReadElementContentAsString();
                }
                reader.ReadToFollowing("Difficulty");
                Difficulty = (Difficulty)Enum.Parse(typeof(Difficulty), reader.ReadElementContentAsString(), true);
                reader.ReadToFollowing("Points");
                Points = reader.ReadElementContentAsInt();
                reader.ReadToFollowing("DeviceRegistered");
                DeviceRegistered = reader.ReadElementContentAsBoolean();
                reader.ReadToFollowing("ReportingEnabled");
                ReportingEnabled = reader.ReadElementContentAsBoolean();
                reader.ReadToFollowing("GameUsage");
                while (reader.Read())
                {
                    if (reader.IsStartElement("GameStat"))
                    {
                        VelesConflictReporting.GameUsageStastics statics = new VelesConflictReporting.GameUsageStastics();
                        reader.ReadToFollowing("Actions");
                        statics.Actions = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("Map");
                        statics.Map = reader.ReadElementContentAsString();
                        reader.ReadToFollowing("Difficulty");
                        statics.Difficulty = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("Winner");
                        statics.Winner = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("TimeSpent");
                        statics.TimeSpent = new TimeSpan(reader.ReadElementContentAsLong());
                        statics.DeviceID = GameBase.DeviceID;
                        GameBase.GameUsage.Add(statics);
                    }
                    else if (reader.Name == "GameUsage")
                    {
                        break;
                    }

                }
                reader.ReadToFollowing("MenuUsage");
                while (reader.Read())
                {
                    if (reader.IsStartElement("MenuStat"))
                    {
                        VelesConflictReporting.MenuUsageStatistic statics = new VelesConflictReporting.MenuUsageStatistic();
                        reader.ReadToFollowing("Actions");
                        statics.Actions = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("Menu");
                        statics.Menu = reader.ReadElementContentAsString();
                        reader.ReadToFollowing("TimeSpent");
                        statics.TimeSpent = new TimeSpan(reader.ReadElementContentAsLong());
                        statics.DeviceID = GameBase.DeviceID;
                        GameBase.MenuUsage.Add(statics);
                    }
                    else if (reader.Name == "MenuUsage")
                        break;
                }
                reader.ReadToFollowing("Research");
                reader.ReadToFollowing("Attack");
                Research["Attack"] = reader.ReadElementContentAsInt();
                reader.ReadToFollowing("Defense");
                Research["Defense"] = reader.ReadElementContentAsInt();
                reader.ReadToFollowing("Speed");
                Research["Speed"] = reader.ReadElementContentAsInt();
                reader.ReadToFollowing("Growth");
                Research["Growth"] = reader.ReadElementContentAsInt();

                while (reader.Read())
                {
                    if (reader.IsStartElement("ProgressEntry"))
                    {
                        reader.ReadToFollowing("Campaing");
                        string campaing = reader.ReadElementContentAsString();
                        reader.ReadToFollowing("Progress");
                        int progress = reader.ReadElementContentAsInt();
                        Progress.Add(campaing, progress);
                    }
                }
                stream.Flush();
                stream.Dispose();
            }
            else
                FirstLoad = true;
            isf.Dispose();
        }