Esempio n. 1
0
        // Gets all users.
        public static List <ProfileSwitcher> GetAllProfiles()
        {
            snaptergramEntities db = new snaptergramEntities();

            List <users> AllUsers = new List <users>();

            using (db)
            {
                var data = from u in db.users select u;
                AllUsers = data.ToList();
            }

            // Convert the users to ProfileBar
            List <ProfileSwitcher> AllResults = new List <ProfileSwitcher>();

            foreach (users U in AllUsers)
            {
                // Need to create a profile bar object.
                ProfileSwitcher Converted = new ProfileSwitcher();
                Converted.ProfileId       = U.userId;
                Converted.ProfilePicture  = U.profilePic;
                Converted.ProfileUserName = U.username;

                AllResults.Add(Converted);
            }

            return(AllResults);
        }
Esempio n. 2
0
 public static void LoadNextProfile(string name = null, string path = null)
 {
     if (name != null)
     {
         int nextProfileIndex = profiles.IndexOf(profilePath + "\\" + name);
         if (nextProfileIndex == -1)
         {
             ProfileSwitcher.Log("Profile not found - check your Profile XML!");
         }
         else
         {
             if (wasLastProfile())
             {
             }
             else
             {
                 LoadProfile(profiles[nextProfileIndex]);
             }
         }
     }
     else if (path != null)
     {
         if (tempProfileWasLoaded)
         {
             tempProfileWasLoaded = false;
             if (wasLastProfile(preDeathProfile))
             {
             }
             else
             {
                 LoadProfile(path);
             }
         }
         else
         {
             LoadProfile(path);
         }
     }
     else
     {
         if (tempProfileWasLoaded)
         {
             tempProfileWasLoaded = false;
             LoadProfile(getNextProfilePath(preDeathProfile));
         }
         else
         {
             if (wasLastProfile())
             {
             }
             else
             {
                 LoadProfile(getNextProfilePath());
             }
         }
     }
     ProfileSwitcher.deathRetries = 0;
 }
Esempio n. 3
0
        public static void readXml(XmlTextReader xml)
        {
            bool error = false;

            profileHandler.profileWaypoints.Clear();
            while (xml.Read())
            {
                switch (xml.NodeType)
                {
                case XmlNodeType.Element:
                    Vector3 waypoint = new Vector3();
                    if (xml.Name == "MoveTo" || xml.Name == "UseWaypoint" || xml.Name == "UseObject")
                    {
                        try
                        {
                            xml.MoveToAttribute("x");
                            waypoint.X = float.Parse(xml.Value, System.Globalization.CultureInfo.CreateSpecificCulture("en-us"));
                        }
                        catch (Exception e)
                        {
                            ProfileSwitcher.Log(String.Format("x coordinate can't be parsed from xml; Element: {0} Line: {1} Position: {2}", xml.Name, xml.LineNumber, xml.LinePosition));
                            error = true;
                        }
                        try
                        {
                            xml.MoveToAttribute("y");
                            waypoint.Y = float.Parse(xml.Value, System.Globalization.CultureInfo.CreateSpecificCulture("en-us"));
                        }
                        catch (Exception e)
                        {
                            ProfileSwitcher.Log(String.Format("y coordinate can't be parsed from xml; Element: {0} Line: {1} Position: {2}", xml.Name, xml.LineNumber, xml.LinePosition));
                            error = true;
                        }
                        try
                        {
                            xml.MoveToAttribute("z");
                            waypoint.Z = float.Parse(xml.Value, System.Globalization.CultureInfo.CreateSpecificCulture("en-us"));
                        }
                        catch (Exception e)
                        {
                            ProfileSwitcher.Log(String.Format("z coordinate can't be parsed from xml; Element: {0} Line: {1} Position: {2}", xml.Name, xml.LineNumber, xml.LinePosition));
                            error = true;
                        }
                    }
                    if (!error)
                    {
                        profileHandler.profileWaypoints.Add(waypoint);
                    }
                    else
                    {
                        error = false;
                        ProfileSwitcher.Log("Ignoring Waypoint");
                    }
                    break;
                }
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
    private void Awake()
    {
        Transform canvas = GameObject.FindGameObjectWithTag("UI").transform;

        if (canvas)
        {
            profiles         = battleUI.transform.GetChild(0).GetComponent <ProfileSwitcher>();
            earthProfile     = profiles.transform.GetChild(1).gameObject;
            lightningProfile = profiles.transform.GetChild(2).gameObject;;

            //    profiles.SwitchAbilityButtons();

            if (fadePlane)
            {
                fadePlane.color = new Color(fadePlane.color.r, fadePlane.color.g, fadePlane.color.b, 1.0f);
                loadingText     = fadePlane.transform.GetComponentInChildren <TextMeshProUGUI>();

                if (loadingText)
                {
                    loadingText.color = new Color(loadingText.color.r, loadingText.color.g, loadingText.color.b, 1.0f);
                }
            }
        }

        Manager.instance.TurnController.PlayerTurnEvent     += TurnEvent;
        Manager.instance.StateController.OnGameStateChanged += GameStateChanged;

        buttons = new Button[]
        {
            move,
            attack,
            specialAttack
        };


        buttonState = new bool[buttons.Length];

        for (int i = 0; i < buttons.Length; i++)
        {
            buttonState[i] = buttons[i].interactable;
        }

        //initialButtonState = buttonState;

        player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
    }
Esempio n. 6
0
        public static bool LoadTempProfile()
        {
            float min = 150;

            xmlHandler.readXml(new XmlTextReader(preDeathProfile));
            revivePosition = ZetaDia.Actors.Me.Position;
            Vector3 closestWP = new Vector3();

            foreach (Vector3 wp in profileWaypoints)
            {
                if (Vector3.Distance(wp, ZetaDia.Actors.Me.Position) < min)
                {
                    min       = Vector3.Distance(wp, revivePosition);
                    closestWP = wp;
                }
            }
            if ((int)min != 150)
            {
                ProfileSwitcher.Log("Closest profile waypoint: " + closestWP.ToString());
                ProfileSwitcher.Log("Distance: " + min);
                ProfileSwitcher.Log("Generating temporary profile...");
                string tmpProfile = xmlHandler.generateTempProfile(closestWP, preDeathProfile, getNextProfilePath(preDeathProfile));
                ProfileSwitcher.Log("Loading temporary profile: " + tmpProfile);
                if (tmpProfile != null)
                {
                    ProfileManager.Load(tmpProfile);
                }
                else
                {
                    ProfileSwitcher.Log("Something went wrong while profile generation - reloading actual profile instead!");
                    ReloadProfile();
                }
                tempProfileWasLoaded = true;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
 public static bool wasLastProfile(string profile = null)
 {
     if (getNextProfilePath(profile) == getFirstProfilePath())
     {
         ProfileSwitcher.Log("All profiles completed, logging out!.");
         if (!ZetaDia.Me.IsInTown)
         {
             ZetaDia.Service.Games.LeaveGame();
             BotMain.PauseFor(System.TimeSpan.FromSeconds(15));
         }
         else
         {
             ZetaDia.Service.Games.LeaveGame();
             BotMain.PauseFor(System.TimeSpan.FromSeconds(2));
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 8
0
 //Defining initial level elements
 public void DefineInitialLevelElements()
 {
     DontDestroyOnLoad(this.gameObject);
     gameUI          = GameObject.Find("Game Initialization UI");
     profileSwitcher = gameUI.transform.Find("Profile Switcher").gameObject.GetComponent <ProfileSwitcher> ();
 }
Esempio n. 9
0
        public static string generateTempProfile(Vector3 nearestWaypoint, string currentProfile, string nextProfile)
        {
            bool indexWritten = false;
            bool foundWP      = false;
            bool error        = false;

            string[]      whileAttrNames  = new string[5];
            string[]      whileAttrValues = new string[5];
            int           j               = 0;
            int           ifindex         = 0;
            int           whileIndex      = 0;
            DateTime      currentDateTime = DateTime.Now;
            String        dateStr         = currentDateTime.ToString("yyyy-MM-dd HH_mm_ss");
            string        tmpProfilePath  = Path.GetTempPath() + dateStr + ".xml";
            XmlTextReader origProfile     = new XmlTextReader(currentProfile);
            XmlTextWriter tempProfile     = new XmlTextWriter(tmpProfilePath, null);

            tempProfile.Formatting = Formatting.Indented;
            tempProfile.WriteStartDocument();
            while (origProfile.Read())
            {
                switch (origProfile.NodeType)
                {
                case XmlNodeType.Element:
                    tempProfile.Flush();
                    if (origProfile.Name == "Order")
                    {
                        tempProfile.WriteStartElement(origProfile.Name);
                        indexWritten = true;
                        break;
                    }
                    if (foundWP)
                    {
                        if (origProfile.Name == "nextProfile" || origProfile.Name == "Continue")
                        {
                            tempProfile.WriteStartElement("nextProfile");
                            tempProfile.WriteAttributeString("path", nextProfile);
                            tempProfile.WriteEndElement();
                            break;
                        }
                        tempProfile.WriteStartElement(origProfile.Name);
                        while (origProfile.MoveToNextAttribute())
                        {
                            tempProfile.WriteAttributeString(origProfile.Name, origProfile.Value);
                        }
                        origProfile.MoveToElement();
                        if (origProfile.Name != "If" && origProfile.Name != "While" && origProfile.Name != "KillMonsters" && origProfile.Name != "PickupLoot" && origProfile.Name != "TargetBlacklists")
                        {
                            tempProfile.WriteEndElement();
                        }
                        break;
                    }
                    if (!indexWritten)
                    {
                        tempProfile.WriteStartElement(origProfile.Name);
                        if (origProfile.HasAttributes)
                        {
                            while (origProfile.MoveToNextAttribute())
                            {
                                tempProfile.WriteAttributeString(origProfile.Name, origProfile.Value);
                            }
                        }
                        origProfile.MoveToElement();
                        if (origProfile.Name == "GameParams" || origProfile.Name == "TargetBlacklist")
                        {
                            tempProfile.WriteEndElement();
                        }
                        break;
                    }
                    if (indexWritten && origProfile.Name == "If" && !foundWP)
                    {
                        ifindex++;
                        break;
                    }
                    if (indexWritten && origProfile.Name == "While" && !foundWP)
                    {
                        Array.Clear(whileAttrNames, 0, whileAttrNames.Length);
                        Array.Clear(whileAttrValues, 0, whileAttrValues.Length);
                        if (origProfile.HasAttributes)
                        {
                            for (int i = 0; i < origProfile.AttributeCount; i++)
                            {
                                origProfile.MoveToNextAttribute();
                                whileAttrNames[i]  = origProfile.Name;
                                whileAttrValues[i] = origProfile.Value;
                            }
                        }
                        whileIndex = 1;
                        break;
                    }
                    if (indexWritten && (origProfile.Name == "MoveTo" || origProfile.Name == "UseWaypoint" || origProfile.Name == "UseObject") && !foundWP)
                    {
                        ProfileSwitcher.Log("Searching WP..." + ++j);
                        Vector3 waypoint = new Vector3();
                        error = false;
                        try
                        {
                            origProfile.MoveToElement();
                            origProfile.MoveToAttribute("x");
                            waypoint.X = float.Parse(origProfile.Value, System.Globalization.CultureInfo.CreateSpecificCulture("en-us"));
                            origProfile.MoveToElement();
                            origProfile.MoveToAttribute("y");
                            waypoint.Y = float.Parse(origProfile.Value, System.Globalization.CultureInfo.CreateSpecificCulture("en-us"));
                            origProfile.MoveToElement();
                            origProfile.MoveToAttribute("z");
                            waypoint.Z = float.Parse(origProfile.Value, System.Globalization.CultureInfo.CreateSpecificCulture("en-us"));
                        }
                        catch (Exception e)
                        {
                            error = true;
                        }
                        origProfile.MoveToElement();
                        if (!error && (waypoint == nearestWaypoint))
                        {
                            ProfileSwitcher.Log("Found WP:" + waypoint.ToString());
                            if (whileIndex == 1)
                            {
                                tempProfile.WriteStartElement("While");
                                for (int i = 0; i < whileAttrNames.Length; i++)
                                {
                                    if (whileAttrNames[i] != null)
                                    {
                                        tempProfile.WriteAttributeString(whileAttrNames[i], whileAttrValues[i]);
                                    }
                                }
                                whileIndex = 0;
                            }
                            tempProfile.WriteStartElement(origProfile.Name);
                            while (origProfile.MoveToNextAttribute())
                            {
                                tempProfile.WriteAttributeString(origProfile.Name, origProfile.Value);
                            }
                            foundWP = true;
                            tempProfile.WriteEndElement();
                        }
                        else
                        {
                            //ProfileSwitcher.Log("Wrong waypoint: " + waypoint.ToString());
                        }
                        break;
                    }
                    break;

                case XmlNodeType.Text:
                    if (!indexWritten || foundWP)
                    {
                        tempProfile.WriteString(origProfile.Value);
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (indexWritten && !foundWP && (ifindex > 0))
                    {
                        ifindex--;
                        break;
                    }
                    if (indexWritten && !foundWP && (whileIndex == 1))
                    {
                        whileIndex = 0;
                        Array.Clear(whileAttrNames, 0, whileAttrNames.Length);
                        Array.Clear(whileAttrValues, 0, whileAttrValues.Length);
                        break;
                    }
                    if (!indexWritten || foundWP)
                    {
                        if (ifindex > 0)
                        {
                            ifindex--;
                            break;
                        }
                        tempProfile.WriteFullEndElement();
                    }
                    break;
                }
            }
            tempProfile.WriteEndDocument();
            tempProfile.Flush();
            tempProfile.Close();
            if (foundWP)
            {
                return(tmpProfilePath);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
0
 public static void ReloadProfile()
 {
     ProfileSwitcher.startRunTimer();
     ProfileSwitcher.Log("Loading profile: " + GlobalSettings.Instance.LastProfile);
     ProfileManager.Load(GlobalSettings.Instance.LastProfile);
 }