Ejemplo n.º 1
0
        public static void LoadProfile(string path)
        {
            DateTime currentDateTime = DateTime.Now;
            String   dateStr         = currentDateTime.ToString("dd.MM HH:mm:ss");

            ProfileSwitcher.Logger("" + dateStr + " loading profile: " + path);
            ProfileSwitcher.startRunTimer();
            ProfileSwitcher.deathRetries = 0;
            ProfileSwitcher.Log("Loading profile: " + path);
            ProfileManager.Load(path);
        }
Ejemplo n.º 2
0
        public static void updateProfiles()
        {
            int startIndex = 0;

            ProfileSwitcher.Log("Updating profiles...");
            profilePath = ProfileSwitcher.profilesPath;
            profiles    = Directory.GetFiles(profilePath, "*.xml");
            if (ProfileSwitcher.profileRandomization == true)
            {
                string randomFilePath = profilePath + "\\random.txt";
                Random randGenerator  = new Random(DateTime.Now.Ticks.GetHashCode());
                profilePriorities = new float[profiles.Length];
                if (File.Exists(randomFilePath))
                {
                    using (StreamReader reader = new StreamReader(randomFilePath))
                    {
                        string line;
                        int    i = 0;
                        while (((line = reader.ReadLine()) != null) && (i < profiles.Length))
                        {
                            int priority = Int32.Parse(line);
                            if ((priority < 1) || (priority > 99) && (priority != 0))
                            {
                                ProfileSwitcher.Log("Warning: Randomization priorities lower than 1 or higher than 99 can cause problems!!!");
                            }
                            profilePriorities[i] = (float)priority;
                            i++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < profiles.Length; i++)
                    {
                        ProfileSwitcher.Log(randomFilePath + " not found, Randomizing all profiles!");
                        profilePriorities[i] = (float)1;
                    }
                }
                for (int i = 0; i < profilePriorities.Length; i++)
                {
                    float multiplier = (float)randGenerator.Next(10000, 10100) / (float)10000.0;
                    profilePriorities[i] = (float)profilePriorities[i] * multiplier;
                }
                randomProfiles = new string[profiles.Length];
                Array.Copy(profiles, randomProfiles, profiles.Length);
                Array.Sort(profilePriorities, randomProfiles);
                startIndex = 0;
                for (int i = 0; i < profilePriorities.Length; i++)
                {
                    if (profilePriorities[i] > 0.0)
                    {
                        startIndex = i;
                        break;
                    }
                }
                if (ZetaDia.IsInGame && Zeta.CommonBot.BotMain.IsRunning)
                {
                    int counter = 0;
                    ProfileSwitcher.Log("Randomized profiles for next run:");
                    ProfileSwitcher.Logger("Randomization order for this run:");
                    for (int i = 0; i < profilePriorities.Length; i++)
                    {
                        if (i >= startIndex)
                        {
                            ProfileSwitcher.Log((++counter) + ": " + randomProfiles[i]);
                            ProfileSwitcher.Logger((counter) + ": " + randomProfiles[i]);
                        }
                    }
                    ProfileSwitcher.Logger("\n");
                }
                Array.Clear(profiles, 0, profiles.Length);
                Array.Copy(randomProfiles, startIndex, profiles, 0, randomProfiles.Length - startIndex);
            }
        }