本文整理汇总了C#中BehaviorNode.MakeRelative方法的典型用法代码示例。如果您正苦于以下问题:C# BehaviorNode.MakeRelative方法的具体用法?C# BehaviorNode.MakeRelative怎么用?C# BehaviorNode.MakeRelative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BehaviorNode
的用法示例。
在下文中一共展示了BehaviorNode.MakeRelative方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreSave
/// <summary>
/// Before saving we must change the reference into a relative path.
/// </summary>
/// <param name="behavior">The behaviour this node belongs to. NOT the referenced one.</param>
public override void PreSave(BehaviorNode behavior)
{
base.PreSave(behavior);
// make the path of the reference relative
_referenceFilename= behavior.MakeRelative(_referenceFilename);
}
示例2: ExportBehavior
/// <summary>
/// Exports a behaviour to the given file.
/// </summary>
/// <param name="file">The file we want to export to.</param>
/// <param name="behavior">The behaviour we want to export.</param>
protected void ExportBehavior(BsonSerializer file, BehaviorNode behavior) {
if (behavior.FileManager == null)
{
return;
}
file.WriteComment("EXPORTED BY TOOL, DON'T MODIFY IT!");
file.WriteComment("Source File: " + behavior.MakeRelative(behavior.FileManager.Filename));
file.WriteStartElement("behavior");
Behavior b = behavior as Behavior;
Debug.Check(b != null);
Debug.Check(b.Id == -1);
//'\\' ->'/'
string behaviorName = b.MakeRelative(b.Filename);
behaviorName = behaviorName.Replace('\\', '/');
int pos = behaviorName.IndexOf(".xml");
if (pos != -1) {
behaviorName = behaviorName.Remove(pos);
}
file.WriteString(behaviorName);
file.WriteString(b.AgentType.AgentTypeName);
file.WriteBool(b.IsFSM);
file.WriteString(b.Version.ToString());
this.ExportProperties(file, b);
this.ExportPars(file, b);
if (!b.IsFSM) {
this.ExportAttachments(file, b);
}
if (b.IsFSM)
{
file.WriteStartElement("node");
file.WriteString("FSM");
file.WriteString("-1");
file.WriteStartElement("properties");
file.WriteAttributeString("initialid", behavior.InitialStateId.ToString());
file.WriteEndElement();
foreach (Node child in ((Node)behavior).FSMNodes)
{
this.ExportNode(file, behavior, child);
}
file.WriteEndElement();
}
else
{
// export the children
foreach (Node child in ((Node)behavior).Children)
{
this.ExportNode(file, behavior, child);
}
}
file.WriteEndElement();
}
示例3: ExportBehavior
/// <summary>
/// Exports a behaviour to the given file.
/// </summary>
/// <param name="file">The file we want to export to.</param>
/// <param name="behavior">The behaviour we want to export.</param>
protected void ExportBehavior(XmlWriter file, BehaviorNode behavior) {
file.WriteComment("EXPORTED BY TOOL, DON'T MODIFY IT!");
file.WriteComment("Source File: " + behavior.MakeRelative(behavior.FileManager.Filename));
file.WriteStartElement("behavior");
Behavior b = behavior as Behavior;
Debug.Check(b != null);
Debug.Check(b.Id == -1);
//'\\' ->'/'
string behaviorName = b.MakeRelative(b.Filename);
behaviorName = behaviorName.Replace('\\', '/');
int pos = behaviorName.IndexOf(".xml");
if (pos != -1) {
behaviorName = behaviorName.Remove(pos);
}
file.WriteAttributeString("name", behaviorName);
//file.WriteAttributeString("event", b.EventName);
file.WriteAttributeString("agenttype", b.AgentType.AgentTypeName);
if (b.IsFSM)
{ file.WriteAttributeString("fsm", "true"); }
file.WriteAttributeString("version", b.Version.ToString());
this.ExportProperties(file, b);
this.ExportPars(file, b);
if (!b.IsFSM)
{ this.ExportAttachments(file, b); }
#if QUERY_EANBLED
//after ExportProperties as DescritorRefs are exported as property
this.ExportDescritorRefs(file, b);
#endif//#if QUERY_EANBLED
if (b.IsFSM)
{
file.WriteStartElement("node");
file.WriteAttributeString("class", "FSM");
file.WriteAttributeString("id", "-1");
file.WriteStartElement("property");
file.WriteAttributeString("initialid", behavior.InitialStateId.ToString());
file.WriteEndElement();
foreach (Node child in ((Node)behavior).FSMNodes)
{
this.ExportNode(file, behavior, child);
}
file.WriteEndElement();
}
else
{
// export the children
foreach (Node child in ((Node)behavior).Children)
{
this.ExportNode(file, behavior, child);
}
}
file.WriteEndElement();
}
示例4: ExportNode
/// <summary>
/// Exports a node to the given file.
/// </summary>
/// <param name="file">The file we want to export to.</param>
/// <param name="namspace">The namespace of the behaviour we are currently exporting.</param>
/// <param name="behavior">The behaviour we are currently exporting.</param>
/// <param name="parentName">The name of the variable of the node which is the parent of this node.</param>
/// <param name="node">The node we want to export.</param>
/// <param name="indentDepth">The indent of the ocde we are exporting.</param>
/// <param name="nodeID">The current id used for generating the variables for the nodes.</param>
protected void ExportNode(StreamWriter file, string namspace, BehaviorNode behavior, string parentName, Node node, int indentDepth, ref int nodeID)
{
// generate some data
string classname= node.ExportClass;
string nodeName= string.Format("node{0}", ++nodeID);
// generate the indent string
string indent= string.Empty;
for(int i= 0; i <indentDepth; ++i)
indent+= '\t';
// we have to handle a referenced behaviour differently
if(node is ReferencedBehaviorNode)
{
// generate the namespace and name of the behaviour we are referencing
string refRelativeFilename= behavior.MakeRelative(((ReferencedBehaviorNode)node).ReferenceFilename);
string refNamespace= GetNamespace(namspace, refRelativeFilename);
string refBehaviorName= Path.GetFileNameWithoutExtension(((ReferencedBehaviorNode)node).ReferenceFilename.Replace(" ", string.Empty));
// simply add the instance of the behaviours we are referencing
file.Write( string.Format("{0}{1}.AddChild({1}.GetConnector(\"{2}\"), {3}.{4}.Instance);\r\n", indent, parentName, node.ParentConnector.Identifier, refNamespace, refBehaviorName) );
}
else
{
// open some brackets for a better formatting in the generated code
file.Write( string.Format("{0}{{\r\n", indent) );
// export the constructor and the properties
ExportConstructorAndProperties(file, node, indent, nodeName, classname);
// add the node to its parent
file.Write( string.Format("{0}\t{1}.AddChild({1}.GetConnector(\"{2}\"), {3});\r\n", indent, parentName, node.ParentConnector.Identifier, nodeName) );
// export the child nodes
foreach(Node child in node.Children)
ExportNode(file, namspace, behavior, nodeName, child, indentDepth +1, ref nodeID);
// close the brackets for a better formatting in the generated code
file.Write( string.Format("{0}}}\r\n", indent) );
}
}
示例5: ExportBehavior
/// <summary>
/// Exports a behaviour to the given file.
/// </summary>
/// <param name="file">The file we want to export to.</param>
/// <param name="behavior">The behaviour we want to export.</param>
protected void ExportBehavior(BsonSerializer file, BehaviorNode behavior)
{
file.WriteComment("EXPORTED BY TOOL, DON'T MODIFY IT!");
file.WriteComment("Source File: " + behavior.MakeRelative(behavior.FileManager.Filename));
file.WriteStartElement("behavior");
Behavior b = behavior as Behavior;
Debug.Check(b != null);
Debug.Check(b.Id == -1);
//'\\' ->'/'
string behaviorName = b.MakeRelative(b.Filename);
behaviorName = behaviorName.Replace('\\', '/');
int pos = behaviorName.IndexOf(".xml");
if (pos != -1)
{
behaviorName = behaviorName.Remove(pos);
}
file.WriteString(behaviorName);
file.WriteString(b.AgentType.AgentTypeName);
file.WriteString(b.Version.ToString());
this.ExportProperties(file, b);
this.ExportParameters(file, (Node)behavior);
this.ExportAttachments(file, b);
// export the children
foreach (Node child in ((Node)behavior).Children)
{
this.ExportNode(file, behavior, (Node)behavior, child);
}
file.WriteEndElement();
}