示例#1
0
    public void SaveGame()
    {
        CurrentRoom = FindObjectOfType <Room>();
        if (CurrentRoom != null)
        {
            if (locationsStates.ContainsKey(SceneManager.GetActiveScene().name))
            {
                locationsStates[SceneManager.GetActiveScene().name] = CurrentRoom.SaveState();
            }
            else
            {
                locationsStates.Add(SceneManager.GetActiveScene().name, CurrentRoom.SaveState());
            }
        }

        SaveGameData data = new SaveGameData();

        data.itemsId         = InventoryController.Instance.items.Select(i => i.idItem).ToArray();
        data.notesId         = JournalController.Instance.notes.Select(n => n.idNote).ToArray();
        data.tasksId         = JournalController.Instance.tasks.Select(t => t.idTask).ToArray();
        data.completeTasksId = JournalController.Instance.completeTasks.Select(t => t.idTask).ToArray();

        data.locationsStates = locationsStates;

        data.globalValues   = Values;
        data.locationName   = SceneManager.GetActiveScene().name;
        data.playerPosition = new Vector4Serializer(PlayerController.Instance.transform.position);
        data.playerRotation = new Vector4Serializer(PlayerController.Instance.transform.rotation);
        data.playerHealth   = PlayerController.Instance.Health;
        data.equipedWearId  = InventoryController.Instance.CurrentDress == null ? "" : InventoryController.Instance.CurrentDress.idItem;

        SaveLoadController.SaveGame(data);
    }