public static NodeNetworkSave FromFile(string fileName) { NodeNetworkSave nodeNetworkSave = FlatRedBall.IO.FileManager.XmlDeserialize <NodeNetworkSave>(fileName); nodeNetworkSave.mFileName = fileName; return(nodeNetworkSave); }
public static NodeNetworkSave FromNodeNetwork(FlatRedBall.AI.Pathfinding.NodeNetwork nodeNetwork) { NodeNetworkSave nodeNetworkSave = new NodeNetworkSave(); foreach (FlatRedBall.AI.Pathfinding.PositionedNode positionedNode in nodeNetwork.Nodes) { nodeNetworkSave.PositionedNodes.Add( PositionedNodeSave.FromPositionedNode(positionedNode)); } return(nodeNetworkSave); }
public static NodeNetworkSave FromNodeNetwork(FlatRedBall.AI.Pathfinding.NodeNetwork nodeNetwork) { NodeNetworkSave nodeNetworkSave = new NodeNetworkSave(); foreach (FlatRedBall.AI.Pathfinding.PositionedNode positionedNode in nodeNetwork.Nodes) { nodeNetworkSave.PositionedNodes.Add( PositionedNodeSave.FromPositionedNode(positionedNode)); } return nodeNetworkSave; }
void SaveNodeNetworkSettingsOk(Window callingWindow) { FlatRedBall.Content.AI.Pathfinding.NodeNetworkSave nodeNetworkSave = FlatRedBall.Content.AI.Pathfinding.NodeNetworkSave.FromNodeNetwork(EditorData.NodeNetwork); AxisFlippingSettings axisFlippingSettings = ((PropertyGrid <AxisFlippingSettings>)callingWindow.Parent).SelectedObject; if (axisFlippingSettings.FlipY) { foreach (PositionedNodeSave pns in nodeNetworkSave.PositionedNodes) { pns.Y = -pns.Y; } } if (axisFlippingSettings.CopyYToZ) { foreach (PositionedNodeSave pns in nodeNetworkSave.PositionedNodes) { pns.Z = pns.Y; } } if (axisFlippingSettings.MakeYZero) { foreach (PositionedNodeSave pns in nodeNetworkSave.PositionedNodes) { pns.Y = 0; } } string companionFile = FileManager.RemoveExtension(mNameOfNodeNetwork) + "." + AIEditorPropertiesSave.Extension; AIEditorPropertiesSave aieps = new AIEditorPropertiesSave(); aieps.SetFromRuntime(SpriteManager.Camera, null, false); aieps.Save(companionFile); nodeNetworkSave.Save(mNameOfNodeNetwork); if (!System.IO.File.Exists(mNameOfNodeNetwork)) { GuiManager.ShowMessageBox("Error saving file " + mNameOfNodeNetwork, "Error saving"); } }
public static void LoadNodeNetwork(string fileName, bool copyYToZ, bool flipY, bool makeYZero) { RemoveNodeNetwork(); FlatRedBall.Content.AI.Pathfinding.NodeNetworkSave nodeNetworkSave = FlatRedBall.Content.AI.Pathfinding.NodeNetworkSave.FromFile(fileName); string possibleCompanionFile = FileManager.RemoveExtension(fileName) + "." + AIEditorPropertiesSave.Extension; if (FileManager.FileExists(possibleCompanionFile)) { AIEditorPropertiesSave aieps = AIEditorPropertiesSave.Load(possibleCompanionFile); if (aieps.Camera != null) { aieps.Camera.SetCamera(SpriteManager.Camera); } //if(aieps.BoundsCamera != null) //{ // aieps.BoundsCamera.SetCamera( } #region Modify loaded NodeNetwork if necessary (copyYToZ, flipY, makeYZero) if (copyYToZ) { foreach (PositionedNodeSave pns in nodeNetworkSave.PositionedNodes) { pns.Y = pns.Z; } } if (flipY) { foreach (PositionedNodeSave pns in nodeNetworkSave.PositionedNodes) { pns.Y = -pns.Y; } } if (makeYZero) { foreach (PositionedNodeSave pns in nodeNetworkSave.PositionedNodes) { pns.Z = 0; } } #endregion LastLoadedFile = fileName; #if FRB_MDX Form1.TitleText = "AIEditor - Editing " + fileName; #else FlatRedBallServices.Owner.Text = "AIEditor - Editing " + fileName; #endif string error; NodeNetwork = nodeNetworkSave.ToNodeNetwork(out error); if (!string.IsNullOrEmpty(error)) { System.Windows.Forms.MessageBox.Show(error); } }