Exemplo n.º 1
0
    //Saves game data at given save slot index
    public void SaveGame(int _saveSlotIndex)
    {
        if (_saveSlotIndex <= 0 || _saveSlotIndex > 8)   //This game will have a maximum 8 (0 to 8) save slots hardcoded. 0 slot should be reserved for quicksave
        {
            Debug.LogError("[Error] Invalid save slot index! Slot number must be between from 1 to 8.");
            return;
        }

        loadedSaveData = new SaveData();
        loadedSaveData.savefileHeader     = "Marco    Lives: " + loadedSaveData.livesAmount + "; Ammo: " + loadedSaveData.ammoAmount + "; Seeds: " + loadedSaveData.seedsCollected + "; Levels Unlocked: " + loadedSaveData.levelsUnlocked;
        loadedSaveData.gameVersion        = this.gameVersion;
        loadedSaveData.playerLocationX    = this.playerLocation.x;
        loadedSaveData.playerLocationY    = this.playerLocation.y;
        loadedSaveData.playerLocationZ    = this.playerLocation.z;
        loadedSaveData.playerOrientationX = this.playerOrientation.x;
        loadedSaveData.playerOrientationY = this.playerOrientation.y;
        loadedSaveData.playerOrientationZ = this.playerOrientation.z;

        loadedSaveData.livesAmount    = this.livesAmount;
        loadedSaveData.ammoAmount     = this.ammoAmount;
        loadedSaveData.seedsCollected = this.seedsCollected;
        loadedSaveData.aliensKilled   = this.aliensKilled;
        loadedSaveData.currentLevel   = this.currentLevel; //0 means not in a level
        loadedSaveData.levelsUnlocked = this.levelsUnlocked;

        SaveFileReaderWriter.WriteToSaveFile(Application.persistentDataPath + "/" + savefileName + _saveSlotIndex + ".hamsave", loadedSaveData);
    }
Exemplo n.º 2
0
    //Saves given game data at given save slot index
    public void SaveGame(int _saveSlotIndex, SaveData _saveData)
    {
        if (_saveSlotIndex <= 0 || _saveSlotIndex > 8)   //This game will have a maximum 8 save slots hardcoded.
        {
            Debug.LogError("[Error] Invalid save slot index! Slot number must be between from 1 to 8.");
            return;
        }

        _saveData.gameVersion    = this.gameVersion;
        _saveData.savefileHeader = "Marco    Lives: " + _saveData.livesAmount + "; Ammo: " + _saveData.ammoAmount + "; Seeds: " + _saveData.seedsCollected + "; Levels Unlocked: " + _saveData.levelsUnlocked;

        SaveFileReaderWriter.WriteToSaveFile(Application.persistentDataPath + "/" + savefileName + _saveSlotIndex + ".hamsave", _saveData);
    }
Exemplo n.º 3
0
    private IEnumerator QuickSaveRoutine(float delay)
    {
        canActivateCheckpoint = false;


        if (saveManagerRef)
        {
            saveManagerRef.QuickSave();
        }
        else
        {
            SaveData newData = new SaveData();
            newData.gameVersion = "0.1";
            SaveFileReaderWriter.WriteToSaveFile(Application.persistentDataPath + "/Hamstronaut0.hamsave", newData);
        }

        yield return(new WaitForSeconds(delay));

        canActivateCheckpoint = true;
    }
Exemplo n.º 4
0
    public void QuickSave()
    {
        loadedSaveData = new SaveData();
        loadedSaveData.savefileHeader     = "(Quicksave) Marco    Lives: " + loadedSaveData.livesAmount + "; Ammo: " + loadedSaveData.ammoAmount + "; Seeds: " + loadedSaveData.seedsCollected + "; Levels Unlocked: " + loadedSaveData.levelsUnlocked;
        loadedSaveData.gameVersion        = this.gameVersion;
        loadedSaveData.playerLocationX    = this.playerLocation.x;
        loadedSaveData.playerLocationY    = this.playerLocation.y;
        loadedSaveData.playerLocationZ    = this.playerLocation.z;
        loadedSaveData.playerOrientationX = this.playerOrientation.x;
        loadedSaveData.playerOrientationY = this.playerOrientation.y;
        loadedSaveData.playerOrientationZ = this.playerOrientation.z;

        loadedSaveData.livesAmount    = this.livesAmount;
        loadedSaveData.ammoAmount     = this.ammoAmount;
        loadedSaveData.seedsCollected = this.seedsCollected;
        loadedSaveData.aliensKilled   = this.aliensKilled;
        loadedSaveData.currentLevel   = this.currentLevel; //0 means not in a level
        loadedSaveData.levelsUnlocked = this.levelsUnlocked;

        SaveFileReaderWriter.WriteToSaveFile(Application.persistentDataPath + "/" + savefileName + "0.hamsave", loadedSaveData);
    }