void Update()
    {
        // We can read the data from any object. If the data is not set 'default' value will be returned.
        Vector3 position = BlackBoard.Read <Vector3>("Player1", "Position");

        // BB can save value type fields from boards to the disc. Could be broken atm ;)
        BlackBoard.Write("SaveData", "PlayerName", "Foo");
        BlackBoard.Write("SaveData", "PlayerScore", 9001);
        BlackBoard.Write("SaveData", "IsPersistent", true);
        BlackBoard.Save();

        // There is some pretty handy functionalities in BB
    }
Beispiel #2
0
    private void _WriteXMLFile(Publisher publisher)
    {
        XmlElement root = this.xmlDoc.CreateElement("Publisher");
        float      num  = Time.realtimeSinceStartup - BlackBoard.Read <float>("time", "DispatcherStartedTime");

        MessageSaver.WriteXMLElement("Time", num, this.xmlDoc, root);
        MessageSaver.WriteXMLElement("Domain", publisher.domain, this.xmlDoc, root);
        MessageSaver.WriteXMLElement("Message", publisher.message, this.xmlDoc, root);
        for (int i = 0; i < publisher.data.Length; i++)
        {
            string elementName = publisher.data[i].GetType().ToString();
            MessageSaver.WriteXMLElement(elementName, publisher.data[i].Read <object>(), this.xmlDoc, root);
        }
        this.xmlDoc.Save("data.xml");
    }
Beispiel #3
0
    public static void Save()
    {
        // Get all IsPersistent board names
        string[] allBoardsContaining = BlackBoard.GetAllBoardsContaining("IsPersistent");

        // List of all objects to be saved. <string>board, <string>field, <string|int|float|bool>value
        List <object> list = new List <object>();

        for (int i = 0; i < allBoardsContaining.Length; i++)
        {
            string[] fields = BlackBoard.GetAllFieldsFromBoard(allBoardsContaining[i]);

            for (int j = 0; j < fields.Length; j++)
            {
                object value = BlackBoard.Read <object>(allBoardsContaining[i], fields[j]);

                list.Add(allBoardsContaining[i]);
                list.Add(fields[j]);

                if (value.GetType() == typeof(bool))
                {
                    list.Add("__BOOLEAN:" + ((bool)value == true ? "true" : "false"));
                }

                if (value.GetType() == typeof(int))
                {
                    list.Add("__INT32:" + value.ToString());
                }

                if (value.GetType() == typeof(string))
                {
                    list.Add(value);
                }
            }
        }

        BinarySaver.WriteBinFile(list.ToArray());
    }