예제 #1
0
        /// <summary>
        /// 还原数据
        /// </summary>
        /// <param name="overlord"></param>
        /// <returns>数据结构是否改变</returns>
        public bool RestoreData(GKToyBaseOverlord overlord)
        {
            _overlord = overlord;
            LoadVariable(overlord, this);
            nodeLst.Clear();
            int  i           = 0;
            bool isEditor    = GKEditor.isUnityEditor();
            bool dataChanged = false;

            foreach (var d in nodeData)
            {
                Type t = GKToyMakerTypeManager.Instance().typeAssemblyDict[nodeTypeData[i]].GetType(nodeTypeData[i]);
                var  n = (GKToyNode)JsonUtility.FromJson(d, t);
                if (n.Restore(d) && !dataChanged)
                {
                    dataChanged = true;
                }
                if (isEditor && typeof(GKToyNodeGroup) == t)
                {
                    ((GKToyNodeGroup)n).data = this;
                }
                nodeLst.Add(n.id, n);
                i++;
            }
            return(dataChanged);
        }
예제 #2
0
        // Json转化为变量.
        public void LoadVariable(GKToyBaseOverlord overlord, GKToyData data)
        {
            variableLst.Clear();
            int i = 0;

            foreach (var d in variableData)
            {
                Type t = Type.GetType(variableTypeData[i]);
                var  v = JsonUtility.FromJson(d, t) as GKToyVariable;

                // 序列化后引用为堆内存, 需要重新指定.
                if (null != v)
                {
                    v.InitializePropertyMapping(overlord, data);
                }

                if (variableLst.ContainsKey(v.PropertyMapping))
                {
                    variableLst[v.PropertyMapping].Add(v);
                }
                else
                {
                    List <object> lst = new List <object>();
                    lst.Add(v);
                    variableLst.Add(v.PropertyMapping, lst);
                }
                i++;
            }
        }
 public override void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
     _output      = new GKToySharedVector3();
     outputObject = _output;
     _transform   = ovelord.gameObject.GetComponent <Transform>();
 }
예제 #4
0
 public OverlordBackData(string dataPath, GKToyBaseOverlord overlord)
 {
     internalData  = new BackupDataItem(AssetDatabase.GetAssetPath(overlord.internalData), string.Format("{0}{1}_back.dbak", dataPath, overlord.internalData.name));
     externalDatas = new Dictionary <string, BackupDataItem>();
     foreach (GKToyExternalData external in overlord.externalDatas)
     {
         externalDatas.Add(external.name, new BackupDataItem(AssetDatabase.GetAssetPath(external), string.Format("{0}{1}_back.dbak", dataPath, external.name)));
     }
     isPlaying = overlord.isPlaying;
 }
예제 #5
0
        virtual public void Init(GKToyBaseOverlord ovelord)
        {
            _overlord = ovelord;

            Type t = GetType();

            props = t.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            var fs = t.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            if (null == propStates)
            {
                propNames  = new string[props.Length];
                propStates = new int[props.Length];
                ioStates   = new int[props.Length];
                propLock   = new bool[props.Length];
                for (int i = 0; i < props.Length; i++)
                {
                    propNames[i]  = props[i].Name;
                    propStates[i] = -1;
                    ioStates[i]   = 0;
                    propLock[i]   = false;
                }
            }
            state = NodeState.Inactive;

            parmRect = new Dictionary <string, NodeParm>();
            parmRect.Clear();
            for (int i = 0; i < props.Length; i++)
            {
                // 引用变量赋值.
                if (-1 != propStates[i])
                {
                    var v    = props[i].PropertyType;
                    var vlst = _overlord.GetVariableListByType(v);
                    if (vlst.Count > propStates[i])
                    {
                        props[i].SetValue(this, ((GKToyVariable)vlst[propStates[i]]), null);
                    }
                }
                NodeParm np = new NodeParm();
                np.propretyInfo = props[i];
                np.rect         = Rect.zero;
                // 参数节点区域初始化.
                parmRect.Add(props[i].Name, np);
            }
        }
예제 #6
0
 public override void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
     outputObject = Target;
 }
예제 #7
0
 override public void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
     outputObject = null;
 }
예제 #8
0
 override public void Init(GKToyBaseOverlord ovelord)
 {
     _overlord = ovelord;
     state     = NodeState.Inactive;
 }
예제 #9
0
 override public void Init(GKToyBaseOverlord ovelord)
 {
     _overlord = ovelord;
 }
예제 #10
0
 public override void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
     _output      = new GKToySharedFloat();
     outputObject = _output;
 }
예제 #11
0
 override public void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
     outputObject = KeyCode.A;
 }
예제 #12
0
 public override void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
 }
예제 #13
0
 public virtual void InitializePropertyMapping(GKToyBaseOverlord overlord, GKToyData data)
 {
     PropertyMappingOwner = overlord;
     PropertyDataOwner    = data;
     PropertyMapping      = GetType().ToString();
 }
예제 #14
0
 override public void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
     _renderer    = ovelord.gameObject.GetComponentInChildren <Renderer>();
     outputObject = Color.white;
 }
예제 #15
0
 public void Init(GKToyBaseOverlord overlord)
 {
     _overlord = overlord;
     LoadVariable(overlord, this);
     LoadNodes();
 }
예제 #16
0
 override public void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
     _output      = new GKToySharedVector3();
     outputObject = _output;
 }
예제 #17
0
 public override void Init(GKToyBaseOverlord ovelord)
 {
     base.Init(ovelord);
     outputObject = Rotation;
     _transform   = ovelord.gameObject.GetComponent <Transform>();
 }