Example #1
0
        public void addBullet(Character c, Color col, int damage)
        {
            Vector2 vel = c.getVel() * 0.1f;
            vel += (new Vector2((float)Math.Cos(c.getRotation() - Math.PI / 2),
                (float)Math.Sin(c.getRotation() - Math.PI / 2))) * 4.0f;
            List<Bullet> l;

            if (c is Player)
            {
                vel *= 3.0f;
                l = playerBullets;
                soundManager.playerFire();
            }
            else
            {
                vel *= 1.5f;
                l = enemyBullets;
                if (enemyBullets.Count < 100)
                {
                    soundManager.enemyFire();
                }
            }

            Bullet b = new Bullet(bulletSprite, c.getPos(), vel, 1, levelManager, col, damage);
            b.setRotation(c.getRotation());
            l.Add(b);
        }
Example #2
0
 public void addBomb(Character c, Color col, int damage)
 {
     Bullet b = new Bullet(explosionSprite, c.getPos(), new Vector2(0.0f, 0.0f), 1, levelManager, col, damage);
     b.setGrow(true, 0.13f);
     b.setStay(true);
     playerBullets.Add(b);
     soundManager.playerDeath();
 }
Example #3
0
        public void makeBackground()
        {
            backgrounds.Clear();
            float zoom = 0.2f;
            for (int i = 0; i < 3; i++)
            {
                List<Character> starfield = new List<Character>();
                for (int j = 0; j < 200; j++)
                {
                    Vector2 pos = new Vector2(Game1.random.Next(currentLevelArea.Left, currentLevelArea.Right) * (2.0f / zoom),
                        Game1.random.Next(currentLevelArea.Top, currentLevelArea.Bottom) * (2.0f / zoom));
                    int st = Game1.random.Next(0, 3);
                    Texture2D starT = starTex[st];
                    Character star = new Character(starT, pos, new Vector2(0.0f, 0.0f), 1, this);
                    float rot = (float)(Game1.random.NextDouble() * 2.0f * Math.PI);
                    star.setRotation(rot);
                    starfield.Add(star);
                }

                backgrounds.Add(new KeyValuePair<float, List<Character>>(zoom, starfield));
                zoom *= 1.4f;
            }

            if (currentLevel >= 1 && currentLevel <= 4)
            {
                List<Character> back1 = new List<Character>();
                List<Character> back2 = new List<Character>();
                Vector2 p = new Vector2(currentLevelArea.X, currentLevelArea.Y);

                TileBackground tb1 = new TileBackground(backTex[currentLevel-1], p, new Vector2(0.0f, 0.0f), 1, this);
                float r = (float)(Game1.random.NextDouble() * 2.0f * Math.PI);
                tb1.setRotation(1.0f);
                back1.Add(tb1);
                TileBackground tb2 = new TileBackground(backTex[currentLevel - 1], p, new Vector2(0.0f, 0.0f), 1, this);
                r = (float)(Game1.random.NextDouble() * 2.0f * Math.PI);
                tb2.setRotation(2.2f);
                back2.Add(tb2);

                backgrounds.Add(new KeyValuePair<float, List<Character>>(0.5f, back1));
                backgrounds.Add(new KeyValuePair<float, List<Character>>(0.75f, back2));
            }

            if (currentLevel >= 5)
            {
                // add earth/moon
                List<Character> planets = new List<Character>();
                Character earth = new Character(earthTex, new Vector2(0.0f, -300.0f), new Vector2(0.0f, 0.0f), 1, this);
                earth.setScale(10.0f);
                planets.Add(earth);
                backgrounds.Add(new KeyValuePair<float, List<Character>>(0.45f, planets));
            }
        }
Example #4
0
        public void addEgg(Vector2 pos)
        {
            Character e;
            if (levelManager.getCurrentLevel() == 0 || levelManager.getCurrentLevel() == 6)
            {
                e = new Character(portalSprite, pos, new Vector2(0.0f, 0.0f), 1, levelManager);
                e.setScale(2.5f);
            }
            else
            {
                e = new Character(eggSprite, pos, new Vector2(0.0f, 0.0f), 1, levelManager);
            }

            eggs.Add(e);
        }