Example #1
0
        private void crearSonido()
        {
            //Instanciar sonido del ambiente Oceano
            sonidoAmbienteOceano = new TgcStaticSound();
            string sonidoPath = Utiles.getDirSonido("Oceano.wav");

            sonidoAmbienteOceano.loadSound(sonidoPath);
        }
Example #2
0
 public static void trueno()
 {
     if (Utiles.iAleatorio() % 2 == 0)
     {
         sonidoTrueno1.play();
     }
     else
     {
         sonidoTrueno2.play();
     }
 }
Example #3
0
        private Enemigo crearBarcoEnemigo(TgcSceneLoader loader, int index)
        {
            float   x0, z0;
            Enemigo pirata;

            sceneCanoa = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir
                                                  + "MeshCreator\\Meshes\\Vehiculos\\Canoa\\Canoa-TgcScene.xml");

            x0 = (Utiles.fAleatorio(100f, 2000f) * index) * Utiles.signoAleatorio();
            z0 = (Utiles.fAleatorio(100f, 2000f) * index) * Utiles.signoAleatorio();

            if (x0 > (LIMITEX_SBOX / 2))
            {
                x0 = (LIMITEX_SBOX / 2);
            }

            if (x0 < -(LIMITEX_SBOX / 2))
            {
                x0 = -(LIMITEX_SBOX / 2);
            }

            if (z0 > (LIMITEZ_SBOX / 2))
            {
                z0 = (LIMITEZ_SBOX / 2);
            }

            if (z0 < -(LIMITEZ_SBOX / 2))
            {
                z0 = -(LIMITEZ_SBOX / 2);
            }

            sceneCanoa.Meshes[0].Position = new Vector3(x0, barcoUser.getPosition().Y, z0);
            sceneCanoa.Meshes[0].Scale    = new Vector3(0.5f, 0.5f, 0.5f);

            //idEnemigos.Add(crearIDGraficoEnemigos(loader, sceneCanoa.Meshes[0].Position));
            pirata = new Enemigo();
            pirata.setBarco(sceneCanoa.Meshes[0]);
            pirata.setIDBarco(crearIDGraficoEnemigos(loader, sceneCanoa.Meshes[0].Position));

            return(pirata);// sceneCanoa.Meshes[0];
        }
Example #4
0
        public Escenario(Barco barco)
        {
            {
                d3dDevice = GuiController.Instance.D3dDevice;

                //Asignar barco del usuario
                barcoUser = barco;

                crearSkyBoxNoche();
                crearTerreno();
                crearSonido();
                cargarMeshes();
                cargarShader();
                cargarShadowMap();
                Camara.initialize();
                cargarPreview();
                Lluvia.cargar(barcoUser.getPosition());
                ContadorEnemigos.cargar();
                animatedSprite = Utiles.crearExplosion();
                crearQuadtree();
            }
        }
Example #5
0
        /// <summary>
        /// Crear un emisor de particulas
        /// </summary>
        /// <param name="texturePath">textura a utilizar</param>
        /// <param name="particlesCount">cantidad maxima de particlas a generar</param>
        public ParticleEmitter(string texturePath, int particlesCount)
        {
            Device device = GuiController.Instance.D3dDevice;

            //valores default
            enabled            = true;
            playing            = true;
            random             = new Random(0);
            creationFrecuency  = 1.0f;
            particleTimeToLive = 5.0f;
            minSizeParticle    = 0.25f;
            maxSizeParticle    = 0.5f;
            dispersion         = 100;
            speed = new Vector3(1, 1, 1) * Utiles.fAleatorio(1, 10);
            particleVertexArray = new Particle.ParticleVertex[1];
            vertexDeclaration   = new VertexDeclaration(device, Particle.ParticleVertexElements);
            position            = new Vector3(0, 0, 0);

            this.particlesCount = particlesCount;
            this.particles      = new Particle[particlesCount];

            this.particlesAlive = new ColaDeParticulas(particlesCount);
            this.particlesDead  = new Stack <Particle>(particlesCount);

            //Creo todas las particulas. Inicialmente estan todas muertas.
            for (int i = 0; i < particlesCount; i++)
            {
                this.particles[i] = new Particle();
                this.particlesDead.Push(this.particles[i]);
            }

            //Cargo la textura que tendra cada particula
            this.texture = TgcTexture.createTexture(device, texturePath);

            Distancia = 1.0f;
        }
Example #6
0
        public void render()
        {
            device = GuiController.Instance.D3dDevice;

            verificarConfiguracion();

            Camara.update(barcoUser.getPosition());

            Control panel3d = GuiController.Instance.Panel3d;

            aspectRatio = (float)panel3d.Width / (float)panel3d.Height;
            time       += GuiController.Instance.ElapsedTime;

            if (timer_preview > 0)
            {
                timer_preview -= GuiController.Instance.ElapsedTime;
                if (timer_preview < 0)
                {
                    timer_preview = 0;
                }
            }

            //animarBarcosEnemigos();
            animarPosicionSol();

            /*if (timer_preview > 0)
             * {
             *  float an = -time * Geometry.DegreeToRadian(10.0f);
             *  lookFrom.X = 1500f * (float)Math.Sin(an);
             *  lookFrom.Z = 1500f * (float)Math.Cos(an);
             * }*/

            // --------------------------------------------------------------------
            device.EndScene();
            if (g_pCubeMapAgua == null)
            {
                // solo la primera vez crea el env map del agua
                crearEnvMapAgua();
            }

            // Parametros para el movimiento del oceano

            /*desplazamiento += GuiController.Instance.ElapsedTime;
             * piso.Effect.SetValue("desplazamiento", desplazamiento);
             * piso.Effect.SetValue("maxHeightSuperficial", (float)GuiController.Instance.Modifiers.getValue("maxHeightSuperficial"));
             * piso.Effect.SetValue("amplitud", (float)GuiController.Instance.Modifiers.getValue("amplitud"));
             * piso.Effect.SetValue("frecuencia", (float)GuiController.Instance.Modifiers.getValue("frecuencia"));
             * piso.Effect.SetValue("smallvalue", 1);*/

            // Matrices de transformacion para pasar de world a clip space

            /*piso.Effect.SetValue("world", GuiController.Instance.D3dDevice.Transform.World);
             * piso.Effect.SetValue("view", GuiController.Instance.D3dDevice.Transform.View);
             * piso.Effect.SetValue("proj", GuiController.Instance.D3dDevice.Transform.Projection);*/

            // Dimensiones del Oceano

            /*piso.Effect.SetValue("radio", RADIO);
             * piso.Effect.SetValue("largo", LARGO);
             * piso.Effect.SetValue("dev", DISTANCIA_ENTRE_VERTICES);*/

            // Creo el env map del barco principal
            crearEnvMapShip();
            //Genero el shadow map
            renderShadowMap();
            // Restauro el estado de las transformaciones
            loadEstadoTransformaciones();
            // dibujo la escena pp dicha:
            device.BeginScene();
            dibujarVista();
            g_pCubeMap.Dispose();

            Lluvia.render();

            //renderModelos();
            if ((bool)Parametros.getModificador("boundingBox"))
            {
                barcoUser.getBarco().BoundingBox.setRenderColor(Color.Red);
                barcoUser.getBarco().BoundingBox.render();
                foreach (Enemigo elemento in enemigos)
                {
                    elemento.getBarco().BoundingBox.setRenderColor(Color.Red);
                    elemento.getBarco().BoundingBox.render();
                }
            }

            ContadorEnemigos.render(barcoUser.calcularColisiones(enemigos));
            foreach (Enemigo elemento in enemigos)
            {
                if (elemento.getColision())
                {
                    Utiles.renderExplosion(animatedSprite, elemento.getBarco().Position);
                    quadtree.removeMesh(elemento.getBarco());
                    quadtree.removeMesh(elemento.getIDBarco());
                }
            }

            enemigos.RemoveAll(pirata => pirata.getColision() == true);
        }
Example #7
0
 public void cargarSonido()
 {
     sonido = new TgcStaticSound();
     string sndPath = Utiles.getDirSonido("canonazo.wav");
     //sonido.loadSound(sndPath);
 }