Esempio n. 1
0
        public void renderSinEmpezar(EjemploAlumno juego)
        {
            render(juego);
            textoComplementario.render();

            jugar(juego);
        }
Esempio n. 2
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Ver si cambio el WAV
            string filePath = (string)GuiController.Instance.Modifiers["WAV-File"];

            loadSound(filePath);


            //Contro el input de teclado
            if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Y))
            {
                bool playLoop = (bool)GuiController.Instance.Modifiers["PlayLoop"];
                sound.play(playLoop);
            }
            else if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.O))
            {
                sound.stop();
            }


            //Render texto
            currentSoundText.render();
            instruccionesText.render();
        }
Esempio n. 3
0
        public override void Render()
        {
            //BackgroundColor
            D3DDevice.Instance.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            D3DDevice.Instance.Device.BeginScene();
            ClearTextures();

            //Cargar variables shader
            mesh.Effect.SetValue("ambientColor", ColorValue.FromColor(Color.Gray));
            mesh.Effect.SetValue("diffuseColor", ColorValue.FromColor(Color.LightBlue));
            mesh.Effect.SetValue("specularColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("specularExp", 10f);
            mesh.Effect.SetValue("lightPosition", lightPos);
            mesh.Effect.SetValue("eyePosition",
                                 TgcParserUtils.vector3ToFloat4Array(Camara.Position));

            mesh.rotateY(-ElapsedTime / 2);
            mesh.render();

            textHelp.render();

            //Help
            if (TgcD3dInput.Instance.keyPressed(Key.H))
            {
                helpForm.ShowDialog();
            }

            PostRender();
        }
Esempio n. 4
0
 public void render()
 {
     GuiController.Instance.Drawer2D.beginDrawSprite();
     nombre.render();
     sprite.render();
     GuiController.Instance.Drawer2D.endDrawSprite();
 }
Esempio n. 5
0
        public override void Render()
        {
            PreRender();

            //Ver si cambio el WAV
            var filePath = (string)Modifiers["WAV-File"];

            loadSound(filePath);

            //Contro el input de teclado
            if (TgcD3dInput.Instance.keyPressed(Key.Y))
            {
                var playLoop = (bool)Modifiers["PlayLoop"];
                sound.play(playLoop);
            }
            else if (TgcD3dInput.Instance.keyPressed(Key.O))
            {
                sound.stop();
            }

            //Render texto
            currentSoundText.render();
            instruccionesText.render();

            PostRender();
        }
        public void Render(float elapsedTime)
        {
            //Iniciar dibujado de todos los Sprites de la escena (en este caso es solo uno)
            GuiController.Instance.Drawer2D.beginDrawSprite();

            healthSprite.render();
            HudFront.render();
            scoreSprite.render();
            hudWeapon.render();
            if (reachedHighScore)
            {
                highScoreSprite.render();
            }

            cross.render();


            //Finalizar el dibujado de Sprites
            GuiController.Instance.Drawer2D.endDrawSprite();

            // TODO, cuando el refresh funque

            renderMinimap();


            scoreText.render();
            captureText.render();
            if (TEXT_DELAY > 0)
            {
                int alphaLerp = (int)(TEXT_DELAY * 255 / TEXT_DELAY_MAX);
                specialKillText.Color = Color.FromArgb(alphaLerp, specialKillText.Color);
                specialKillText.render();
            }
        }
Esempio n. 7
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Ver si cambio el MP3
            string filePath = (string)GuiController.Instance.Modifiers["MP3-File"];

            loadMp3(filePath);


            //Contro del reproductor por teclado
            TgcMp3Player player = GuiController.Instance.Mp3Player;

            TgcMp3Player.States currentState = player.getStatus();
            if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Y))
            {
                if (currentState == TgcMp3Player.States.Open)
                {
                    //Reproducir MP3
                    player.play(true);
                }
                if (currentState == TgcMp3Player.States.Stopped)
                {
                    //Parar y reproducir MP3
                    player.closeFile();
                    player.play(true);
                }
            }
            else if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.U))
            {
                if (currentState == TgcMp3Player.States.Playing)
                {
                    //Pausar el MP3
                    player.pause();
                }
            }
            else if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.I))
            {
                if (currentState == TgcMp3Player.States.Paused)
                {
                    //Resumir la ejecución del MP3
                    player.resume();
                }
            }
            else if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.O))
            {
                if (currentState == TgcMp3Player.States.Playing)
                {
                    //Parar el MP3
                    player.stop();
                }
            }


            //Render texto
            currentMusicText.render();
            instruccionesText.render();
        }
Esempio n. 8
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Renderizar los tres textoss
            text1.render();
            text2.render();
            text3.render();
        }
 internal override void Render(float elapsedTime)
 {
     base.Render(elapsedTime);
     integrante1.render();
     integrante2.render();
     integrante3.render();
     integrante4.render();
     grupo.render();
 }
Esempio n. 10
0
        public void render()
        {
            meshCanion.render();

            if (elevacion_visible)
            {
                texto_elevacion.render();
            }
        }
Esempio n. 11
0
 private void renderFloatingVegetation()
 {
     if (Mesh != null)
     {
         Mesh.render();
         Mesh.BoundingBox.render();
         label.render();
     }
 }
Esempio n. 12
0
        public override void Render()
        {
            PreRender();

            //Ver si cambio el MP3
            var filePath = (string)Modifiers["MP3-File"];

            loadMp3(filePath);

            //Contro del reproductor por teclado
            var currentState = mp3Player.getStatus();

            if (TgcD3dInput.Instance.keyPressed(Key.Y))
            {
                if (currentState == TgcMp3Player.States.Open)
                {
                    //Reproducir MP3
                    mp3Player.play(true);
                }
                if (currentState == TgcMp3Player.States.Stopped)
                {
                    //Parar y reproducir MP3
                    mp3Player.closeFile();
                    mp3Player.play(true);
                }
            }
            else if (TgcD3dInput.Instance.keyPressed(Key.U))
            {
                if (currentState == TgcMp3Player.States.Playing)
                {
                    //Pausar el MP3
                    mp3Player.pause();
                }
            }
            else if (TgcD3dInput.Instance.keyPressed(Key.I))
            {
                if (currentState == TgcMp3Player.States.Paused)
                {
                    //Resumir la ejecución del MP3
                    mp3Player.resume();
                }
            }
            else if (TgcD3dInput.Instance.keyPressed(Key.O))
            {
                if (currentState == TgcMp3Player.States.Playing)
                {
                    //Parar el MP3
                    mp3Player.stop();
                }
            }

            //Render texto
            currentMusicText.render();
            instruccionesText.render();

            PostRender();
        }
Esempio n. 13
0
        public void render(EjemploAlumno juego)
        {
            GuiController.Instance.Drawer2D.beginDrawSprite();
            fondo.render();

            GuiController.Instance.Drawer2D.endDrawSprite();

            sombra.render();
            titulo.render();
        }
Esempio n. 14
0
        public override void Render()
        {
            PreRender();

            //Renderizar los tres textoss
            text1.render();
            text2.render();
            text3.render();

            PostRender();
        }
Esempio n. 15
0
        /// <summary>
        /// Método que se llama cada vez que hay que refrescar la pantalla.
        /// Escribir aquí todo el código referido al renderizado.
        /// </summary>
        /// <param name="elapsedTime">Tiempo en segundos transcurridos desde el último frame</param>
        public override void render(float elapsedTime)
        {
            if (!this.explosion.finalizada())
            {
                this.camara.Target = this.personaje.getPersonaje().Position;
                this.escenario.render(elapsedTime, this.camara);

                if (this.personaje.alive())
                {
                    this.personaje.render(elapsedTime);
                    lifeText.Text = "+" + Convert.ToString(this.personaje.getLife());
                    if (this.personaje.getLife() < 30)
                    {
                        lifeText.Color = Color.Red;
                    }
                    lifeText.render();
                }
                else
                {
                    this.personaje.renderDeading();
                }

                this.explosion.render(elapsedTime);
                this.patrulla.render(elapsedTime, this.personaje, this.llegada, this.explosion);
                this.quadtree.render(GuiController.Instance.Frustum, this.personaje, false);
                int distance = getDistanceToTarget();
                this.personaje.canExplode = false;
                if (distance < MIN_DISTANCE_TO_EXPLODE)
                {
                    onTargetPosition.render();
                    this.personaje.canExplode = true;
                }
                distanceTargetText.Text = "Distancia a objetivo: " + Convert.ToString(distance);
                distanceTargetText.render();

                if (GuiController.Instance.D3dInput.keyDown(Microsoft.DirectX.DirectInput.Key.L))
                {
                    if (showingCursor)
                    {
                        System.Windows.Forms.Cursor.Hide();
                    }
                    else
                    {
                        System.Windows.Forms.Cursor.Show();
                    }
                    showingCursor = !showingCursor;
                }
            }
            else
            {
                this.fin.render();
            }
        }
Esempio n. 16
0
            public static void Render()
            {
                // animacion de la moneda que gira en el marcador
                GuiController.Instance.Drawer2D.beginDrawSprite();
                AnimatedSprite.updateAndRender();
                GuiController.Instance.Drawer2D.endDrawSprite();

                // texto que indica la cantidad de monedas juntadas
                SpriteDrawer.BeginDrawSprite();
                Puntos2d.Text = Puntos.ToString();
                Puntos2d.render();
                SpriteDrawer.EndDrawSprite();
            }
Esempio n. 17
0
 public void render()
 {
     text2.render();
     this.moverPuerta();
     puerta1.renderAll();
     cobertura1.renderAll();
     cobertura3.renderAll();
     cobertura2.renderAll();
     meshP.BoundingBox.transform(meshP.Transform);
     meshC1.BoundingBox.transform(meshC1.Transform);
     meshC2.BoundingBox.transform(meshC2.Transform);
     meshC3.BoundingBox.transform(meshC3.Transform);
 }
Esempio n. 18
0
        private void renderHUD()
        {
            tvidas.Text = "VIDAS = " + this.vidas.ToString();
            tvidas.render();

            if (ammo > -1)
            {
                tammo.Text = "AMMO = " + this.ammo.ToString();
            }
            else
            {
                tammo.Text = "AMMO = INF";
            }
            //tammo.render();

            tpuntos.Text = "PUNTOS: " + (this.puntos * 100).ToString();
            tpuntos.render();
        }
Esempio n. 19
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.V))
            {
                ShowVegetation ^= true;
            }

            if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.P))
            {
                PlanePicking ^= true;
            }

            if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.F))
            {
                FpsModeEnable ^= true;
            }

            if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.B))
            {
                RenderBoundingBoxes ^= true;
            }

            if (FpsModeEnable)
            {
                labelFPS.render();
            }

            if (!ShowVegetation)
            {
                labelVegetationHidden.render();
            }

            Terrain.Technique = "PositionColoredTextured";

            Brush.update(this);

            Brush.render(this);
        }
Esempio n. 20
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar variables shader
            mesh.Effect.SetValue("ambientColor", ColorValue.FromColor(Color.Gray));
            mesh.Effect.SetValue("diffuseColor", ColorValue.FromColor(Color.LightBlue));
            mesh.Effect.SetValue("specularColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("specularExp", 10f);
            mesh.Effect.SetValue("lightPosition", lightPos);
            mesh.Effect.SetValue("eyePosition", TgcParserUtils.vector3ToFloat4Array(GuiController.Instance.FpsCamera.getPosition()));


            mesh.rotateY(-elapsedTime / 2);
            mesh.render();

            textHelp.render();

            //Help
            if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.H))
            {
                helpForm.ShowDialog(GuiController.Instance.MainForm);
            }
        }
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            cajaporon.render();
            if (aciertos == 28)
            {
                finalText1.Text = "!!!!GANASTE¡¡¡¡¡, Total fracasos 70, tus fracasos" + fracazos.ToString();
                finalText.render();
                finalText1.render();
                tiempoTranscurrido.Text = (timeDif - time).Minutes.ToString() + ":" + (timeDif - time).Seconds.ToString();
                tiempoTranscurrido.render();
                return;
            }
            if (fracazos == 70)
            {
                finalText1.Text = "!!!!PERDISTE¡¡¡¡¡, Total fracazos 70, tus fracasos" + fracazos.ToString();
                finalText.render();
                finalText1.render();
                tiempoTranscurrido.Text = (timeDif - time).Minutes.ToString() + ":" + (timeDif - time).Seconds.ToString();
                tiempoTranscurrido.render();

                return;
            }
            timeDif = DateTime.Now;
            puntuacionFracazosText.Text = fracazos.ToString();
            puntuacionAciertosText.Text = aciertos.ToString();
            puntuacionFracazosText.render();
            puntuacionAciertosText.render();

            aciertosText.render();
            fracazosText.render();

            //Obtiene la caja collisionada de las posibles tomo la que tiene menor distancia a la camara
            if (GuiController.Instance.D3dInput.buttonPressed(TgcViewer.Utils.Input.TgcD3dInput.MouseButtons.BUTTON_LEFT) && (countDeseleccion > 0 || countDeseleccionExito > 0))
            {
                if (countDeseleccion > 0)
                {
                    selectedMeshAnt.getBox_caja1().Enabled = true;
                    selectedMeshAnt.Enabled = true;
                    selectedMeshAnt.deseleccionar(d3dDevice);
                    selectedMesh.deseleccionar(d3dDevice);
                    selectedMeshAnt  = null;
                    countDeseleccion = 0;
                }
                if (countDeseleccionExito > 0)
                {
                    selectedMesh.getBox_caja1().Enabled = false;
                    selectedMesh.Enabled  = false;
                    countDeseleccionExito = 0;
                }
            }
            this.obtenerCajaCollisionada();


            if ((((DateTime.Now.Minute * 100000) + (DateTime.Now.Second * 1000) + DateTime.Now.Millisecond) - tiempoUltimaLlamada) > 3)
            {
                foreach (BoundingBoxExtendida box in boxes)
                {
                    box.getBox_caja1().relizarefecto(d3dDevice);
                    box.getBox_caja1().updateValues();
                    box.relizarefecto(d3dDevice);
                    box.updateValues();
                }
                tiempoUltimaLlamada = ((DateTime.Now.Minute * 100000) + (DateTime.Now.Second * 1000) + DateTime.Now.Millisecond);
            }

            foreach (BoundingBoxExtendida box in boxes)
            {
                box.getboxinterna().render();
                box.getBox_caja1().render();
                box.render();
            }

            if (GuiController.Instance.D3dInput.buttonPressed(TgcViewer.Utils.Input.TgcD3dInput.MouseButtons.BUTTON_LEFT))
            {
                if (selected)                                //Indica que se realizo alguna seleccion
                {
                    if (!selectedMesh.getSeleccionado())     //Si la caja seleccionada ya se encuentra descubierta
                    {
                        selectedMesh.seleccionar(d3dDevice); //realiza el efecto sobre la caja selecionada

                        if (selectedMeshAnt == null)         //Al ser el primero a seleccionar queda marcado
                        {
                            selectedMeshAnt = selectedMesh;
                            selectedMesh.setSeleccionado(true);
                        }
                        else
                        {
                            //Seria el caso en que no es el primero y se quiere seleccionar el proximo, pueden pasar tres cosas:
                            //que el que se selecciono sea el mismo cuadrado que el anterior
                            //que el nuevo seleccionado no teng la misma figura que el primero
                            //que el nuevo seleccionado conincida la figura con el primero.
                            selectedMeshAnt.getBox_caja1().Enabled = false;
                            selectedMeshAnt.Enabled = false;
                            if (selectedMesh.getName().Equals(selectedMeshAnt.getName()))
                            {
                                aciertos++;
                                animatedSprite.restart();
                                selectedMesh.setSeleccionado(true);
                                countDeseleccionExito = 200;
                                selectedMeshAnt       = null;
                            }
                            else
                            {
                                fracazos++;
                                countDeseleccion = 200;
                                animatedSpriteTriste.restart();
                                selectedMeshAnt.setSeleccionado(false);
                                selectedMesh.setSeleccionado(false);
                            }
                        }
                    }
                }
            }
            if (countDeseleccion > 0)
            {
                if (countDeseleccion == 1)
                {
                    selectedMeshAnt.getBox_caja1().Enabled = true;
                    selectedMeshAnt.Enabled = true;
                    selectedMeshAnt.deseleccionar(d3dDevice);
                    selectedMesh.deseleccionar(d3dDevice);
                    selectedMeshAnt = null;
                }
                countDeseleccion--;
                //Iniciar dibujado de todos los Sprites de la escena (en este caso es solo uno)
                GuiController.Instance.Drawer2D.beginDrawSprite();
                //Dibujar sprite (si hubiese mas, deberian ir todos aquí)
                // animatedSpriteTriste.mover(countDeseleccion);
                //Actualizamos el estado de la animacion y renderizamos
                animatedSpriteTriste.updateAndRender();

                //Finalizar el dibujado de Sprites
                GuiController.Instance.Drawer2D.endDrawSprite();
            }
            if (countDeseleccionExito > 0)
            {
                if (countDeseleccionExito == 1)
                {
                    selectedMesh.getBox_caja1().Enabled = false;
                    selectedMesh.Enabled = false;
                }

                countDeseleccionExito--;
                //Iniciar dibujado de todos los Sprites de la escena (en este caso es solo uno)
                GuiController.Instance.Drawer2D.beginDrawSprite();
                //Dibujar sprite (si hubiese mas, deberian ir todos aquí)
                //animatedSprite.mover(countDeseleccionExito);
                //Actualizamos el estado de la animacion y renderizamos
                animatedSprite.updateAndRender();

                //Finalizar el dibujado de Sprites
                GuiController.Instance.Drawer2D.endDrawSprite();
            }
        }
Esempio n. 22
0
        public void render(float elapsedTime)
        {
            TgcD3dInput d3dInput = GuiController.Instance.D3dInput;
            //Calcular proxima posicion de personaje segun Input
            float     moveForward     = 0f;
            float     moveSide        = 0f;
            float     rotateY         = 0;
            float     rotateX         = 0;
            float     jump            = 0;
            bool      moving          = false;
            bool      rotating        = false;
            bool      rotatingY       = false;
            bool      rotatingX       = false;
            bool      running         = false;
            bool      jumping         = false;
            string    animationAction = "StandBy";
            TgcSprite mira;

            //Crear Sprite de mira
            mira         = new TgcSprite();
            mira.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "\\Kamikaze3D\\mira.png");

            //Ubicarlo centrado en la pantalla
            Size screenSize  = GuiController.Instance.Panel3d.Size;
            Size textureSize = mira.Texture.Size;

            mira.Position = new Vector2(screenSize.Width / 2 - textureSize.Width / 2, screenSize.Height / 2 - textureSize.Height / 2);

            TgcText2d hitCantTextY = new TgcText2d();

            hitCantTextY.Position = new Point(0, 0);
            hitCantTextY.Color    = Color.White;

            TgcText2d hitCantTextX = new TgcText2d();

            hitCantTextX.Position = new Point(0, 20);
            hitCantTextX.Color    = Color.White;

            //obtener velocidades de Modifiers (no deberia estar porque es fijo)
            float velocidadCaminar = (float)GuiController.Instance.Modifiers.getValue("VelocidadCaminar");
            //float velocidadMoveSide = (float)GuiController.Instance.Modifiers.getValue("velocidadMoveSide");
            float velocidadRotacion = (float)GuiController.Instance.Modifiers.getValue("VelocidadRotacion");
            //Obtener boolean para saber si hay que mostrar Bounding Box (tampoco deberia estar)
            bool showBB = (bool)GuiController.Instance.Modifiers.getValue("showBoundingBox");

            //Adelante
            if (d3dInput.keyDown(Key.W))
            {
                moveForward = -velocidadCaminar;
                moving      = true;
            }

            //Atras
            if (d3dInput.keyDown(Key.S))
            {
                moveForward = velocidadCaminar;
                moving      = true;
            }

            //Derecha
            if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && d3dInput.XposRelative > 0)
            {
                if (camara.RotationY < (Math.PI))
                {
                    rotateY   = velocidadRotacion;
                    rotating  = true;
                    rotatingY = true;
                }
            }

            //Mover Derecha
            if (d3dInput.keyDown(Key.D))
            {
                moveSide = -velocidadCaminar;
                moving   = true;
            }

            //Izquierda
            if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && d3dInput.XposRelative < 0)
            {
                if (camara.RotationY > -(Math.PI))
                {
                    rotateY   = -velocidadRotacion;
                    rotating  = true;
                    rotatingY = true;
                }
            }

            //Mover Izquierda
            if (d3dInput.keyDown(Key.A))
            {
                moveSide = velocidadCaminar;
                moving   = true;
            }

            //Arriba
            if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && d3dInput.YposRelative < 0)
            {
                if (camara.RotationX > -(Math.PI / 3))
                {
                    rotateX   = -velocidadRotacion;
                    rotating  = true;
                    rotatingX = true;
                }
            }

            //Abajo
            if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && d3dInput.YposRelative > 0)
            {
                if (camara.RotationX < (Math.PI / 3))
                {
                    rotateX   = velocidadRotacion;
                    rotating  = true;
                    rotatingX = true;
                }
            }

            //Jump

            /* if (d3dInput.keyDown(Key.Space))
             * {
             *   jump = 30;
             *   moving = true;
             * }*/

            //Run
            if (d3dInput.keyDown(Key.LeftShift))
            {
                running      = true;
                moveForward *= 1.5f;
            }

            if (d3dInput.keyDown(Key.E))
            {
                animationAction = "WeaponPos";
            }

            //Si hubo rotacion
            if (rotating)
            {
                if (rotatingY)
                {
                    //Rotar personaje y la camara, hay que multiplicarlo por el tiempo transcurrido para no atarse a la velocidad el hardware

                    float rotAngleY = Geometry.DegreeToRadian(rotateY * elapsedTime);
                    personaje.rotateY(rotAngleY);
                    camara.rotateY(rotAngleY);
                }
                if (rotatingX)
                {
                    //Rotar personaje y la camara, hay que multiplicarlo por el tiempo transcurrido para no atarse a la velocidad el hardware
                    float rotAngleX = Geometry.DegreeToRadian(rotateX * elapsedTime);
                    camara.rotateX(rotAngleX);
                }
            }


            //Si hubo desplazamiento
            if (moving)
            {
                //Activar animacion de caminando
                if (running)
                {
                    personaje.playAnimation("Run", true);
                }
                else if (jumping)
                {
                    personaje.playAnimation("Jump", true);
                }
                else
                {
                    personaje.playAnimation("Walk", true);
                }
            }

            //Si no se esta moviendo, activar animationAction
            else
            {
                personaje.playAnimation(animationAction, true);
            }



            //Vector de movimiento
            Vector3 movementVector = Vector3.Empty;

            if (moving)
            {
                //Aplicar movimiento, desplazarse en base a la rotacion actual del personaje
                //Grupo Kamikaze3D :: Se agrega también al desplazamiento sobre el eje x y eje z, el valor de desplazamiento lateral
                movementVector = new Vector3(
                    (FastMath.Sin(personaje.Rotation.Y) * moveForward) + (FastMath.Cos(personaje.Rotation.Y) * moveSide),
                    jump,
                    (FastMath.Cos(personaje.Rotation.Y) * moveForward) + (-FastMath.Sin(personaje.Rotation.Y) * moveSide)
                    );
            }


            //Actualizar valores de gravedad
            collisionManager.GravityEnabled = (bool)GuiController.Instance.Modifiers["HabilitarGravedad"];
            collisionManager.GravityForce   = (Vector3)GuiController.Instance.Modifiers["Gravedad"];
            collisionManager.SlideFactor    = (float)GuiController.Instance.Modifiers["SlideFactor"];


            //Mover personaje con detección de colisiones, sliding y gravedad
            Vector3 realMovement = collisionManager.moveCharacter(characterSphere, movementVector, objetosColisionables);

            personaje.move(realMovement);

            //Actualizar valores de la linea de movimiento
            directionArrow.PStart = characterSphere.Center;
            directionArrow.PEnd   = characterSphere.Center + Vector3.Multiply(movementVector, 50);
            directionArrow.updateValues();

            //Cargar desplazamiento realizar en UserVar
            GuiController.Instance.UserVars.setValue("Movement", TgcParserUtils.printVector3(realMovement));

            //Render linea
            if (renderDirectionArrow)
            {
                directionArrow.render();
            }


            //Render personaje
            personaje.animateAndRender();

            /* //Iniciar dibujado de todos los Sprites de la escena (en este caso es solo uno)
             * GuiController.Instance.Drawer2D.beginDrawSprite();
             *
             * //Dibujar sprite (si hubiese mas, deberian ir todos aquí)
             * mira.render();
             *
             * //Finalizar el dibujado de Sprites
             * GuiController.Instance.Drawer2D.endDrawSprite();*/

            hitCantTextY.Text = "Y: " + camara.RotationY;
            hitCantTextX.Text = "X: " + camara.RotationX;
            hitCantTextY.render();
            hitCantTextX.render();

            if (showBB)
            {
                characterSphere.render();
            }
        }
Esempio n. 23
0
 public void render()
 {
     text2.render();
 }
Esempio n. 24
0
        public override void render(float elapsedTime)
        {
            motionBlurFlag = (bool)GuiController.Instance.Modifiers["motionBlurFlag"];
            TgcTexture texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Pista\\pistaCarreras.png");

            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;


            //pantalla De Inicio
            if (flagInicio == 0)
            {
                //Actualizar valores cargados en modifiers

                /*sprite.Position = (Vector2)GuiController.Instance.Modifiers["position"];
                 * sprite.Scaling = (Vector2)GuiController.Instance.Modifiers["scaling"];
                 * sprite.Rotation = FastMath.ToRad((float)GuiController.Instance.Modifiers["rotation"]);
                 */
                //Iniciar dibujado de todos los Sprites de la escena (en este caso es solo uno)
                GuiController.Instance.Drawer2D.beginDrawSprite();
                sprite.render();
                //Finalizar el dibujado de Sprites
                GuiController.Instance.Drawer2D.endDrawSprite();
                flagInicio = jugador.verSiAprietaSpace();
                textIngreseTeclaSombra.render();
                textIngreseTecla.render();
                musica.verSiCambioMP3();
            }
            else
            {
                //Para contar el tiempo desde que preciona la barra espaciadora y comienza el juego
                if (primerRenderDelJuegoAndando == true)
                {
                    this.horaInicio             = DateTime.Now;
                    primerRenderDelJuegoAndando = false;
                }
                //Todo lo referente a lo que debe hacer el IA
                autoIA.elapsedTime = elapsedTime;
                autoIA.establecerVelocidadMáximaEn((float)GuiController.Instance.Modifiers["velocidadMaxima"] * 1.02f);

                if (colision.getTiempoQueChoco() == 0)
                {
                    jugadorIA.jugar(trayectoDeIA[0].Center, meshAutoIA.Position);
                }

                meshAutoIA.Rotation = new Vector3(0f, autoIA.rotacion, 0f);
                jugadorIA.setRotacion(meshAutoIA.Rotation);

                meshAutoIA.moveOrientedY(-autoIA.velocidad * elapsedTime);
                //Fin movimiento de auto IA

                //Le paso el elapsed time al auto porque sus metodos no deben depender de los FPS
                auto.elapsedTime = elapsedTime;

                //Varío la velocidad Máxima del vehículo con el modifier "velocidadMáxima"
                auto.establecerVelocidadMáximaEn((float)GuiController.Instance.Modifiers["velocidadMaxima"]);

                //El jugador envia mensajes al auto dependiendo de que tecla presiono
                //Se pone un tiempo para que luego de chocar 2 autos, estos no puedan ingresar movimiento (sólo se mueve por inercia)
                if (colision.getTiempoQueChoco() == 0)
                {
                    jugador.jugar(cantidadDeNitro);
                }
                else
                {
                    colision.setTiempoQueChoco(colision.getTiempoQueChoco() - (8 * elapsedTime));
                    if (colision.getTiempoQueChoco() < 0)
                    {
                        colision.setTiempoQueChoco(0);
                    }
                }

                //Transfiero la rotacion del auto abstracto al mesh, y su obb
                autoMesh.Rotation = new Vector3(0f, auto.rotacion, 0f);
                oBBAuto.Center    = autoMesh.Position;
                oBBAuto.setRotation(autoMesh.Rotation);
                meshAutoIA.Rotation = new Vector3(0f, autoIA.rotacion, 0f);
                oBBAutoIa.Center    = meshAutoIA.Position;
                oBBAutoIa.setRotation(meshAutoIA.Rotation);


                //Calculo de giro de la rueda
                rotacionVertical -= auto.velocidad * elapsedTime / 60;

                //Calculo el movimiento del mesh dependiendo de la velocidad del auto
                autoMesh.moveOrientedY(-auto.velocidad * elapsedTime);
                //Detección de colisiones
                //Hubo colisión con un objeto. Guardar resultado y abortar loop.



                //Si hubo alguna colisión, hacer esto:
                if (huboColision(oBBAuto))
                {
                    autoMesh.moveOrientedY(20 * auto.velocidad * elapsedTime); //Lo hago "como que rebote un poco" para no seguir colisionando
                    auto.velocidad = -(auto.velocidad * 0.3f);                 //Lo hago ir atrás un tercio de velocidad de choque
                }
                if (huboColision(oBBAutoIa))
                {
                    meshAutoIA.moveOrientedY(20 * autoIA.velocidad * elapsedTime); //Lo hago "como que rebote un poco" para no seguir colisionando
                    autoIA.velocidad = -(autoIA.velocidad * 0.3f);                 //Lo hago ir atrás un tercio de velocidad de choque
                }

                //Colisión entre los autos
                for (int i = 0; i < 4; i++)
                {
                    float ro, alfa_rueda;
                    float posicion_xA1;
                    float posicion_yA1;
                    float posicion_xA2;
                    float posicion_yA2;

                    ro = FastMath.Sqrt(dx[i] * dxAColision[i] + dyAColision[i] * dyAColision[i]);

                    alfa_rueda = FastMath.Asin(dxAColision[i] / ro);
                    if (i == 0 || i == 2)
                    {
                        alfa_rueda += FastMath.PI;
                    }
                    posicion_xA1 = FastMath.Sin(alfa_rueda + auto.rotacion) * ro;
                    posicion_yA1 = FastMath.Cos(alfa_rueda + auto.rotacion) * ro;

                    posicion_xA2 = FastMath.Sin(alfa_rueda + autoIA.rotacion) * ro;
                    posicion_yA2 = FastMath.Cos(alfa_rueda + autoIA.rotacion) * ro;

                    obbsAuto[i].Position = (new Vector3(posicion_xA1, 15.5f, posicion_yA1) + autoMesh.Position);

                    obbsOtroAuto[i].Position = (new Vector3(posicion_xA2, 15.5f, posicion_yA2) + meshAutoIA.Position);
                }

                colision.colisionEntreAutos(obbsAuto, obbsOtroAuto, jugador, auto, autoIA, autoMesh, meshAutoIA, elapsedTime);

                //Cosas sobre derrape
                int direcGiroDerrape = 0;

                if (auto.velocidad > 1500 && (jugador.estaGirandoDerecha() || jugador.estaGirandoIzquierda()))
                {
                    if (jugador.estaGirandoIzquierda())
                    {
                        direcGiroDerrape = -1;
                    }
                    else if (jugador.estaGirandoDerecha())
                    {
                        direcGiroDerrape = 1;
                    }

                    autoMesh.Rotation = new Vector3(0f, auto.rotacion + (direcGiroDerrape * anguloDerrape), 0f);
                    oBBAuto.setRotation(new Vector3(autoMesh.Rotation.X, autoMesh.Rotation.Y + (direcGiroDerrape * anguloDerrape / 2), autoMesh.Rotation.Z));


                    if (anguloDerrape <= anguloMaximoDeDerrape)
                    {
                        anguloDerrape += velocidadDeDerrape * elapsedTime;
                    }
                }
                else
                {
                    direcGiroDerrape = 0;
                    anguloDerrape    = 0;
                }
                //Fin derrape

                //Posiciono las ruedas
                for (int i = 0; i < 4; i++)
                {
                    float ro, alfa_rueda;
                    float posicion_x;
                    float posicion_y;
                    ro = FastMath.Sqrt(dx[i] * dx[i] + dy[i] * dy[i]);

                    alfa_rueda = FastMath.Asin(dx[i] / ro);
                    if (i == 0 || i == 2)
                    {
                        alfa_rueda += FastMath.PI;
                    }
                    posicion_x = FastMath.Sin(alfa_rueda + auto.rotacion + (anguloDerrape * direcGiroDerrape)) * ro;
                    posicion_y = FastMath.Cos(alfa_rueda + auto.rotacion + (anguloDerrape * direcGiroDerrape)) * ro;

                    ruedas[i].Position = (new Vector3(posicion_x, 15.5f, posicion_y) + autoMesh.Position);
                    //Si no aprieta para los costados, dejo la rueda derecha (por ahora, esto se puede modificar)
                    if (input.keyDown(Key.Left) || input.keyDown(Key.A) || input.keyDown(Key.Right) || input.keyDown(Key.D))
                    {
                        ruedas[i].Rotation = new Vector3(rotacionVertical, auto.rotacion + auto.rotarRueda(i) + (anguloDerrape * direcGiroDerrape), 0f);
                    }
                    else
                    {
                        ruedas[i].Rotation = new Vector3(rotacionVertical, auto.rotacion + (anguloDerrape * direcGiroDerrape), 0f);
                    }
                }

                //comienzo humo
                float rohumo, alfa_humo;
                float posicion_xhumo;
                float posicion_yhumo;
                rohumo = FastMath.Sqrt(-19f * -19f + 126f * 126f);

                alfa_humo      = FastMath.Asin(-19f / rohumo);
                posicion_xhumo = FastMath.Sin(alfa_humo + auto.rotacion + (anguloDerrape * direcGiroDerrape)) * rohumo;
                posicion_yhumo = FastMath.Cos(alfa_humo + auto.rotacion + (anguloDerrape * direcGiroDerrape)) * rohumo;

                humo.Position = (new Vector3(posicion_xhumo, 15.5f, posicion_yhumo) + autoMesh.Position);
                //Si no aprieta para los costados, dejo la rueda derecha (por ahora, esto se puede modificar)
                if (input.keyDown(Key.Left) || input.keyDown(Key.A) || input.keyDown(Key.Right) || input.keyDown(Key.D))
                {
                    humo.Rotation = new Vector3(0f, auto.rotacion + (anguloDerrape * direcGiroDerrape), 0f);
                }
                else
                {
                    humo.Rotation = new Vector3(0f, auto.rotacion + (anguloDerrape * direcGiroDerrape), 0f);
                }
                //fin de humo
                fuego.Position = humo.Position;
                fuego.Rotation = humo.Rotation;
                //fin fuego

                cantidadDeNitro += 0.5f * elapsedTime;
                cantidadDeNitro  = FastMath.Min(cantidadDeNitro, 100f);
                if (auto.nitro)
                {
                    cantidadDeNitro -= 7 * elapsedTime;
                    cantidadDeNitro  = FastMath.Max(cantidadDeNitro, 0f);
                    if (cantidadDeNitro > 1)
                    {
                        humo.Enabled  = false;
                        fuego.Enabled = false;
                    }
                }
                else
                {
                    humo.Enabled  = false;
                    fuego.Enabled = false;
                }
                tiempoHumo   += elapsedTime;
                humo.UVOffset = new Vector2(0.9f, tiempoHumo);
                humo.updateValues();
                fuego.UVOffset = new Vector2(0.9f, tiempoHumo);
                fuego.updateValues();

                if (tiempoHumo > 50f)
                {
                    tiempoHumo = 0f;
                }
                autoMeshPrevX = autoMesh.Position.X;
                autoMeshPrevZ = autoMesh.Position.Z;

                //Lineas de Frenado
                if (jugador.estaFrenandoDeMano())
                {
                    lineaDeFrenado[0].addTrack(new Vector3(ruedaDerechaDelanteraMesh.Position.X, 0, ruedaDerechaDelanteraMesh.Position.Z));
                    lineaDeFrenado[1].addTrack(new Vector3(ruedaDerechaTraseraMesh.Position.X, 0, ruedaDerechaTraseraMesh.Position.Z));
                    lineaDeFrenado[2].addTrack(new Vector3(ruedaIzquierdaDelanteraMesh.Position.X, 0, ruedaIzquierdaDelanteraMesh.Position.Z));
                    lineaDeFrenado[3].addTrack(new Vector3(ruedaIzquierdaTraseraMesh.Position.X, 0, ruedaIzquierdaTraseraMesh.Position.Z));
                }
                if (jugador.dejoDeFrenarDeMano())
                {
                    for (int i = 0; i < lineaDeFrenado.Length; i++)
                    {
                        lineaDeFrenado[i].endTrack();
                    }
                }

                for (int i = 0; i < lineaDeFrenado.Length; i++)
                {
                    lineaDeFrenado[i].render();
                    lineaDeFrenado[i].pasoDelTiempo(elapsedTime);
                }

                //Dibujo el reflejo de la luz en el auto
                reflejo.Render();

                //////Camara///////

                if (jugador.estaMirandoHaciaAtras())
                {
                    GuiController.Instance.ThirdPersonCamera.setCamera(autoMesh.Position, 200, -500);
                    GuiController.Instance.ThirdPersonCamera.Target    = autoMesh.Position;
                    GuiController.Instance.ThirdPersonCamera.RotationY = auto.rotacion;
                }
                else
                {
                    coheficienteCamara = jugador.verSiCambiaCamara();
                    GuiController.Instance.ThirdPersonCamera.setCamera(autoMesh.Position, 100 + (coheficienteCamara), 900 - (coheficienteCamara) * 4);
                    GuiController.Instance.ThirdPersonCamera.Target    = autoMesh.Position;
                    GuiController.Instance.ThirdPersonCamera.RotationY = auto.rotacion;
                }

                //La camara no rota exactamente a la par del auto, hay un pequeño retraso
                //GuiController.Instance.ThirdPersonCamera.RotationY += 5 * (auto.rotacion - prevCameraRotation) * elapsedTime;
                //Ajusto la camara a menos de 360 porque voy a necesitar hacer calculos entre angulos
                while (prevCameraRotation > 360)
                {
                    prevCameraRotation -= 360;
                }
                prevCameraRotation = GuiController.Instance.ThirdPersonCamera.RotationY;

                ///////Musica/////////
                jugador.verSiModificaMusica(musica);

                //Dibujar objeto principal
                //Siempre primero hacer todos los cálculos de lógica e input y luego al final dibujar todo (ciclo update-render)
                foreach (TgcMesh mesh in scenePista.Meshes)
                {
                    mesh.Enabled = (TgcCollisionUtils.classifyFrustumAABB(GuiController.Instance.Frustum, mesh.BoundingBox) != TgcCollisionUtils.FrustumResult.OUTSIDE);
                }
                if (motionBlurFlag)
                {
                    motionBlur.update(elapsedTime);
                    motionBlur.motionBlurRender(elapsedTime, HighResolutionTimer.Instance.FramesPerSecond, auto.velocidad, 0);
                }
                else
                {
                    foreach (TgcMesh mesh in scenePista.Meshes)
                    {
                        mesh.Technique = "DefaultTechnique";
                        mesh.render();
                    }
                }

                //Mostrar al auto IA
                meshAutoIA.render();

                //Muestro el punto siguiente
                trayecto[0].render();
                //mostrar el auto manejado por el humano
                autoMesh.render();

                for (int i = 0; i < 4; i++)
                {
                    ruedas[i].render();
                }

                humo.render();
                fuego.render();

                //Colision con puntos de control, tanto de persona como IA
                for (int i = 0; i < trayecto.Count; i++)
                {
                    //Pregunto si colisiona con un punto de control activado. Lo sé, feo.
                    if ((i == 0) && TgcCollisionUtils.testPointCylinder(oBBAuto.Position, trayecto[i].BoundingCylinder))
                    {
                        TgcCylinder cilindroModificado = new TgcCylinder(trayecto[i].Center, 130, 30);

                        if (contadorDeActivacionesDePuntosDeControl != (posicionesPuntosDeControl.Count * 3))
                        {
                            trayecto.RemoveAt(i);
                            trayecto.Add(cilindroModificado);
                            contadorDeActivacionesDePuntosDeControl++;
                            textPuntosDeControlAlcanzados.Text = "Puntos De Control Alcanzados = " + contadorDeActivacionesDePuntosDeControl.ToString();
                            textTiempo.Text = (Convert.ToDouble(textTiempo.Text) + 3).ToString();
                        }
                        else
                        {
                            gano             = true;
                            textGanaste.Text = "Ganaste y obtuviste un puntaje de  " + textTiempo.Text + " puntos";
                            textGanaste.render();
                            auto.estatico();
                            //Para el IA
                            autoIA.estatico();
                        }
                    }
                }
                for (int i = 0; i < trayectoDeIA.Count; i++)
                {
                    //Pregunto si colisiona con un punto de control activado
                    if ((i == 0) && TgcCollisionUtils.testPointCylinder(meshAutoIA.Position, trayectoDeIA[i].BoundingCylinder))
                    {
                        TgcCylinder cilindroModificado = new TgcCylinder(trayectoDeIA[i].Center, 130, 30);

                        if (contadorDeActivacionesDePuntosDeControlDeIA != (posicionesPuntosDeControlDeIA.Count * 3))
                        {
                            trayectoDeIA.RemoveAt(i);
                            trayectoDeIA.Add(cilindroModificado);
                            contadorDeActivacionesDePuntosDeControlDeIA++;
                        }
                        else
                        {
                            gano             = true;
                            textGanaste.Text = "Ganó la máquina :P  ";
                            textGanaste.render();
                            //Para el IA
                            autoIA.estatico();
                            auto.estatico();
                        }
                    }
                }

                textPosicionDelAutoActual.Text = autoMesh.Position.ToString();

                //Renderizar los tres textos

                textoVelocidad.mostrarVelocidad(auto.velocidad / 10).render(); //renderiza la velocidad

                textPuntosDeControlAlcanzados.render();
                textPosicionDelAutoActual.render();

                //Cosas del tiempo
                tiempo.incrementarTiempo(this, elapsedTime, (bool)GuiController.Instance.Modifiers["jugarConTiempo"]);

                //Actualizo y dibujo el relops
                if ((bool)GuiController.Instance.Modifiers["jugarConTiempo"])
                {
                    if ((DateTime.Now.Subtract(this.horaInicio).TotalSeconds) > segundosAuxiliares)
                    {
                        if (Convert.ToDouble(textTiempo.Text) == 0)
                        {
                            textPerdiste.Text = "Perdiste y lograste " + contadorDeActivacionesDePuntosDeControl.ToString() + " puntos de control";
                            textPerdiste.render();
                            auto.estatico();
                            //Para el IA
                            autoIA.estatico();
                        }
                        else if (gano == true)
                        {
                        }
                        else
                        {
                            this.textTiempo.Text = (Convert.ToDouble(textTiempo.Text) - 1).ToString();
                            segundosAuxiliares++;
                        }
                    }
                }
                emisorHumo.update(elapsedTime, GuiController.Instance.CurrentCamera.getLookAt(), auto.rotacion, autoMesh.Position, anguloDerrape, direcGiroDerrape, auto.nitro && (cantidadDeNitro > 1), auto.velocidad);
                emisorHumo.render(GuiController.Instance.CurrentCamera.getPosition());
                textTiempo.render();
                stringTiempo.render();
                contadorDeFrames++;

                hud.render(auto.velocidad, cantidadDeNitro);
            }//cierra el if de que no esta en pantalla inicio
            textFPS.Text = "            FPS: " + HighResolutionTimer.Instance.FramesPerSecond.ToString();
            textFPS.render();
        }
Esempio n. 25
0
 internal override void Render(float elapsedTime)
 {
     base.Render(elapsedTime);
     instrucciones.render();
 }
Esempio n. 26
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            showAcumTime += elapsedTime;

            TgcKinectSkeletonData data = tgcKinect.update();

            if (data.Active)
            {
                tgcKinect.DebugSkeleton.render(data.Current.KinectSkeleton);

                //Buscar gesto en mano derecha
                TgcKinectSkeletonData.AnalysisData rAnalysisData = data.HandsAnalysisData[TgcKinectSkeletonData.RIGHT_HAND];


                if (showAcumTime > 0.3f)
                {
                    showAcumTime = 0;
                    estadisticas = "Diff AvgZ: " + printFloat(rAnalysisData.Z.DiffAvg) + ", AvgZ: " + printFloat(rAnalysisData.Z.Avg) + ", varX: " + printFloat(rAnalysisData.X.Variance) + " varY: " + printFloat(rAnalysisData.Y.Variance);
                    posicion     = "Pos rHand: " + TgcParserUtils.printVector3(data.Current.RightHandSphere.Center);
                }
                GuiController.Instance.Text3d.drawText(estadisticas, 50, 150, Color.Yellow);
                GuiController.Instance.Text3d.drawText(posicion, 50, 200, Color.Yellow);


                if (gestoDetectado)
                {
                    acumTime += elapsedTime;
                    if (acumTime > 1)
                    {
                        gestoDetectado = false;
                        text.Color     = Color.Red;
                        text.Text      = "Nada";
                    }
                }
                else
                {
                    /*
                     * if ((rAnalysisData.Z.Max - rAnalysisData.Z.Min) > 10f)
                     * {
                     *  gestoDetectado = true;
                     *  acumTime = 0;
                     *  text.Color = Color.Green;
                     *  text.Text = "Abriendo cajon";
                     * }
                     */


                    float diff = (float)GuiController.Instance.Modifiers["diff"];

                    //Gesto de abrir cajon
                    if (rAnalysisData.Z.DiffAvg < diff && FastMath.Abs(rAnalysisData.X.Variance) < 5f && FastMath.Abs(rAnalysisData.Y.Variance) < 10f)
                    {
                        gestoDetectado = true;
                        acumTime       = 0;
                        text.Color     = Color.Green;
                        text.Text      = "Abriendo cajon";
                    }
                }
            }



            text.render();
        }
Esempio n. 27
0
        public void render()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            textoActual.render();
        }