当前位置: 首页>>代码示例>>C#>>正文


C# Node.GetType方法代码示例

本文整理汇总了C#中Behaviac.Design.Nodes.Node.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Node.GetType方法的具体用法?C# Node.GetType怎么用?C# Node.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Behaviac.Design.Nodes.Node的用法示例。


在下文中一共展示了Node.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateInstance

        public static NodeCsExporter CreateInstance(Node node)
        {
            if (node != null)
            {
                Type exporterType = getExporterType(node.GetType());
                if (exporterType != null)
                    return (NodeCsExporter)Activator.CreateInstance(exporterType);
            }

            return new NodeCsExporter();
        }
开发者ID:675492062,项目名称:behaviac,代码行数:11,代码来源:NodeCsExporter.cs

示例2: AddChildNotModified

        /// <summary>
        /// Add a new child but the behaviour does not need to be saved.
        /// Used for collapsed referenced behaviours which show the behaviours they reference.
        /// </summary>
        /// <param name="connector">The connector the node will be added to. Use null for default connector.</param>
        /// <param name="node">The node you want to append.</param>
        /// <returns>Returns true if the child could be added.</returns>
        public virtual bool AddChildNotModified(Connector connector, Node node)
        {
            Debug.Check(connector != null && _children.HasConnector(connector));

            if (!connector.AcceptsChild(node.GetType()))
            {
                //throw new Exception(Resources.ExceptionNodeHasTooManyChildren);
                return false;
            }

            if (!connector.AddChild(node))
            {
                return false;
            }

            node._parent = this;

            node.CopyWasModifiedFromParent(this);

            return true;
        }
开发者ID:KeyleXiao,项目名称:behaviac,代码行数:28,代码来源:Node.cs

示例3: AddChild

        /// <summary>
        /// Add a new child node.
        /// </summary>
        /// <param name="connector">The connector the node will be added to. Use null for default connector.</param>
        /// <param name="node">The node you want to append.</param>
        /// <param name="index">The index of the new node.</param>
        /// <returns>Returns true if the child could be added.</returns>
        public virtual bool AddChild(Connector connector, Node node, int index)
        {
            Debug.Check(connector != null && _children.HasConnector(connector));

            if (!connector.AcceptsChild(node.GetType()))
            {
                throw new Exception(Resources.ExceptionNodeHasTooManyChildren);
            }

            if (!connector.AddChild(node, index))
            {
                return false;
            }

            node._parent = this;

            BehaviorWasModified();

            return true;
        }
开发者ID:KeyleXiao,项目名称:behaviac,代码行数:27,代码来源:Node.cs

示例4: SaveNode

        /// <summary>
        /// Saves a node to the XML file.
        /// </summary>
        /// <param name="root">The XML node we want to attach the node to.</param>
        /// <param name="node">The node we want to save.</param>
        protected void SaveNode(XmlElement root, Node node) {
            try {
                // allow the node to process its attributes in preparation of the save
                node.PreSave(_behavior);

                // store the class we have to create when loading
                XmlElement elem = _xmlfile.CreateElement("Node");
                elem.SetAttribute("Class", node.GetType().FullName);

                bool isPrefabInstance = !string.IsNullOrEmpty(node.PrefabName) && !node.IsPrefabDataDirty();

                // save attributes
                IList<DesignerPropertyInfo> properties = node.GetDesignerProperties();

                for (int p = 0; p < properties.Count; ++p) {
                    if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) {
                        bool bDo = !isPrefabInstance || properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NotPrefabRelated);

                        if (bDo) {
                            if (bDo) {
                                elem.SetAttribute(properties[p].Property.Name, properties[p].GetSaveValue(node));
                            }
                        }
                    }
                }

                // append node to root
                root.AppendChild(elem);

                // save comment
                if (node.CommentObject != null) {
                    XmlElement comment = _xmlfile.CreateElement("Comment");

                    properties = node.CommentObject.GetDesignerProperties();

                    for (int p = 0; p < properties.Count; ++p) {
                        if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                        { comment.SetAttribute(properties[p].Property.Name, properties[p].GetSaveValue(node.CommentObject)); }
                    }

                    elem.AppendChild(comment);
                }

                if (!isPrefabInstance) {
                    // save parameters
                    if (node.LocalVars != null) {
                        Debug.Check(node is Behavior || node is ReferencedBehavior) ;
                        SaveParameters(elem, node.LocalVars);
                    }

                    // save DescriptorRefs
                    if (node is Behavior) {
#if QUERY_EANBLED
                        Behavior b = node as Behavior;
                        SaveDescriptorRefs(elem, b);
#endif//#if QUERY_EANBLED
                    }

                    // save attachments
                    foreach(Attachments.Attachment attach in node.Attachments) {
                        XmlElement attelem = _xmlfile.CreateElement("Attachment");
                        attelem.SetAttribute("Class", attach.GetType().FullName);

                        // save attributes
                        properties = attach.GetDesignerProperties();

                        for (int p = 0; p < properties.Count; ++p) {
                            if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                            { attelem.SetAttribute(properties[p].Property.Name, properties[p].GetSaveValue(attach)); }
                        }

                        if (attach.LocalVars != null && attach.LocalVars.Count > 0) {
                            Debug.Check(attach is Attachments.Event);
                            SaveParameters(attelem, attach.LocalVars);
                        }

                        elem.AppendChild(attelem);
                    }

                    // save children if allowed. Disallowed for referenced behaviours.
                    if (node.SaveChildren) {
                        // save connectors
                        foreach(Nodes.Node.Connector connector in node.Connectors) {
                            // if we have no children to store we can skip the connector
                            if (connector.ChildCount < 1)
                            { continue; }

                            XmlElement conn = _xmlfile.CreateElement("Connector");
                            conn.SetAttribute("Identifier", connector.Identifier);
                            elem.AppendChild(conn);

                            // save their children
                            for (int i = 0; i < connector.ChildCount; ++i)
                            { SaveNode(conn, (Node)connector.GetChild(i)); }
                        }
//.........这里部分代码省略.........
开发者ID:675492062,项目名称:behaviac,代码行数:101,代码来源:FileManagerXML.cs

示例5: GetPrefabNode

        public static Node GetPrefabNode(Node instanceNode)
        {
            if (instanceNode != null && !string.IsNullOrEmpty(instanceNode.PrefabName)) {
                string fullpath = Behaviac.Design.FileManagers.FileManager.GetFullPath(instanceNode.PrefabName);

                if (File.Exists(fullpath)) {
                    BehaviorNode behavior = Behaviac.Design.BehaviorManager.Instance.LoadBehavior(fullpath);

                    if (behavior != null) {
                        DefaultObject obj = Plugin.GetObjectById((Node)behavior, instanceNode.PrefabNodeId);

                        if (obj != null && obj.GetType() == instanceNode.GetType())
                        { return (Node)obj; }
                    }
                }
            }

            return null;
        }
开发者ID:wuzhen,项目名称:behaviac,代码行数:19,代码来源:Plugin.cs

示例6: AutoRestruct

        //if there is a 'Predicate' attachment, convert it to a Condition node and attach it to the '_custom_condition' connector.
        private void AutoRestruct(List<Node.ErrorCheck> result, int version, Behaviac.Design.Attachments.Attachment a, Node node)
        {
            if (version <= 1)
            {
                string attachClass = a.GetType().FullName;
                if (attachClass.IndexOf("PluginBehaviac.Events.Predicate") >= 0)
                {
                    DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Opl");
                    RightValueDef opl = propInfo.GetValue(a) as RightValueDef;
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Opr");
                    RightValueDef opr = propInfo.GetValue(a) as RightValueDef;
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Operator");
                    OperatorType oprr = (OperatorType)propInfo.GetValue(a);
                    OperatorTypes oprType = (OperatorTypes)((int)OperatorTypes.Equal - (int)OperatorType.Equal + (int)oprr);
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "BinaryOperator");
                    Behaviac.Design.Attachments.BinaryOperator binaryOpr = (Behaviac.Design.Attachments.BinaryOperator)propInfo.GetValue(a);

                    string clss = node.GetType().FullName;
                    bool bIsSeqSel = (node.GetType().IsSubclassOf(typeof(Sequence)) ||
                        node.GetType().IsSubclassOf(typeof(Selector)));

                    bool bCare = (bIsSeqSel ||
                        node.GetType().IsSubclassOf(typeof(Impulse))
                       );

                    if (bCare ||
                        clss == "PluginBehaviac.Nodes.Query" ||
                        clss == "PluginBehaviac.Nodes.DecoratorCountLimit")
                    {
                        node.RemoveAttachment(a);
                        node.Behavior.TriggerWasModified(node);

                        Type newType = Plugin.GetType("PluginBehaviac.Nodes.Condition");

                        Behaviac.Design.Nodes.Node newNode = Behaviac.Design.Nodes.Node.Create(newType);
                        Behaviac.Design.Nodes.Node.Connector connector = node.GetConnector(Node.Connector.kInterupt);

                        if (connector != null && connector.Identifier == Node.Connector.kInterupt && connector.ChildCount > 0)
                        {
                            //it has multiple Predicates, so insert all of them to a newly created Sequence
                            Node oldOne = (Node)connector.GetChild(0);
                            if (oldOne.GetType().IsSubclassOf(typeof(Condition)))
                            {
                                AddAfterConditions(node, binaryOpr, newNode, connector, oldOne);
                            }
                            else
                            {
                                if (bIsSeqSel)
                                {
                                    Debug.Check(oldOne.GetType().IsSubclassOf(typeof(Decorator)));
                                    Decorator d = oldOne as Decorator;
                                    node = oldOne;
                                    connector = node.GetConnector(BaseNode.Connector.kGeneric);
                                    oldOne = (Node)d.Children[0];
                                }

                                if (oldOne.GetType()== typeof(PluginBehaviac.Nodes.And))
                                {
                                    if (binaryOpr == Behaviac.Design.Attachments.BinaryOperator.Or)
                                    {
                                        node.RemoveChild(connector, oldOne);
                                        Type selType1 = Plugin.GetType("PluginBehaviac.Nodes.Or");

                                        Behaviac.Design.Nodes.Node sel = Behaviac.Design.Nodes.Node.Create(selType1);
                                        sel.AddChild(BaseNode.Connector.kGeneric, oldOne);
                                        sel.AddChild(BaseNode.Connector.kGeneric, newNode);

                                        node.AddChild(BaseNode.Connector.kInterupt, sel);
                                    }
                                    else
                                    {
                                        oldOne.AddChild(BaseNode.Connector.kGeneric, newNode);
                                    }
                                }
                                else if (oldOne.GetType() == typeof(PluginBehaviac.Nodes.Or))
                                {
                                    if (binaryOpr == Behaviac.Design.Attachments.BinaryOperator.And)
                                    {
                                        node.RemoveChild(connector, oldOne);
                                        Type selType1 = Plugin.GetType("PluginBehaviac.Nodes.And");

                                        Behaviac.Design.Nodes.Node sel = Behaviac.Design.Nodes.Node.Create(selType1);
                                        sel.AddChild(BaseNode.Connector.kGeneric, oldOne);
                                        sel.AddChild(BaseNode.Connector.kGeneric, newNode);

                                        node.AddChild(BaseNode.Connector.kInterupt, sel);
                                    }
                                    else
                                    {
                                        oldOne.AddChild(BaseNode.Connector.kGeneric, newNode);
                                    }
                                }
                                else if (oldOne.GetType().IsSubclassOf(typeof(Condition)))
                                {
                                    AddAfterConditions(node, binaryOpr, newNode, connector, oldOne);
                                }
                                else
                                {
                                    Debug.Check(false);
//.........这里部分代码省略.........
开发者ID:675492062,项目名称:behaviac,代码行数:101,代码来源:Predicate.cs


注:本文中的Behaviac.Design.Nodes.Node.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。