void Awake()
    {
        string   sceneName = SceneManager.GetActiveScene().name;
        RoomSave roomSave  = GameStateManager.getRoomSave(sceneName);

        instantiateRoomPrefabs(roomSave);
    }
    private void instantiateRoomPrefabs(RoomSave roomSave)
    {
        // spawn player prefab
        Vector3 playerSpawnPoint = roomSave.playerSpawnLocations[roomSave.playerSpawnIndex]; // will need direction of entry for animation, possibly also player state

        Instantiate(Resources.Load("player"), playerSpawnPoint, Quaternion.identity);
    }
Exemple #3
0
    public void updateRoomData(string sceneName, int playerSpawnIndex)
    {
        RoomSave temp = save.roomSaves[sceneName];

        temp.playerSpawnIndex = playerSpawnIndex;

        save.roomSaves[sceneName] = temp;
    }
Exemple #4
0
    public void LoadDungeonsRooms()
    {
        int objCount     = 0,
            chestCount   = 0,
            itemCount    = 0,
            blockCount   = 0,
            torchCount   = 0,
            pitsCount    = 0,
            spritesCount = 0,
            roomCount    = 0;

        for (int i = 0; i < 296; i++)
        {
            try
            {
                all_rooms[i]  = new RoomSave((short)i);
                objCount     += all_rooms[i].tilesObjects.Count;
                chestCount   += all_rooms[i].chest_list.Count;
                itemCount    += all_rooms[i].pot_items.Count;
                blockCount   += all_rooms[i].blocks.Count;
                torchCount   += all_rooms[i].torches.Count;
                pitsCount    += all_rooms[i].damagepit ? 1 : 0;
                spritesCount += all_rooms[i].sprites.Count;
                if (all_rooms[i].tilesObjects.Count != 0)
                {
                    roomCount++;
                }
                if (i == 5)
                {
                    Console.WriteLine(all_rooms[i].tilesObjects.Count);
                }
            }
            catch (Exception e)
            {
                WriteLog("Error : " + e.Message.ToString(), Color.Red);
                return;
            }
        }
        LoadedProjectStatistics.blocksRooms        = blockCount;
        LoadedProjectStatistics.chestsRooms        = chestCount;
        LoadedProjectStatistics.chestsRoomsLength  = ((ROM.DATA[ConstantsReader.GetAddress("chests_length_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("chests_length_pointer")])) / 3;
        LoadedProjectStatistics.blocksRoomsLength  = ((short)((ROM.DATA[ConstantsReader.GetAddress("blocks_length") + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("blocks_length")])) / 4;
        LoadedProjectStatistics.torchesRoomsLength = 86;//(ROM.DATA[ConstantsReader.GetAddress("torches_length_pointer + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("torches_length_pointer];
        LoadedProjectStatistics.entrancesRooms     = 132;
        LoadedProjectStatistics.itemsRooms         = itemCount;
        LoadedProjectStatistics.pitsRooms          = pitsCount;
        LoadedProjectStatistics.pitsRoomsLength    = (ROM.DATA[ConstantsReader.GetAddress("pit_count")] / 2);
        LoadedProjectStatistics.torchesRooms       = torchCount;
        LoadedProjectStatistics.usedRooms          = roomCount;
        LoadedProjectStatistics.spritesRooms       = spritesCount;
        LoadedProjectStatistics.objectsRooms       = objCount;
        WriteLog("All dungeon rooms data loaded properly : ", Color.Green);
    }
Exemple #5
0
 public void writeRooms(string path)
 {
     if (!Directory.Exists(path + "Dungeons"))
     {
         Directory.CreateDirectory(path + "Dungeons");
     }
     if (!Directory.Exists(path + "Dungeons//Rooms"))
     {
         Directory.CreateDirectory(path + "Dungeons//Rooms");
     }
     for (int i = 0; i < 296; i++)
     {
         RoomSave rs = new RoomSave((short)i);
         File.WriteAllText(path + "Dungeons//Rooms//Room " + i.ToString("D3") + ".json", JsonConvert.SerializeObject(rs, Formatting.None, new JsonSerializerSettings()
         {
             ReferenceLoopHandling = ReferenceLoopHandling.Ignore
         }));
     }
 }
    private void loadDefaultSave()
    {
        TotalRoomSave totalRoomSave            = new TotalRoomSave();
        Dictionary <string, RoomSave> tempDict = new Dictionary <string, RoomSave>();

        RoomSave room1 = new RoomSave();

        room1.playerSpawnIndex     = 0;
        room1.playerSpawnLocations = new SVector3[] {
            new SVector3(-10.3f, 12.67f, 0),
            new SVector3(-8.72f, 1.67f, 0f),
            new SVector3(34.84f, -31.3f, 0),
            new SVector3(37.13f, 7.65f, 0),
            new SVector3(5.07f, 19.61f, 0)
        };
        tempDict.Add("Arboretum0", room1);

        RoomSave room2 = new RoomSave();

        room2.playerSpawnIndex     = 0;
        room2.playerSpawnLocations = new SVector3[] {
            new SVector3(-7.88f, 1.65f, 0),
            new SVector3(72.44f, -0.31f, 0)
        };
        tempDict.Add("Arboretum1", room2);

        RoomSave room3 = new RoomSave();

        room3.playerSpawnIndex     = 0;
        room3.playerSpawnLocations = new SVector3[] {
            new SVector3(-7.36f, 1.7f, 0),
            new SVector3(-7.75f, -32.33f, 0),
            new SVector3(0.46f, -48.33f, 0),
            new SVector3(67.26f, -0.34f, 0)
        };
        tempDict.Add("Arboretum2", room3);

        RoomSave room4 = new RoomSave();

        room4.playerSpawnIndex     = 0;
        room4.playerSpawnLocations = new SVector3[] {
            new SVector3(-4.88f, 1.66f, 0),
            new SVector3(63.68f, 3.30f, 0),
            new SVector3(66.12f, 8.71f, 0)
        };
        tempDict.Add("Arboretum3", room4);

        RoomSave room5 = new RoomSave();

        room5.playerSpawnIndex     = 4;
        room5.playerSpawnLocations = new SVector3[] {
            new SVector3(-11.26f, 1.67f, 0)
        };
        tempDict.Add("Arboretum4", room5);

        RoomSave room6 = new RoomSave();

        room6.playerSpawnIndex     = 0;
        room6.playerSpawnLocations = new SVector3[] {
            new SVector3(-7.84f, 1.65f, 0)
        };
        tempDict.Add("Arboretum5", room6);

        totalRoomSave.roomSaves = tempDict;
        SaveManager.saveTotalRoomSave(totalRoomSave);

        // initiate gamestateManager
        GameStateManager.loadRoomStats();
    }