コード例 #1
0
    public static void LoadNewProfile(string profession, string profileName)
    {
        Profile = new GrinderProfile();
        string filePath = Application.StartupPath + "\\Profiles\\Wholesome Professions\\" + profileName;

        Bot.ProfileName = profileName;

        // If grinder School Load Profile
        if (!string.IsNullOrWhiteSpace(profileName) && File.Exists(filePath))
        {
            Profile = XmlSerializer.Deserialize <GrinderProfile>(filePath);
            if (Profile.GrinderZones.Count <= 0)
            {
                Logger.Log($"Profile '{filePath}' seems incorrect. Please use a Grinder profile.");
                UnloadCurrentProfile();
                return;
            }
            else
            {
                Logger.Log("Profile loaded");
            }
        }
        else
        {
            Logger.LogLineBroadcastImportant($"Profile file '{filePath}' not found");
            UnloadCurrentProfile();
            return;
        }

        SelectZone();

        // Black List:
        var blackListDic =
            Profile.GrinderZones.SelectMany(zone => zone.BlackListRadius).ToDictionary(b => b.Position,
                                                                                       b => b.Radius);

        //wManager.wManagerSetting.AddRangeBlackListZone(blackListDic);

        // Add Npc
        foreach (var zone in Profile.GrinderZones)
        {
            NpcDB.AddNpcRange(zone.Npc);
        }

        // Go to first hotspot or travel
        if (Profile.GrinderZones.Count > 0)
        {
            string zoneName    = Profile.GrinderZones[ZoneIdProfile].Name;
            int    continentId = TravelHelper.GetContinentFromZoneName(zoneName);
            Logger.LogDebug($"Zone {zoneName} is on continent {continentId.ToString()}");
            if (continentId == -1)
            {
                Logger.LogLineBroadcastImportant($"ERROR : The zone name {zoneName} from your profile is incorrect. Please use default zone names.");
                UnloadCurrentProfile();
                return;
            }

            if (continentId != Usefuls.ContinentId)
            {
                Logger.Log($"{Profile.GrinderZones[ZoneIdProfile].Name} is on another continent ({continentId}). Launching traveler.");
                Bot.SetContinent((ContinentId)continentId);
                return;
            }

            Bot.ProfileProfession = profession;
            Logger.Log($"Heading to first spot {Profile.GrinderZones[ZoneIdProfile].Vectors3[0]} in {Profile.GrinderZones[ZoneIdProfile].Name}");
            Broadcaster.autoBroadcast = false;
            Broadcaster.BroadCastSituation();
            GoToTask.ToPosition(Profile.GrinderZones[ZoneIdProfile].Vectors3[0], 50);
            Broadcaster.autoBroadcast = true;
        }
        else
        {
            Logger.LogDebug("No grinder zone found");
            UnloadCurrentProfile();
        }
    }