コード例 #1
0
        //+++++++++++++++++++++++         INITIALIZE        +++++++++++++++++
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            rnd = new Random();
            texto = "";

            tiempoMuertoKielTotal = 7000;
            estaEnSuSitio = false;
            kielMuertoSprite = false;
            tiempoMuertoKiel = 0;
            kielMuerto = false;
            tocaRayoKiel = false;
            tiempoTocaRayoKiel = 5000;
            currMouseState = Mouse.GetState();
            lastMouseState = Mouse.GetState();
            fondo = false;
            completoDelTo = false;
            tiempoFin = 0;
            collisionOffSet = Point.Zero;
            cayendo = false;
            tiempoLluvia = 0;
            densidadLluvia2 = 500;
            tiempoLluvia2 = 0;
            colision = 0;
            colisiond = 0;
            colisioni = 0;
            parada = 0;
            alturaTerreno = 4;
            jumpTimer = -10f;
            tiempoVelocidadSalto = 0;
            mundo1 = new Mundo(2.2f);
            currentDisparoState = DisparoState.Quieto;
            currentGravedadState = GravedadState.Aire;
            borrarBala = false;
            filas = 20;
            columnas = 0;
            count = 0;

            spriteList = new List<AutomatedSprite>();
            kiel = new List<JefeFinal>();
            disparoList = new List<Disparo>();
            lluviaList = new List<Disparo>();
            lluviaList2 = new List<Disparo>();
            mapaList = new List<Mapa>();
            terrenoList = new List<Mapa>();
            terrenoList2 = new List<Mapa>();
            terrenoListSuelo = new List<Mapa>();
            fondoList1 = new List<Mapa>();
            fondoList2 = new List<Mapa>();
            map = new List<Point>();
            disparoJefeList = new List<Mapa>();
            jefeList = new List<Jefe>();
            vidaList = new List<Mapa>();
            vidaList2 = new List<Mapa>();
            vidaListKiel = new List<Mapa>();
            vidaList2Kiel = new List<Mapa>();
            tigres = new List<Mapa>();
            maxPosBloque = 0f;
            terrenoTiempoPasado = 0;
            terrenoDireccion = 0;
            terrenoDireccionAnterior = 4;
            terrenoTiempo = 100;
            temblorTerrenoTime = 0;
            temblorTerrenoElec = 0;
            temblorTerrenoNivel = 3;
            arrastre = 0;
            //Lluvia
            densidadLluvia = 500; //milisegundos entre mota
            velocidadLluvia = 6f;
            viento = -2;

            enemySpawnMinMilliseconds = 1000;
            enemySpawnMaxMilliseconds = 2000;
            enemyMinSpeed = 2;
            enemyMaxSpeed = 6;

            nextSpawnTime = 0;

            //Variables jefe
            respawnJefeMin = 0;
            respawnJefeMax = 1;

            //Posiciones
            posicionTerrenoX = 0;
            posicionTerrenoY = 700;
            posicionTerrenoBase = 0;
            posicionFondo1 = -1000;
            posicionFondo2 = -1000;

            //Disparo
            delayDisparo = 200;
            delayDisparoCurrent = 900;
            animaDisparo = 0;
            //Monsturo
            heridoDelayCurrent = 0;
            //Mapa
            cambioMapaDelay = 8000;
            cambioMapaDelayCurrent = 0;
            hastaMapa1 = 8000;
            hastaMapa2 = 15000;
            currentParteMapa = ParteMapa.Suelo;
            numFondo1 = 0;
            numFondo2 = 0;
            numTerreno1 = 0;
            capaTerreno = 0.5f;

            //Muerte
            caido = false;
            puntosControl = new List<float>();
            puntoControl = 0;
            vidaPos = 0;
            vidaPosKiel = 0;
            tiempoHerido = 500f;
            tiempoMuerto = 0;
            muertoDelTo = false;

            for (int n = 0; n < 200; n++)
                map.Add(new Point(2, 0));

            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            audioEngine = new AudioEngine(@"Content\Sonidos\sonidos.xgs");
            waveBank = new WaveBank(audioEngine, @"Content\Sonidos\Wave Bank.xwb");
            soundBank = new SoundBank(audioEngine, @"Content\Sonidos\Sound Bank.xsb");
            waveBank2 = new WaveBank(audioEngine, @"Content\Sonidos\Wave Bank 2.xwb");
            soundBank2 = new SoundBank(audioEngine, @"Content\Sonidos\Sound Bank 2.xsb");
            musicaWave = new WaveBank(audioEngine, @"Content\Sonidos\Wave Music.xwb");
            musicaBank = new SoundBank(audioEngine, @"Content\Sonidos\Music Bank.xsb");
            ambientWave = new WaveBank(audioEngine, @"Content\Sonidos\Wave Ambient.xwb");
            ambientBank = new SoundBank(audioEngine, @"Content\Sonidos\Ambient Bank.xsb");
            musicCategory = audioEngine.GetCategory("Default");
            musicCategory.SetVolume(0);
            //disparoJefeList.Add(new Mapa(
            //                Game.Content.Load<Texture2D>(@"Images/DisparoJefe"),
            //                new Vector2(kiel.getPlayerPosition.X + posxDisparoKiel, kiel.getPlayerPosition.Y),
            //                new Point(0, 0),
            //                new Point(200, 200),
            //                new Point(0, 0),
            //                new Point(4, 1),
            //                new Vector2(0f, 0),
            //                0f,
            //                1000, 0.89f));

            complete = new Mapa(
                Game.Content.Load<Texture2D>(@"Images/LevelComplete"),
                new Vector2(120, 120),
                new Point(1140, 496),
                new Point(0, 0),
                new Point(0, 0),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f);

            vidaList.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(0, 0),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
            vidaPos += 7;
            for (int i = 0; i < 28; i++)
            {
                vidaList.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(1, 0),
                new Point(1, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
                vidaPos += 7;
            }
            vidaList.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(2, 0),
                new Point(2, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
            vidaPos = 0;
            vidaList2.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(0, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
            vidaPos += 7;
            for (int i = 0; i < 28; i++)
            {
                vidaList2.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(1, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
                vidaPos += 7;
            }
            vidaList2.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(2, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
            vidaPos += 7;

            //Vida de kiel

            vidaListKiel.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSpriteKiel"),
                new Vector2(500 + vidaPosKiel, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(0, 0),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
            vidaPosKiel += 7;
            for (int i = 0; i < 98; i++)
            {
                vidaListKiel.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSpriteKiel"),
                new Vector2(500 + vidaPosKiel, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(1, 0),
                new Point(1, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
                vidaPosKiel += 7;
            }
            vidaListKiel.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSpriteKiel"),
                new Vector2(500 + vidaPosKiel, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(2, 0),
                new Point(2, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
            vidaPosKiel = 0;
            vidaList2Kiel.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSpriteKiel"),
                new Vector2(500 + vidaPosKiel, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(0, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
            vidaPosKiel += 7;
            for (int i = 0; i < 98; i++)
            {
                vidaList2Kiel.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSpriteKiel"),
                new Vector2(500 + vidaPosKiel, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(1, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
                vidaPosKiel += 7;
            }
            vidaList2Kiel.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSpriteKiel"),
                new Vector2(500 + vidaPosKiel, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(2, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
            vidaPosKiel += 7;

            player = new UserControlledSprite(
            Game.Content.Load<Texture2D>(@"Images/pj"),
            new Vector2((1366 / 2) - 152, 300),
            new Point(194, 178),
            new Point(collisionOffSet.X, collisionOffSet.Y),
            new Point(0, 0),
            new Point(0, 0),
            new Vector2(0f, 0),
            0f,
            70, 0.80f, 30);

            pointer = new StaticSprite(
            Game.Content.Load<Texture2D>(@"Images/cursor"),
            new Vector2(0, 0),
            new Point(24, 28),
            new Point(5, 5),
            new Point(0, 0),
            new Point(0, 0),
            Vector2.Zero,
            0f,
            1000, 0.9f);

            reproducirMusica("kiel");
            reproducirAmbiente("viento");
            trackCue = soundBank.GetCue("caido");
            trackCue2 = soundBank2.GetCue("bicho1");
            //Suelo(-100, posicionTerrenoY, 0, -600, terrenoList);
            SueloGrande(0, posicionTerrenoY, 0, -100, terrenoList);
            SueloGrande(posicionTerrenoX + 1000, posicionTerrenoY, 0, 0, terrenoList);
            Escaleras(-400 , posicionTerrenoY - 200, 600, 0, 2, terrenoList2, 0.210f, true);

            kiel.Add(new JefeFinal(
            Game.Content.Load<Texture2D>(@"Images/kiel"),
            new Vector2(500, 20),
            new Point(180, 200),
            new Point(80, 30),
            new Point(0, 0),
            new Point(4, 2),
            new Vector2(5, 5),
            0f,
            400, 0.95f, 100));

            final = new Mapa(
            Game.Content.Load<Texture2D>(@"Images/final"),
            new Vector2(posicionTerrenoX + 2000, posicionTerrenoY - 146),
            new Point(171, 156),
            new Point(0, 0),
            new Point(0, 1),
            new Point(4, 3),
            new Vector2(0f, 0),
            0f,
            200, 0.9f);
            posicionTerrenoX = 0;
            posicionTerrenoY = 0;

            //Escaleras(posicionTerrenoX + 600, posicionTerrenoY, 100, 10, 10, terrenoList2, 0.210f, true);
            //SegundoPlano();

            foreach (Sprite s in terrenoList2)
            {
                s.getEscala = 0.8f;
                s.GetCollisionOffSet = new Point(60, 60);
            }

            puntuacionFuente = Game.Content.Load<SpriteFont>(@"Fuentes\fuente");

            player.setTamAura = 300;
            foreach (Sprite s in jefeList)
                s.setTamAura = 400;
        }
コード例 #2
0
        //+++++++++++++++++++++++         INITIALIZE        +++++++++++++++++
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            rnd = new Random();
            texto = "";

            currMouseState = Mouse.GetState();
            lastMouseState = Mouse.GetState();
            fondo = false;
            completoDelTo = false;
            tiempoFin = 0;
            collisionOffSet = Point.Zero;
            tiempoLluvia = 0;
            colisiond = 0;
            colisioni = 0;
            parada = 0;
            alturaTerreno = 4;
            jumpTimer = -10f;
            tiempoVelocidadSalto = 0;
            mundo1 = new Mundo(2.2f);
            currentDisparoState = DisparoState.Quieto;
            currentGravedadState = GravedadState.Aire;
            borrarBala = false;

            spriteList = new List<AutomatedSprite>();
            disparoList = new List<Disparo>();
            lluviaList = new List<Disparo>();
            mapaList = new List<Mapa>();
            terrenoList = new List<Mapa>();
            terrenoList2 = new List<Mapa>();
            terrenoListSuelo = new List<Mapa>();
            fondoList1 = new List<Mapa>();
            fondoList2 = new List<Mapa>();
            map = new List<Point>();
            jefeList = new List<Jefe>();
            vidaList = new List<Mapa>();
            vidaList2 = new List<Mapa>();
            tigres = new List<Mapa>();
            maxPosBloque = 0f;
            terrenoTiempoPasado = 0;
            terrenoDireccion = 0;
            terrenoTiempo = 100;
            arrastre = 0;

            //Variables jefe
            respawnJefeMin = 0;
            respawnJefeMax = 1;

            //Posiciones
            posicionTerrenoX = 0;
            posicionTerrenoY = 700;
            posicionFondo1 = -1000;
            posicionFondo2 = -1000;

            //Disparo
            delayDisparo = 200;
            delayDisparoCurrent = 900;
            currentParteMapa = ParteMapa.Suelo;
            numFondo1 = 0;
            numFondo2 = 0;
            numTerreno1 = 0;
            capaTerreno = 0.5f;

            //Muerte
            caido = false;
            puntosControl = new List<float>();
            puntoControl = 0;
            vidaPos = 0;
            tiempoHerido = 500f;
            tiempoMuerto = 0;
            muertoDelTo = false;

            for (int n = 0; n < 200; n++)
                map.Add(new Point(2, 0));

            complete = new Mapa(
                Game.Content.Load<Texture2D>(@"Images/LevelComplete"),
                new Vector2(120, 120),
                new Point(1140, 496),
                new Point(0, 0),
                new Point(0, 0),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f);

            vidaList.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(0, 0),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
            vidaPos += 7;
            for (int i = 0; i < 28; i++)
            {
                vidaList.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(1, 0),
                new Point(1, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
                vidaPos += 7;
            }
            vidaList.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(2, 0),
                new Point(2, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.89f));
            vidaPos = 0;
            vidaList2.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(0, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
            vidaPos += 7;
            for (int i = 0; i < 28; i++)
            {
                vidaList2.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(1, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
                vidaPos += 7;
            }
            vidaList2.Add(new Mapa(
                Game.Content.Load<Texture2D>(@"Images/vidaSprite"),
                new Vector2(50 + vidaPos, 30),
                new Point(10, 23),
                new Point(0, 0),
                new Point(2, 1),
                new Point(0, 0),
                new Vector2(0f, 0),
                0f,
                1000, 0.99f));
            vidaPos += 7;

            player = new UserControlledSprite(
            Game.Content.Load<Texture2D>(@"Images/pj"),
            new Vector2((1366 / 2) - 152, 164),
            new Point(194, 178),
            new Point(collisionOffSet.X, collisionOffSet.Y),
            new Point(0, 0),
            new Point(0, 0),
            new Vector2(0f, 0),
            0f,
            70, 0.80f, 30);

            pointer = new StaticSprite(
            Game.Content.Load<Texture2D>(@"Images/cursor"),
            new Vector2(0, 0),
            new Point(24, 28),
            new Point(5, 5),
            new Point(0, 0),
            new Point(0, 0),
            Vector2.Zero,
            0f,
            1000, 0.9f);

            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            audioEngine = new AudioEngine(@"Content\Sonidos\sonidos.xgs");
            waveBank = new WaveBank(audioEngine, @"Content\Sonidos\Wave Bank.xwb");
            soundBank = new SoundBank(audioEngine, @"Content\Sonidos\Sound Bank.xsb");
            waveBank2 = new WaveBank(audioEngine, @"Content\Sonidos\Wave Bank 2.xwb");
            soundBank2 = new SoundBank(audioEngine, @"Content\Sonidos\Sound Bank 2.xsb");
            musicaWave = new WaveBank(audioEngine, @"Content\Sonidos\Wave Music.xwb");
            musicaBank = new SoundBank(audioEngine, @"Content\Sonidos\Music Bank.xsb");
            ambientWave = new WaveBank(audioEngine, @"Content\Sonidos\Wave Ambient.xwb");
            ambientBank = new SoundBank(audioEngine, @"Content\Sonidos\Ambient Bank.xsb");
            musicCategory = audioEngine.GetCategory("Default");
            musicCategory.SetVolume(0);
            reproducirMusica("ingame");
            reproducirAmbiente("viento");
            trackCue = soundBank.GetCue("caido");

            Suelo(-100, posicionTerrenoY, 0, -600, terrenoList, 0.540f);
            SueloGrande(0, posicionTerrenoY, 0, 400, terrenoList, 0.530f);
            PuntoControlTigre(1366 / 2 - 15, posicionTerrenoY);
            puntosControl.Add(-(1366 / 2 - 15));
            Suelo(posicionTerrenoX, posicionTerrenoY, 860, -120, terrenoList, 0.541f);
            texto = "Posicion escaleras X" + posicionTerrenoX + "Posicion escaleras Y" + posicionTerrenoY;
            Escaleras2(posicionTerrenoX-1000, posicionTerrenoY - 200, 500, 0, 9, terrenoList2, 0.300f, true);

            Suelo(posicionTerrenoX, posicionTerrenoY+300, 4500, -120, terrenoList, 0.542f);
            PuntoControlTigre(posicionTerrenoX + 350, posicionTerrenoY - tigres[0].getFrameSize.Y + 30);
            puntosControl.Add(-posicionTerrenoX + 350);
            Suelo(posicionTerrenoX, posicionTerrenoY+300, 1000, -120, terrenoList, 0.542f);

            PuntoControlTigre(posicionTerrenoX + 350, posicionTerrenoY - tigres[0].getFrameSize.Y + 30);
            puntosControl.Add(-posicionTerrenoX + 350);
            SueloChico(posicionTerrenoX, posicionTerrenoY, 800, -50, 0, terrenoList, 0.543f);
            SueloChico(posicionTerrenoX, posicionTerrenoY, 250, -50, 4, terrenoList, 0.543f);
            SueloChico(posicionTerrenoX, posicionTerrenoY, 250, -50, 3, terrenoList, 0.543f);
            SueloChico(posicionTerrenoX, posicionTerrenoY, 250, -50, 3, terrenoList, 0.543f);
            Suelo(posicionTerrenoX + 700, posicionTerrenoY + 100, 0, 0, terrenoList, 0.543f);
            Escaleras(posicionTerrenoX +700, posicionTerrenoY + 200, 100, 50, 9, terrenoList, 0.543f, true);
            Suelo(posicionTerrenoX + 700, posicionTerrenoY + 200, 0, 0, terrenoList, 0.543f);
            SueloChico(posicionTerrenoX, posicionTerrenoY - 50, 700, 0, 6, terrenoList, 0.543f);
            Suelo(posicionTerrenoX + 200, posicionTerrenoY +50, 0, 0, terrenoList, 0.543f);
            SueloChico(posicionTerrenoX, posicionTerrenoY - 50, 700, 0, 6, terrenoList, 0.543f);
            Suelo(posicionTerrenoX + 200, posicionTerrenoY + 50, 0, 0, terrenoList, 0.543f);
            SueloChico(posicionTerrenoX, posicionTerrenoY - 50, 700, 0, 6, terrenoList, 0.543f);
            Suelo(posicionTerrenoX + 200, posicionTerrenoY + 50, 0, 0, terrenoList, 0.543f);
            Escaleras(posicionTerrenoX + 2800, posicionTerrenoY, 100, 10, 20, terrenoList, 0.543f, false);

            final = new Mapa(
            Game.Content.Load<Texture2D>(@"Images/final"),
            new Vector2(posicionTerrenoX + 200, posicionTerrenoY - 146),
            new Point(171, 156),
            new Point(0, 0),
            new Point(0, 1),
            new Point(4, 3),
            new Vector2(0f, 0),
            0f,
            200, 0.9f);
            posicionTerrenoX = 0;
            posicionTerrenoY = 0;

            Suelo(posicionTerrenoX+6500, posicionTerrenoY+300, 0, 0, terrenoList2, 0.302f);
            Escaleras(posicionTerrenoX + 3000, posicionTerrenoY + 200, 100, 30, 15, terrenoList2, 0.302f, true);
            foreach (Sprite s in terrenoList2)
            {
                s.getEscala = 0.8f;
                s.GetCollisionOffSet = new Point(60, 60);
            }

            puntuacionFuente = Game.Content.Load<SpriteFont>(@"Fuentes\fuente");

            player.setTamAura = 300;
            foreach (Sprite s in jefeList)
                s.setTamAura = 400;

            //base.Initialize();
        }