public Settings()
        {
            if (!Directory.Exists(CustomJsonFolder))
            {
                Directory.CreateDirectory(CustomJsonFolder);
                string   executeDirectoryPath   = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string   pathToModuleData       = @"..\..\ModuleData\";
                string   pathToModuleDataFolder = Path.GetFullPath(Path.Combine(executeDirectoryPath, pathToModuleData));
                string[] defaultCustomExamples  = Directory.GetFiles(pathToModuleDataFolder);
                foreach (string exampleFilePath in defaultCustomExamples)
                {
                    string exampleFileName = Path.GetFileName(exampleFilePath);
                    string destinationPath = Path.Combine(CustomJsonFolder, exampleFileName);
                    File.Copy(exampleFilePath, destinationPath, true);
                }
            }
            string[]      customFilePaths = Directory.GetFiles(CustomJsonFolder, "*.json");
            List <string> customFiles     = new List <string>();

            foreach (string customFilePath in customFilePaths)
            {
                string fileName = Path.GetFileName(customFilePath);
                customFiles.Add(fileName);
            }
            IEnumerable <string> spawnOptions = spawnOptionsProgrammatically.Concat(customFiles);

            RecruitmentSettings = new DefaultDropdown <string>(spawnOptions, 0);
        }
Exemple #2
0
        public static bool FactionInScope(IFaction faction, DefaultDropdown <string> scope)
        {
            if (faction is null || faction.MapFaction is null || scope is null || scope.SelectedIndex < 0 || scope.SelectedIndex > 2)
            {
                return(false);
            }

            switch (scope.SelectedIndex)
            {
            case 0: break;

            case 1:
                if (Clan.PlayerClan.MapFaction is null || !Clan.PlayerClan.MapFaction.IsKingdomFaction || Clan.PlayerClan.MapFaction != faction.MapFaction)
                {
                    return(false);
                }
                break;

            case 2:
                if (Clan.PlayerClan.MapFaction is null || !Clan.PlayerClan.MapFaction.IsKingdomFaction || !(faction.MapFaction.IsKingdomFaction && faction.MapFaction.Leader != Hero.MainHero))
                {
                    return(false);
                }
                break;

            default:
                break;
            }

            return(true);
        }
Exemple #3
0
        public static bool SubSystemEnabled(SubSystemType subSystem, List <IFaction> factionList)
        {
            if (!SubSystemEnabled(subSystem))
            {
                return(false);
            }
            DefaultDropdown <string> scope = DetermineSubSystemScope(subSystem);

            foreach (IFaction faction in factionList)
            {
                if (FactionInScope(faction, scope))
                {
                    return(true);
                }
            }
            return(false);
        }