Exemplo n.º 1
0
        public override void Update()
        {
            PreUpdate();

            var input = Input;

            //Camaras
            Camara01 = new CamaraAtrasAF(AutoFisico1);
            Camara02 = new CamaraAtrasAF(AutoFisico2);
            Camara03 = new CamaraEspectador();

            GrupoPolicias.Update();
            AutoFisico1.Update(input);
            AutoFisico2.Update(input);

            //Colisiones entre los autos y los policias
            foreach (var Policia in GrupoPolicias.Todos)
            {
                if (TgcCollisionUtils.testAABBAABB(AutoFisico1.BBFinal, Policia.BBFinal) && inGame)
                {
                    if (SwitchFX)
                    {
                        AutoFisico1.choque.play(false);
                    }
                    AutoFisico1.Vida -= 5;
                }
                if (TgcCollisionUtils.testAABBAABB(AutoFisico2.BBFinal, Policia.BBFinal) && inGame)
                {
                    if (SwitchFX)
                    {
                        AutoFisico1.choque.play(false);
                    }
                    AutoFisico2.Vida -= 5;
                }
            }
            //Colisiones entre los autos y el escenario
            foreach (var mesh in Plaza.Meshes)
            {
                if (TgcCollisionUtils.testAABBAABB(AutoFisico1.BBFinal, mesh.BoundingBox) && inGame)
                {
                    if (SwitchFX)
                    {
                        AutoFisico1.choque.play(false);
                    }
                    AutoFisico1.Vida -= 5;
                }
                if (TgcCollisionUtils.testAABBAABB(AutoFisico2.BBFinal, mesh.BoundingBox) && inGame)
                {
                    if (SwitchFX)
                    {
                        AutoFisico1.choque.play(false);
                    }
                    AutoFisico2.Vida -= 5;
                }
            }

            switch (SwitchCamara)
            {
            case 1:
            {
                Camara        = Camara01;
                JugadorActivo = AutoFisico1;
                pantallaDoble = false;
                if (input.keyPressed(Key.F6) && juegoDoble)
                {
                    SwitchCamara = 2;
                }
                else if (input.keyPressed(Key.F7))
                {
                    SwitchCamara = 3;
                }
                break;
            }

            case 2:
            {
                Camara        = Camara02;
                JugadorActivo = AutoFisico2;
                pantallaDoble = false;
                if (input.keyPressed(Key.F5))
                {
                    SwitchCamara = 1;
                }
                else if (input.keyPressed(Key.F7))
                {
                    SwitchCamara = 3;
                }
                break;
            }

            case 3:
            {
                Camara        = Camara03;
                pantallaDoble = true;
                if (input.keyPressed(Key.F5))
                {
                    SwitchCamara = 1;
                }
                else if (input.keyPressed(Key.F6) && juegoDoble)
                {
                    SwitchCamara = 2;
                }
                break;
            }
            }

            switch (SwitchMusica)
            {
            case true:
            {
                Sonidos.SuenaMusica();
                if (Input.keyPressed(Key.F8))
                {
                    SwitchMusica = false;
                }
                break;
            }

            case false:
            {
                Sonidos.ParaMusica();
                if (Input.keyPressed(Key.F8))
                {
                    SwitchMusica = true;
                }
                break;
            }
            }
            switch (SwitchFX)
            {
            case true:
            {
                Sonidos.SuenaTribuna();
                if (Input.keyPressed(Key.F9))
                {
                    SwitchFX = false;
                }
                break;
            }

            case false:
            {
                Sonidos.ParaTribuna();
                if (Input.keyPressed(Key.F9))
                {
                    SwitchFX = true;
                }
                break;
            }
            }

            switch (SwitchInvisibilidadJ1)
            {
            case 1:
            {
                Jugadores[0] = AutoFisico1;
                if (Input.keyPressed(Key.F3))
                {
                    Jugadores[0].Invisible = true;
                    SwitchInvisibilidadJ1  = 2;
                }
                break;
            }

            case 2:
            {
                Jugadores[0] = null;
                if (Input.keyPressed(Key.F3))
                {
                    AutoFisico1.Invisible = false;
                    SwitchInvisibilidadJ1 = 1;
                }
                break;
            }

            default:
            {
                if (Input.keyPressed(Key.F3))
                {
                    Jugadores[0].Invisible = true;
                    SwitchInvisibilidadJ1  = 2;
                }
                break;
            }
            }
            if (juegoDoble)
            {
                switch (SwitchInvisibilidadJ2)
                {
                case 1:
                {
                    Jugadores[1] = AutoFisico2;
                    if (Input.keyPressed(Key.F4))
                    {
                        Jugadores[1].Invisible = true;
                        SwitchInvisibilidadJ2  = 2;
                    }
                    break;
                }

                case 2:
                {
                    Jugadores[1] = null;
                    if (Input.keyPressed(Key.F4))
                    {
                        AutoFisico2.Invisible = false;
                        SwitchInvisibilidadJ2 = 1;
                    }
                    break;
                }

                default:
                {
                    if (Input.keyPressed(Key.F4))
                    {
                        Jugadores[1].Invisible = true;
                        SwitchInvisibilidadJ2  = 2;
                    }
                    break;
                }
                }
            }

            PostUpdate();
        }
Exemplo n.º 2
0
        public override void Update()
        {
            PreUpdate();

            var input = Input;

            //Camaras
            Camara01 = new CamaraAtrasAF(AutoFisico1);
            Camara02 = new CamaraAtrasAF(AutoFisico2);
            Camara03 = new CamaraEspectador();

            GrupoPolicias.Update(juegoDoble);
            AutoFisico1.Update(input, Plaza, GrupoPolicias, InGame);
            AutoFisico2.Update(input, Plaza, GrupoPolicias, InGame);

            switch (SwitchCamara)
            {
            case 1:
            {
                Camara        = Camara01;
                JugadorActivo = AutoFisico1;
                pantallaDoble = false;
                if (input.keyPressed(Key.F6) && juegoDoble)
                {
                    SwitchCamara = 2;
                }
                else if (input.keyPressed(Key.F7))
                {
                    SwitchCamara = 3;
                }
                break;
            }

            case 2:
            {
                Camara        = Camara02;
                JugadorActivo = AutoFisico2;
                pantallaDoble = false;
                if (input.keyPressed(Key.F5))
                {
                    SwitchCamara = 1;
                }
                else if (input.keyPressed(Key.F7))
                {
                    SwitchCamara = 3;
                }
                break;
            }

            case 3:
            {
                Camara        = Camara03;
                JugadorActivo = null;;
                pantallaDoble = true;
                if (input.keyPressed(Key.F5))
                {
                    SwitchCamara = 1;
                }
                else if (input.keyPressed(Key.F6) && juegoDoble)
                {
                    SwitchCamara = 2;
                }
                break;
            }
            }

            switch (SwitchMusica)
            {
            case true:
            {
                Sonidos.SuenaMusica();
                if (Input.keyPressed(Key.F8))
                {
                    SwitchMusica = false;
                }
                break;
            }

            case false:
            {
                Sonidos.ParaMusica();
                if (Input.keyPressed(Key.F8))
                {
                    SwitchMusica = true;
                }
                break;
            }
            }
            switch (SwitchFX)
            {
            case true:
            {
                Sonidos.SuenaTribuna();
                if (Input.keyPressed(Key.F9))
                {
                    SwitchFX = false;
                }
                break;
            }

            case false:
            {
                Sonidos.ParaTribuna();
                if (Input.keyPressed(Key.F9))
                {
                    SwitchFX = true;
                }
                break;
            }
            }
            if (Input.keyPressed(Key.F3))
            {
                AutoFisico1.SwitchInvisibile();
            }

            if (Input.keyPressed(Key.F4))
            {
                AutoFisico2.SwitchInvisibile();
            }

            PostUpdate();
        }