public void CreateSolid() { var solid = new SubSolid(); Level.Solids.Add(solid); solid.State = SubSolidState.Creating; SelectedObject = solid; }
public void CreateRespawnPoint() { var respawnPoint = new SubRespawnPoint(); Level.RespawnPoints.Add(respawnPoint); respawnPoint.State = SubSolidState.Creating; SelectedObject = respawnPoint; }
public void Open(Stream stream) { using (StreamReader sr = new StreamReader(stream)) { string line; line = sr.ReadLine(); int width = int.Parse(line.Split('=')[1]); line = sr.ReadLine(); int height = int.Parse(line.Split('=')[1]); Level = new SubLevel(); Level.Position = new Point(50, 50); Level.Size = new Point(width, height); // объекты while ((line = sr.ReadLine()) != null) { if (line == "[Solid]") { SubSolid solid = new SubSolid(); solid.State = SubSolidState.Saved; line = sr.ReadLine(); int w = int.Parse(line.Split('=')[1]); line = sr.ReadLine(); int h = int.Parse(line.Split('=')[1]); solid.Size = new Point(w, h); line = sr.ReadLine(); int pX = int.Parse(line.Split('=')[1]); line = sr.ReadLine(); int pY = int.Parse(line.Split('=')[1]); solid.Position = new Point(pX - (w >> 1), pY - (h >> 1)); line = sr.ReadLine(); solid.Angle = float.Parse(line.Split('=')[1]); Level.Solids.Add(solid); solid.CalcVertices(); } if (line == "[RespawnPoint]") { SubRespawnPoint respawnPoint = new SubRespawnPoint(); respawnPoint.State = SubSolidState.Saved; line = sr.ReadLine(); line = sr.ReadLine(); int pX = int.Parse(line.Split('=')[1]); line = sr.ReadLine(); int pY = int.Parse(line.Split('=')[1]); respawnPoint.Position = new Point(pX, pY); Level.RespawnPoints.Add(respawnPoint); } } SelectedObject = null; } }
internal void DeleteSolid() { if (SelectedObject is SubSolid) { Level.Solids.Remove((SubSolid)SelectedObject); } else if (SelectedObject is SubRespawnPoint) { Level.RespawnPoints.Remove((SubRespawnPoint)SelectedObject); } SelectedObject = null; }
public void SaveObject() { SelectedObject.State = SubSolidState.Saved; SelectedObject = null; }