Exemplo n.º 1
0
        public static bool Convert(string path)
        {
            try
            {
                GrinderProfile flyingProfile     = XmlSerializer.Deserialize <GrinderProfile>(path);
                GrinderProfile tempFlyingProfile = new GrinderProfile();
                string         flyingProfileName = Path.GetFileNameWithoutExtension(path);

                if (flyingProfile.GrinderZones.Count <= 0)
                {
                    Logging.Write(string.Format("The file {0} is not a valid Grinder Profile.", flyingProfileName));
                    return(false);
                }

                foreach (GrinderZone zone in flyingProfile.GrinderZones)
                {
                    if (zone.Points.Any(point => point.Type.ToLower() == "flying"))
                    {
                        MovementManager.FlyingToGroundProfilesConverter(zone.Points, out _points, out _result);
                        if (_result)
                        {
                            zone.Points = _points;
                            tempFlyingProfile.GrinderZones.Add(zone);
                            continue;
                        }
                        Logging.Write(string.Format("The profile {0} contains at least one Flying Grinder Zone but the conversion has failed.", flyingProfileName));
                        return(false);
                    }
                    Logging.Write(string.Format("The profile {0} does not contains any Flying Grinder Zone.", flyingProfileName));
                    return(false);
                }

                flyingProfile.GrinderZones = tempFlyingProfile.GrinderZones;

                string pathDir  = Application.StartupPath + "\\Profiles\\Grinder\\";
                string fullPath = pathDir + "Ground_" + flyingProfileName + ".xml";
                if (XmlSerializer.Serialize(fullPath, flyingProfile))
                {
                    Logging.Write(string.Format("The Flying profile {0} have been saved.", flyingProfileName));
                    Logging.Write("Path: " + fullPath);
                    return(true);
                }
                Logging.Write(string.Format("The Flying profile {0} have not been saved correctly, make sure you have access right on the directory {1}.",
                                            flyingProfileName, pathDir));
                return(false);
            }
            catch
            {
                Logging.Write("Conversion of the file failed.");
                return(false);
            }
        }
Exemplo n.º 2
0
        public static bool Convert(string path)
        {
            try
            {
                GathererProfile flyingProfile     = XmlSerializer.Deserialize <GathererProfile>(path);
                string          flyingProfileName = Path.GetFileNameWithoutExtension(path);

                if (flyingProfile.Points.Count <= 0)
                {
                    Logging.Write(string.Format("The file {0} is not a valid Gatherer Profile.", flyingProfileName));
                    return(false);
                }

                if (flyingProfile.Points.Any(p => p.Type.ToLower() == "flying"))
                {
                    MovementManager.FlyingToGroundProfilesConverter(flyingProfile.Points, out _points, out _result);
                }
                else
                {
                    Logging.Write(string.Format("The profile {0} is not a Flying Gatherer Profile.", flyingProfileName));
                    return(false);
                }
                if (!_result)
                {
                    return(false);
                }
                flyingProfile.Points = _points;
                string pathDir  = Application.StartupPath + "\\Profiles\\Gatherer\\";
                string fullPath = pathDir + "Ground_" + flyingProfileName + ".xml";
                if (XmlSerializer.Serialize(fullPath, flyingProfile))
                {
                    Logging.Write(string.Format("The Flying profile {0} have been saved.", flyingProfileName));
                    Logging.Write("Path: " + fullPath);
                    return(true);
                }
                Logging.Write(string.Format("The Flying profile {0} have not been saved correctly, make sure you have access right on the directory {1}.",
                                            flyingProfileName, pathDir));
                return(false);
            }
            catch
            {
                Logging.Write("Conversion Failled (WowRobot to Gatherer bot): " + path);
                return(false);
            }
        }