Beispiel #1
0
        public override void Update()
        {
            TwistedMetal tm = TwistedMetal.getInstance();

            if (cambiarCamara())
            {
                alternaCamara();
            }

            if (cambiarMusica())
            {
                tm.cambiarMusica();
            }


            if (moverArriba())
            {
                base.startSalto();
            }

            base.Update();
            camaraInterna.Target = this.getMesh().Position;
            camaraRotante.SetCamera(new Vector3(camaraInterna.Position.X, 150, camaraInterna.Position.Z),
                                    new Vector3(camaraInterna.Target.X, 100, camaraInterna.Target.Z));

            /*foreach (var rueda in base.getRueda())
             * {
             *  rueda.up
             * }*/
            this.velocimetro.Update(FastMath.Abs(this.getVelocidadX()));
        }
        /// <summary>
        ///     Inicio todos los objetos necesarios para cargar el ejemplo y directx.
        /// </summary>
        public void InitGraphics()
        {
            //Se inicio la aplicación
            ApplicationRunning = true;

            //Inicio Device
            D3DDevice.Instance.InitializeD3DDevice(panel3D);

            //Inicio inputs
            Input = new TgcD3dInput();
            Input.Initialize(this, panel3D);

            //Inicio sonido
            DirectSound = new TgcDirectSound();
            DirectSound.InitializeD3DDevice(panel3D);

            //Directorio actual de ejecución
            var currentDirectory = Environment.CurrentDirectory + "\\";

            //Juego a ejecutar, si quisiéramos tener diferentes modelos aquí podemos cambiar la instancia e invocar a otra clase.
            Modelo = new TwistedMetal(currentDirectory + Game.Default.MediaDirectory,
                                      currentDirectory + Game.Default.ShadersDirectory);

            //Cargar shaders del framework
            TgcShaders.Instance.loadCommonShaders(currentDirectory + Game.Default.ShadersDirectory);

            //Cargar juego.
            ExecuteModel();
        }
 public Arma(TgcMesh Mesh, TwistedMetal env, string sonido, float aceleracion, float orientacion,
             float angulo, Vector3 scale, TgcMesh meshOrigen, bool esDisparo) : base(Mesh, env)
 {
     this.doblar(0.001f);//Inicializa las matrices de rotación, no tocar!!
     this.getMesh().AutoTransformEnable   = false;
     this.getMesh().AutoUpdateBoundingBox = true;
     this.getMesh().createBoundingBox();
     this.setVelocidadMaxima(150);
     this.setVelocidadRotacion(0);
     this.setVelocidadMinima(0);
     this.setConstanteDeAsceleracionX(aceleracion);
     this.orientacion     = orientacion;
     this.escalado        = scale;
     this.getMesh().Scale = scale;
     this.setAnguloFinal(angulo);
     base.setSonido(sonido);
     base.setSonidoMotor(sonido);
     base.setSonidoArma(sonido);
     base.setSonidoColision(env.MediaDir + "MySounds\\Crash4.wav");
     base.setSonidoItem(env.MediaDir + "MySounds\\Crash4.wav");
     base.setSonidoSalto(env.MediaDir + "MySounds\\Crash4.wav");
     base.setEsArma(true);
     if (esDisparo)
     {
         base.setEsDisparo(true);
     }
     base.setMeshDeOrigen(meshOrigen);
     this.doblar(orientacion);
 }
 public Humo(TwistedMetal env, bool deChoque)
 {
     this.env = env;
     if (!deChoque)
     {
         return;            //solo para cuando quiero que sea de choque
     }
     Init();
 }
        public PuntoDeLuz(TwistedMetal env, Vector3 Posicion)
        {
            this.env  = env;
            lighthPos = Posicion;
            float t = 10f;

            lightMesh = TgcBox.fromSize(lighthPos, new Vector3(t, t, t), Color.White);
            lightMesh.AutoTransformEnable = false;
            lightMesh.updateValues();
            //currentShader = TgcShaders.Instance.TgcMeshPointLightShader;
            currentShader = TgcShaders.loadEffect(this.env.ShadersDir + "TgcMeshSpotLightShader.fx");
        }
Beispiel #6
0
 public Rueda(TwistedMetal env, TgcMesh mesh, bool ruedaDelantera) : base(mesh, env)
 {
     this.setMesh(mesh);
     this.setVelocidadMaxima(70);
     this.setVelocidadMinima(-5);
     this.setConstanteDeAsceleracionX(0.7f);
     this.setEsRueda(true);
     this.setEsRuedaDelantera(ruedaDelantera);
     //      base.setPEndDirectionArrow(new Vector3(this.getMesh().Position.X, this.getMesh().Position.Y, -500));
     //   this.setAlturaInicial(this.getMesh().Position.Y);
     //camaraManager();
     this.doblar(0.001f);//Inicializa las matrices de rotación, no tocar!!
 }
        private void Init(Vector3 pos, Vector3 dir, float intensidad, Color colorLuz, TwistedMetal env)
        {
            this.env    = env;
            lightEnable = true;
            lightPos    = pos;
            lightDir    = dir;
            lightDir.Normalize();
            lightColor     = colorLuz;
            lightIntensity = intensidad;
            specularEx     = 9f;
            spotAngle      = 36f;
            spotExponent   = 7f;

            effect = TgcShaders.loadEffect(this.env.ShadersDir + "MultiDiffuseLights.fx");
        }
 public Niebla(TwistedMetal env)
 {
     effect            = TgcShaders.loadEffect(env.ShadersDir + "TgcFogShader.fx");
     fog               = new TgcFog();
     fog.Enabled       = true;
     fog.StartDistance = 4000;
     fog.EndDistance   = 6000;
     fog.Density       = 0.0005f;
     fog.Color         = Color.Gray;
     fogShader         = true;
     skyBox            = env.Ciudad.getSkyBox();
     this.env          = env;
     //  mapScene = gm.MapScene;
     //bosqueScene = gm.BosqueScene;
     //ahora cargo todo en el efecto de directX
 }
Beispiel #9
0
        float agujaPuntoMax  = (FastMath.PI * 1.76f) - FastMath.PI / 4; // 220 en el velocimetro

        public Velocimetro(TwistedMetal env, float vMax)
        {
            this.env = env;
            //  this.velocidadMaxAuto = vMax;
            this.velocidadMaxAuto     = 150;
            spriteVelocimetro         = new CustomSprite();
            spriteVelocimetro.Bitmap  = new CustomBitmap(this.env.MediaDir + "\\Velocimetro\\velocimetro.png", D3DDevice.Instance.Device);
            spriteVelocimetro.Scaling = new Vector2(0.8f, 0.8f);
            var textureSize = spriteVelocimetro.Bitmap.Size;

            //Velocimetro a derecha:
            //   spriteVelocimetro.Position = new Vector2(FastMath.Max(D3DDevice.Instance.Width - textureSize.Width, 0), FastMath.Max(D3DDevice.Instance.Height - textureSize.Height, 0));
            //Velocimetro a izquierda:
            spriteVelocimetro.Position = new Vector2(0, FastMath.Max(D3DDevice.Instance.Height - textureSize.Height, 0));

            spriteAguja          = new CustomSprite();
            spriteAguja.Bitmap   = new CustomBitmap(this.env.MediaDir + "\\Velocimetro\\aguja.png", D3DDevice.Instance.Device);
            spriteAguja.Scaling  = new Vector2(0.2f, 0.3f);
            spriteAguja.Position = new Vector2(spriteVelocimetro.Position.X + (textureSize.Width / 2.5f), spriteVelocimetro.Position.Y + (textureSize.Height / 2.5f));

            drawer2D = new Drawer2D();
        }
Beispiel #10
0
 public Cronometro(float tiempo, TwistedMetal env)
 {
     this.env  = env;
     tiempoMax = tiempo;
 }
 public FixedLight(Vector3 pos, Vector3 dir, float intensidad, Color colorLuz, TwistedMetal env)
 {
     Init(pos, dir, intensidad, colorLuz, env);
 }
Beispiel #12
0
        public VehiculoPrincipal(TwistedMetal env) : base(env)
        {
            Personaje personaje = Personaje.getInstance();

            loader = new TgcSceneLoader();
            var scene = loader.loadSceneFromFile(personaje.FileMesh);

            this.setMesh(scene.Meshes[0]);
            this.getMesh().Position = new Vector3(100, 5, 3000);
            camaraManager();
            this.setVelocidadMaxima(personaje.VelocidadMax);
            this.setVelocidadMinima(personaje.VelocidadMin);
            this.setConstanteDeAsceleracionX(personaje.ConstanteAceleracion);
            //      base.setPEndDirectionArrow(new Vector3(this.getMesh().Position.X, this.getMesh().Position.Y, -500));
            //   this.setAlturaInicial(this.getMesh().Position.Y);

            this.doblar(0.001f);//Inicializa las matrices de rotación, no tocar!!

            base.setSonido(personaje.FileSonido);
            base.setSonidoMotor(personaje.FileSonidoMotor);
            base.setSonidoArma(personaje.FileSonidoArma);
            base.setSonidoColision(personaje.FileSonidoColision);
            base.setSonidoItem(personaje.FileSonidoItem);
            base.setSonidoSalto(personaje.FileSonidoSalto);
            this.getMesh().AutoUpdateBoundingBox = true;

            seteaPosicionRuedas(personaje.NroPersonaje);

            Vector3 scale = new Vector3(0.1f, 0.1f, 0.1f);
            Matrix  mEsc  = Matrix.Scaling(scale);
            //var sceneRueda = loader.loadSceneFromFile(env.MediaDir + "Wheel\\wheel2-TgcScene.xml");
            var sceneRueda = loader.loadSceneFromFile(env.MediaDir + "Wheel\\wheel2-TgcScene.xml");

            Vector3 pos  = new Vector3(-40, 0, -48);
            Matrix  mRot = Matrix.RotationY(FastMath.PI);
            Matrix  mTra = Matrix.Translation(pos);

            TgcMesh rueda1_p1 = sceneRueda.Meshes[0];

            rueda1_p1.AutoTransformEnable = false;
            rueda1_p1.Transform           = mEsc * mRot * mTra;
            TgcMesh rueda1_p2 = sceneRueda.Meshes[1];

            rueda1_p2.AutoTransformEnable = false;
            rueda1_p2.Transform           = mEsc * mRot * mTra;
            TgcMesh rueda1_p3 = sceneRueda.Meshes[2];

            rueda1_p3.AutoTransformEnable = false;
            rueda1_p3.Transform           = mEsc * mRot * mTra;

            TgcMesh[] meshRuedas = new TgcMesh[] { rueda1_p1, rueda1_p2, rueda1_p3 };
            base.setRuedaDelDer(meshRuedas);

            pos  = new Vector3(-40, 0, 68);
            mRot = Matrix.RotationY(FastMath.PI);
            mTra = Matrix.Translation(pos);

            TgcMesh rueda2_p1 = sceneRueda.Meshes[0];

            rueda2_p1.AutoTransformEnable = false;
            rueda2_p1.Transform           = mEsc * mRot * mTra;
            TgcMesh rueda2_p2 = sceneRueda.Meshes[1];

            rueda2_p2.AutoTransformEnable = false;
            rueda2_p2.Transform           = mEsc * mRot * mTra;
            TgcMesh rueda2_p3 = sceneRueda.Meshes[2];

            rueda2_p3.AutoTransformEnable = false;
            rueda2_p3.Transform           = mEsc * mRot * mTra;

            meshRuedas = new TgcMesh[] { rueda2_p1, rueda2_p2, rueda2_p3 };
            base.setRuedaTraDer(meshRuedas);

            pos  = new Vector3(30, 0, -48);
            mRot = Matrix.RotationY(FastMath.PI);
            mTra = Matrix.Translation(pos);

            TgcMesh rueda3_p1 = sceneRueda.Meshes[0];

            rueda3_p1.AutoTransformEnable = false;
            rueda3_p1.Transform           = mEsc * mRot * mTra;
            TgcMesh rueda3_p2 = sceneRueda.Meshes[1];

            rueda3_p2.AutoTransformEnable = false;
            rueda3_p2.Transform           = mEsc * mRot * mTra;
            TgcMesh rueda3_p3 = sceneRueda.Meshes[2];

            rueda3_p3.AutoTransformEnable = false;
            rueda3_p3.Transform           = mEsc * mRot * mTra;

            meshRuedas = new TgcMesh[] { rueda3_p1, rueda3_p2, rueda3_p3 };
            base.setRuedaDelIzq(meshRuedas);

            pos  = new Vector3(30, 0, 68);
            mRot = Matrix.RotationY(FastMath.PI);
            mTra = Matrix.Translation(pos);

            TgcMesh rueda4_p1 = sceneRueda.Meshes[0];

            rueda4_p1.AutoTransformEnable = false;
            rueda4_p1.Transform           = mEsc * mRot * mTra;
            TgcMesh rueda4_p2 = sceneRueda.Meshes[1];

            rueda4_p2.AutoTransformEnable = false;
            rueda4_p2.Transform           = mEsc * mRot * mTra;
            TgcMesh rueda4_p3 = sceneRueda.Meshes[2];

            rueda4_p3.AutoTransformEnable = false;
            rueda4_p3.Transform           = mEsc * mRot * mTra;

            meshRuedas = new TgcMesh[] { rueda4_p1, rueda4_p2, rueda4_p3 };
            base.setRuedaTraIzq(meshRuedas);

            this.cargarShaders();
            this.mover();

            crearVelocimetro();
            cargarShaders();
        }
Beispiel #13
0
 public Enemigo(TwistedMetal env, TgcMesh mesh) : base(mesh, env)
 {
     base.doblar(0.001f);//Inicializa las matrices de rotación, no tocar!!
     this.getMesh().AutoUpdateBoundingBox = true;
     base.esEnemigo = true;
 }
 public Humo(TwistedMetal env)
 {
     this.env     = env;
     offsetEscape = new Vector3(10, 5, 52);
     Init();
 }
 public ControladorDeVehiculos(TwistedMetal env)
 {
     this.env   = env;
     myInstance = this;
     loader     = new TgcSceneLoader();
 }