Exemplo n.º 1
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));
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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);
        }