Exemple #1
0
 public void init(string mediaDir, string shaderDir, TgcCamera camara)
 {
     inicio = new Boton("INICIO", 0f, 0.8f, () => AdministradorDeEscenarios.getSingleton().agregarEscenario(new nivelF1(), camara));
     //inicio = new Boton("INICIO", 0f, 0.8f, () => AdministradorDeEscenarios.getSingleton().agregarEscenario(new nivelPDP(), camara));
     sprite  = new Sprite(D3DDevice.Instance.Device);
     trustMe = TgcTexture.createTexture(D3DDevice.Instance.Device, mediaDir + "imgMenu.png");
 }
Exemple #2
0
        private void ChocarConBolasDeCanion()
        {
            foreach (var mesh in scene.Meshes)
            {
                var mainMeshBoundingBox  = personajePrincipal.BoundingBox;
                var sceneMeshBoundingBox = mesh.BoundingBox;

                if (mainMeshBoundingBox == sceneMeshBoundingBox)
                {
                    continue;
                }

                var collisionResult = TgcCollisionUtils.classifyBoxBox(mainMeshBoundingBox, sceneMeshBoundingBox);

                if (collisionResult != TgcCollisionUtils.BoxBoxResult.Afuera)
                {
                    if (mesh.Name == "Sphere")
                    {
                        if (cantVidas < 1)
                        {
                            AdministradorDeEscenarios.getSingleton().agregarEscenario(new GameOver(), camaraInterna);
                        }
                        personajePrincipal.Position = puntoCheckpointActual;
                        cantVidas--;
                    }
                }
            }
        }
Exemple #3
0
        private void CruzarPuertas(TgcMesh mesh)
        {
            if (mesh.Name.Contains("Puerta"))
            {
                if (puertaCruzada == 0)
                {
                    activarTeleport = true;
                    ultimoCP        = puerta1;
                    puertaCruzada++;
                    return;
                }
                if (puertaCruzada == 1 && cantidadColeccionablesAgarrados == 3)
                {
                    activarTeleport = true;
                    puertaCruzada++;
                    return;
                }
                if (puertaCruzada == 2 && cantidadColeccionablesAgarrados == 6)
                {
                    activarTeleport = true;
                    ultimoCP        = new TGCVector3(2715, 1, 2635);
                    puertaCruzada++;
                    return;
                }

                if (puertaCruzada == 3 && cantidadColeccionablesAgarrados == 9)
                {
                    reproductorMp3.closeFile();
                    AdministradorDeEscenarios.getSingleton().agregarEscenario(new Victoria(), camaraInterna);
                }
            }
        }
Exemple #4
0
        public static AdministradorDeEscenarios getSingleton()
        {
            if (singleton == null)
            {
                singleton = new AdministradorDeEscenarios();
            }

            return(singleton);
        }
Exemple #5
0
 private void CaerseAlAgua(TgcMesh mesh, TGCVector3 movementRay)
 {
     if ((mesh.Name.Contains("Agua") && mesh.Name.Contains("Floor")) || mesh.Name == "Subsuelo9-Floor-0")
     {
         if (cantVidas < 1)
         {
             AdministradorDeEscenarios.getSingleton().agregarEscenario(new GameOver(), camaraInterna);
         }
         personajePrincipal.Position = puntoCheckpointActual;
         cantVidas--;
     }
 }
Exemple #6
0
        /// /////////////////////////////////////////////////////////////////////
        /// ////////////////////////////INIT/////////////////////////////////////
        /// /////////////////////////////////////////////////////////////////////

        public void init(string MediaDir, string shaderDir, TgcCamera camara)
        {
            var d3dDevice = D3DDevice.Instance.Device;

            resolucionX = d3dDevice.PresentationParameters.BackBufferWidth;
            resolucionY = d3dDevice.PresentationParameters.BackBufferHeight;

            var loader = new TgcSceneLoader();

            scene           = loader.loadSceneFromFile(MediaDir + "ParadigmasEscena\\nivelParadigmas-TgcScene.xml");
            pathDeLaCancion = MediaDir + "Musica\\FeverTime.mp3";


            var skeletalLoader = new TgcSkeletalLoader();

            personajePrincipal = skeletalLoader.loadMeshAndAnimationsFromFile(
                MediaDir + "Robot\\Robot-TgcSkeletalMesh.xml",
                MediaDir + "Robot\\",
                new[] {
                MediaDir + "Robot\\Caminando-TgcSkeletalAnim.xml",
                MediaDir + "Robot\\Parado-TgcSkeletalAnim.xml",
            });

            personajePrincipal.playAnimation("Parado", true);

            personajePrincipal.Position = new TGCVector3(210, 1, 310);
            personajePrincipal.RotateY(Geometry.DegreeToRadian(180));

            camaraInterna = new TgcThirdPersonCamera(personajePrincipal.Position, 250, 500);
            camaraInterna.rotateY(Geometry.DegreeToRadian(180));

            HUD    = new Sprite(D3DDevice.Instance.Device);
            vida   = TgcTexture.createTexture(MediaDir + "Textures\\vida.png");
            mumuki = TgcTexture.createTexture(MediaDir + "Textures\\iconoMumuki.png");

            coleccionablesAdquiridos = new Boton(cantidadColeccionablesAgarrados.ToString(), 0.9f, 0.88f, null);

            SetearListas();
            AplicarShaders(shaderDir);


            scene.Meshes.Add(charcoEstatic1);
            scene.Meshes.Add(charcoEstatic2);
            scene.Meshes.Add(charcoEstatic3);

            reproductorMp3.FileName = pathDeLaCancion;
            reproductorMp3.play(true);
            AdministradorDeEscenarios.getSingleton().SetCamara(camaraInterna);
        }
Exemple #7
0
 private void verSiSeCompletoNivel(TgcMesh mesh)
 {
     if (mesh.Name.Contains("Box_8"))
     {
         if (cantidadLibrosAdquiridos >= 10)
         {
             reproductorMp3.closeFile();
             AdministradorDeEscenarios.getSingleton().agregarEscenario(new Intermedio(), camaraInterna);
         }
         else
         {
             personajePrincipal.Position = new TGCVector3(652, 13, 9815);
         }
     }
 }
Exemple #8
0
 private void Caer(TgcMesh mesh)
 {
     if (dangerPlaces.Contains(mesh))
     {
         if (vidasRestantes > 1)
         {
             vidasRestantes--;
             personajePrincipal.Position = ultimoCP;
         }
         else
         {
             AdministradorDeEscenarios.getSingleton().agregarEscenario(new GameOver(), camaraInterna);
         }
     }
 }
Exemple #9
0
        public void init(string mediaDir, string shaderDir, TgcCamera camara)
        {
            pathDeLaCancion         = mediaDir + "Musica\\MissionComplete.mp3";
            reproductorMp3.FileName = pathDeLaCancion;
            reproductorMp3.play(true);

            volver  = new Boton("Cursar PdeP", 0f, 0.8f, () => { reproductorMp3.closeFile(); AdministradorDeEscenarios.getSingleton().agregarEscenario(new nivelPDP(), camara); });
            texto   = new Boton("Bien, te hiciste todos los ejercicios habidos y por haber ¿Seguimos?", 0f, 0.7f, null);
            sprite  = new Sprite(D3DDevice.Instance.Device);
            victory = TgcTexture.createTexture(D3DDevice.Instance.Device, mediaDir + "missionPassed.png");
        }
Exemple #10
0
 public void init(string mediaDir, string shaderDir, TgcCamera camara)
 {
     reproductorMp3.closeFile();
     pathDeLaCancion         = mediaDir + "Musica\\gameover.mp3";
     reproductorMp3.FileName = pathDeLaCancion;
     volver   = new Boton("Volver al Menú principal", 0f, 0.8f, () => { reproductorMp3.closeFile(); AdministradorDeEscenarios.getSingleton().agregarEscenario(new Menu(), camara); });
     sprite   = new Sprite(D3DDevice.Instance.Device);
     gameOver = TgcTexture.createTexture(D3DDevice.Instance.Device, mediaDir + "gameover.jpg");
     reproductorMp3.play(true);
 }
Exemple #11
0
        public void init(string mediaDir, string shaderDir, TgcCamera camara)
        {
            pathDeLaCancion         = mediaDir + "Musica\\MissionComplete.mp3";
            reproductorMp3.FileName = pathDeLaCancion;
            reproductorMp3.play(true);

            volver  = new Boton("Volver al Menú principal", 0f, 0.8f, () => { reproductorMp3.closeFile(); AdministradorDeEscenarios.getSingleton().agregarEscenario(new Menu(), camara); });
            texto   = new Boton("Felicidades, aprobaste 2 materias ¿Hasta dónde llegarás?", 0f, 0.7f, null);
            sprite  = new Sprite(D3DDevice.Instance.Device);
            victory = TgcTexture.createTexture(D3DDevice.Instance.Device, mediaDir + "victory.jpg");
        }
Exemple #12
0
        /////////////////////////////////////////////////////////////////////////
        ////////////////////////////////INIT/////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////


        public void init(string MediaDir, string shaderDir, TgcCamera camara)
        {
            var d3dDevice = D3DDevice.Instance.Device;

            resolucionX = d3dDevice.PresentationParameters.BackBufferWidth;
            resolucionY = d3dDevice.PresentationParameters.BackBufferHeight;

            D3DDevice.Instance.ParticlesEnabled = true;
            D3DDevice.Instance.EnableParticles();

            var loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(MediaDir + "NivelFisica1\\EscenaSceneEditorFisica1-TgcScene.xml");

            SetearAguas();

            pathDeLaCancion = MediaDir + "Musica\\FeverTime.mp3";


            meshesDeLaEscena = new List <TgcMesh>();

            HUD       = new Sprite(D3DDevice.Instance.Device);
            vida      = TgcTexture.createTexture(MediaDir + "Textures\\vida.png");
            fisicaLib = TgcTexture.createTexture(MediaDir + "NivelFisica1\\Textures\\TexturaTapaLibro.jpg");

            var skeletalLoader = new TgcSkeletalLoader();

            personajePrincipal =
                skeletalLoader.loadMeshAndAnimationsFromFile(
                    MediaDir + "Robot\\Robot-TgcSkeletalMesh.xml",
                    MediaDir + "Robot\\",
                    new[]
            {
                MediaDir + "Robot\\Caminando-TgcSkeletalAnim.xml",
                MediaDir + "Robot\\Parado-TgcSkeletalAnim.xml",
                MediaDir + "Robot\\Empujar-TgcSkeletalAnim.xml",
            });
            //Configurar animacion inicial
            personajePrincipal.playAnimation("Parado", true);

            personajePrincipal.Position = puntoCheckpointActual;
            personajePrincipal.RotateY(Geometry.DegreeToRadian(180));


            camaraInterna = new TgcThirdPersonCamera(personajePrincipal.Position, 250, 500);
            // camara = camaraInterna;
            camaraInterna.rotateY(Geometry.DegreeToRadian(180));

            librosAdquiridos = new Boton(cantidadLibrosAdquiridos.ToString(), resolucionX - (resolucionX / 9), resolucionY - (resolucionY / 7), null);

            plataforma1 = scene.Meshes[164];
            plataforma2 = scene.Meshes[165];

            plataformasMovibles.Add(plataforma1);
            plataformasMovibles.Add(plataforma2);

            bolaDeCanion1 = scene.Meshes[172];
            bolaDeCanion2 = scene.Meshes[173];
            bolaDeCanion3 = scene.Meshes[174];

            posicionInicialBolaDeCanion1 = scene.Meshes[172].Position;
            posicionInicialBolaDeCanion2 = scene.Meshes[173].Position;
            posicionInicialBolaDeCanion3 = scene.Meshes[174].Position;

            bolasDeCanion.Add(bolaDeCanion1);
            bolasDeCanion.Add(bolaDeCanion2);
            bolasDeCanion.Add(bolaDeCanion3);

            pathTexturaEmisorDeParticulas = MediaDir + "Textures\\fuego.png";
            cantidadDeParticulas          = 10;

            emisorDeParticulas1 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas1.MinSizeParticle    = 30f;
            emisorDeParticulas1.MaxSizeParticle    = 30f;
            emisorDeParticulas1.ParticleTimeToLive = 1f;
            emisorDeParticulas1.CreationFrecuency  = 1f; //0.25
            emisorDeParticulas1.Dispersion         = 500;
            emisorDeParticulas1.Speed          = new TGCVector3(-25, 40, 50);
            posicionInicialEmisorDeParticulas1 = new TGCVector3(1935, 200, 4345);
            emisorDeParticulas1.Position       = posicionInicialEmisorDeParticulas1;

            emisorDeParticulas2 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas2 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas2.MinSizeParticle    = 30f;
            emisorDeParticulas2.MaxSizeParticle    = 30f;
            emisorDeParticulas2.ParticleTimeToLive = 1f;
            emisorDeParticulas2.CreationFrecuency  = 1f;
            emisorDeParticulas2.Dispersion         = 500;
            emisorDeParticulas2.Speed          = new TGCVector3(-25, 40, 50);
            posicionInicialEmisorDeParticulas2 = new TGCVector3(2205, 200, 4345);
            emisorDeParticulas2.Position       = posicionInicialEmisorDeParticulas2;

            emisorDeParticulas3 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas3 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas3.MinSizeParticle    = 30f;
            emisorDeParticulas3.MaxSizeParticle    = 30f;
            emisorDeParticulas3.ParticleTimeToLive = 1f;
            emisorDeParticulas3.CreationFrecuency  = 1f;
            emisorDeParticulas3.Dispersion         = 500;
            emisorDeParticulas3.Speed          = new TGCVector3(-25, 40, 50);
            posicionInicialEmisorDeParticulas3 = new TGCVector3(2495, 200, 4345);
            emisorDeParticulas3.Position       = posicionInicialEmisorDeParticulas3;

            reproductorMp3.FileName = pathDeLaCancion;
            reproductorMp3.play(true);

            AdministradorDeEscenarios.getSingleton().SetCamara(camaraInterna);

            cantVidas = 3;
            effect    = TgcShaders.loadEffect(shaderDir + "MultiDiffuseLights.fx");
            for (var i = 224; i < 250; ++i)
            {
                lights.Add(scene.Meshes[i]);
            }

            scene.Meshes[4].D3dMesh.ComputeNormals();
            scene.Meshes[48].D3dMesh.ComputeNormals();
            var lightColors           = new ColorValue[lights.Count];
            var pointLightPositions   = new Vector4[lights.Count];
            var pointLightIntensity   = new float[lights.Count];
            var pointLightAttenuation = new float[lights.Count];

            for (var i = 0; i < lights.Count; i++)
            {
                var lightMesh = lights[i];

                lightColors[i]           = ColorValue.FromColor(Color.White);
                pointLightPositions[i]   = TGCVector3.Vector3ToVector4(lightMesh.BoundingBox.Position);
                pointLightIntensity[i]   = 20;
                pointLightAttenuation[i] = 0.07f;
            }
            tecnicaNormal = scene.Meshes[0].Technique;
            sinEfectos    = scene.Meshes[0].Effect;
            foreach (var mesh in scene.Meshes)
            {
                //if (mesh.Name.Contains("Box") || mesh.Name.Contains("Madera") || mesh.Name.Contains("East") || mesh.Name.Contains("South") || mesh.Name.Contains("North") || mesh.Name.Contains("West"))
                if (!mesh.Name.Contains("Floor"))
                {
                    continue;
                }
                mesh.Effect = effect;

                mesh.Effect.SetValue("lightColor", lightColors);
                mesh.Effect.SetValue("lightPosition", pointLightPositions);
                mesh.Effect.SetValue("lightIntensity", pointLightIntensity);
                mesh.Effect.SetValue("lightAttenuation", pointLightAttenuation);
                mesh.Effect.SetValue("materialEmissiveColor", ColorValue.FromColor(Color.Black));
                mesh.Effect.SetValue("materialDiffuseColor", ColorValue.FromColor(Color.White));
                mesh.Technique = "MultiDiffuseLightsTechnique";
                if (mesh.Name.Contains("Box") || mesh.Name.Contains("Madera"))
                {
                    mesh.Effect.SetValue("lightAttenuation", pointLightAttenuation);
                    mesh.D3dMesh.ComputeNormals();
                }
            }

            AplicarShaders(shaderDir);
        }