Example #1
0
 // pelotaPerdida = funcion de cuando se cae la pelota
 void pelotaPerdida()
 {
     if (transform.position.y < -4)    //AL PERDER UNA PELOTA
     {
         if (scriptGM.cntPelotas != 1) //AL HABER MAS DE UNA PELOTA
         {
             scriptGM.cntPelotas--;    //resto una pelota a la variable GM
             Destroy(gameObject);
         }
         else //AL NO HABER PELOTAS EN JUEGO(se cayo la ultima)
         {
             scriptGM.contadorVidasPerdidas++;
             scriptGM.vidasTotalesPerdidas++;
             posicionarPelota();
             vaus.desactivarUpgrades();
             vaus.reiniciarFuerzaDeRebote();
             Pelota scriptPelota = GameObject.Find("pelota").GetComponent <Pelota>();
             scriptPelota.segLargada = scriptGM.segundos + esperaLargada; //al caer la ultima pelota reinicio el contador para q espere al largar la pelota
             scriptGM.vidas--;                                            //al caer la ultima pelota descuento una vida
             PlayerPrefs.SetInt("vidas", scriptGM.vidas);                 //guardo en disco el valor actual de vidas para tener las mismas en el sig. nivel
             AudioSource camara = GameObject.Find("Main Camera").GetComponent <AudioSource>();
             camara.pitch = 1f;                                           //la velocidad de la musica vuelve a la normalidad
             Instantiate(GM.esteObjeto.explosion, Svaus.esteObjeto.transform.position, Quaternion.identity);
             Svaus.esteObjeto.reproducirSonidoExplosion();
             Svaus.esteObjeto.iniciarVaus();
         }
     }
 }
Example #2
0
    /// <summary>
    /// es el upgrade de lanzar 2 pelotas
    /// </summary>
    public void lanzarPelotas()
    {
        if (scriptGM.segundos - recargando > .5 && bLanzarPelotas == true)
        {
            recargando = scriptGM.segundos;
            Svaus vaus = GameObject.Find("Vaus").GetComponent <Svaus>();//busca el objeto del script y lo asigna a la variable
            vaus.bLanzarPelotas = false;
            vaus.bAnimPelotas   = false;

            GameObject pelota2 = scriptGM.pelotaParaLanzar1;
            GameObject pelota3 = scriptGM.pelotaParaLanzar2;

            Vector3 posPelota2 = new Vector3(vaus.transform.position.x + 0.5f, vaus.transform.position.y + 0.4f, 0);
            Vector3 posPelota3 = new Vector3(vaus.transform.position.x - 0.5f, vaus.transform.position.y + 0.4f, 0);
            pelota2.transform.position = posPelota2;//las posiciones de las pelotas q van a dispararse
            pelota3.transform.position = posPelota3;

            scriptGM.cntPelotas += 2;                                                               //aumenta la variable de pelotas en 3
            Instantiate(pelota2, pelota2.transform.position, Quaternion.identity);                  //crea una pelota mas
            pelota2.name = "pelota2";
            Instantiate(pelota3, pelota3.transform.position, Quaternion.identity);                  //crea una pelota mas
            pelota3.name = "pelota3";
            Pelota    scriptPelota2 = GameObject.Find("pelota2(Clone)").GetComponent <Pelota>();    //le pongo el nombre de "pelota" a todas las pelotas
            Rigidbody rb2           = GameObject.Find("pelota2(Clone)").GetComponent <Rigidbody>(); //le pongo el nombre de "pelota" a todas las pelotas
            scriptPelota2.name = "pelota";
            Pelota    scriptPelota3 = GameObject.Find("pelota3(Clone)").GetComponent <Pelota>();
            Rigidbody rb3           = GameObject.Find("pelota3(Clone)").GetComponent <Rigidbody>(); //le pongo el nombre de "pelota" a todas las pelotas
            scriptPelota3.name = "pelota";
            if (sonidoDispPel)
            {
                AudioSource.PlayClipAtPoint(sonidoDispPel, transform.position, 2);
            }
        }
    }
        /// <summary>
        /// Genera un formulario para vender el producto Pelota.
        /// Si se vende con exito y el stock del producto llega a cero, lo elimina de la lista.
        /// </summary>
        private void VenderPelotas()
        {
            int     i    = this.dgvGrilla.SelectedRows[0].Index;
            DataRow fila = this.dtPelotas.Rows[i];

            EDeporte deporte = (EDeporte)Enum.Parse(typeof(EDeporte), fila["deporte"].ToString(), true);
            string   marca   = fila["marca"].ToString();
            float    precio  = float.Parse(fila["precio"].ToString());
            int      stock   = int.Parse(fila["stock"].ToString());

            Pelota             pelota = new Pelota(marca, precio, stock, deporte);
            FormVenta <Pelota> frm    = new FormVenta <Pelota>(pelota);

            frm.StartPosition = FormStartPosition.CenterScreen;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.Producto.Stock == 0)
                {
                    fila.Delete();
                }
                else if (frm.Producto.Stock > 0)
                {
                    fila["stock"] = frm.Producto.Stock;
                }
                this.registros.pelotasVendidas.Add(frm.Venta);
            }
        }
Example #4
0
    /// <summary>
    /// Revisa si el objeto colisionado es una pelota. En caso afirmativo, resta vida y calcula el nuevo color que debe tomar el shader.
    /// Si la vida fuera 0, avisa a Level Manager y se destruye.
    /// </summary>
    /// <param name="collision"></param>
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Pelota p = collision.gameObject.GetComponent <Pelota>();

        if (p != null)
        {
            currentHealth--;

            if (currentHealth <= 0)
            {
                GameManager.instance.GetLevelManager().SumaPuntos();
                Destroy(gameObject);
            }
            else
            {
                float healthPercentage = (currentHealth * 100) / maxHealth;
                //Si % de vida es mayor a 50, estĆ” en el rango "primer golpe".
                //En caso contrario estarĆ” en el segundo rango.
                if (healthPercentage > 50)
                {
                    GetComponent <Renderer>().material.SetColor("_Color", firstHit);
                }
                else
                {
                    GetComponent <Renderer>().material.SetColor("_Color", secondHit);
                }
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Pelota p = collision.GetComponent <Pelota>();

        if (p != null)
        {
            if (!Usado)
            {
                Usado = true;
                LevelManager.instance.RestaPowerUp(gameObject);
            }

            //Activa el rayo en funciĆ³n de si es horizontal o vertical
            switch (Tipo)
            {
            case TipoLaser.Vertical:
                RaycastVertical();
                break;

            case TipoLaser.Horizontal:
                RaycastHorizontal();
                break;
            }

            //Activa la parte visual
            Laser Rayo = gameObject.GetComponentInChildren <Laser>(true);
            Rayo.gameObject.SetActive(true);
        }
    }
Example #6
0
 private void OnLightningBallDisable(Pelota obj)
 {
     if (this != null)
     {
         this.boxCollider.isTrigger = false;
     }
 }
Example #7
0
    // guardarJuego = guarda la partida en el disco para poder continuarla despues
    public void guardarJuego()
    {
        Pelota pelota = GameObject.Find("pelota").GetComponent <Pelota>();//busca el objeto

        if (pelota.transform.position.y >= 0)
        {
            GM.esteObjeto.mostrarPublicidad();
            //guardar un string con los bloques q se rompieron y al poner "guardar"
            //guardar ese sting en el disco y modificar las funciones correspondientes

            /*otra opcion ir guardando en un string cuando se rompe un bloque con su color y pos
             * y al apretar guardar se guarda ese string en disco luego al cargar se carga el nivel
             * completo pero se lee el archivo guardado y se destruyen los bloques q indiquen(hacerlo antes
             * de asignar las capsulas)*/

            GM scriptGM = GameObject.Find("GM").GetComponent <GM>();
            PlayerPrefs.SetInt("continuarNivel", scriptGM.nivel);
            PlayerPrefs.SetInt("vidasGuardadas", scriptGM.vidas);
            //File.Delete(Application.persistentDataPath + "/saves/slot1.bin");
            crearNiveles scriptCrearNiveles = GameObject.Find("crear").GetComponent <crearNiveles>();
            Time.timeScale = 1;
            fpausa         = false;
            if (scriptCrearNiveles.guardarJuego())
            {
                SceneManager.LoadScene("menuPrincipal");
            }
        }
        else
        {
            Time.timeScale = 1;
            fpausa         = false;
            Scanvas.esteObjeto.slider.gameObject.GetComponent <Slider>().enabled = true;
        }
    }
Example #8
0
        protected override void InicializarComponentes()
        {
            playerOne = new Paleta(manejador.CargarRecurso <Texture2D>("Texturas/" + coloresPaletaP1[ColoresIndexP1]),
                                   PlayerPaleta.PlayerOne, new Point(20, 100));
            playerTwo = new Paleta(manejador.CargarRecurso <Texture2D>("Texturas/" + coloresPaletaP2[ColoresIndexP2]),
                                   PlayerPaleta.PlayerTwo, new Point(20, 100));

            playerOne.Rapidez = Paleta.RapidezBase * MultiplicadorDeRapidez;
            playerTwo.Rapidez = Paleta.RapidezBase * MultiplicadorDeRapidez;

            tipoDeLetraPuntaje = manejador.CargarRecurso <SpriteFont>("Fonts/fontPuntaje");
            puntajeSize        = tipoDeLetraPuntaje.MeasureString("998");
            puntajeOffset      = 100;
            posicionPuntaje1   = new Vector2(puntajeOffset, 30);
            int p2offset = puntajeOffset + (int)puntajeSize.X;

            posicionPuntaje2 = new Vector2(LimitesDeVentana.X - p2offset, 30);


            Vector2 medidasGano = tipoDeLetraPuntaje.MeasureString("Player Xxx gana!");

            alguienGanoPosicion = new Vector2(CentroDeVentana.X - (medidasGano.X / 2),
                                              CentroDeVentana.Y - (medidasGano.Y / 2));

            pelota         = new Pelota(manejador.CargarRecurso <Texture2D>("Texturas/pongPelota"), new Point(30, 30));
            pelota.Rapidez = Pelota.RapidezBase * MultiplicadorDeRapidez;

            fondoTextura = manejador.CargarRecurso <Texture2D>("Texturas/pongBackground2");
            fondoSize    = new Point((int)LimitesDeVentana.X, (int)LimitesDeVentana.Y);
        }
Example #9
0
 public Jugador(TgcSkeletalMesh skeletalMesh, IJugadorMoveStrategy strategy, Pelota pelota)
 {
     this.skeletalMesh     = skeletalMesh;
     this.box              = TgcBox.fromExtremes(this.skeletalMesh.BoundingBox.PMin, this.skeletalMesh.BoundingBox.PMax);
     this.strategy         = strategy;
     this.pelota           = pelota;
     this.posicionOriginal = skeletalMesh.Position;
 }
Example #10
0
 public Jugador(TgcSkeletalMesh skeletalMesh, IJugadorMoveStrategy strategy, Pelota pelota)
 {
     this.skeletalMesh = skeletalMesh;
     this.box = TgcBox.fromExtremes(this.skeletalMesh.BoundingBox.PMin, this.skeletalMesh.BoundingBox.PMax);
     this.strategy = strategy;
     this.pelota = pelota;
     this.posicionOriginal = skeletalMesh.Position;
 }
Example #11
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Pelota p = collision.gameObject.GetComponent <Pelota>();

        if (p != null)
        {
            RestaVida();
        }
    }
Example #12
0
        public FormPelota(Pelota p) 
            : this()
        {
            this.p = p;

            this.txtDeporte.Text = p.Deporte.ToString();
            this.txtMarca.Text = p.Marca;
            this.txtPrecio.Text = p.Precio.ToString();
            this.txtStock.Text = p.Stock.ToString();
        }
Example #13
0
    /// <summary>
    /// Cuando un objeto atraviesa la deathzone, busca si son pelota u bloque.
    /// Si detecta uno de esos dos, el juego terminarĆ”
    /// </summary>
    /// <param name="collision"></param>
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Pelota p = collision.GetComponent <Pelota>();
        Bloque b = collision.GetComponent <Bloque>();

        if (p != null || b != null)
        {
            GameManager.instance.GetLevelManager().OnPlayerDeath();
        }
    }
Example #14
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Pelota p = collision.GetComponent <Pelota>();

        if (p != null)
        {
            //Notificamos al Levelmanager que ha llegado una pelota
            LevelManager.instance.LlegadaPelota(p);
        }
    }
Example #15
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Pelota")
        {
            Pelota pelota = collision.GetComponent <Pelota>();

            ballsManagers.Instance.pelotas.Remove(pelota);
            pelota.Die();
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Pelota p = collision.GetComponent <Pelota>();

        //Si es una pelota, activo la flecha
        if (p != null)
        {
            flecha.gameObject.SetActive(true);
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Pelota aux = collision.gameObject.GetComponent <Pelota>();

        if (aux != null)
        {
            LevelManager.instance.SumaPelotasAlNumeroMaximo(bolasQueSuma);
            LevelManager.instance.InsertaObjetoParaEliminar(gameObject);
            Destroy(this.gameObject);
        }
    }
        private bool SigoColisionadoConPelota(Pelota pelota, Jugador jugador)
        {
            TgcCollisionUtils.BoxBoxResult result = TgcCollisionUtils.classifyBoxBox(pelota.BoundingBox, jugador.GetTgcBoundingBox());

            if (result == TgcCollisionUtils.BoxBoxResult.Adentro || result == TgcCollisionUtils.BoxBoxResult.Atravesando)
            {
                return(true);
            }

            return(false);
        }
 // Metodo que calcula si la pelota ha chocado con alguno de los bordes horizontales
 public void ChoquePared(Pelota ball)
 {
     if ((ball.GetPos().X) <= bordeY1)
     {
         ball.ChoqueX();
     }
     if ((ball.GetPos().X + ball.GetTam()) >= bordeY2)
     {
         ball.ChoqueX();
     }
 }
 // Metodo que calcula si se ha marcdo un punto
 public int PuntoMarcado(Pelota ball, Pala p1, Pala p2)
 {
     if (ball.GetPos().Y < 0)
     {
         return(2); // Marca el jugador 2
     }
     if ((ball.GetPos().Y + ball.GetTam()) > bordeX)
     {
         return(1); // Marca el jugador 1
     }
     return(0);     // Nadie ha marcado
 }
Example #21
0
    private void InitBall()
    {
        Vector3 posicionBarra    = barra.Instance.gameObject.transform.position;
        Vector3 startingPosition = new Vector3(posicionBarra.x, posicionBarra.y + .27f, 0);

        pelota_inicial  = Instantiate(pelota_Prefab, startingPosition, Quaternion.identity);
        pelotaInicialRB = pelota_inicial.GetComponent <Rigidbody2D>();

        this.pelotas = new List <Pelota> {
            pelota_inicial
        };
    }
    /// <summary>
    /// Determina la posicion nueva del spawner si es la primera bola
    /// Llama a la bola para avisarla de que modifique su comportamiento
    /// </summary>
    /// <param name="pelota">Pelota del deathzone</param>
    public void LlegadaPelota(Pelota pelota)
    {
        if (!llegadaPrimeraPelota)
        {
            llegadaPrimeraPelota = true;
            SetSpawnerVisible(true);
            spawnerPosition.x = pelota.gameObject.transform.position.x;
            spawner.ActualizaPosicionSpawner(spawnerPosition);
        }

        pelota.GoToSpawner(10, RestaPelota);
    }
Example #23
0
    /// <summary>
    /// Genera numPelotas instancias del prefab de Pelota que recibe,
    /// Mediante una coroutina que las instancia en la posicion del raton
    /// en el momento en el que el mƩtodo fue llamado.
    /// </summary>
    /// <param name="numPelotas">Numero de pelotas que tiene que generar</param>
    /// <param name="p">PRefab de pelota</param>
    public void GeneraPelotas(int numPelotas, Pelota p)
    {
        //Desactivar el texto

        Vector3 mousePos  = Input.mousePosition;
        Vector2 targetPos = Camera.main.ScreenToWorldPoint(new Vector2(mousePos.x, mousePos.y));
        Vector2 posOrigen = new Vector2(transform.position.x, transform.position.y);

        //Calcular la direccion restando el target a la posicion de origen2D
        targetPos -= posOrigen;


        StartCoroutine(InstanciaPelota(numPelotas, p, targetPos, transform.position));
    }
Example #24
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.name == "Vaus")                               //cuando choca con la vaus activa la habilidad
     {
         Svaus vaus = GameObject.Find("Vaus").GetComponent <Svaus>(); //busca el objeto del script y lo asigna a la variable
         vaus.desactivarUpgrades();                                   //desactivo cualquier otro upgrade
         scriptGM.capsulaEnCaida = false;
         Pelota pelota = GameObject.Find("pelota").GetComponent <Pelota>();
         pelota.color           = true;
         pelota.tiempoDeUpGrade = GM.esteObjeto.segundos + 20;
         pelota.tiempoDeColor   = GM.esteObjeto.segundos + 2;
         Destroy(gameObject);//y destruye la capsula
     }
 }
Example #25
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        bool instantKill = false;

        if (collision.tag == "Pelota")
        {
            Pelota pelota = collision.gameObject.GetComponent <Pelota>();
            instantKill = pelota.isLightningBall;
        }

        if (collision.tag == "Pelota" || collision.tag == "Projectile")
        {
            this.TakeDamage(instantKill);
        }
    }
Example #26
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Controlador()
 {
     this.raquetaEnemigo        = new Raqueta();
     this.raquetaJugador        = new Raqueta();
     this.raquetaJugador.Pegada = 8;
     this.raquetaEnemigo.Pegada = 6;
     this.marcador = new Puntuacion();
     this.raquetaJugador.Posicion = new System.Drawing.Point(100, 235);
     this.destino = this.RaquetaJugador.Posicion;
     this.raquetaJugador.Velocidad = 3;
     this.raquetaEnemigo.Velocidad = 2;
     this.raquetaEnemigo.Posicion  = new System.Drawing.Point(100, 5);
     this.bola = new Pelota();
     this.ComienzaJuego();
 }
Example #27
0
 public void SpawnBalls(Vector3 position, int count, bool isLightningBall)
 {
     for (int i = 0; i < count; i++)
     {
         Pelota spawnedBall = Instantiate(pelota_Prefab, position, Quaternion.identity) as Pelota;
         if (isLightningBall)
         {
             spawnedBall.StartLightningBall();
         }
         Rigidbody2D spawnedBallRB = spawnedBall.GetComponent <Rigidbody2D>();
         spawnedBallRB.isKinematic = false;
         spawnedBallRB.AddForce(new Vector2(0, velocidadPelotaInicial));
         this.pelotas.Add(spawnedBall);
     }
 }
Example #28
0
        public void AccionConPelota(Jugador jugador, float elapsedTimePelota, Pelota pelota)
        {
            if (!this.inteligenciaArtificial)
            {
                return;
            }

            //TODO revisar ĀæPorque con pelot no se mveria??
            if (!this.TengoQueMoverme(jugador))
            {
                jugador.playAnimation(jugador.AnimacionParado, true);
                return;
            }

            Vector3 direccion = jugador.EquipoPropio.ArcoRival.Red.GetPosition() - jugador.Position;

            direccion.Normalize();

            //Por ahora hago esto... :p, pero hay que pensar una IA real :)
            double tamanoCanchaParcial = Partido.Instance.Cancha.Size.Length() / 3;
            double distanciaArco       = (jugador.EquipoPropio.ArcoRival.Red.GetPosition() - jugador.Position).Length();
            double distanciaArcoPropio = (jugador.EquipoPropio.ArcoPropio.Red.GetPosition() - jugador.Position).Length();

            if (jugador.Atacando)
            {
                if (distanciaArco < tamanoCanchaParcial)
                {
                    pelota.Patear(direccion, this.semilla.Next(this.maximoFuerzaPatear * MULTIPLICADOR_FUERZA_PATEAR));
                }
                else
                {
                    if (distanciaArcoPropio < tamanoCanchaParcial / 3)
                    {
                        pelota.Patear(direccion, this.maximoFuerzaPatear * MULTIPLICADOR_FUERZA_PATEAR);
                    }
                    else
                    {
                        pelota.Mover(direccion);
                    }
                }
            }
            else
            {
                pelota.Patear(direccion, this.semilla.Next(this.maximoFuerzaPatear * MULTIPLICADOR_FUERZA_PATEAR));
            }

            jugador.PelotaDominada = false;
        }
    //GM es notificado de que ha llegado una pelota
    //Si es la ultima, reset del bool de posicion del Spawner
    public void RestaPelota(Pelota pelotaQuitada)
    {
        //La sacamos de la lista
        numPelotasAct--;

        ListaPelotas.Remove(pelotaQuitada);

        Destroy(pelotaQuitada.gameObject);

        //TODO: BOOL AQUI PARA DETERMINAR SI NO SE HA LLAMADO ANTES

        if (numPelotasAct == 0) //Si han llegado todas las pelotas
        {
            PreparaSiguienteGameRound();
        }
    }
        public void AccionConPelota(Jugador jugador, float elapsedTimePelota, Pelota pelota)
        {
            if (!this.inteligenciaArtificial)
            {
                return;
            }

            //TODO revisar ĀæPorque con pelot no se mveria??
            if (!this.TengoQueMoverme(jugador))
            {
                jugador.playAnimation(jugador.AnimacionParado, true);
                return;
            }

            Vector3 direccion = jugador.EquipoPropio.ArcoRival.Red.GetPosition() - jugador.Position;
            direccion.Normalize();

            //Por ahora hago esto... :p, pero hay que pensar una IA real :)
            double tamanoCanchaParcial = Partido.Instance.Cancha.Size.Length() / 3;
            double distanciaArco = (jugador.EquipoPropio.ArcoRival.Red.GetPosition() - jugador.Position).Length();
            double distanciaArcoPropio = (jugador.EquipoPropio.ArcoPropio.Red.GetPosition() - jugador.Position).Length();

            if (jugador.Atacando)
            {
                if (distanciaArco < tamanoCanchaParcial)
                {
                    pelota.Patear(direccion, this.semilla.Next(this.maximoFuerzaPatear * MULTIPLICADOR_FUERZA_PATEAR));
                }
                else
                {
                    if (distanciaArcoPropio < tamanoCanchaParcial / 3)
                    {
                        pelota.Patear(direccion, this.maximoFuerzaPatear * MULTIPLICADOR_FUERZA_PATEAR);
                    }
                    else
                    {
                        pelota.Mover(direccion);
                    }
                }
            }
            else
            {
                pelota.Patear(direccion, this.semilla.Next(this.maximoFuerzaPatear * MULTIPLICADOR_FUERZA_PATEAR));
            }

            jugador.PelotaDominada = false;
        }
        public void moverPelota(Pelota ov)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                Canvas ct = cancha[ov.antx, ov.anty];
                if ((string)ct.Tag == "pl")
                {
                    Grid.SetColumn(ct, ov.PX);
                    Grid.SetRow(ct, ov.PY);
                    cancha[ov.PX, ov.PY]     = ct;
                    cancha[ov.antx, ov.anty] = null;
                    ov.antx = 0; //Incorporar en la propiedad
                    ov.anty = 0;

                    if (ov.PX == 0 || ov.PX == 49)
                    {
                        if (ov.ultimoTirador == equipo.azul)
                        {
                            if (ov.PX == 49)
                            {
                                this.agoles++;
                            }
                            else
                            {
                                this.rgoles++;
                                MessageBox.Show("derp");
                            }
                            this.initnMap();
                        }
                        else if (ov.ultimoTirador == equipo.rojo)
                        {
                            if (ov.PX == 49)
                            {
                                this.agoles++;
                                MessageBox.Show("derp");
                            }
                            else
                            {
                                this.rgoles++;
                            }
                            this.initnMap();
                        }
                    }
                }
            }));
        }
        private Vector3 CalcularDireccionDePateado(Jugador jugador, Pelota pelota, Vector3 movimiento)
        {
            Vector3 direccion = Vector3.Empty;

            if (movimiento.Equals(Vector3.Empty))
            {
                direccion = pelota.Position - jugador.Position;
            }
            else
            {
                direccion = new Vector3(movimiento.X, movimiento.Y, movimiento.Z);
            }

            direccion.Normalize();

            return(direccion);
        }
        /// <summary>
        /// Event handler for Kinect sensor's SkeletonFrameReady event
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            Skeleton[] skeletons = new Skeleton[0];

            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                    frame_act = skeletonFrame.FrameNumber; // Capturamos el nĆŗmero de frame en el que estamos
                }
            }

            using (DrawingContext dc = this.drawingGroup.Open())
            {
                dc.DrawRectangle(Brushes.White, null, new Rect(0, 0, RenderWidth, RenderHeight));

                if (skeletons.Length != 0)
                {
                    foreach (Skeleton skel in skeletons)
                    {
                        //RenderClippedEdges(skel, dc);

                        if (skel.TrackingState == SkeletonTrackingState.Tracked)
                        {

                            /****************************** IMPLEMENTACION DEL JUEGO *********************/
                            Point manoDer = new Point();
                            manoDer = SkeletonPointToScreen(skel.Joints[JointType.HandRight].Position);

                            if (etapa == 0)
                            {

                                menu.Visibility = System.Windows.Visibility.Visible;
                                Inicial1_1.Visibility = System.Windows.Visibility.Visible;
                                Inicial1_2.Visibility = System.Windows.Visibility.Visible;
                                Inicial2_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial2_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_3.Visibility = System.Windows.Visibility.Hidden;
                                anterior.Visibility = System.Windows.Visibility.Hidden;
                                siguiente.Visibility = System.Windows.Visibility.Visible;
                                ayuda.Visibility = System.Windows.Visibility.Hidden;
                                siguiente.Content = "SIGUIENTE";
                                puntuacionDos.Content = "0";
                                puntuacionUno.Content = "0";
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(375, 295, 150, 40));

                                // Boton Siguiente

                                if (tocaBoton(manoDer, bot_siguiente, new Point(150, 40))) // Toca el boton 'siguiente'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(375, 295, 150, 40));
                                    if (contando_sig == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_sig = true;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {

                                        if ((frame_ini + 45) <= (frame_act)) // Hemos presionado el boton 'siguiente'
                                        {
                                            etapa += 1;
                                            contando_sig = false;
                                            id_jug_bot = -1;
                                        }
                                    }
                                }

                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_sig) contando_sig = true;
                                    else
                                    {
                                        contando_sig = false;
                                        id_jug_bot = -1;
                                    }
                                }
                            }

                            if (etapa == 1)
                            {

                                Inicial1_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial1_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial2_1.Visibility = System.Windows.Visibility.Visible;
                                Inicial2_2.Visibility = System.Windows.Visibility.Visible;
                                Inicial3_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_3.Visibility = System.Windows.Visibility.Hidden;
                                anterior.Visibility = System.Windows.Visibility.Visible;
                                siguiente.Visibility = System.Windows.Visibility.Visible;
                                siguiente.Content = "SIGUIENTE";
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(115, 295, 150, 40));
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(375, 295, 150, 40));

                                // Boton Siguiente

                                if (tocaBoton(manoDer, bot_siguiente, new Point(150, 40))) // Toca el boton 'siguiente'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(375, 295, 150, 40));
                                    if (contando_sig == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_sig = true;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {
                                        if ((frame_ini + 45) <= (frame_act)) // Hemos presionado el boton 'siguiente'
                                        {
                                            id_jug_bot = -1;
                                            etapa += 1;
                                            contando_sig = false;
                                        }
                                    }
                                }
                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_sig) contando_sig = true;
                                    else
                                    {
                                        contando_sig = false;
                                        id_jug_bot = -1;
                                    }
                                }

                                // Boton Anterior

                                if (tocaBoton(manoDer, bot_anterior, new Point(150, 40))) // Toca el boton 'siguiente'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(115, 295, 150, 40));
                                    if (contando_ant == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_ant = true;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {
                                        if ((frame_ini + 45) <= (frame_act)) // Hemos presionado el boton 'anterior'
                                        {
                                            id_jug_bot = -1;
                                            etapa -= 1;
                                            contando_ant = false;
                                        }
                                    }
                                }
                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_ant) contando_sig = true;
                                    else
                                    {
                                        id_jug_bot = -1;
                                        contando_ant = false;
                                    }
                                }
                            }

                            if (etapa == 2)
                            {

                                Inicial1_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial1_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial2_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial2_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_1.Visibility = System.Windows.Visibility.Visible;
                                Inicial3_2.Visibility = System.Windows.Visibility.Visible;
                                Inicial3_3.Visibility = System.Windows.Visibility.Visible;
                                anterior.Visibility = System.Windows.Visibility.Visible;
                                siguiente.Visibility = System.Windows.Visibility.Visible;
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(115, 295, 150, 40));
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(375, 295, 150, 40));
                                siguiente.Content = "EMPEZAR";

                                // Boton Siguiente

                                if (tocaBoton(manoDer, bot_siguiente, new Point(150, 40))) // Toca el boton 'siguiente'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(375, 295, 150, 40));
                                    if (contando_sig == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_sig = true;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {
                                        if ((frame_ini + 45) <= (frame_act)) // Hemos presionado el boton 'siguiente'
                                        {
                                            id_jug_bot = -1;
                                            etapa += 1;
                                            contando_sig = false;
                                        }
                                    }
                                }
                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_sig) contando_sig = true;
                                    else
                                    {
                                        contando_sig = false;
                                        id_jug_bot = -1;
                                    }
                                }

                                // Boton Anterior

                                if (tocaBoton(manoDer, bot_anterior, new Point(150, 40))) // Toca el boton 'siguiente'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(115, 295, 150, 40));
                                    if (contando_ant == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_ant = true;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {
                                        if ((frame_ini + 45) <= (frame_act)) // Hemos presionado el boton 'anterior'
                                        {
                                            id_jug_bot = -1;
                                            etapa -= 1;
                                            contando_ant = false;
                                        }
                                    }
                                }
                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_ant) contando_sig = true;
                                    else
                                    {
                                        id_jug_bot = -1;
                                        contando_ant = false;
                                    }
                                }
                            }
                            if (etapa == 3)
                            {

                                menu.Visibility = System.Windows.Visibility.Hidden;
                                Inicial1_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial1_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial2_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial2_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_1.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_2.Visibility = System.Windows.Visibility.Hidden;
                                Inicial3_3.Visibility = System.Windows.Visibility.Hidden;
                                anterior.Visibility = System.Windows.Visibility.Hidden;
                                siguiente.Visibility = System.Windows.Visibility.Hidden;
                                puntuacionUno.Visibility = System.Windows.Visibility.Visible;
                                puntuacionDos.Visibility = System.Windows.Visibility.Visible;

                                pausa1.Visibility = System.Windows.Visibility.Visible;
                                pausa2.Visibility = System.Windows.Visibility.Visible;
                                reiniciar.Visibility = System.Windows.Visibility.Visible;
                                ayuda.Visibility = System.Windows.Visibility.Visible;

                                // Dibujar el fondo negro
                                dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight));
                                // Fondo blanco fuera de la zona de juego
                                dc.DrawRectangle(Brushes.White, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight / 6.0));
                                dc.DrawRectangle(Brushes.White, null, new Rect(0.0, RenderHeight - RenderHeight / 6.0, RenderWidth, RenderHeight / 6.0));

                                // Dibujamos un marco para diferenciar la pantalla
                                dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, RenderWidth, 2));
                                dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, 2, RenderHeight));
                                dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, RenderHeight - 2, RenderWidth, 2));
                                dc.DrawRectangle(Brushes.Black, null, new Rect(RenderWidth - 2, 0.0, 2, RenderHeight));

                                // Linea discontinua central
                                float ini = RenderHeight / 6, tam_ = 4;
                                while ((ini + tam_) <= RenderHeight - (RenderHeight / 6))
                                {
                                    dc.DrawRectangle(Brushes.White, null, new Rect((RenderWidth / 2) - (tam_ / 2), ini, tam_, tam_));
                                    ini += 2 * tam_;
                                }

                                // Pausa jugador 1
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(bot_pausa1.X, bot_pausa1.Y, 90, 30));
                                // Pausa jugador 2
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(bot_pausa2.X, bot_pausa2.Y, 90, 30));
                                // Reiniciar
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(bot_reiniciar.X, bot_reiniciar.Y, 110, 30));

                                // Ayuda
                                dc.DrawRectangle(Brushes.LightGreen, null, new Rect(bot_ayuda.X, bot_ayuda.Y, 40, 30));

                                // Identificacion del Skeleton
                                // El jugador que se encuentre en la mitad derecha controla esa pala y viceversa

                                if (SkeletonPointToScreen(skel.Joints[JointType.Head].Position).X < (RenderWidth / 2))
                                    skeleton_id = 1;
                                else
                                    skeleton_id = 2;

                                if (skeleton_id == 1) // Actualizamos la posicion del jugador 1
                                    pala1.CambiarPos(SkeletonPointToScreen(skel.Joints[JointType.HandRight].Position).Y);

                                if (skeleton_id == 2) // Actualizamos la posicion del jugador 2
                                    pala2.CambiarPos(SkeletonPointToScreen(skel.Joints[JointType.HandRight].Position).Y);

                                // Comprobamos si choca arriba o abajo
                                ChoquePared(ball);

                                // Comprobamos si choca con alguna de las palas de juego
                                ColisionPelota(ball, pala1, pala2);

                                // Comprobamos si algun jugador ha marcado
                                int marcado = PuntoMarcado(ball, pala1, pala2);

                                if (marcado > 0)
                                {
                                    // Actualizamos la puntuacion
                                    if (marcado == 1)
                                    {
                                        jugador1.Marcar();
                                        puntuacionUno.Content = jugador1.GetPuntuacion().ToString();
                                    }

                                    if (marcado == 2)
                                    {
                                        jugador2.Marcar();
                                        puntuacionDos.Content = jugador2.GetPuntuacion().ToString();
                                    }

                                    ball = new Pelota(new Point(RenderHeight / 2, RenderWidth / 2), ball.GetTam());
                                }

                                // Dibujamos las palas de juego
                                pala1.Dibujar(dc);
                                pala2.Dibujar(dc);

                                // Actualizamos la posicion de la pelota
                                ball.ActualizarPos();
                                ball.Dibujar(dc); // La dibujamos

                                // Funcionalidad de los botones
                                // Boton de pausa del jugador 1
                                if (tocaBoton(manoDer, bot_pausa1, new Point(90, 30))) // Toca el boton 'Pausar'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(bot_pausa1.X, bot_pausa1.Y, 90, 30));
                                    if (contando_pau1 == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_pau1 = true;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {
                                        if ((frame_ini + 40) <= (frame_act)) // Hemos presionado el boton 'Pausar'
                                        {
                                            id_jug_bot = -1;
                                            if (pausa==true)
                                            {
                                                ball.ActualizarVel(velx, vely);
                                                pausa = false;
                                            }
                                            else
                                            {
                                                ball.ActualizarVel(0.0, 0.0);
                                                velx = ball.GetVel().X;
                                                vely = ball.GetVel().Y;
                                                pausa = true;
                                            }
                                            contando_pau1 = false;
                                        }
                                    }
                                }
                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_pau1) contando_pau1 = true;
                                    else
                                    {
                                        id_jug_bot = -1;
                                        contando_pau1 = false;
                                    }
                                }

                                // Boton de pausa del jugador 2
                                if (tocaBoton(manoDer, bot_pausa2, new Point(90, 30))) // Toca el boton 'Pausar'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(bot_pausa2.X, bot_pausa2.Y, 90, 30));
                                    if (contando_pau2 == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_pau2 = true;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {
                                        if ((frame_ini + 40) <= (frame_act)) // Hemos presionado el boton 'Pausar'
                                        {
                                            id_jug_bot = -1;
                                            if (pausa==true)
                                            {
                                                ball.ActualizarVel(velx, velx);
                                                pausa = false;
                                            }
                                            else
                                            {
                                                ball.ActualizarVel(0.0, 0.0);
                                                velx = ball.GetVel().X;
                                                vely = ball.GetVel().Y;
                                                pausa = true;
                                            }
                                            contando_pau2 = false;
                                        }
                                    }
                                }
                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_pau2) contando_pau2 = true;
                                    else
                                    {
                                        id_jug_bot = -1;
                                        contando_pau2 = false;
                                    }
                                }

                                // Boton de reinicio
                                if (tocaBoton(manoDer, bot_reiniciar, new Point(110, 30))) // Toca el boton 'Reiniciar'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(bot_reiniciar.X, bot_reiniciar.Y, 110, 30));
                                    if (contando_rei == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_rei = true;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {
                                        if ((frame_ini + 60) <= (frame_act)) // Hemos presionado el boton 'Reiniciar'
                                        {
                                            id_jug_bot = -1;
                                            jugador1 = new Jugador();
                                            jugador2 = new Jugador();
                                            puntuacionUno.Content = jugador1.GetPuntuacion().ToString();
                                            puntuacionDos.Content = jugador2.GetPuntuacion().ToString();
                                            ball = new Pelota(new Point(RenderHeight/2, RenderWidth/2), ball.GetTam());
                                            contando_rei = false;
                                        }
                                    }
                                }
                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_rei) contando_rei = true;
                                    else
                                    {
                                        id_jug_bot = -1;
                                        contando_rei = false;
                                    }
                                }

                                // Boton de ayuda
                                if (tocaBoton(manoDer, bot_ayuda, new Point(40, 30))) // Toca el boton 'Ayuda'
                                {
                                    dc.DrawRectangle(Brushes.Green, null, new Rect(bot_ayuda.X, bot_ayuda.Y, 40, 30));
                                    if (contando_ayu == false)
                                    {
                                        id_jug_bot = skel.TrackingId;
                                        contando_ayu = true;
                                        volver.Visibility = System.Windows.Visibility.Visible;
                                        frame_ini = frame_act;
                                    }
                                    else
                                    {
                                        if ((frame_ini + 30) <= (frame_act)) // Hemos presionado el boton 'Ayuda'
                                        {
                                            id_jug_bot = -1;
                                            jugador1 = new Jugador();
                                            jugador2 = new Jugador();
                                            puntuacionUno.Content = jugador1.GetPuntuacion().ToString();
                                            puntuacionDos.Content = jugador2.GetPuntuacion().ToString();
                                            ball = new Pelota(new Point(RenderWidth / 2, RenderHeight / 2), ball.GetTam());
                                            volver.Visibility = System.Windows.Visibility.Hidden;
                                            etapa = 0;
                                            contando_ayu = false;

                                        }
                                    }
                                }
                                else
                                {
                                    if ((id_jug_bot != skel.TrackingId) && contando_ayu) contando_ayu = true;
                                    else
                                    {
                                        id_jug_bot = -1;
                                        contando_ayu = false;
                                        volver.Visibility = System.Windows.Visibility.Hidden;
                                    }
                                }

                            }

                            // Dibujamos la mano por encima de todo lo demas
                            dc.DrawEllipse(Brushes.Black, null, SkeletonPointToScreen(skel.Joints[JointType.HandRight].Position), 10, 10);

                        }
                        else if (skel.TrackingState == SkeletonTrackingState.PositionOnly)
                        {
                            dc.DrawEllipse(Brushes.Black, null, SkeletonPointToScreen(skel.Joints[JointType.HandRight].Position), 10, 10);
                        }
                    }
                }

                // prevent drawing outside of our render area
                this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, RenderWidth, RenderHeight));
            }
        }
Example #34
0
 public void ColisionasteConPelota(Pelota pelota)
 {
     //por ahora nada, aca tendria que hacer ruido de palo.
 }
Example #35
0
 /// /// <summary>
 /// Crea un jugador con IA
 /// </summary>
 /// <param name="pathRecursos"> De donde saco el mesh</param>
 /// /// <param name="pelota">La pelota del partido</param>
 /// <returns> Una lista de jugadores</returns>
 private Jugador CrearJugadorIA(string pathRecursos, string textura, Vector3 posicion, float angulo, Pelota pelota)
 {
     return this.CrearJugador(pathRecursos, textura, posicion, angulo, new JugadorIAStrategy(), pelota);
 }
Example #36
0
 private Jugador CrearArqueroIA(string pathRecursos, string textura, Vector3 posicion, float angulo, Pelota pelota)
 {
     //TODO deberia usar la inteligencia del arquero no la IA pero no la puedo hacer andar :(
     return this.CrearJugador(pathRecursos, textura, posicion, angulo, new JugadorIAStrategy(), pelota);
 }
Example #37
0
 /// <summary>
 /// Crea el jugador que hay que manejar manualmente
 /// </summary>
 /// <param name="pathRecursos"> De donde saco el mesh</param>
 /// /// /// <param name="pelota">La pelota del partido</param>
 /// <returns> El jugador controlado manualmente</returns>
 private Jugador CrearJugadorHumano(string pathRecursos, string textura, Vector3 posicion, float angulo, Pelota pelota, TgcD3dInput input)
 {
     return this.CrearJugador(pathRecursos, textura, posicion, angulo, new JugadorManualStrategy(input), pelota);
 }
Example #38
0
 public void ColisionasteConPelota(Pelota pelota)
 {
     Partido.Instance.NotificarPelotaDominada(this);
 }
        // Metodo que calcula si se ha marcdo un punto
        public int PuntoMarcado(Pelota ball, Pala p1, Pala p2)
        {
            if (ball.GetPos().Y < 0)
                return 2; // Marca el jugador 2

            if ((ball.GetPos().Y + ball.GetTam()) > bordeX)
                return 1; // Marca el jugador 1

            return 0; // Nadie ha marcado
        }
        //-----------------------------------------------------------------
        //
        // Metodos que calcula si ha colisionado la Pelota con una pala
        //
        //------------------------------------------------------------------
        public void ColisionPelota(Pelota ball, Pala p1, Pala p2)
        {
            // Comprobamos que la pelota no se choca con la pala 1
            if ((ball.GetPos().Y <= (p1.GetPos().X+10)) &&
                ((ball.GetPos().X >= p1.GetPos().Y) && (ball.GetPos().X <= (p1.GetPos().Y + p1.GetTam()))))
            {
                ball.ChoqueY();
            }

            // Comprobamos que la pelota no se choca con la pala 2

            if ((ball.GetPos().Y + ball.GetTam() > (p2.GetPos().X)) &&
                 ((ball.GetPos().X > p2.GetPos().Y) && (ball.GetPos().X < (p2.GetPos().Y + p2.GetTam()))))
            {
                ball.ChoqueY();
            }
        }
 // Metodo que calcula si la pelota ha chocado con alguno de los bordes horizontales
 public void ChoquePared(Pelota ball)
 {
     if ((ball.GetPos().X) <= bordeY1)
         ball.ChoqueX();
     if ((ball.GetPos().X + ball.GetTam()) >= bordeY2)
         ball.ChoqueX();
 }
Example #42
0
 public void ColisionasteConPelota(Pelota pelota)
 {
     //TODO Avisar al partido que se fue la pelota
 }
Example #43
0
        /// <summary>
        /// Creo un jugador basado en el Robot de TGC
        /// </summary>
        /// <param name="posicion">Posicion donde va a estar el jugador</param>
        /// <param name="angulo">El angulo donde va a mirar</param>
        /// <param name="pathRecursos"></param>
        /// <param name="nombreTextura">Que textura va a tener</param>
        /// <returns></returns>
        private Jugador CrearJugador(string pathRecursos, string nombreTextura, Vector3 posicion, float angulo, IJugadorMoveStrategy strategy, Pelota pelota)
        {
            //Cargar personaje con animaciones
            TgcSkeletalMesh personaje = new TgcSkeletalLoader().loadMeshAndAnimationsFromFile(
                pathRecursos + Settings.Default.meshFolderPlayer + Settings.Default.meshFilePlayer,
                pathRecursos + Settings.Default.meshFolderPlayer,
                new string[] {
                    pathRecursos + Settings.Default.meshFolderPlayer + Settings.Default.animationWalkFilePlayer,
                    pathRecursos + Settings.Default.meshFolderPlayer + Settings.Default.animationRunFilePlayer,
                    pathRecursos + Settings.Default.meshFolderPlayer + Settings.Default.animationStopFilePlayer,
                    }
                );

            //Le cambiamos la textura
            //personaje.changeDiffuseMaps(new TgcTexture[] {
            //    TgcTexture.createTexture(pathRecursos + Settings.Default.meshFolderPlayer + nombreTextura)
            //    });

            //TODO cambiar por matrices
            personaje.AutoTransformEnable = true;

            //Configurar animacion inicial
            personaje.playAnimation(Settings.Default.animationStopPlayer, true);
            personaje.Position = posicion;

            //Lo Escalo porque es muy grande
            personaje.Scale = new Vector3(0.5f, 0.5f, 0.5f);
            personaje.rotateY(Geometry.DegreeToRadian(angulo));

            //Recalculo las normales para evitar problemas con la luz
            personaje.computeNormals();

            Jugador jugador = new Jugador(personaje, strategy, pelota);
            jugador.ShadowEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshPlanarShadows.fx");
            jugador.LightEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\SkeletalMeshMultiplePointLight.fx");
            return jugador;
        }
Example #44
0
 public void ColisionasteConPelota(Pelota pelota)
 {
     //TODO feo que este vacio este metodo pero la Pelota no hace nada con la cancha
 }
Example #45
0
        /// <summary>
        /// Creo la pelota en el centro de la cancha
        /// </summary>
        /// <param name="pathRecursos"> De donde saco la textura</param>
        /// <returns> Una pelota</returns>
        private Pelota CrearPelota(string pathRecursos, Cancha cancha)
        {
            //int radio = 10; Original
            int radio = 6;
            //Crear esfera
            TgcSphere sphere = new TgcSphere();
            //TODO cambiar por matrices
            sphere.AutoTransformEnable = true;
            //sphere.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall));
            sphere.Radius = radio;
            sphere.Position = new Vector3(cancha.Position.X, cancha.Position.Y + radio, cancha.Position.Z);
            sphere.updateValues();

            Pelota pelota = new Pelota(sphere);
            pelota.ShadowEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshPlanarShadows.fx");
            pelota.LightEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshMultiplePointLight.fx");
            return pelota;
        }