public void Update(TgcD3dInput Input)
        {
            #region chequearInput

            if (cambiar)
            {
                if (Input.keyUp(Key.LeftArrow))
                {
                    siguiente++;
                    if (siguiente > 2)
                    {
                        siguiente = 0;
                    }
                    cambiar = false;
                }
                if (Input.keyUp(Key.RightArrow))
                {
                    siguiente--;
                    if (siguiente < 0)
                    {
                        siguiente = 2;
                    }
                    cambiar = false;
                }
            }

            if (Input.keyUp(Key.Return))
            {
                cambiarEstado(Input);
            }

            #endregion
        }
Esempio n. 2
0
 private void Salto(TgcD3dInput input)
 {
     if (input.keyUp(Key.Space) && DistanciaAlPisoSalto())
     {
         jumping  = 280f;
         moving   = true;
         enElPiso = false;
     }
 }
 private void RestartSpeedForKeyUp()
 {
     if (Input.keyUp(Key.W) || Input.keyUp(Key.S) || Input.keyUp(Key.A) || Input.keyUp(Key.D) ||
         Input.keyUp(Key.Space) || Input.keyUp(Key.LeftControl))
     {
         RestartBodySpeed();
     }
 }
Esempio n. 4
0
 public void Update(TgcD3dInput Input)
 {
     #region chequearInput
     if (Input.keyUp(Key.LeftArrow))
     {
         seleccion--;
         if (seleccion < 0)
         {
             seleccion = 2;
         }
     }
     if (Input.keyUp(Key.RightArrow))
     {
         seleccion++;
         if (seleccion > 2)
         {
             seleccion = 0;
         }
     }
     if (Input.keyUp(Key.Return))
     {
         if (seleccion == 0)
         {
             cambiarEstado(Input);
         }
         else if (seleccion == 1)
         {
             cambiarOpciones(Input);
         }
         else
         {
             cambiarAyuda(Input);
         }
     }
     #endregion
 }
Esempio n. 5
0
        public void SaltaHiperEspacio()
        {
            TgcD3dInput input = GuiController.Instance.D3dInput;

            if (Saltando == false)
            {
                if (input.keyDown(Key.Space))
                {
                    VelocidadMovimiento += 400f;
                    Saltando             = true;
                }
            }
            if (Saltando)
            {
                if (input.keyUp(Key.Space))
                {
                    VelocidadMovimiento -= 400f;
                    Saltando             = false;
                }
            }
        }
Esempio n. 6
0
        public void jugar(float cantidadDeNitro)
        {
            if ((input.keyDown(Key.LeftControl) || input.keyDown(Key.LeftShift)) && (cantidadDeNitro > 1))
            {
                auto.ponerNitro();
            }
            else
            {
                auto.sacarNitro();
            }
            if (input.keyDown(Key.Left) || input.keyDown(Key.A))
            {
                auto.rotar(-1); //-1 representa la izquierda
                giraIzquierda = true;
            }
            if (input.keyDown(Key.Right) || input.keyDown(Key.D))
            {
                auto.rotar(1); //1 representa la derecha
                giraDerecha = true;
            }
            if (input.keyDown(Key.Up) || input.keyDown(Key.W))
            {
                auto.avanzar();
                estaRetrocediendo = false;
            }
            if (input.keyDown(Key.Down) || input.keyDown(Key.S))
            {
                auto.retroceder();
                estaRetrocediendo = true;
            }
            if (!input.keyDown(Key.Down) && !input.keyDown(Key.S) && !input.keyDown(Key.Up) && !input.keyDown(Key.W))
            {
                auto.noMover();
                estaRetrocediendo = false;
            }
            if (!input.keyDown(Key.Right) && !input.keyDown(Key.D))
            {
                giraDerecha = false;
            }
            if (!input.keyDown(Key.Left) && !input.keyDown(Key.A))
            {
                giraIzquierda = false;
            }

            //Para el freno de mano que deja marcas en el suelo
            if (input.keyDown(Key.Space))
            {
                recienSoltoFrenoDeMano = false;
                if (auto.velocidad > 0)
                {
                    auto.frenoDeMano();
                    frenaDeMano = true;
                }
                else
                {
                    frenaDeMano = false;
                }
            }
            else
            {
                frenaDeMano = false;
            }
            if (input.keyUp(Key.Space))
            {
                recienSoltoFrenoDeMano = true;
            }

            //Para mirar hacia atrás
            if (input.keyDown(Key.Tab))
            {
                mirandoHaciaAtras = true;
            }
            else
            {
                mirandoHaciaAtras = false;
            }
        }
        /// <summary>
        /// Calculo cual es la proxima posicion en base a lo que tocan en el teclado
        /// </summary>
        /// <param name="elapsedTime"> Tiempo en segundos transcurridos desde el último frame</param>
        public Vector3 CalcularPosicionSegunInput(Jugador jugador, float elapsedTime, TgcD3dInput d3dInput)
        {
            //Calcular proxima posicion de personaje segun Input
            Vector3 movimiento = Vector3.Empty;
            Vector3 direccion  = new Vector3(0, 0, 0);
            bool    moving     = false;
            bool    correr     = false;

            //Multiplicar la velocidad por el tiempo transcurrido, para no acoplarse al CPU
            float velocidad = jugador.VelocidadCaminar * elapsedTime;

            //Si presiono W corre
            if (d3dInput.keyDown(Key.W))
            {
                //Multiplicar la velocidad por el tiempo transcurrido, para no acoplarse al CPU
                velocidad = jugador.VelocidadCorrer * elapsedTime;
                correr    = true;
            }

            //Si suelto, vuelve a caminar
            if (d3dInput.keyUp(Key.W))
            {
                correr = false;
            }

            //Adelante
            if (d3dInput.keyDown(Key.UpArrow))
            {
                movimiento.Z = velocidad;
                direccion.Y  = (float)Math.PI;
                moving       = true;
            }

            //Atras
            if (d3dInput.keyDown(Key.DownArrow))
            {
                movimiento.Z = -velocidad;
                //No hago nada en este caso por la rotacion
                moving = true;
            }

            //Derecha
            if (d3dInput.keyDown(Key.RightArrow))
            {
                movimiento.X = velocidad;
                direccion.Y  = -(float)Math.PI / 2;
                moving       = true;
            }

            //Izquierda
            if (d3dInput.keyDown(Key.LeftArrow))
            {
                movimiento.X = -velocidad;
                direccion.Y  = (float)Math.PI / 2;
                moving       = true;
            }

            //Diagonales, lo unico que hace es girar al jugador, el movimiento se calcula con el ingreso de cada tecla.
            if (d3dInput.keyDown(Key.UpArrow) && d3dInput.keyDown(Key.Right))
            {
                direccion.Y = (float)Math.PI * 5 / 4;
            }

            if (d3dInput.keyDown(Key.UpArrow) && d3dInput.keyDown(Key.LeftArrow))
            {
                direccion.Y = (float)Math.PI * 3 / 4;
            }
            if (d3dInput.keyDown(Key.DownArrow) && d3dInput.keyDown(Key.LeftArrow))
            {
                direccion.Y = (float)Math.PI / 4;
            }
            if (d3dInput.keyDown(Key.DownArrow) && d3dInput.keyDown(Key.RightArrow))
            {
                direccion.Y = (float)Math.PI * 7 / 4;
            }

            //Si hubo desplazamiento
            if (moving)
            {
                //Activar animacion que corresponda
                if (correr)
                {
                    jugador.playAnimation(jugador.AnimacionCorriendo, true);
                }
                else
                {
                    jugador.playAnimation(jugador.AnimacionCaminando, true);
                }

                //Aplicar movimiento hacia adelante o atras segun la orientacion actual del Mesh
                Vector3 lastPos = jugador.Position;

                jugador.move(movimiento);
                jugador.Rotation = direccion;

                //Detecto las colisiones
                if (jugador.CollisionManager.DetectarColisiones(jugador, lastPos))
                {
                    //Si hubo colision, restaurar la posicion anterior
                    jugador.Position = lastPos;
                }
            }
            //Si no se esta moviendo, activar animacion de Parado
            else
            {
                jugador.playAnimation(jugador.AnimacionParado, true);
            }

            return(movimiento);
        }
        public void Update(TgcD3dInput Input)
        {
            #region chequearInput

            if (cambiar)
            {
                if (Input.keyUp(Key.UpArrow))
                {
                    if (tipoEscena)
                    {
                        escenaSel--;
                        if (escenaSel < 0)
                        {
                            escenaSel = 4;
                        }
                    }
                    else
                    {
                        musicaSel = !musicaSel;
                    }

                    cambiar = false;
                }
                if (Input.keyUp(Key.DownArrow))
                {
                    if (tipoEscena)
                    {
                        escenaSel++;
                        if (escenaSel > 4)
                        {
                            escenaSel = 0;
                        }
                    }
                    else
                    {
                        musicaSel = !musicaSel;
                    }
                    cambiar = false;
                }
                if (Input.keyUp(Key.LeftArrow))
                {
                    tipoEscena = true;
                    cambiar    = false;
                }
                if (Input.keyUp(Key.RightArrow))
                {
                    tipoEscena = false;
                    cambiar    = false;
                }
            }

            if (Input.keyUp(Key.Return))
            {
                cambiarEstado(Input);
            }

            #endregion

            #region manejarInput
            switch (escenaSel)
            {
            case 0:
                gameModel.normal();
                break;

            case 1:
                gameModel.picante();
                break;

            case 2:
                gameModel.congelar();
                break;

            case 3:
                gameModel.glow();
                break;

            case 4:
                gameModel.god();
                break;
            }
            gameModel.musica(musicaSel);
            #endregion
        }
        virtual protected void ManageEntry(TgcD3dInput input)
        {
            if (input.keyDown(Key.NumPad4))
            {
                Scene.GetInstance().camera.rotateY(-0.0005f);
            }
            if (input.keyDown(Key.NumPad6))
            {
                Scene.GetInstance().camera.rotateY(0.0005f);
            }

            if (input.keyDown(Key.RightArrow))
            {
                Scene.GetInstance().camera.OffsetHeight += 0.005f;
            }
            if (input.keyDown(Key.LeftArrow))
            {
                Scene.GetInstance().camera.OffsetHeight -= 0.005f;
            }

            if (input.keyDown(Key.UpArrow))
            {
                Scene.GetInstance().camera.OffsetForward += 0.01f;
            }
            if (input.keyDown(Key.DownArrow))
            {
                Scene.GetInstance().camera.OffsetForward -= 0.01f;
            }

            if (input.keyDown(Key.W))
            {
                this.estado.Advance();
            }

            if (input.keyDown(Key.S))
            {
                this.estado.Back();
            }

            float rotation;

            if (input.keyDown(Key.D))
            {
                rotation = this.estado.Right();
                Scene.GetInstance().camera.rotateY(rotation);
            }
            else if (input.keyDown(Key.A))
            {
                rotation = this.estado.Left();
                Scene.GetInstance().camera.rotateY(rotation);
            }

            if (!input.keyDown(Key.A) && !input.keyDown(Key.D))
            {
                this.estado.UpdateWheels();
            }

            if (input.keyDown(Key.Space))
            {
                this.estado.Jump();
            }

            if (!input.keyDown(Key.W) && !input.keyDown(Key.S))
            {
                this.estado.SpeedUpdate();
            }

            if (input.keyDown(Key.P))
            {
                this.Shoot();
            }

            if (input.keyDown(Key.E))
            {
                this.SoundsManager.GetSound("Bocina").play();
            }

            if (input.keyDown(Key.R))
            {
                this.SoundsManager.GetSound("Alarma").play();
            }

            if (input.keyUp(Key.U))
            {
                NextWeapon();
            }
            if (input.keyDown(Key.C))
            {
                estado = new Frozen(this);
            }

            /*
             * if (input.keyDown(Key.K))
             * {
             *  life -= 50;
             * }
             */
            if (input.keyDown(Key.NumPad1))
            {
                this.pointsOfCollision.constantOfDeformation += 0.01f;
            }
            if (input.keyDown(Key.NumPad2))
            {
                this.pointsOfCollision.constantOfDeformation -= 0.01f;
            }

            if (input.keyDown(Key.NumPad7))
            {
                this.pointsOfCollision.radio -= 0.01f;
            }
            if (input.keyDown(Key.NumPad9))
            {
                this.pointsOfCollision.radio += 0.01f;
            }
        }
Esempio n. 10
0
        public void Update(float elapsedTime)
        {
            dynamicsWorld.StepSimulation(1 / 60f, 100);

            var director = Camera.LookAt - Camera.Position;

            director.Normalize();
            var strength = 10f;

            if (Camera.Position.Y > 4119)
            {
                director.Y = 0;
            }

            if (Input.keyDown(Key.W))
            {
                RigidCamera.ActivationState = ActivationState.ActiveTag;

                RigidCamera.ApplyCentralImpulse(strength * director.ToBulletVector3());
            }
            if (Input.keyUp(Key.W))
            {
                //op1
                //RigidCamera.ActivationState = ActivationState.IslandSleeping;
                //op2
                //rigidCamera.ActivationState = ActivationState.DisableSimulation;
            }

            if (Input.keyDown(Key.A))
            {
                RigidCamera.ActivationState = ActivationState.ActiveTag;

                var left = new TGCVector3();
                left.X = director.X * FastMath.Cos(FastMath.PI_HALF) - director.Z * FastMath.Sin(FastMath.PI_HALF);
                left.Z = director.X * FastMath.Sin(FastMath.PI_HALF) + director.Z * FastMath.Cos(FastMath.PI_HALF);

                RigidCamera.ApplyCentralImpulse(strength * left.ToBulletVector3());
            }
            if (Input.keyUp(Key.A))
            {
                //op1
                //RigidCamera.ActivationState = ActivationState.IslandSleeping;
                //op2
                //rigidCamera.ActivationState = ActivationState.DisableSimulation;
            }

            if (Input.keyDown(Key.D))
            {
                RigidCamera.ActivationState = ActivationState.ActiveTag;

                var right = new TGCVector3();
                right.X = director.X * FastMath.Cos(FastMath.PI + FastMath.PI_HALF) - director.Z * FastMath.Sin(FastMath.PI + FastMath.PI_HALF);
                right.Z = director.X * FastMath.Sin(FastMath.PI + FastMath.PI_HALF) + director.Z * FastMath.Cos(FastMath.PI + FastMath.PI_HALF);

                RigidCamera.ApplyCentralImpulse(strength * right.ToBulletVector3());
            }
            if (Input.keyUp(Key.D))
            {
                //op1
                //RigidCamera.ActivationState = ActivationState.IslandSleeping;
                //op2
                //rigidCamera.ActivationState = ActivationState.DisableSimulation;
            }

            if (Input.keyDown(Key.S))
            {
                RigidCamera.ActivationState = ActivationState.ActiveTag;
                RigidCamera.ApplyCentralImpulse(-strength * director.ToBulletVector3());
            }
            if (Input.keyUp(Key.S))
            {
                //op1
                //RigidCamera.ActivationState = ActivationState.IslandSleeping;
                //op2
                //rigidCamera.ActivationState = ActivationState.DisableSimulation;
            }

            ((FpsCamera)Camera).SetPosicion(new TGCVector3(RigidCamera.CenterOfMassPosition));

            PlayerModel.Position = Camera.Position;

            dynamicsWorld.Gravity = gravityUnderSurface;
            if (!PlayerModel.UnderSurface())
            {
                dynamicsWorld.Gravity = gravity;
            }
        }
Esempio n. 11
0
 public bool keyUp(Key key)
 {
     return(keyboard.keyUp(key));
 }
Esempio n. 12
0
        public void Update(TgcD3dInput input, TgcMesh monstruo, TgcMesh monstruoSil)
        {
            monstruoMesh    = monstruo;
            monstruoSilueta = monstruoSil;

            dynamicsWorld.StepSimulation(1 / 60f, 100);

            #region Comportamiento

            if (input.keyDown(Key.Space) && ModoCreativo)
            {
                //Activa el comportamiento de la simulacion fisica para la capsula
                personajeBody.ActivationState = ActivationState.ActiveTag;
                personajeBody.AngularVelocity = TGCVector3.Empty.ToBulletVector3();
                personajeBody.ApplyCentralImpulse(strength * 10 * (new TGCVector3(0, 1, 0)).ToBulletVector3());
            }

            if (input.keyDown(Key.W))
            {
                //Activa el comportamiento de la simulacion fisica para la capsula
                personajeBody.ActivationState = ActivationState.ActiveTag;
                personajeBody.AngularVelocity = TGCVector3.Empty.ToBulletVector3();
                personajeBody.ApplyCentralImpulse(-strength * director.ToBulletVector3());
            }
            if (input.keyUp(Key.W))
            {
                personajeBody.ActivationState = ActivationState.IslandSleeping;
            }
            if (input.keyUp(Key.S))
            {
                personajeBody.ActivationState = ActivationState.IslandSleeping;
            }

            if (input.keyDown(Key.S))
            {
                //Activa el comportamiento de la simulacion fisica para la capsula
                personajeBody.ActivationState = ActivationState.ActiveTag;
                personajeBody.AngularVelocity = TGCVector3.Empty.ToBulletVector3();
                personajeBody.ApplyCentralImpulse(strength * director.ToBulletVector3());
            }

            if (input.keyDown(Key.A))
            {
                director.TransformCoordinate(TGCMatrix.RotationY(-angle * rotationStrength));
                personaje.Transform          = TGCMatrix.Translation(TGCVector3.Empty) * TGCMatrix.RotationY(-angle * rotationStrength) * new TGCMatrix(personajeBody.InterpolationWorldTransform);
                personajeBody.WorldTransform = personaje.Transform.ToBsMatrix;
                personaje.RotateY(-angle * rotationStrength);
                personajeActual.RotarManos(-angle * rotationStrength);
                monstruo.RotateY(-angle * rotationStrength);
                monstruoSilueta.RotateY(-angle * rotationStrength);
            }

            if (input.keyDown(Key.D))
            {
                director.TransformCoordinate(TGCMatrix.RotationY(angle * rotationStrength));
                personaje.Transform          = TGCMatrix.Translation(TGCVector3.Empty) * TGCMatrix.RotationY(angle * rotationStrength) * new TGCMatrix(personajeBody.InterpolationWorldTransform);
                personajeBody.WorldTransform = personaje.Transform.ToBsMatrix;
                personaje.RotateY(angle * rotationStrength);
                personajeActual.RotarManos(angle * rotationStrength);
                monstruo.RotateY(angle * rotationStrength);
                monstruoSilueta.RotateY(angle * rotationStrength);
            }


            #endregion Comportamiento
        }