Exemple #1
0
 public void addAnimatedSpriteStrip(SpriteStrip thisAnim)
 {
     if (actionsAddedCount > myAnimatedSpriteStrips.Length)
     {
         Console.WriteLine("adding too many actions for your actions manager");
     }
     else
     {
         myAnimatedSpriteStrips[actionsAddedCount] = thisAnim;
         actionsAddedCount = actionsAddedCount + 1;
     }
 }
 public void SpawnChildren(SpriteStripManager item, List <SpriteStripManager> itemlist, SpriteStrip texture, int current, int amount, Random ranGen)
 {
     //spawns smaller versions of a given item.
     for (int i = 0; i < amount; i++)
     {
         texture = new SpriteStrip(itemlist[current].getTexture(), 0.1f, true);
         texture.setName("Idle");
         item = new SpriteStripManager(1, false, ranGen, itemlist[current].XPos, itemlist[current].YPos, itemlist[current].Scale / 2, itemlist[current].myID);
         itemlist.Add(item);
         itemlist[itemlist.Count - 1].addAnimatedSpriteStrip(texture);
         itemlist[itemlist.Count - 1].Update();
     }
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            font     = Content.Load <SpriteFont>("asteroids");
            hud.font = font;
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Texture2D   ship     = Content.Load <Texture2D>("ship");
            Texture2D   shipgo   = Content.Load <Texture2D>("shipgo");
            Texture2D   shot     = Content.Load <Texture2D>("bullet");
            Texture2D   asteroid = Content.Load <Texture2D>("asteroid");
            Texture2D   alien    = Content.Load <Texture2D>("alien");
            Texture2D   spark    = Content.Load <Texture2D>("spark");
            Texture2D   beam     = Content.Load <Texture2D>("beam");
            Texture2D   star     = Content.Load <Texture2D>("star");
            Texture2D   portal   = Content.Load <Texture2D>("portal");
            SoundEffect fire     = Content.Load <SoundEffect>("fire");

            soundlist.Add(fire);
            SoundEffect bangSmall = Content.Load <SoundEffect>("bangSmall");

            soundlist.Add(bangSmall);
            SoundEffect bangMedium = Content.Load <SoundEffect>("bangMedium");

            soundlist.Add(bangMedium);
            SoundEffect bangLarge = Content.Load <SoundEffect>("bangLarge");

            soundlist.Add(bangSmall);
            SoundEffect saucerBig = Content.Load <SoundEffect>("saucerBig");

            soundlist.Add(saucerBig);
            SoundEffect extraShip = Content.Load <SoundEffect>("extraShip");

            soundlist.Add(extraShip);
            SoundEffect thrust = Content.Load <SoundEffect>("thrust");

            soundlist.Add(thrust);
            SoundEffect beat1 = Content.Load <SoundEffect>("beat1");

            soundlist.Add(beat1);
            SoundEffect beat2 = Content.Load <SoundEffect>("beat2");

            soundlist.Add(beat2);
            //SoundEffect titlemusic = Content.Load<SoundEffect>("TitleMusic");
            //soundlist.Add(titlemusic);
            //SoundEffect gamemusic = Content.Load<SoundEffect>("GameMusic");
            // soundlist.Add(gamemusic);
            foreach (SoundEffect effect in soundlist)
            {
                soundlistinstance.Add(effect.CreateInstance());
            }

            List <Texture2D> particleeffects = new List <Texture2D>();

            particleeffects.Add(spark);
            particleeffects.Add(beam);

            starIdle = new SpriteStrip(star, 1, false);
            starIdle.setName("Idle");

            alienIdle = new SpriteStrip(alien, 0.1f, true);
            alienIdle.setName("Idle");

            PlayerBulletParticles = new ParticleManager(shot, new Vector2(400, 240), 0);
            EnemyBulletParticles  = new ParticleManager(shot, new Vector2(400, 240), 0);
            ParticleEffects       = new ParticleManager(particleeffects, new Vector2(400, 240), 0);

            asteroidIdle = new SpriteStrip(asteroid, 0.1f, true);
            asteroidIdle.setName("Idle");

            //these two are used if the game spawns asteroids or aliens at the very beggining.
            for (int i = 0; i < numAsteroid; i++)
            {
                asteroidIdle = new SpriteStrip(asteroid, 0.1f, true);
                asteroidIdle.setName("Idle");
                objectlist[i].addAnimatedSpriteStrip(asteroidIdle);
            }
            for (int i = 0; i < numAliens; i++)
            {
                alienIdle = new SpriteStrip(asteroid, 0.1f, true);
                alienIdle.setName("Idle");
                objectlist[i].addAnimatedSpriteStrip(alienIdle);
            }

            SpriteStrip myShipIdle = new SpriteStrip(ship, 0.1f, true);

            myShipIdle.setName("Idle");
            myShipMoving = new SpriteStrip(shipgo, 0.1f, true);
            myShipMoving.setName("Moving");
            myShip.addAnimatedSpriteStrip(myShipIdle);
            myShip.addAnimatedSpriteStrip(myShipMoving);
            hud.life = ship;

            SpriteStrip portalIdle = new SpriteStrip(portal, 0.1f, true);

            portalIdle.setName("Idle");
            myPortal.addAnimatedSpriteStrip(portalIdle);
        }
 public void NewItem(SpriteStripManager item, List <SpriteStripManager> itemlist, SpriteStrip texture, int itemid, Random ranGen)
 {
     item = new SpriteStripManager(1, false, ranGen, itemid);
     itemlist.Add(item);
     itemlist[itemlist.Count - 1].addAnimatedSpriteStrip(texture);
     itemlist[itemlist.Count - 1].Update();
 }