Esempio n. 1
0
    public static SavedVaultPath ConvertFrom(VaultPath path)
    {
        var output = new SavedVaultPath();

        foreach (var room in path.rooms)
        {
            output.roomIds.Add(room.uuid);
        }
        return(output);
    }
Esempio n. 2
0
    public VaultPath ConvertTo(List <Room> rooms)
    {
        var output = new VaultPath();

        foreach (var id in roomIds)
        {
            foreach (var room in rooms)
            {
                if (room.uuid == id)
                {
                    output.rooms.Add(room);
                    break;
                }
            }
        }
        return(output);
    }
        private string GetLocalFolder(string vaultFolderPath, string localPath)
        {
            string local = localPath;
            string vaultFolder;

            if (!String.IsNullOrWhiteSpace(Output))
            {
                local = Output;
                string subFolder;
                if (vaultFolderPath.Equals(VaultPath, StringComparison.InvariantCultureIgnoreCase))
                {
                    subFolder = "";//System.IO.Path.GetFileName(vaultFolderPath);
                }
                else if (VaultPath.EndsWith("/"))
                {
                    subFolder = vaultFolderPath.Substring(VaultPath.Length).Replace('/', '\\');
                }
                else
                {
                    subFolder = vaultFolderPath.Substring(VaultPath.Length + 1).Replace('/', '\\');
                }
                vaultFolder = System.IO.Path.Combine(Output, subFolder);
            }
            else
            {
                vaultFolder = local + System.IO.Path.Combine(vaultFolderPath.Substring(1)).Replace('/', '\\');
            }
            foreach (Tuple <string, string> folderMapping in FolderMappings)
            {
                if (folderMapping.Item1.Equals(vaultFolderPath, StringComparison.InvariantCultureIgnoreCase))
                {
                    vaultFolder = folderMapping.Item2;
                    if (!vaultFolder.EndsWith("\\"))
                    {
                        vaultFolder += "\\";
                    }
                }
                else if (vaultFolderPath.StartsWith(folderMapping.Item1, StringComparison.InvariantCultureIgnoreCase))
                {
                    vaultFolder = folderMapping.Item2 + "\\" + vaultFolderPath.Substring(folderMapping.Item1.Count() + 1).Split("/").StringJoin("\\");
                }
            }

            return(vaultFolder);
        }
Esempio n. 4
0
    private void AttachToRoom(VaultPath path, Room attachRoom, List <Corridor> corridors)
    {
        var corridor = new Corridor()
        {
            connectedRooms = { path.rooms[0], attachRoom }
        };
        int corridorRoll = RNG.Int(0, 2);

        if (corridorRoll == 0)
        {
            corridor.size = 4;
        }
        else
        {
            corridor.size = RNG.Int(6, 22);
        }
        corridors.Add(corridor);
    }
Esempio n. 5
0
    private int GetPathEncounterNumber(VaultPath path)
    {
        int count = 0;

        foreach (var room in path.rooms)
        {
            if (room is VaultRoom vaultRoom)
            {
                if (vaultRoom.hasEncounter)
                {
                    count++;
                }
            }
            else if (room is BossRoom)
            {
                count++;
            }
        }
        return(count);
    }
Esempio n. 6
0
    private void AttachRandomly(VaultPath path, List <VaultPath> paths, VaultRoom startingRoom, List <Corridor> corridors)
    {
        int x = RNG.Int(-1, paths.Count);

        if (paths.Count == 1)
        {
            return;
        }
        while (x == paths.IndexOf(path))
        {
            x = RNG.Int(-1, paths.Count);
        }
        if (x == -1)
        {
            AttachToRoom(path, startingRoom, corridors);
        }
        else
        {
            var attachPath = paths[x];
            int y          = RNG.Int(0, attachPath.rooms.Count);
            var attachRoom = attachPath.rooms[y];
            AttachToRoom(path, attachRoom, corridors);
        }
    }
        /************************************************************************************************************/
        /************************************************************************************************************/
        private bool AbhereSynchronizationRules(FileFolder file, bool recursive, bool children)
        {
            if (!children && !recursive && !(file.Folder.FullName.Equals(VaultPath, StringComparison.InvariantCultureIgnoreCase) || (file.Folder.FullName + "/" + file.File.Name).Equals(VaultPath, StringComparison.InvariantCultureIgnoreCase)))
            {
                return(false);
            }

            if (!children && !(file.Folder.FullName + "/" + file.File.Name).ToLower().Contains(VaultPath.ToLower()))
            {
                return(false);
            }

            if (((PatternsToSynchronize.Count() > 0) && (!PatternsToSynchronize.Any(s => file.File.Name.ToLower().EndsWith(s.ToLower())))) && !((PatternsToSynchronize.Count() == 1) && (PatternsToSynchronize[0].Equals("/", StringComparison.InvariantCultureIgnoreCase))))
            {
                return(false);
            }

            if ((Excludes.Count() > 0) && (Excludes.Any(s => (file.Folder.FullName + "/" + file.File.Name).ToLower().Contains(s.ToLower()))))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 8
0
    private void CreateEncounterPath(VaultPath path, int targetLevel)
    {
        var   difficulties       = new List <float>();
        var   conceptsUsed       = new List <List <bool> >();
        var   conceptsIntroduced = new List <bool>();
        var   numConcepts        = encounterThemes.Count;
        var   numPathEncounters  = GetPathEncounterNumber(path);
        float scaleFactor        = 1;

        // determine difficulty of each encounter
        for (int i = 1; i < targetLevel; i++)
        {
            scaleFactor *= 1.44f;
        }
        for (int i = 0; i < numPathEncounters; i++)
        {
            var currentDifficulty = nishikadoBaseDifficultyLookup[targetLevel - 1] * nishikadoEncounterDifficultyLookup[i] * scaleFactor;
            var fudgeFactor       = RNG.Float(0.75f, 1.25f);
            difficulties.Add(currentDifficulty * fudgeFactor);
        }

        // determine which concepts to use in each encounter
        for (int i = 0; i < numConcepts; i++)
        {
            conceptsIntroduced.Add(false);
        }
        conceptsIntroduced[0] = true;
        var conceptList = new List <bool> {
            true
        };

        for (int i = 1; i < numConcepts; i++)
        {
            conceptList.Add(false);
        }
        conceptsUsed.Add(conceptList);
        for (int i = 1; i < numPathEncounters; i++)
        {
            conceptList = new List <bool>();
            float chanceOfNew = i / numPathEncounters;
            float roll        = RNG.Float(0, 1);
            if (roll <= chanceOfNew && HasUnintroducedConcepts(conceptsIntroduced))
            {
                //introduce new concept
                var conceptIndex = conceptsIntroduced.IndexOf(false);
                conceptsIntroduced[conceptIndex] = true;
                for (int j = 0; j < numConcepts; j++)
                {
                    if (j == conceptIndex)
                    {
                        conceptList.Add(true);
                    }
                    else
                    {
                        conceptList.Add(false);
                    }
                }
                conceptsUsed.Add(conceptList);
            }
            else
            {
                //use existing concepts
                conceptList = new List <bool>();
                foreach (var concept in conceptsIntroduced)
                {
                    if (!concept)
                    {
                        conceptList.Add(false);
                    }
                    else
                    {
                        var roll2 = RNG.Int(0, 3);
                        if (roll2 == 0)
                        {
                            conceptList.Add(false);
                        }
                        else
                        {
                            conceptList.Add(true);
                        }
                    }
                }
                ValidateConceptSet(conceptList);
                conceptsUsed.Add(conceptList);
            }
        }

        // create monsters for each encounter
        int encounterNumber = 0;

        foreach (var room in path.rooms)
        {
            if (room is VaultRoom vaultRoom)
            {
                if (vaultRoom.hasEncounter)
                {
                    AddMonstersForRoom(room, difficulties[encounterNumber], conceptsUsed[encounterNumber], scaleFactor);
                    encounterNumber++;
                }
            }
            else if (room is BossRoom)
            {
                AddBoss(room, difficulties[encounterNumber], conceptsUsed[encounterNumber]);
                encounterNumber++;
            }
        }
    }