Example #1
0
 public void CreateRespawnPoint()
 {
     var respawnPoint = new SubRespawnPoint();
     Level.RespawnPoints.Add(respawnPoint);
     respawnPoint.State = SubSolidState.Creating;
     SelectedObject = respawnPoint;
 }
Example #2
0
        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;
            }
        }