Esempio n. 1
0
        private void Start()
        {
            DataNodeComponent dataNodeComponent = GameEntry.GetComponent <DataNodeComponent>();

            // 使用数据结点组件,直接通过绝对路径获取或设置数据
            dataNodeComponent.SetData <VarString>("Player.Name", "Ellan");
            string playerName = dataNodeComponent.GetData <VarString>("Player.Name");

            Log.Info("Player name is {0}.", playerName);

            // 使用数据结点组件,通过参照某个数据结点和相对路径获取或设置数据
            IDataNode playerNode = dataNodeComponent.GetNode("Player");

            dataNodeComponent.SetData <VarInt>("Level", 99, playerNode);
            int playerLevel = dataNodeComponent.GetData <VarInt>("Level", playerNode);

            Log.Info("Player level is {0}.", playerLevel.ToString());

            // 使用数据结点组件获取数据结点后,通过数据结点的接口进行更多操作。
            IDataNode playerExpNode = playerNode.GetOrAddChild("Exp");

            playerExpNode.SetData <VarInt>(1000);
            int playerExp = playerExpNode.GetData <VarInt>();

            Log.Info("Player exp is {0}.", playerExp.ToString());
        }
    protected internal override void OnEnter(IFsm <IProcedureManager> procedureOwner)
    {
        base.OnEnter(procedureOwner);

        //根据绝对路径设置与获取数据
        DataNodeComponent dataComponent = GameEntry.GetComponent <DataNodeComponent>();
        VarString         var1          = new VarString();

        var1.SetValue("Ellan");
        dataComponent.SetData <VarString> ("Player.Name", var1);
        string playerName = dataComponent.GetData <LocalVariable <string> >("Player.Name").Value;

        Log.Info(playerName);

        //根据相对路径设置与获取数据
        IDataNode playerNode = dataComponent.GetNode("Player");
        VarInt    var2       = new VarInt();

        var2.SetValue(99);
        dataComponent.SetData <VarInt>("Level", var2, playerNode);
        int playerLevel = dataComponent.GetData <VarInt>("Level", playerNode).Value;

        Log.Info(playerLevel);

        //直接通过数据结点来操作
        VarInt var3 = new VarInt();

        var3.SetValue(1000);
        IDataNode playerExpNode = playerNode.GetOrAddChild("Exp");

        playerExpNode.SetData(var3);
        int playerExp = playerExpNode.GetData <VarInt>().Value;

        Log.Info(playerExp);
    }
Esempio n. 3
0
        /// <summary>
        /// 设置数据结点的数据。
        /// </summary>
        /// <param name="path">相对于 node 的查找路径。</param>
        /// <param name="data">要设置的数据。</param>
        /// <param name="node">查找起始结点。</param>
        public void SetData(string path, Variable data, IDataNode node)
        {
            IDataNode current = GetOrAddNode(path, node);

            current.SetData(data);
        }
Esempio n. 4
0
        /// <summary>
        /// 设置数据结点的数据。
        /// </summary>
        /// <typeparam name="T">要设置的数据类型。</typeparam>
        /// <param name="path">相对于 node 的查找路径。</param>
        /// <param name="data">要设置的数据。</param>
        /// <param name="node">查找起始结点。</param>
        public void SetData <T>(string path, T data, IDataNode node) where T : Variable
        {
            IDataNode current = GetOrAddNode(path, node);

            current.SetData(data);
        }
        public void SetData <T>(string path, T t, IDataNode dataNode)
        {
            IDataNode current = GetOrAddNode(path, dataNode);

            current.SetData <T>(t);
        }