コード例 #1
0
    private void SaveToPlayerPrefs()
    {
        PlayerPrefs.SetString(CURRENT_ROOM, CurrentRoom);
        Vector3 cPosition = CurrentPosition;

        PlayerPrefs.SetFloat(CURRENT_POSITION_X, cPosition.x);
        PlayerPrefs.SetFloat(CURRENT_POSITION_Y, cPosition.y);
        Vector3 rPosition = RestartPosition;

        PlayerPrefs.SetFloat(RESTART_POSITION_X, rPosition.x);
        PlayerPrefs.SetFloat(RESTART_POSITION_Y, rPosition.y);
        PlayerPrefs.SetString(ROOM_STATE, RoomStateSummary);
        PlayerPrefs.SetInt(ITEMS_COLLECTED, ItemsCollected);
        PlayerPrefs.SetInt(CREATURES_KILLED, CreaturesKilled);
        PlayerPrefs.SetInt(LIVES_REMAINING, LivesRemaining);
        PlayerPrefs.SetString(IN_GAME_TIME, InGameTime.Ticks.ToString());
        PlayerPrefs.SetString(MAID_INSTRUCTIONS, MaidGivenInstructions.ToString());
        PlayerPrefs.SetString(MAID_MENTIONED_WEAPON, MaidMentionedWeapon.ToString());
        PlayerPrefs.SetString(MAID_WARNING, MaidGivenWarning.ToString());
        PlayerPrefs.SetString(MAID_RECEIVED_ITEMS, MaidReceivedItems.ToString());
        PlayerPrefs.SetString(BED_REACHED, BedReached.ToString());
        PlayerPrefs.SetString(HELP_SHOWN, HelpShown.ToString());
        PlayerPrefs.SetString(HAS_THE_WEAPON, PlayerHasTheWeapon.ToString());
        PlayerPrefs.SetString(DISABLE_MUSIC, DisableMusic.ToString());
        PlayerPrefs.SetString(DISABLE_EFFECTS, DisableSoundEffects.ToString());
        PlayerPrefs.SetFloat(DIFFICULTY_MULTIPLIER, difficultyMultiplier);
        //Debug.Log("Save gamestate: " + Dump());
    }
コード例 #2
0
    /// <summary>
    /// Dumping the game state forces all properties to be initialized to their current state.
    /// </summary>
    /// <returns>The dump.</returns>
    public string Dump()
    {
        StringBuilder sb = new StringBuilder();

        sb.Append(CurrentRoom + "#");
        sb.Append(CurrentPosition.x.ToString() + "#");
        sb.Append(CurrentPosition.y.ToString() + "#");
        sb.Append(RestartPosition.x.ToString() + "#");
        sb.Append(RestartPosition.y.ToString() + "#");
        sb.Append(RoomStateSummary + "#");
        sb.Append(ItemsCollected.ToString() + "#");
        sb.Append(CreaturesKilled.ToString() + "#");
        sb.Append(LivesRemaining.ToString() + "#");
        sb.Append(InGameTime.ToShortTimeString() + "#");
        sb.Append(MaidGivenInstructions.ToString() + "#");
        sb.Append(MaidGivenWarning.ToString() + "#");
        sb.Append(MaidReceivedItems.ToString() + "#");
        sb.Append(BedReached.ToString() + "#");
        sb.Append(PlayerHasTheWeapon.ToString() + "#");
        sb.Append(DisableMusic.ToString() + "#");
        sb.Append(DisableSoundEffects.ToString() + "#");
        sb.Append(DifficultyMultiplier.ToString());
        return(sb.ToString());
    }