Ejemplo n.º 1
0
 public object Clone()
 {
     Connection Tmp = new Connection(Game);
     Tmp.A = this.A;
     Tmp.B = this.B;
     Tmp.Position1 = this.Position1;
     Tmp.Position2 = this.Position2;
     return Tmp;
 }
Ejemplo n.º 2
0
 public RawConnection GetRawFromConnection(Connection Connection)
 {
     RawConnection Raw = new RawConnection();
     Raw.A = Connection.A;
     Raw.B = Connection.B;
     Raw.Pos1 = Connection.Position1;
     Raw.Pos2 = Connection.Position2;
     return Raw;
 }
Ejemplo n.º 3
0
 public static void AddConnection(int A, int B, Vector2 Position1, Vector2 Position2)
 {
     Connection Tmp = new Connection(Renderer.Singleton.Game);
     Tmp.A = A;
     Tmp.B = B;
     Tmp.Position1 = Position1;
     Tmp.Position2 = Position2;
     GeneratingLevel.ConnectionsCount++;
     GeneratingLevel.Components.Add(Tmp);
 }
Ejemplo n.º 4
0
        public static void Load(Game game, SpriteBatch spriteBatch)
        {
            IAsyncResult result = Guide.BeginShowStorageDeviceSelector(PlayerIndex.One, null, null);
            StorageDevice device = Guide.EndShowStorageDeviceSelector(result);

            result.AsyncWaitHandle.WaitOne();

            StorageContainer container = device.OpenContainer("StorageDemo");
            result.AsyncWaitHandle.Close();

            string filename = Path.Combine(container.Path, "savegame.sav");

            if (!File.Exists(filename))
            {
                // If not, dispose of the container and return.
                container.Dispose();
                return;
            }

            // Open the file.
            FileStream stream = File.Open(filename, FileMode.Open);

            XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));
            SaveGameData data = (SaveGameData)serializer.Deserialize(stream);

            //GeneralManager.Singleton.CurrentLevel = new Level(game, spriteBatch);

            using (Connection Tmp = new Connection(game))
            {
                int i = 0;
                foreach (RawConnection v in data.Connections)
                {
                    Tmp.A = v.A;
                    Tmp.B = v.B;
                    Tmp.Position1 = v.Pos1;
                    Tmp.Position2 = v.Pos2;
                    GeneralManager.Singleton.CurrentLevel.Components.Add(Tmp.Clone() as Connection);
                    i++;
                }
                GeneralManager.Singleton.CurrentLevel.ConnectionsCount = i;
            }

            using (Vertex Tmp = new Vertex(game, Vector2.Zero, Renderer.Singleton.Content.Load<Texture2D>("indicator"), null))
            {
                int i = 0;
                foreach (RawVertex v in data.Vertex)
                {
                    Tmp.Position = v.Position;
                    GeneralManager.Singleton.CurrentLevel.Components.Add(Tmp.Clone() as Vertex);
                    i++;
                }
                GeneralManager.Singleton.CurrentLevel.VertexCount = i;
            }

            GeneralManager.Singleton.IsLevelInitalized = true;

            // Close the file.
            stream.Close();
            container.Dispose();
        }