49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using PixelCrushers;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond {
|
|
public class CutsceneSaver : Saver
|
|
{
|
|
[SerializeField] private CutScene[] m_cutscenes;
|
|
[Serializable]
|
|
public class Data
|
|
{
|
|
public bool[] wasPlayed;
|
|
}
|
|
// Start is called before the first frame update
|
|
void Awake()
|
|
{
|
|
if (m_cutscenes == null || m_cutscenes.Length == 0)
|
|
m_cutscenes = GetComponentsInChildren<CutScene>();
|
|
}
|
|
|
|
public override string RecordData()
|
|
{
|
|
Data d = new Data();
|
|
d.wasPlayed = new bool[m_cutscenes.Length];
|
|
for (int i = 0; i < d.wasPlayed.Length; i++)
|
|
{
|
|
d.wasPlayed[i] = m_cutscenes[i].WasPlayed;
|
|
}
|
|
return SaveSystem.Serialize(d);
|
|
|
|
}
|
|
|
|
public override void ApplyData(string s)
|
|
{
|
|
if (String.IsNullOrEmpty(s))
|
|
return;
|
|
Data d = SaveSystem.Deserialize<Data>(s);
|
|
if (d.wasPlayed == null)
|
|
return;
|
|
for (int i = 0; i < d.wasPlayed.Length; i++)
|
|
{
|
|
m_cutscenes[i].WasPlayed = d.wasPlayed[i];
|
|
}
|
|
}
|
|
}
|
|
}
|