예제 #1
0
    public static SavedDungeon ConvertFrom(OverworldDungeon dungeon)
    {
        if (dungeon.dungeonData == null)
        {
            return new SavedDungeon()
                   {
                       location = SavedVector2.ConvertFrom(dungeon.position),
                       uuid     = dungeon.uuid
                   }
        }
        ;
        var output = new SavedDungeon {
            entered                     = true,
            location                    = SavedVector2.ConvertFrom(dungeon.position),
            numFloors                   = dungeon.dungeonData.numFloors,
            grid                        = dungeon.dungeonData.grid,
            maxSocialTier               = dungeon.dungeonData.maxSocialTier,
            maxDimensions               = dungeon.dungeonData.maxDimensions,
            encounterThemes             = dungeon.dungeonData.encounterThemes,
            seeds                       = dungeon.seeds,
            uuid                        = dungeon.uuid,
            lootSlotAffinities          = dungeon.dungeonData.lootSlotAffinities,
            lootPrimaryStatAffinities   = dungeon.dungeonData.lootPrimaryStatAffinities,
            lootSecondaryStatAffinities = dungeon.dungeonData.lootSecondaryStatAffinities,
            elementalAffinity           = dungeon.dungeonData.elementalAffinity,
            bossLootSlotAffinities      = dungeon.dungeonData.bossLootSlotAffinities
        };

        foreach (var kvp in dungeon.dungeonData.enemyStatBoosts)
        {
            output.enemyStatBoostEnemies.Add(kvp.Key);

            output.enemyStatBoostStats.Add(kvp.Value);
        }
        foreach (var kvp in dungeon.dungeonData.enemyBonusAbilities)
        {
            output.enemyBonusAbilityEnemies.Add(kvp.Key);
            output.enemyBonusAbilityAbilities.Add(SavedActiveAbility.ConvertFrom(kvp.Value));
        }
        foreach (var room in dungeon.dungeonData.rooms)
        {
            output.rooms.Add(SavedRoom.ConvertFrom(room));
        }
        foreach (var monster in dungeon.dungeonData.monsters)
        {
            output.monsters.Add(SavedMonsterData.ConvertFrom(monster));
        }
        foreach (var path in dungeon.dungeonData.paths)
        {
            output.paths.Add(SavedVaultPath.ConvertFrom(path));
        }
        return(output);
    }
예제 #2
0
 public static void OverwriteDungeonData(OverworldDungeon dungeonData)
 {
     if (lastSavedWorld == null)
     {
         return;
     }
     for (int i = 0; i < lastSavedWorld.dungeons.Count; i++)
     {
         var dungeon = lastSavedWorld.dungeons[i];
         if (dungeon.uuid == dungeonData.uuid)
         {
             lastSavedWorld.dungeons[i] = SavedDungeon.ConvertFrom(dungeonData);
             break;
         }
     }
 }
예제 #3
0
    public static SavedWorld ConvertFrom(GameObject go)
    {
        var obj            = new SavedWorld();
        var worldAutoSaver = go.GetComponent <WorldAutoSaver>();

        if (PlayerCharacter.localPlayer != null)
        {
            foreach (var item in PlayerCharacter.localPlayer.inventory.items)
            {
                obj.inventory.Add(SavedItem.ConvertFrom(item));
            }
        }
        obj.name = worldAutoSaver.worldName;
        if (OverworldGenerator.instance != null)
        {
            obj.savedOverworld = true;
            obj.elevation      = OverworldGenerator.instance.elevation;
            foreach (var landmark in OverworldLandmarkGenerator.landmarks)
            {
                if (landmark.type == "base")
                {
                    obj.baseCoords = SavedVector2.ConvertFrom(landmark.position);
                }
                else if (landmark.type == "dungeon")
                {
                    obj.dungeons.Add(SavedDungeon.ConvertFrom((OverworldDungeon)landmark));
                }
            }
        }
        else if (lastSavedWorld != null)
        {
            obj.savedOverworld = lastSavedWorld.savedOverworld;
            obj.elevation      = lastSavedWorld.elevation;
            obj.baseCoords     = lastSavedWorld.baseCoords;
            obj.dungeons       = lastSavedWorld.dungeons;
        }
        lastSavedWorld = obj;
        return(obj);
    }