示例#1
0
        private SerializableNode Deserialize(Stream aStream)
        {
            BinaryFormatter  bf = new BinaryFormatter();
            SerializableNode ob = (SerializableNode)bf.Deserialize(aStream);

            return(ob);
        }
    void CreateNodeElement(SerializableNode node)
    {
        var nodeElement = new NodeElement(node);

        Add(nodeElement);
        m_Nodes.Add(nodeElement);
    }
示例#3
0
            public static SerializableNode Serialize(INode aRoot, bool onlyChild)
            {
                SerializableNode Result = new SerializableNode(aRoot, onlyChild);

                Serialize(aRoot, Result);
                return(Result);
            }
示例#4
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog()
            {
                Title  = "Open Material...",
                Filter = "Hedgehog Engine Material (*.material)|*.material|All files (*.*)|*.*"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var mat = new GensMaterial();
                try
                {
                    mat.Load(ofd.FileName);
                }
                catch (Exception ex)
                {
                    GUI.ShowErrorBox($"ERROR: {ex.Message}");
                    return;
                }

                useMirageHeader = (mat.Header is MirageHeader);
                if (useMirageHeader)
                {
                    root = new SerializableNode(((MirageHeader)mat.Header).RootNode);
                }

                Material = mat;
                matPath  = ofd.FileName;
                UpdateTitle(Path.GetFileNameWithoutExtension(ofd.FileName));
                RefreshUI();
            }
        }
示例#5
0
    void AddNodeToSerializedNodes(Node n)
    {
        SerializableNode serializedNode = new SerializableNode()
        {
            id               = n.id,
            type             = n.type,
            waitTime         = n.waitTime,
            ControlMode      = n.ControlMode,
            boundDirect      = n.boundDirect,
            compassDirection = n.compassDirection,
            location         = n.Location,
            inControl        = n.InControl,
            outControl       = n.OutControl,
            inLinkANode      = new List <int>(),
            inLinkBNode      = new List <int>(),
            outLinkANode     = new List <int>(),
            outLinkBNode     = new List <int>()
        }
        ;

        foreach (Spline spline in n.inLinks)
        {
            serializedNode.inLinkANode.Add(spline.inNode.id);
            serializedNode.inLinkBNode.Add(spline.outNode.id);
        }
        foreach (Spline spline in n.outLinks)
        {
            serializedNode.outLinkANode.Add(spline.inNode.id);
            serializedNode.outLinkBNode.Add(spline.outNode.id);
        }
        serializedNodes.Add(serializedNode);
    }
示例#6
0
 public void Save(SerializableNode serializable)
 {
     serializable.DefaultTransition = VictoryTransition.Value;
     serializable.FailureTransition = DefeatTransition.Value;
     serializable.Enemy             = Enemy.Id;
     serializable.Loot = Loot.Id;
 }
示例#7
0
    public ReadNode(SerializableNode node) : base()
    {
        title = node.name;

        serializableNode = node;
        //入力用ポートの作成(state key)
        Port inputStateKey = Port.Create <Edge>(Orientation.Horizontal, Direction.Input, Port.Capacity.Single, typeof(string)); // 第三引数をPort.Capacity.Multipleにすると複数のポートへの接続が可能になる

        inputStateKey.portName = "State Key";
        inputContainer.Add(inputStateKey); // 入力用ポートはinputContainerに追加する

        //入力用ポートの作成(is Base)
        Port inputIsBase = Port.Create <Edge>(Orientation.Horizontal, Direction.Input, Port.Capacity.Single, typeof(bool));

        inputIsBase.portName = "Is Base";
        inputContainer.Add(inputIsBase);



        //出力する値その1(events)
        Port outputEvents = Port.Create <Edge>(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, typeof(List <ActionData>));

        outputEvents.portName = "events Value";
        outputContainer.Add(outputEvents);

        //出力する値その2(clipPath)
        Port outputClipPath = Port.Create <Edge>(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, typeof(List <string>));

        outputClipPath.portName = "clipPath Value";
        outputContainer.Add(outputClipPath);
    }
示例#8
0
 public void Load(SerializableNode serializable, Database database)
 {
     VictoryTransition = new NumericValue <int>(serializable.DefaultTransition, 1, 1000);
     DefeatTransition  = new NumericValue <int>(serializable.FailureTransition, 1, 1000);
     Enemy             = database.GetFleetId(serializable.Enemy);
     Loot = database.GetLootId(serializable.Loot);
 }
示例#9
0
        private Node DeSerializeNode(int index, List <Node> nodeByIndex)
        {
            //IL_0038: Unknown result type (might be due to invalid IL or missing references)
            //IL_003d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0044: Unknown result type (might be due to invalid IL or missing references)
            //IL_0049: Unknown result type (might be due to invalid IL or missing references)
            if (index < 0 || index >= m_serializableNodeList.Count || m_serializableNodeList.Count == 0)
            {
                return(null);
            }
            SerializableNode serializableNode = m_serializableNodeList[index];
            Node             node             = nodeByIndex[index];

            node.min            = serializableNode.min;
            node.max            = serializableNode.max;
            node.height         = serializableNode.height;
            node.topLeft        = DeSerializeNode(serializableNode.topLeftIndex, nodeByIndex);
            node.topRight       = DeSerializeNode(serializableNode.topRightIndex, nodeByIndex);
            node.bottomLeft     = DeSerializeNode(serializableNode.bottomLeftIndex, nodeByIndex);
            node.bottomRight    = DeSerializeNode(serializableNode.bottomRightIndex, nodeByIndex);
            node.connectedNodes = new List <Node>();
            for (int i = 0; i < serializableNode.connectedNodeIndex.Count; i++)
            {
                int index2 = serializableNode.connectedNodeIndex[i];
                node.connectedNodes.Add(nodeByIndex[index2]);
            }
            return(node);
        }
示例#10
0
    void LoadTextDataFile(SaveData saveData, Vector2 mousePos, bool addFlag = true, string pathName = null)
    {
        baseEdge = new BaseEdge();
        var file = new SaveManager();

        if (pathName == null)
        {
            file.OpenFile();
        }
        else
        {
            file.LoadFile(pathName);
        }

        var nodeName = file.GetExtensionFileNameSaveData(saveData.pathName);
        var node     = new SerializableNode()
        {
            position = mousePos, data = saveData, name = nodeName
        };
        var data = new SaveData()
        {
            stateKey = saveData.stateKey, isBase = saveData.isBase, clipPath = saveData.clipPath, events = saveData.events, position = saveData.position, pathName = saveData.pathName
        };
        var view = GetGraphView();

        if (addFlag == true)
        {
            CreateNodeElement(node, data);
        }
        else
        {
            LoadNodeElement(node, data);
        }
    }
示例#11
0
        private int SerializeNode(Node node, List <Node> nodeByIndex)
        {
            //IL_0010: Unknown result type (might be due to invalid IL or missing references)
            //IL_0015: Unknown result type (might be due to invalid IL or missing references)
            //IL_001d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0022: Unknown result type (might be due to invalid IL or missing references)
            if (node == null)
            {
                return(-1);
            }
            SerializableNode item = default(SerializableNode);

            item.min              = node.min;
            item.max              = node.max;
            item.height           = node.height;
            item.topLeftIndex     = SerializeNode(node.topLeft, nodeByIndex);
            item.topRightIndex    = SerializeNode(node.topRight, nodeByIndex);
            item.bottomLeftIndex  = SerializeNode(node.bottomLeft, nodeByIndex);
            item.bottomRightIndex = SerializeNode(node.bottomRight, nodeByIndex);
            int count = m_serializableNodeList.Count;

            m_serializableNodeList.Add(item);
            nodeByIndex.Add(node);
            return(count);
        }
示例#12
0
        private void SerializeNodeConnection(Node node, List <Node> nodeByIndex)
        {
            if (node == null)
            {
                return;
            }
            int index = nodeByIndex.IndexOf(node);
            SerializableNode serializableNode = m_serializableNodeList[index];

            if (node.connectedNodes != null)
            {
                for (int i = 0; i < node.connectedNodes.Count; i++)
                {
                    Node item  = node.connectedNodes[i];
                    int  item2 = nodeByIndex.IndexOf(item);
                    if (serializableNode.connectedNodeIndex == null)
                    {
                        serializableNode.connectedNodeIndex = new List <int>();
                    }
                    serializableNode.connectedNodeIndex.Add(item2);
                }
            }
            m_serializableNodeList[index] = serializableNode;
            SerializeNodeConnection(node.topLeft, nodeByIndex);
            SerializeNodeConnection(node.topRight, nodeByIndex);
            SerializeNodeConnection(node.bottomLeft, nodeByIndex);
            SerializeNodeConnection(node.bottomRight, nodeByIndex);
        }
        /// <summary>
        /// There are a couple things we need to watch out for here:
        /// 1. We'll generate a new node for serialization - we'll add to that node only if the node was
        ///    never seen before (keep a HashSet of seen nodes)
        /// 2. If the node was seen before, we'll only serialize it's id.
        ///    If not, then serialize it fully (with children and properties)
        /// </summary>
        public static string SerializeGraph(Node rootNode)
        {
            Dictionary <Node, Guid> visitedNodes = new Dictionary <Node, Guid>();

            SerializableNode serializableRootNode = GetSerializableNode(rootNode, visitedNodes);

            return(JsonConvert.SerializeObject(serializableRootNode));
        }
示例#14
0
        public QuestNode(SerializableNode serializable, Database database)
        {
            Id   = new NumericValue <int>(serializable.Id, 1, 1000);
            Type = (NodeType)serializable.Type;

            Content = NodeFactory.CreateNode(Type);
            Content.Load(serializable, database);
        }
示例#15
0
        public SerializableNode Save()
        {
            var serializable = new SerializableNode {
                Type = (int)Type, Id = Id.Value
            };

            Content.Save(serializable);
            return(serializable);
        }
示例#16
0
        public override void OnDeserialization(SerializableNode sNode)
        {
            var aditionalSocketsCount = _times.Count;

            while (Sockets.Count <= aditionalSocketsCount)
            {
                AddInputSocket(false);
            }
        }
示例#17
0
    public NodeElement CreateNodeElement(SerializableNode node)
    {
        var nodeElement = new NodeElement(node);

        Add(nodeElement);
        m_Nodes.Add(nodeElement);

        return(nodeElement);
    }
示例#18
0
 public void Load(SerializableNode serializable, Database database)
 {
     QuestLogText = serializable.Message;
     if (serializable.Transitions != null && serializable.Transitions.Length > 0)
     {
         var transition = serializable.Transitions[0];
         TargetNode  = new NumericValue <int>(transition.TargetNode, 1, 1000);
         Requirement = new Requirement(transition.Requirement ?? new SerializableRequirement(), database);
     }
 }
示例#19
0
 void AddNodeToSerializedNodes(Node n)
 {
     var serializedNode = new SerializableNode () {
         interestingValue = n.interestingValue,
         childCount = n.children.Count,
         indexOfFirstChild = serializedNodes.Count+1
     };
     serializedNodes.Add (serializedNode);
     foreach (var child in n.children)
         AddNodeToSerializedNodes (child);
 }
示例#20
0
    //ロード時
    void LoadNodeElement(SerializableNode node, SaveData data)
    {
        object objNode;
        // 引数の存在するコンストラクタを呼び出したい場合先に生成する
        var args = new object[] { node };

        objNode = Activator.CreateInstance(typeof(ReadNode), BindingFlags.CreateInstance, null, args, null);

        saveData = data;
        AddElements(objNode, saveData, false);
    }
示例#21
0
    public NodeElement(SerializableNode node)
    {
        serializableNode = node;

        style.position     = Position.Absolute;
        style.height       = 50;
        style.width        = 100;
        transform.position = node.position;

        this.AddManipulator(new NodeDragger());
    }
        public SerializableNodeContainer Initialize(SerializableNode target, NodeGraph graphData)
        {
            node  = target;
            graph = graphData;
            var nodeType = node?.GetType();

            type     = node?.GetType().Name;
            script   = nodeType.GetScriptAsset();
            fullType = node?.GetType().AssemblyQualifiedName;
            return(this);
        }
示例#23
0
    private void AddNodeMenuAction(DropdownMenuAction menuAction)
    {
        Vector2 mousePosition = menuAction.eventInfo.localMousePosition;
        var     node          = new SerializableNode()
        {
            position = mousePosition
        };

        m_GraphAsset.nodes.Add(node);

        CreateNodeElement(node);
    }
示例#24
0
            private static SerializableNode Serialize(INode aRoot, SerializableNode stream)
            {
                stream.Children = new SerializableNode[aRoot.Count];
                int i = 0;

                foreach (INode child in aRoot.Enumerable.GetNodes(false))
                {
                    SerializableNode childSer = new SerializableNode(child, false);
                    stream.Children[i++] = childSer;
                    Serialize(child, childSer);
                }
                return(stream);
            }
示例#25
0
    public NodeElement(SerializableNode node)
    {
        serializableNode = node;

        style.position = Position.Absolute;
        style.height   = 50;
        style.width    = 100;

        transform.position = node.position;

        this.AddManipulator(new NodeDragger());
        this.AddManipulator(new EdgeConnector());
        this.AddManipulator(new ContextualMenuManipulator(OnContextualMenuPopulate));
    }
示例#26
0
 public void Save(SerializableNode serializable)
 {
     serializable.Message = QuestLogText;
     if (TargetNode.Value > 0)
     {
         serializable.Transitions = new [] { new SerializableNode.Transition {
                                                 Requirement = Requirement.Save(), TargetNode = TargetNode.Value
                                             } }
     }
     ;
     else
     {
         serializable.Transitions = null;
     }
 }
示例#27
0
        public void NewMaterial()
        {
            Material = new GensMaterial();
            var mHeader = new MirageHeader()
            {
                RootNodeType = 3
            };

            mHeader.GenerateNodes(GensMaterial.MaterialMirageType);
            root = new SerializableNode(mHeader.RootNode);

            matPath = null;
            UpdateTitle("Untitled");
            RefreshUI();
        }
示例#28
0
    void AddNodeToSerializedNodes(Node n)
    {
        var serializedNode = new SerializableNode()
        {
            interestingValue  = n.interestingValue,
            childCount        = n.children.Count,
            indexOfFirstChild = serializedNodes.Count + 1
        };

        serializedNodes.Add(serializedNode);
        foreach (var child in n.children)
        {
            AddNodeToSerializedNodes(child);
        }
    }
示例#29
0
        public static SerializableNode[] CreateSerializableNodes(ObjectElement tree)
        {
            var helper = new SerializerHelper();

            // Get the list of objects contained in the Tree
            helper.Explore( tree );

            // Create the list of nodes
            var objects = new SerializableNode[ helper.VisitedObjects.Count ];
            int i=0;
            foreach( var obj in helper.VisitedObjects.Values )
                objects[i++] = obj;

            return objects;
        }
示例#30
0
        public void Load(SerializableNode serializable, Database database)
        {
            DefaultTransition = new NumericValue <int>(serializable.DefaultTransition, 0, 1000);
            QuestLogText      = serializable.Message;

            Transitions = serializable.Transitions?.Select(transition =>
            {
                var requirement = new Requirement(transition.Requirement ?? new SerializableRequirement(), database);
                return(new QuestTransition
                {
                    TargetNode = new NumericValue <int>(transition.TargetNode, 1, 1000),
                    Requirement = requirement,
                    Weight = new NumericValue <float>(transition.Weight, 0, 100),
                });
            }).ToArray();
        }
示例#31
0
        public override void OnDeserialization(SerializableNode sNode)
        {
            int serializedCount = _landscapeCount;

            _landscapeCount = 0;
            while (_landscapeCount < serializedCount)
            {
                AddLandscapeSocket();
            }
            serializedCount = _entitiesCount;
            _entitiesCount  = 0;
            while (_entitiesCount < serializedCount)
            {
                AddGameObjectsSocket();
            }
        }
示例#32
0
        void AddNodeToSerializedNodes(DialogueNode n)
        {
            var serializedNode = new SerializableNode()
            {
                text              = n.text,
                childCount        = n.children.Count,
                indexOfFirstChild = serializedNodes.Count + 1
            }
            ;

            serializedNodes.Add(serializedNode);
            foreach (var child in n.children)
            {
                AddNodeToSerializedNodes(child);
            }
        }
 public override void OnDeserialization(SerializableNode sNode)
 {
     SetSize(GUISize);
     Update();
 }
示例#34
0
    private void SaveState()
    {
        List<SerializableNode> serializableNodes = new List<SerializableNode> ();
        foreach (Node node in Nodes)
        {
            SerializableNode newNode = new SerializableNode();
            newNode.Name = node.Name;
            newNode.Position = new Double2 (node.Position.x, node.Position.y);
            newNode.HasOutput = node.HasOutput;
            newNode.Content = node._content;

            newNode.Inputs = new List<int>();
            newNode.InputNames = new List<string>();
            if (node.Inputs != null)
            {
                int i=0;
                foreach (Node input in node.Inputs)
                {
                    newNode.InputNames.Add (node.InputNames[i]);
                    if (input != null)
                    {
                        newNode.Inputs.Add(Nodes.IndexOf(input));
                    }
                    else
                    {
                        newNode.Inputs.Add(-1);
                    }
                    i++;
                }
            }

            newNode.FloatUserInputs = new List<double>();
            newNode.Vector2UserInputs = new List<Double2>();
            newNode.ColorUserInputs = new List<Double4>();
            foreach (object userInput in node.UserInputs)
            {
                if (userInput.GetType() == typeof(float))
                {
                    double value = (float)userInput;
                    newNode.FloatUserInputs.Add(value);
                }
                if (userInput.GetType() == typeof(Vector2))
                {
                    Double2 value = new Double2(((Vector2)userInput).x, ((Vector2)userInput).y);
                    newNode.Vector2UserInputs.Add(value);
                }
                if (userInput.GetType() == typeof(Color))
                {
                    Double4 value = new Double4(((Color)userInput).r, ((Color)userInput).g, ((Color)userInput).b, ((Color)userInput).a);
                    newNode.ColorUserInputs.Add(value);
                }
            }
            serializableNodes.Add(newNode);
        }
        string json = JsonMapper.ToJson (serializableNodes);
        string actualSavePath = string.Format(WINDOW_SAVESTATE_PATH, SelectedmaterialName) + ".txt";
        File.WriteAllText (actualSavePath, json);
    }
示例#35
0
        /// <returns>The root element of the tree</returns>
        public static ObjectElement RecreateObjectTree(SerializableNode[] nodes)
        {
            // Recreate all objects
            ObjectElement root = null;
            var elements = new Dictionary<int,ObjectElement>();
            foreach( var obj in nodes )
            {
                ObjectElement element;
                switch( obj.Type )
                {
                    case ObjectElement.Types.Root:
                        element = ObjectElement.CreateRoot();
                        if( root != null )
                            throw new ApplicationException( "There is more than 1 root element in the XML document." );
                        root = element;
                        break;

                    case ObjectElement.Types.Exception: {
                        string str;
                        if( obj.ValueTranslatable != null )
                        {
                            element = ObjectElement.CreateException( obj.ValueTranslatable.CreateTranslatableElement(), obj.Class, obj.StackTrace );
                        }
                        else if( (str = obj.ValuePrimitive.Value as string) != null )
                        {
                            element = ObjectElement.CreateException( str, obj.Class, obj.StackTrace );
                        }
                        else
                        {
                            System.Diagnostics.Debug.Fail( "Unsupported element type '" + obj.ValuePrimitive.Value.GetType().FullName + "'" );
                            continue;
                        }
                        break; }

                    case ObjectElement.Types.Object:
                        if( obj.NameTranslatable != null )
                            element = ObjectElement.CreateObject( obj.NameTranslatable.CreateTranslatableElement(), obj.Class );
                        else
                            element = ObjectElement.CreateObject( obj.NameString, obj.Class );
                        break;

                    case ObjectElement.Types.Field:
                        if( obj.NameTranslatable != null )
                            element = ObjectElement.CreateField( obj.NameTranslatable.CreateTranslatableElement(), obj.Class, obj.ValuePrimitive != null ? obj.ValuePrimitive.Value : obj.ValueTranslatable );
                        else
                            element = ObjectElement.CreateField( obj.NameString, obj.Class, obj.ValuePrimitive != null ? obj.ValuePrimitive.Value : obj.ValueTranslatable );
                        break;

                    default:
                        throw new NotImplementedException( "The object type '" + obj.Type.ToString() + "' is not supported" );
                }
                elements.Add( obj.ID, element );
            }
            if( root == null )
                throw new ApplicationException( "There is no root element in the XML document." );

            // Recreate parent/child links between objects
            foreach( var obj in nodes )
            {
                var parentElement = elements[ obj.ID ];
                if( obj.Children != null )
                    foreach( var childObj in obj.Children )
                        parentElement.Children.Add( elements[childObj] );
            }

            return root;
        }
示例#36
0
        /// <remarks>Recursive</remarks>
        private void Explore(ObjectElement node)
        {
            System.Diagnostics.Debug.Assert( VisitedObjects != null, "Property 'VisitedElements' is not set" );
            System.Diagnostics.Debug.Assert( node != null, "Parameter 'node' is not set" );
            System.Diagnostics.Debug.Assert( node.Children != null, "Node's children is not set" );

            int id = node.GetHashCode();
            if( VisitedObjects.ContainsKey(id) )
                return;

            int[] children = null;
            if( node.Children.Count > 0 )
            {
                children = new int[ node.Children.Count ];
                for( int i=0; i<node.Children.Count; ++i )
                    children[i] = node.Children[i].GetHashCode();
            }

            var name_translatable = node.Name as TranslatableElement;
            var value_translatable = node.Value as TranslatableElement;
            var xmlNode = new SerializableNode {
                                    ID = id,
                                    Type = node.Type,
                                    NameTranslatable = name_translatable != null ? new SerializableTranslatable(name_translatable) : null,
                                    NameString = name_translatable == null ? (string)node.Name : null,
                                    Class = node.ClassName,
                                    ValueTranslatable = value_translatable != null ? new SerializableTranslatable(value_translatable) : null,
                                    ValuePrimitive = value_translatable == null ? new SerializablePrimitive(node.Value) : null,
                                    StackTrace = node.StackTrace,
                                    Children = children };
            VisitedObjects.Add( node.GetHashCode(), xmlNode );
            foreach( var childNode in node.Children )
                Explore( childNode );
        }