// TODO fill me in
        public void OnLoad(GameData data)
        {
            foreach (Transform shrapnel in _holder)
            {
                GameObject.Destroy(shrapnel.gameObject);
            }
            BulletsData updateList = (BulletsData)data;

            foreach (BulletData update in updateList.Bullets)
            {
                ForceSpawn(update.Pos, Quaternion.Euler(0, 0, update.Rotation), update.Velocity, Time.time + Bullet.Lifetime);
            }
        }
        // TODO fill me in
        public void OnLoad(GameData data)
        {
            foreach (Bullet b in Game.FindObjectsOfType(typeof(Bullet)))
            {
                Game.Destroy(b.gameObject);
            }
            BulletsData highnoon = (BulletsData)data;

            foreach (BulletData a in highnoon.Bullets)
            {
                ForceSpawn(a.Pos, new Quaternion(), a.Velocity, Time.time + Bullet.Lifetime);
            }
        }
        public void OnLoad(GameData data)
        {
            Object[] listOfBullets = Object.FindObjectsOfType(typeof(Bullet));
            foreach (var b in listOfBullets)
            {
                Bullet currBullet = (Bullet)b;
                Object.Destroy(currBullet.gameObject);
            }

            BulletsData allBulletsData = (BulletsData)data;

            foreach (var bulletData in allBulletsData.Bullets)
            {
                ForceSpawn(bulletData.Pos, Quaternion.Euler(0, 0, bulletData.Rotation), bulletData.Velocity, Time.time + Bullet.Lifetime);
            }
        }
        // TODO fill me in
        public GameData OnSave()
        {
            BulletsData newBullets = new BulletsData();

            newBullets.Bullets = new List <BulletData>();
            Bullet[] oldBullets = (Bullet[])Object.FindObjectsOfType(typeof(Bullet));
            foreach (Bullet shrapnel in oldBullets)
            {
                BulletData temp = new BulletData();
                temp.Pos      = shrapnel.GetComponent <Rigidbody2D>().position;
                temp.Velocity = shrapnel.GetComponent <Rigidbody2D>().velocity;
                temp.Rotation = shrapnel.GetComponent <Rigidbody2D>().rotation;
                newBullets.Bullets.Add(temp);
            }
            return(newBullets);
        }
        // TODO fill me in
        public void OnLoad(GameData data)
        {
            while (_holder.childCount > 0)
            {
                Transform child = _holder.GetChild(0);
                child.parent = null;
                Object.Destroy(child.gameObject);
            }
            BulletsData allData = (BulletsData)data;

            foreach (BulletData b in allData.Bullets)
            {
                Quaternion q = Quaternion.Euler(0, 0, b.Rotation);
                ForceSpawn(b.Pos, q, b.Velocity, Time.time + Bullet.Lifetime);
            }
        }
        public GameData OnSave()
        {
            BulletsData allBulletsData = new BulletsData();

            Object[] listOfBullets = Object.FindObjectsOfType(typeof(Bullet));
            foreach (var b in listOfBullets)
            {
                Bullet      currBullet = (Bullet)b;
                BulletData  bulletData = new BulletData();
                Rigidbody2D rigidBody  = currBullet.GetComponent <Rigidbody2D> ();
                bulletData.Pos      = rigidBody.position;
                bulletData.Velocity = rigidBody.velocity;
                bulletData.Rotation = rigidBody.rotation;
                allBulletsData.Bullets.Add(bulletData);
            }
            return(allBulletsData);
        }
        // TODO fill me in
        public GameData OnSave()
        {
            BulletsData Bulletstorm = new BulletsData();

            List <BulletData> chamber = new List <BulletData>();

            foreach (Bullet a in Game.FindObjectsOfType(typeof(Bullet)))
            {
                BulletData b = new BulletData();
                b.Pos      = a.GetComponent <Rigidbody2D>().position;
                b.Velocity = a.GetComponent <Rigidbody2D>().velocity;
                b.Rotation = a.GetComponent <Rigidbody2D>().rotation;
                chamber.Add(b);
            }
            Bulletstorm.Bullets = chamber;
            return(Bulletstorm);
        }
        // TODO fill me in
        public GameData OnSave()
        {
            Bullet[]    bullets = Object.FindObjectsOfType(typeof(Bullet)) as Bullet[];
            BulletsData bData   = new BulletsData();

            bData.Bullets = new List <BulletData>();
            foreach (Bullet bullet in bullets)
            {
                BulletData  b  = new BulletData();
                Rigidbody2D rb = bullet.GetComponent <Rigidbody2D>();
                b.Pos      = rb.position;
                b.Velocity = rb.velocity;
                b.Rotation = rb.rotation;
                bData.Bullets.Add(b);
            }
            return(bData);
        }
Beispiel #9
0
        public GameData OnSave()
        {
            BulletsData bulletsData = new BulletsData();
            var         bullets     = Object.FindObjectsOfType(typeof(Bullet));

            foreach (Bullet bullet in bullets)
            {
                BulletData bulletData = new BulletData();
                bulletData.Pos      = bullet.GetComponent <Rigidbody2D>().position;
                bulletData.Rotation = bullet.GetComponent <Rigidbody2D>().rotation;
                bulletData.Velocity = bullet.GetComponent <Rigidbody2D>().velocity;

                bulletsData.Bullets.Add(bulletData);
            }

            return(bulletsData);
        }
Beispiel #10
0
        public void OnLoad(GameData data)
        {
            // destroy exiting bullets
            //var list = _holder.GetComponents<Bullet>();
            var list = Object.FindObjectsOfType(typeof(Bullet));

            foreach (Bullet bullet in list)
            {
                Object.Destroy(bullet.gameObject);
            }

            BulletsData bullets = data as BulletsData;

            foreach (BulletData bullet in bullets.Bullets)
            {
                ForceSpawn(bullet.Pos,
                           Quaternion.Euler(0, 0, bullet.Rotation),
                           bullet.Velocity,
                           Time.time + Bullet.Lifetime);
            }
        }
Beispiel #11
0
        // TODO fill me in
        public GameData OnSave()
        {
            BulletsData bData = new BulletsData();

            bData.Bullets = new List <BulletData>();
            var bList = (Bullet[])Object.FindObjectsOfType(typeof(Bullet));

            if (bList != null)
            {
                foreach (var bull in bList)
                {
                    var currData = new BulletData();
                    currData.Pos      = new Vector2();
                    currData.Velocity = new Vector2();
                    var rb2 = bull.gameObject.GetComponent <Rigidbody2D>();
                    currData.Pos      = rb2.position;
                    currData.Velocity = rb2.velocity;
                    currData.Rotation = rb2.rotation;
                    bData.Bullets.Add(currData);
                }
            }
            return(bData);
        }