public void SaveLevel() { var db = new DB(); Debug.Log(spawn); db.startpos = spawn; foreach (Transform t in level) { var w = t.GetComponent <Tool>(); var b = new Tooldb { toolid = w.toolid, Pos = w.pos, rot = w.rot, scale = w.scale }; var txt = t.GetComponent <TextMesh>(); if (txt != null) { b.text = txt.text; } var score = t.GetComponent <Score>(); if (score != null) { b.spawn = score.spawn; } var anim = t.GetComponent <AnimHelper>(); if (anim != null) { b.animSpeedFactor = anim.animationSpeedFactor; b.timeOffsetFactor = anim.TimeOffsetFactor; } var wall = t.GetComponent <Wall>(); if (wall != null) { b.speedTrackVell = wall.SpeedTrackVell; } db.tools.Add(b); } Map.Dispose(); Map = new MemoryStream(); DB.xml.Serialize(Map, db); }
public void SaveLevel() { var db = new DB(); Debug.Log(spawn); db.startpos = spawn; foreach (Transform t in level) { var w = t.GetComponent<Tool>(); var b = new Tooldb { toolid = w.toolid, Pos = w.pos, rot = w.rot, scale = w.scale }; var txt = t.GetComponent<TextMesh>(); if (txt != null) b.text = txt.text; var score = t.GetComponent<Score>(); if (score != null) b.spawn = score.spawn; var anim = t.GetComponent<AnimHelper>(); if (anim != null) { b.animSpeedFactor = anim.animationSpeedFactor; b.timeOffsetFactor = anim.TimeOffsetFactor; } var wall = t.GetComponent<Wall>(); if (wall != null) { b.speedTrackVell = wall.SpeedTrackVell; } db.tools.Add(b); } Map.Dispose(); Map = new MemoryStream(); DB.xml.Serialize(Map, db); }