Exemplo n.º 1
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;
        }
Exemplo n.º 2
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;
        }
        //TODO esto lo deberia ejecutar desde el animate and render o desde colisionastecon?
        public void AccionConPelota(Jugador jugador, float elapsedTime, Pelota pelota)
        {
            Vector3 movimiento = this.CalcularPosicionSegunInput(jugador, elapsedTime, d3dInput);

            //Si presiono S, paso la pelota
            if (this.d3dInput.keyPressed(Key.S))
            {
                jugador.Pelota.Pasar(jugador.EquipoPropio.JugadorMasCercano(jugador).Position, MULTIPLICADOR_FUERZA_PASAR);
                jugador.PelotaDominada = false;
                return;
            }

            //Si presiono A, paso la pelota
            if (this.d3dInput.keyPressed(Key.A))
            {
                jugador.Pelota.Centro(jugador.EquipoPropio.JugadorMasCercano(jugador).Position, MULTIPLICADOR_FUERZA_CENTRO);
                jugador.PelotaDominada = false;
                return;
            }

            //Si presiono D, comienzo a acumular cuanto patear
            if (this.d3dInput.keyDown(Key.D))
            {
                if (this.acumuladoPatear < this.maximoFuerzaPatear)
                {
                    this.acumuladoPatear += elapsedTime + 0.2f;
                }
                else
                {
                    Vector3 direccion = CalcularDireccionDePateado(jugador, pelota, movimiento);
                    jugador.Pelota.Patear(direccion, this.maximoFuerzaPatear * MULTIPLICADOR_FUERZA_PATEAR);
                    jugador.PelotaDominada = false;
                    this.acumuladoPatear   = minimoFuerzaPatear;

                    return;
                }
            }

            //Si suelto D pateo la pelota con la fuerza acumulada
            if (this.d3dInput.keyUp(Key.D) && this.acumuladoPatear != 0)
            {
                Vector3 direccion = CalcularDireccionDePateado(jugador, pelota, movimiento);
                jugador.Pelota.Patear(direccion, this.acumuladoPatear * MULTIPLICADOR_FUERZA_PATEAR);
                jugador.PelotaDominada = false;
                this.acumuladoPatear   = minimoFuerzaPatear;

                return;
            }

            //RENE: Revisar esto, si el jugador deja de coslionar con la pelota, entonces la suelta y no la tieen mas, esto arregla el tema de ir para atras, el codigo no es lindo, hace tu magia!
            if (this.SigoColisionadoConPelota(pelota, jugador))
            {
                if (movimiento != Vector3.Empty)
                {
                    pelota.Mover(movimiento);
                }
            }
            else
            {
                jugador.PelotaDominada = false;
            }
        }