Пример #1
0
    public override void Load()
    {
        path = Application.persistentDataPath + "\\" + filePath;

        // On récupère notre QTable si elle existe déjà
        try
        {
            BinaryFormatter formatter = new BinaryFormatter();
            Stream          stream    = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
            qTable = (QTable)formatter.Deserialize(stream);
            stream.Close();
            stream.Dispose();

            // Si elle n'existe pas, on l'initialise :)
        } catch (Exception e) {
            Debug.LogError(e.Message);
            // Initialiser la QTable
            qTable = new QTable();
            foreach (GameState gs in GameState.AllStates())
            {
                foreach (MyInput input in MyInput.AllInputs())
                {
                    qTable.table.Add(new QValue(gs, input));
                }
            }
        }
        Debug.Log("Taille de la QTable = " + qTable.table.Count);
    }