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


C# XmlTextWriter.WriteWhitespace方法代码示例

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


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

示例1: Save

    public void Save()
    {
        FileInfo pFileInfo = new FileInfo(Application.dataPath + "/Resources/paths.txt");

        // Tonk the file if it already exists
        if(pFileInfo.Exists)
        {
            pFileInfo.Delete();
        }

        // Create the stream writer and dump the file out to the resources directory
        StreamWriter pStream;
        pStream = pFileInfo.CreateText();

        StringWriter pStr = new StringWriter();

        XmlTextWriter pXML = new XmlTextWriter(pStr);
        pXML.WriteStartDocument();
        pXML.WriteWhitespace("\n");
        pXML.WriteStartElement("paths");
        pXML.WriteWhitespace("\n");
        pXML.WriteWhitespace("\n");

        for(int i = 0; i < _WayPoints.Count; ++i)
        {
            pXML.WriteStartElement("path");
            pXML.WriteWhitespace("\n");
            _WayPoints[i].WriteXML(pXML);
            pXML.WriteEndElement();
            pXML.WriteWhitespace("\n");
            pXML.WriteWhitespace("\n");
        }

        pXML.WriteEndElement();
        pXML.WriteEndDocument();

        pStream.Write(pStr.ToString());
        pStream.Close();
    }
开发者ID:Johangsl,项目名称:GameDevChronicles,代码行数:39,代码来源:WayPointDatabase.cs

示例2: SaveSpace

    /// <summary>
    /// Saves the space.
    /// </summary>
    public static void SaveSpace()
    {
        bool directoryExists = Directory.Exists(directory);
        bool fileExists = File.Exists(directory + "CreatedWorlds.xml");

        if(directoryExists && fileExists)
        {
            List<WorldSpecs> existingSpecs = GetCreatedWorlds();
            bool skipSaving = false;
            foreach(WorldSpecs obj in existingSpecs)
            {
                if(obj.spaceName == worldspec.spaceName)
                {
                    skipSaving = true;
                }
            }
            if(!skipSaving)
            {
                existingSpecs.Add(worldspec);
                XmlTextWriter writer = new XmlTextWriter( directory + "CreatedWorlds.xml" , System.Text.Encoding.UTF8);
                writer.WriteStartDocument();
                writer.WriteStartElement("Root");
                writer.WriteWhitespace("\n");
                foreach(WorldSpecs obj in existingSpecs)
                {
                    writer.WriteWhitespace("\t");
                    writer.WriteStartElement("WorldSpec");
                    writer.WriteAttributeString("name", obj.spaceName);
                    writer.WriteAttributeString("area", obj.spaceArea.ToString());
                    writer.WriteAttributeString("spaceLength", obj.mapLength.ToString());
                    writer.WriteAttributeString("cellLength", obj.cellLength.ToString());
                    writer.WriteAttributeString("start-x", obj.start.x.ToString());
                    writer.WriteAttributeString("start-y",obj.start.y.ToString());
                    writer.WriteAttributeString("degreeJump", obj.degreeJumpStep.ToString());
                    writer.WriteAttributeString("subdivisions", obj.subdivisions.ToString());
                    writer.WriteAttributeString("numOfCells", obj.totalNumberOfCells.ToString());
                    writer.WriteAttributeString("Seed", obj.seed.ToString());
                    if(obj.planetPositions.Length > 0)
                    {
                        for(int i = 0; i < obj.planetPositions.Length; i++)
                        {
                            writer.WriteAttributeString("pPos-x" + i,obj.planetPositions[i].x.ToString());
                            writer.WriteAttributeString("pPos-y" + i,obj.planetPositions[i].y.ToString());
                        }
                    }
                    writer.WriteEndElement();
                    writer.WriteWhitespace("\n");
                }
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();

            }
            //read the entire xml data populate it into a list and several data fields to resave
        }
        else if(directoryExists && !fileExists)
        {
            XmlTextWriter writer = new XmlTextWriter( directory + "CreatedWorlds.xml" , System.Text.Encoding.UTF8);

            writer.WriteStartDocument();
            writer.WriteStartElement("Root");
            writer.WriteWhitespace("\n\t");
            writer.WriteStartElement("WorldSpec");
            writer.WriteAttributeString("name", worldspec.spaceName.ToString());
            writer.WriteAttributeString("area", worldspec.spaceArea.ToString());
            writer.WriteAttributeString("spaceLength", worldspec.mapLength.ToString());
            writer.WriteAttributeString("cellLength", worldspec.cellLength.ToString());
            writer.WriteAttributeString("start-x", worldspec.start.x.ToString());
            writer.WriteAttributeString("start-y",worldspec.start.y.ToString());
            writer.WriteAttributeString("degreeJump", worldspec.degreeJumpStep.ToString());
            writer.WriteAttributeString("subdivisions", worldspec.subdivisions.ToString());
            writer.WriteAttributeString("numOfCells", worldspec.totalNumberOfCells.ToString());
            writer.WriteAttributeString("Seed", worldspec.seed.ToString());
            if(worldspec.planetPositions.Length > 0)
            {
                for(int i = 0; i < worldspec.planetPositions.Length; i++)
                {
                    writer.WriteAttributeString("pPos-x" + i,worldspec.planetPositions[i].x.ToString());
                    writer.WriteAttributeString("pPos-y" + i,worldspec.planetPositions[i].y.ToString());
                }
            }
            writer.WriteEndElement();
            writer.WriteWhitespace("\n");
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
            //create just the new file with the new world
        }
        else if(!directoryExists && !fileExists)
        {
            Directory.CreateDirectory(directory);

            XmlTextWriter writer = new XmlTextWriter( directory + "CreatedWorlds.xml" , System.Text.Encoding.UTF8);

            writer.WriteStartDocument();

            writer.WriteStartElement("Root");
//.........这里部分代码省略.........
开发者ID:Jetblacktsunami,项目名称:CSE455-Salvage,代码行数:101,代码来源:WorldGenerator.cs

示例3: SaveData

    public void SaveData()
    {
        player = GameObject.FindGameObjectWithTag("Player");

        if (player)
        {
            playerPos = player.transform.position;
            cameraPos = Camera.main.transform.position;
            currentScene = Application.loadedLevelName;
        }

        if (File.Exists(savePath))
        {
            Debug.Log("Overwriting player information @ \n" + savePath);
            File.Delete(savePath);
        }
        else
        {
            Debug.Log("Saving player information @\n" + savePath);
        }

        XmlWriter writer = new XmlTextWriter (savePath, System.Text.Encoding.UTF8);

        writer.WriteStartDocument();
        writer.WriteWhitespace("\n");
        writer.WriteStartElement("Root");
        writer.WriteWhitespace("\n\t");
        writer.WriteStartElement("Body");

        writer.WriteWhitespace("\n\t\t");
        writer.WriteElementString ("bDisplayTutorial", bDisplayTutorial.ToString ());
        writer.WriteWhitespace("\n\t\t");
        writer.WriteElementString ("CurrentScene", currentScene);
        writer.WriteWhitespace("\n\t\t");
        writer.WriteStartElement ("PlayerPos");
        writer.WriteAttributeString ("X", playerPos.x.ToString ());
        writer.WriteAttributeString ("Y", playerPos.y.ToString ());
        writer.WriteAttributeString ("Z", playerPos.z.ToString ());
        writer.WriteWhitespace("\n\t\t");
        writer.WriteStartElement ("CameraPos");
        writer.WriteAttributeString ("X", cameraPos.x.ToString ());
        writer.WriteAttributeString ("Y", cameraPos.y.ToString ());
        writer.WriteAttributeString ("Z", cameraPos.z.ToString ());
        writer.WriteEndElement ();

        //Save Items In Inventory
        for (int i = 0; i < items.Count; i++)
        {
            writer.WriteWhitespace("\n\t\t");
            writer.WriteStartElement ("Item");
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("ItemName", items[i].itemName.ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("ItemID", items[i].itemID.ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("ItemDescription", items[i].itemDescription.ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("SpriteName", items[i].spriteName.ToString());
            writer.WriteWhitespace("\n\t\t");
            writer.WriteEndElement();
        }

        writer.WriteWhitespace("\n\t");
        writer.WriteEndElement();
        writer.WriteWhitespace("\n");
        writer.WriteEndElement();
        writer.WriteEndDocument();

        writer.Close();
    }
开发者ID:jcabe4,项目名称:Reignite,代码行数:70,代码来源:PlayerInformation.cs

示例4: SaveMap

    /// <summary>
    /// Save the map to file.
    /// </summary>
    /// <param name="filename">
    /// A <see cref="System.String"/>
    /// </param>
    private void SaveMap(string filename)
    {
        //XML file
        string xmlFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), System.IO.Path.GetFileNameWithoutExtension(filename) + ".xml");
        //Tile data file
        //string tdFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), System.IO.Path.GetFileNameWithoutExtension(filename) + ".td");

        Log.Write("Saving current map to XML " + xmlFile);

        XmlWriter xmlWriter = new XmlTextWriter(xmlFile, new System.Text.UTF8Encoding());

        xmlWriter.WriteStartDocument();
        xmlWriter.WriteWhitespace("\r\n");
        xmlWriter.WriteStartElement("map");
        xmlWriter.WriteStartAttribute("id");
        xmlWriter.WriteValue(model.MapID);
        xmlWriter.WriteEndAttribute();

        //Write dimensions
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("geometry");

        //Write dimensions
        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("width");
        xmlWriter.WriteValue(model.TileMap.Width);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("height");
        xmlWriter.WriteValue(model.TileMap.Height);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("layers");
        xmlWriter.WriteValue(model.TileMap.Layers);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("tilesize");
        xmlWriter.WriteValue(model.TileMap.Tilesize);
        xmlWriter.WriteEndElement();

        //Offsets
        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("xoffset");
        xmlWriter.WriteValue(model.TileMap.OffsetX);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("yoffset");
        xmlWriter.WriteValue(model.TileMap.OffsetY);
        xmlWriter.WriteEndElement();

        //Geometry end
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteEndElement();
        xmlWriter.WriteWhitespace("\r\n");

        //Tileset
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("tileset");
        {

            bool foundTileset = false;
            foreach (string tsName in model.ResourceManager.Tilesets)
            {
                Tileset ts = model.ResourceManager.GetTileset(tsName);
                if (ts == model.CurrentTileset)
                {
                    xmlWriter.WriteValue(tsName);
                    foundTileset = true;
                    break;
                }
            }
            if (!foundTileset)
            {
                throw new NotFoundException("Tileset was not found in resource manager. This should not happen! What did you do?");
            }
        }

        xmlWriter.WriteEndElement();

        //Background
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("background");
        xmlWriter.WriteValue(model.Background);
        xmlWriter.WriteEndElement();
        xmlWriter.WriteWhitespace("\r\n");

        //Extra properties
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("properties");
        foreach (KeyValuePair<string, string> o in model.ExtraProperties)
//.........这里部分代码省略.........
开发者ID:hallgeirl,项目名称:Hiage,代码行数:101,代码来源:MainWindow.cs

示例5: GenerateXMLData

	//if this is the first time being activated the cell will call this to spawn the asteroids
	public void GenerateXMLData ()
	{
		if(!Directory.Exists(directory))
		{
			Directory.CreateDirectory(directory);
		}

		if(!hasPlanet)
		{
			WorldGenerator.WorldSpecs details = WorldGenerator.worldspec;

			Random.seed = details.seed;
			float maxDistance = details.mapLength / 2.0f;
			float halfCellLength = Mathf.Ceil(details.cellLength/2.0f);
			Vector2 startingPos = new Vector2( -halfCellLength, -halfCellLength);
			Vector2 endPos = new Vector2( halfCellLength, halfCellLength);

			for(int i = (int)startingPos.x; i < endPos.x ; i++)
			{
				for(int j = (int)startingPos.y; j < endPos.y ; j++)
				{				
					float distance = Mathf.Sqrt( Mathf.Pow(i + transform.position.x,2) + Mathf.Pow(j + transform.position.y ,2));
					if(distance < maxDistance && distance > maxDistance / 10.0)
					{
						float xCoord = ((i + transform.position.x) + details.mapLength /2) / (float)details.mapLength * 25.6f;
						float yCoord = ((j + transform.position.y) + details.mapLength /2) / (float)details.mapLength * 25.6f;						
						float scale = Mathf.PerlinNoise(xCoord,yCoord);

						if(scale > 0.95f || scale < 0.1f || (scale > 0.45f && scale < 0.5f))
						{
							positions.Add( new Vector2(i + transform.position.x, j + transform.position.y));
							perlin.Add(scale);
						}
					}
				}
			}

			XmlTextWriter writer = new XmlTextWriter (fileName, System.Text.Encoding.UTF8);
			
			writer.WriteStartDocument();
			writer.WriteWhitespace("\n");
			writer.WriteStartElement("Root");
			writer.WriteWhitespace("\n");
			
			for(int i = 0, j = 0; i < positions.Count && j < perlin.Count; i++, j++)
			{
				writer.WriteWhitespace("\t");
				writer.WriteStartElement("AsteroidPosition");
				writer.WriteAttributeString("x ",positions[i].x.ToString());
				writer.WriteAttributeString("y ",positions[i].y.ToString());
				writer.WriteEndElement();
				writer.WriteWhitespace("\n\t\t");
				writer.WriteElementString("PerlinValue", perlin[j].ToString());
				writer.WriteWhitespace("\n");
			}
			
			writer.WriteEndDocument ();
			writer.Close ();
		}
		else
		{
			XmlTextWriter writer = new XmlTextWriter (fileName, System.Text.Encoding.UTF8);
			
			writer.WriteStartDocument();
			writer.WriteWhitespace("\n");
			writer.WriteStartElement("Root");
			writer.WriteEndElement();
			writer.WriteWhitespace("\n");
			writer.WriteEndDocument();
			writer.Close ();
		}
	}
开发者ID:Jetblacktsunami,项目名称:CSE455-Salvage,代码行数:73,代码来源:WorldCell.cs

示例6: AutoSave

	public void AutoSave()
	{
		if(!Directory.Exists(directory))
		{
			Directory.CreateDirectory(directory);
		}
		if(File.Exists(fileName) && positions.Count > 0)
		{
			XmlTextWriter writer = new XmlTextWriter (fileName, System.Text.Encoding.UTF8);
			
			writer.WriteStartDocument();
			writer.WriteWhitespace("\n");
			writer.WriteStartElement("Root");
			writer.WriteWhitespace("\n");
			
			for(int i = 0, j = 0; i < positions.Count && j < perlin.Count; i++, j++)
			{
				writer.WriteWhitespace("\t");
				writer.WriteStartElement("AsteroidPosition");
				writer.WriteAttributeString("x ",positions[i].x.ToString());
				writer.WriteAttributeString("y ",positions[i].y.ToString());
				writer.WriteEndElement();
				writer.WriteWhitespace("\n\t\t");
				writer.WriteElementString("PerlinValue", perlin[j].ToString());
				writer.WriteWhitespace("\n");
			}
			
			writer.WriteEndDocument ();
			writer.Close ();
		}
	}
开发者ID:Jetblacktsunami,项目名称:CSE455-Salvage,代码行数:31,代码来源:WorldCell.cs

示例7: SaveFile

    void SaveFile(string file)
    {
        savePath = "Assets/Resources/Song Data/" + file;

        if (File.Exists(savePath))
        {
            Debug.Log("Overwriting " + file + " @ \n" + savePath);
            File.Delete(savePath);
        }
        else
        {
            Debug.Log("Saving " + file + " @ \n" + savePath);
        }

        XmlWriter writer = new XmlTextWriter (savePath, System.Text.Encoding.UTF8);

        writer.WriteStartDocument();
        writer.WriteWhitespace ("\n");
        writer.WriteStartElement ("Root");
        writer.WriteWhitespace ("\n\t");
        writer.WriteStartElement ("Body");

        for (int i = 0; i < notes.Count; i++)
        {
            writer.WriteWhitespace("\n\t\t");
            writer.WriteElementString("LengthRatio", lengthRatio.ToString());
            writer.WriteWhitespace("\n\t\t");
            writer.WriteStartElement("Note");
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("Color", ((int)notes[i].color).ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("StartTotal", notes[i].startTotal.ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("EndTotal", notes[i].endTotal.ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("NoteDuration", notes[i].noteDuration.ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteElementString("PitchPosition", notes[i].pitchPosition.ToString());

            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteStartElement("StartTime");
            writer.WriteWhitespace("\n\t\t\t\t");
            writer.WriteElementString("Minutes", notes[i].startTime.x.ToString());
            writer.WriteWhitespace("\n\t\t\t\t");
            writer.WriteElementString("Seconds", notes[i].startTime.y.ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteEndElement();

            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteStartElement("EndTime");
            writer.WriteWhitespace("\n\t\t\t\t");
            writer.WriteElementString("Minutes", notes[i].endTime.x.ToString());
            writer.WriteWhitespace("\n\t\t\t\t");
            writer.WriteElementString("Seconds", notes[i].endTime.y.ToString());
            writer.WriteWhitespace("\n\t\t\t");
            writer.WriteEndElement();

            writer.WriteWhitespace("\n\t\t");
            writer.WriteEndElement();
        }

        writer.WriteWhitespace ("\n\t");
        writer.WriteEndElement ();
        writer.WriteWhitespace ("\n");
        writer.WriteEndElement ();
        writer.WriteEndDocument ();

        writer.Close ();
    }
开发者ID:jcabe4,项目名称:Reignite,代码行数:69,代码来源:MusicSheetBuilder.cs

示例8: GenerateALLXMLData

	public static IEnumerator GenerateALLXMLData (float Range)
	{
#if UNITY_EDITOR
		string tempDir = Application.dataPath + "/SaveData/";
#else
		string tempDir = Application.persistentDataPath + "/SaveData/";
#endif
		if(!Directory.Exists(tempDir))
		{
			Directory.CreateDirectory(tempDir);
		}
		tempDir += WorldGenerator.worldspec.spaceName + "/";
		if(!Directory.Exists(tempDir))
		{
			Directory.CreateDirectory(tempDir);
		}

		WorldGenerator.WorldSpecs details = WorldGenerator.worldspec;
		Random.seed = details.seed;
		float halfCellLength = Mathf.Ceil(details.cellLength/2.0f);
		Vector2 startingPos = new Vector2( -halfCellLength, -halfCellLength);
		Vector2 endPos = new Vector2( halfCellLength, halfCellLength);

		foreach( WorldCell cell in ObjectPool.Pool.cells)
		{
			cell.Start();
			if(Vector2.Distance(cell.transform.position,Vector2.zero) < Range)
			{
				if(!cell.hasPlanet)
				{
					for(int i = (int)startingPos.x; i < endPos.x ; i++)
					{
						for(int j = (int)startingPos.y; j < endPos.y ; j++)
						{				
							float xCoord = ((i + cell.transform.position.x) + details.mapLength /2) / (float)details.mapLength * 25.6f;
							float yCoord = ((j + cell.transform.position.y) + details.mapLength /2) / (float)details.mapLength * 25.6f;						
							float scale = Mathf.PerlinNoise(xCoord,yCoord);
							
							if(scale > 0.95f || scale < 0.1f || (scale > 0.45f && scale < 0.5f))
							{
								cell.positions.Add(new Vector2(i + cell.transform.position.x, j + cell.transform.position.y));
								cell.perlin.Add(scale);
							}
						}
					}
					
					XmlTextWriter writer = new XmlTextWriter (cell.fileName, System.Text.Encoding.UTF8);
					
					writer.WriteStartDocument();
					writer.WriteWhitespace("\n");
					writer.WriteStartElement("Root");
					writer.WriteWhitespace("\n");
					
					for(int i = 0, j = 0; i < cell.positions.Count && j < cell.perlin.Count; i++, j++)
					{
						writer.WriteWhitespace("\t");
						writer.WriteStartElement("AsteroidPosition");
						writer.WriteAttributeString("x ",cell.positions[i].x.ToString());
						writer.WriteAttributeString("y ",cell.positions[i].y.ToString());
						writer.WriteEndElement();
						writer.WriteWhitespace("\n\t\t");
						writer.WriteElementString("PerlinValue", cell.perlin[j].ToString());
						writer.WriteWhitespace("\n");
					}
					
					writer.WriteEndDocument ();
					writer.Close ();
				}
				else
				{
					XmlTextWriter writer = new XmlTextWriter (cell.fileName, System.Text.Encoding.UTF8);
					
					writer.WriteStartDocument();
					writer.WriteWhitespace("\n");
					writer.WriteStartElement("Root");
					writer.WriteEndElement();
					writer.WriteWhitespace("\n");
					writer.WriteEndDocument();
					writer.Close ();
				}
			}
		}
	
		yield return new WaitForSeconds(0);
	}
开发者ID:Jetblacktsunami,项目名称:CSE455-Salvage,代码行数:85,代码来源:WorldCell.cs

示例9: SaveData

    private void SaveData()
    {
        fileName = "Dialogue (Ch " + chapterNum.ToString () + ", Scene " + sceneNum.ToString () + ")";
        savePath = Application.dataPath + "/Resources/Dialogue Data/" + fileName + ".xml";

        if (File.Exists(savePath))
        {
            Debug.Log("Overwriting " + fileName + ".xml @ \n" + savePath);
            File.Delete(savePath);
        }
        else
        {
            Debug.Log("Saving " + fileName + ".xml @ \n" + savePath);
        }

        XmlWriter writer = new XmlTextWriter (savePath, System.Text.Encoding.UTF8);

        writer.WriteStartDocument();
        writer.WriteWhitespace ("\n");
        writer.WriteStartElement ("Root");
        writer.WriteWhitespace ("\n\t");
        writer.WriteStartElement ("Body");

        for (int i = 0; i < conversations.Count; i++)
        {
            writer.WriteWhitespace("\n\t\t");
            writer.WriteStartElement("Conversation");
            writer.WriteAttributeString("index", i.ToString());

            for (int j = 0; j < conversations[i].quotes.Count; j++)
            {
                writer.WriteWhitespace("\n\t\t\t");
                writer.WriteStartElement("Quote");
                writer.WriteAttributeString("quoteIndex", conversations[i].quotes[j].quoteIndex.ToString());
                writer.WriteAttributeString("speaker", conversations[i].quotes[j].speaker);
                writer.WriteAttributeString("statement", conversations[i].quotes[j].statement);

                writer.WriteWhitespace("\n\t\t\t");
                writer.WriteEndElement();
            }
            writer.WriteWhitespace("\n\t\t");
            writer.WriteEndElement();
        }

        writer.WriteWhitespace ("\n\t");
        writer.WriteEndElement ();
        writer.WriteWhitespace ("\n");
        writer.WriteEndElement ();
        writer.WriteEndDocument ();
        writer.Close ();
    }
开发者ID:jcabe4,项目名称:Reignite,代码行数:51,代码来源:DialogueBuilder.cs

示例10: WriteXML

    public void WriteXML(XmlTextWriter pXML)
    {
        //Debug.Log("Saving path to XML");

        for(int i = 0; i < _Points.Count; ++i)
        {
            pXML.WriteStartElement("point");
            pXML.WriteWhitespace("\n");
            pXML.WriteElementString("x","" + _Points[i].x);
            pXML.WriteElementString("z","" + _Points[i].z);
            pXML.WriteWhitespace("\n");
            pXML.WriteEndElement();
            pXML.WriteWhitespace("\n");
        }
    }
开发者ID:Johangsl,项目名称:GameDevChronicles,代码行数:15,代码来源:WayPoints.cs

示例11: AutoSave

    public void AutoSave()
    {
        if(!Directory.Exists(WorldGenerator.directory + "/" + WorldGenerator.worldspec.spaceName + "/"))
        {
            Directory.CreateDirectory(WorldGenerator.directory + "/" + WorldGenerator.worldspec.spaceName + "/");
        }
        if(File.Exists(savePath))
        {
            File.Delete(savePath);
        }

        XmlWriter writer = new XmlTextWriter(savePath, System.Text.Encoding.UTF8);
        writer.WriteStartDocument();
        writer.WriteWhitespace("\n");
        writer.WriteStartElement("Root");
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("deviceID", SystemInfo.deviceUniqueIdentifier);
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("ship", ship);
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("playerPosition", transform.position.x.ToString() + "," + transform.position.y.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("maxHealth", maxHealth.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("currentHealth", currentHealth.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("maxShields", maxShields.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("currentShields", currentShields.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("shieldRechargeDelay", shieldRechargeDelay.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("shieldRechargeRate", shieldRechargeRate.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("maxFuel", maxFuel.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("currentFuel", currentFuel.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("fuelConsumptionRate", fuelConsumptionRate.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("acceleration", acceleration.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("speed", speed.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("maxSpeed", maxSpeed.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("thrusterDelay", thrusterDelay.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("rotationSpeed", rotationSpeed.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("currentWeapon", WeaponManager.Instance.ammo.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("currentMaxAmmo", WeaponManager.Instance.MaxAmmo.ToString());
        writer.WriteWhitespace("\n\t");
        writer.WriteElementString("currentAmmo", WeaponManager.Instance.CurrentAmmo.ToString());

        Dictionary<WeaponManager.ammoType, float>.KeyCollection keys = WeaponManager.Instance.totalMaxAmmo.Keys;
        for( Dictionary<WeaponManager.ammoType, float>.KeyCollection.Enumerator i = keys.GetEnumerator(); ; )
        {
            if(i.Current == WeaponManager.ammoType.none)
            {
                if(!i.MoveNext())
                {
                    break;
                }
            }
            writer.WriteWhitespace("\n\t");
            writer.WriteElementString( i.Current.ToString() + "_MAX", WeaponManager.Instance.totalMaxAmmo[i.Current].ToString());
            if(!i.MoveNext())
            {
                break;
            }
        }

        keys = WeaponManager.Instance.totalCurrentAmmo.Keys;
        for( Dictionary<WeaponManager.ammoType, float>.KeyCollection.Enumerator i = keys.GetEnumerator(); ; )
        {
            if(i.Current == WeaponManager.ammoType.none)
            {
                if(!i.MoveNext())
                {
                    break;
                }
            }
            writer.WriteWhitespace("\n\t");
            writer.WriteElementString( i.Current.ToString() + "_CURRENT", WeaponManager.Instance.totalCurrentAmmo[i.Current].ToString());
            if(!i.MoveNext())
            {
                break;
            }
        }

        writer.WriteEndElement();
        writer.Close();

        XMLFileManager.EncryptFile(savePath);
    }
开发者ID:Jetblacktsunami,项目名称:CSE455-Salvage,代码行数:97,代码来源:PlayerInformation.cs

示例12: ExportStrategy

    public static bool ExportStrategy(string fileName, IList strategyList)
    {
        FileStream fileStream = null;
        bool bRet = false;
        try
        {
            fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
            fileStream.SetLength(0L);
            XmlTextWriter writer = new XmlTextWriter(fileStream, Encoding.Default);
            byte[] strategyBytes;

            //声明
            writer.WriteStartDocument();
            writer.WriteWhitespace("\n");

            writer.WriteStartElement("StrategyList");
            foreach (Strategy strategy in strategyList)
            {                
                writer.WriteWhitespace("\n\t");
                writer.WriteStartElement("Strategy");
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Name", strategy.SecurityObject.Name);
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Comment", strategy.SecurityObject.Comment);
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Event", ((int)strategy.Event).ToString());
                writer.WriteWhitespace("\n\t\t");

                writer.WriteStartElement("Automation");
                strategyBytes = AdminServer.TheInstance.AutomationManager.Save(strategy.Automation);
                writer.WriteBinHex(strategyBytes, 0, strategyBytes.Length);
                writer.WriteEndElement();
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Enable", strategy.Enabled ? "1" : "0");
                writer.WriteWhitespace("\n\t");

                writer.WriteEndElement();
                
            }
            writer.WriteWhitespace("\n");
            writer.WriteEndElement();

            writer.Flush();
            bRet = true;
        }
        catch (Exception)
        {
            bRet = false;
        }
        finally
        {
            if (fileStream != null) fileStream.Close();
        }
        return bRet;
    }
开发者ID:viticm,项目名称:pap2,代码行数:59,代码来源:WebUtil.cs

示例13: ExportScheduledTask

    public static bool ExportScheduledTask(string fileName, IList taskList)
    {
        FileStream fileStream = null;
        bool bRet = false;
        try
        {
            fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
            fileStream.SetLength(0L);
            XmlTextWriter writer = new XmlTextWriter(fileStream, Encoding.Default);            
            IFormatter formatter = new BinaryFormatter();
            MemoryStream taskDataStream;

            //声明
            writer.WriteStartDocument();
            writer.WriteWhitespace("\n");

            writer.WriteStartElement("TaskList");
            foreach (ScheduledTaskUnit taskUnit in taskList)
            {
                taskDataStream = new MemoryStream();
                formatter.Serialize(taskDataStream, taskUnit.Task);

                writer.WriteWhitespace("\n\t");
                writer.WriteStartElement("Task");
                writer.WriteWhitespace("\n\t\t");
                
                writer.WriteElementString("Name", taskUnit.Task.SecurityObject.Name);
                writer.WriteWhitespace("\n\t\t");

                writer.WriteElementString("Comment", taskUnit.Task.SecurityObject.Comment);
                writer.WriteWhitespace("\n\t\t");

                writer.WriteStartElement("Data");
                writer.WriteBinHex(taskDataStream.ToArray(), 0, (int)taskDataStream.Length);
                writer.WriteEndElement();
                writer.WriteWhitespace("\n\t");

                writer.WriteEndElement();
            }

            writer.WriteWhitespace("\n");
            writer.WriteEndElement();

            writer.Flush();            
        }
        catch (Exception)
        {
            bRet = false;
        }
        finally
        {
            if (fileStream != null) fileStream.Close();
        }
        return bRet;
    }
开发者ID:viticm,项目名称:pap2,代码行数:55,代码来源:WebUtil.cs


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