// TODO fill me in
        public GameData OnSave()
        {
            AsteroidsData storm = new AsteroidsData();


            foreach (Asteroid a in FindObjectsOfType(typeof(Asteroid)))
            {
                AsteroidData c = new AsteroidData();
                c.Size     = a.Size;
                c.Pos      = a.GetComponent <Rigidbody2D>().position;
                c.Velocity = a.GetComponent <Rigidbody2D>().velocity;
                storm.Asteroids.Add(c);
            }
            return(storm);
        }
示例#2
0
        // TODO fill me in
        public GameData OnSave()
        {
            AsteroidsData newRocks = new AsteroidsData();

            Asteroid[] oldRocks = (Asteroid[])FindObjectsOfType(typeof(Asteroid));
            newRocks.Asteroids = new List <AsteroidData>();
            foreach (Asteroid rock in oldRocks)
            {
                AsteroidData temp = new AsteroidData();
                temp.Size     = rock.GetComponent <Asteroid>().Size;
                temp.Pos      = rock.GetComponent <Rigidbody2D>().position;
                temp.Velocity = rock.GetComponent <Rigidbody2D>().velocity;
                newRocks.Asteroids.Add(temp);
            }
            return(newRocks);
        }
        // TODO fill me in
        public GameData OnSave()
        {
            Asteroid[]    asteroids = Object.FindObjectsOfType(typeof(Asteroid)) as Asteroid[];
            AsteroidsData aData     = new AsteroidsData();

            aData.Asteroids = new List <AsteroidData>();
            foreach (Asteroid asteroid in asteroids)
            {
                AsteroidData a  = new AsteroidData();
                Rigidbody2D  rb = asteroid.GetComponent <Rigidbody2D>();
                a.Pos      = rb.position;
                a.Velocity = rb.velocity;
                a.Size     = asteroid.GetComponent <Asteroid>().Size;
                aData.Asteroids.Add(a);
            }
            return(aData);
        }
        public GameData OnSave()
        {
            AsteroidsData asteroidsData = new AsteroidsData();
            var           asteroids     = Object.FindObjectsOfType(typeof(Asteroid));

            foreach (Asteroid asteroid in asteroids)
            {
                AsteroidData asteroidData = new AsteroidData();
                asteroidData.Size     = asteroid.Size;
                asteroidData.Pos      = asteroid.GetComponent <Rigidbody2D>().position;
                asteroidData.Velocity =
                    asteroid.GetComponent <Rigidbody2D>().velocity;

                asteroidsData.Asteroids.Add(asteroidData);
            }
            return(asteroidsData);
        }
        public GameData OnSave()
        {
            AsteroidsData allAsteroidsData = new AsteroidsData();

            Object[] listOfAsteroids = FindObjectsOfType(typeof(Asteroid));
            foreach (var a in listOfAsteroids)
            {
                Asteroid     currAsteroid = (Asteroid)a;
                AsteroidData asteroidData = new AsteroidData();
                Rigidbody2D  rigidBody    = currAsteroid.GetComponent <Rigidbody2D> ();
                asteroidData.Size     = currAsteroid.Size;
                asteroidData.Pos      = rigidBody.position;
                asteroidData.Velocity = rigidBody.velocity;
                allAsteroidsData.Asteroids.Add(asteroidData);
            }
            return(allAsteroidsData);
        }
示例#6
0
        // TODO fill me in
        public GameData OnSave()
        {
            var aData = new AsteroidsData();
            var aList = (Asteroid[])Object.FindObjectsOfType(typeof(Asteroid));

            if (aList != null)
            {
                foreach (var ast in aList)
                {
                    var currData = new AsteroidData();
                    var rb2      = ast.GetComponent <Rigidbody2D>();
                    currData.Pos      = rb2.position;
                    currData.Velocity = rb2.velocity;
                    currData.Size     = ast.GetComponent <Asteroid>().Size;
                    aData.Asteroids.Add(currData);
                }
            }
            return(aData);
        }