Пример #1
0
        public bool AlarmaChoque(Flyer element)
        {
            bool      alarma        = false;
            Rectangle cuadradoFlyer = new Rectangle((int)element.Position.X - (int)(element.tFlyer.Width * 1.5f),
                                                    (int)element.Position.Y - (int)(element.tFlyer.Height * 1.5f),
                                                    (int)element.tFlyer.Width * 3,
                                                    (int)element.tFlyer.Height * 3);     //Rectangulo mas grande

            foreach (Flyer elementB in Global.flyers)
            {
                if ((element != elementB) &&
                    (!element.landed && !elementB.landed) &&
                    ((!element.touchDown && !elementB.touchDown) &&
                     ((cuadradoFlyer.Intersects(new Rectangle((int)elementB.Position.X - elementB.tFlyer.Width / 2,
                                                              (int)elementB.Position.Y - elementB.tFlyer.Height / 2,
                                                              (int)elementB.tFlyer.Width,
                                                              (int)elementB.tFlyer.Height))))))   //Si se intersectan se devuelve true
                {
                    alarma = true;
                    break;
                }
                else
                {
                    alarma = false;
                }
            }
            if (alarma)
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
 //Tutorial - start
 public static bool UpdateOnTutorial(GraphicsDevice graphicsD, Flyer element)
 {
     if (element.direccion < element.turningDir - 1)
     {
         element.direccion += 0.5f;
     }
     else if (element.direccion > element.turningDir + 1)
     {
         element.direccion -= 0.5f;
     }
     else
     {
         element.turningDir = element.direccion;
     }
     return(false);
 }
Пример #3
0
        } //Se decide si el tipo va a ser un OVNI (aterrizados = multipos de 5, excepto 1 y 5 Y excepto que todavia haya un ovni en el juego)

        public float SetPositionDireccion(Flyer flyobj, int heightVP, int widthVP, out float x, out float y)
        {
            switch (Global.random.Next(0, 4))
            {
            //se suma 1 porque el random no incluye el fin del intervalo //se resta el tamaño del sprite para que tarde en entrar al viewport
            case 0:
                //Borde Izquierda //Cualquier punto en Y
                x = 0;
                y = Global.random.Next(0, heightVP + 1);
                //Cualquier direccion que vaya hacia: derecha es decir no directo al borde. +30 -30 para que no avanze paralelo al borde
                return(Global.random.Next(30, 151));

            case 1:
                //Borde Derecha //Cualquier punto en Y
                x = widthVP;
                y = Global.random.Next(0, heightVP + 1);
                //Cualquier direccion que vaya hacia: izquierda es decir no directo al borde. +30 -30 para que no avanze paralelo al borde
                return(Global.random.Next(210, 331));

            case 2:
                //Borde Arriba //Cualquier punto en X
                x = Global.random.Next(0, widthVP + 1);
                y = 0;
                //Cualquier direccion que vaya hacia: abajo es decir no directo al borde. +30 -30 para que no avanze paralelo al borde
                return(Global.random.Next(120, 241));

            case 3:
                //Borde Abajo //Cualquier punto en X
                x = Global.random.Next(0, widthVP + 1);
                y = heightVP;
                //Cualquier direccion que vaya hacia: arriba es decir no directo al borde. +30 -30 para que no avanze paralelo al borde
                if (Global.random.Next(0, 2) == 0)
                {
                    return(Global.random.Next(0, 61));
                }
                else
                {
                    return(Global.random.Next(300, 361));
                }

            default:
                x = 0;
                y = 0;
                return(135);
            }
        }
Пример #4
0
        public bool Colisiones(Flyer element)
        {
            Rectangle cuadradoFlyer = new Rectangle((int)element.Position.X - element.tFlyer.Width / 2,  //Se debe restar la mitad del tamaño de la nave
                                                    (int)element.Position.Y - element.tFlyer.Height / 2, //para lograr la correcta ubicacion del rectangulo
                                                    (int)element.tFlyer.Width,
                                                    (int)element.tFlyer.Height);                         //Rectangulo de la aeronave A

            foreach (Flyer elementB in Global.flyers)
            {
                if ((element != elementB) &&
                    (!element.landed && !elementB.landed) &&
                    ((!element.touchDown && !elementB.touchDown) &&
                     ((cuadradoFlyer.Intersects(new Rectangle((int)elementB.Position.X - elementB.tFlyer.Width / 2,        //Se debe restar la mitad del tamaño de la nave
                                                              (int)elementB.Position.Y - elementB.tFlyer.Height / 2,       //para lograr la correcta ubicacion del rectangulo
                                                              (int)elementB.tFlyer.Width,
                                                              (int)elementB.tFlyer.Height))))))
                {
                    //If transparent
                    return(true);
                }
            }
            return(false);
        }
Пример #5
0
        //Update
        public static bool Update(GraphicsDevice graphicsD, int index, Flyer element, out int indexToRemove)
        {
            bool gameover = false;

            if (element.exists)                        //Si el elemento esta activo
            {
                if (element.moving || element.landing) //Solo si se encuentra en movimiento o aterrizando
                {
                    element.Mover(graphicsD);          //Se mueve, en la direccion que esta yendo * su velocidad
                    element.Landed(index);             //Se le da una nueva direccion hacia la pista/Se pregunta si ya llego a la pista/Se pregunta si llego al final de la pista
                    if (element.down && element.touchDown && element.scale > 0.40f)
                    {
                        element.scale -= 0.0030f; //Se achica el tamaño de la aeronave
                    }
                }
                else
                {
                    element.Girar(graphicsD); //Estado de "ESPERA", las aeronaves esperan girando en circulo
                }
            }
            //ALARMA DE CHOQUE
            if (element.AlarmaChoque(element)) //La alarma de choque es un "beep" que suena cuando dos aeronaves se encuentran muy cercanas.
            {
                //Funciona de la misma forma que las coliciones, pero con un rectangulo mayor
                //Console.Beep(1000, 10);
                if (!Global.soundmute)
                {
                    Global.SEInstances[0].Play();
                }
                else
                {
                    Global.SEInstances[0].Stop();
                }
            }
            //Colisiones
            Rectangle cuadradoFlyer = new Rectangle((int)element.Position.X - element.tFlyer.Width / 2,  //Se debe restar la mitad del tamaño de la nave
                                                    (int)element.Position.Y - element.tFlyer.Height / 2, //para lograr la correcta ubicacion del rectangulo
                                                    (int)element.tFlyer.Width,
                                                    (int)element.tFlyer.Height);                         //Rectangulo de la aeronave A

            foreach (Flyer elementB in Global.flyers)
            {
                if ((element != elementB) &&
                    (!element.landed && !elementB.landed) &&
                    ((!element.touchDown && !elementB.touchDown) &&
                     ((cuadradoFlyer.Intersects(new Rectangle((int)elementB.Position.X - elementB.tFlyer.Width / 2,  //Se debe restar la mitad del tamaño de la nave
                                                              (int)elementB.Position.Y - elementB.tFlyer.Height / 2, //para lograr la correcta ubicacion del rectangulo
                                                              (int)elementB.tFlyer.Width,
                                                              (int)elementB.tFlyer.Height))))))                      //Se pregunta si se intersecta con el rectangulo de la aeronave B
                {
                    gameover = true;
                    Global.partes.Clear();
                    foreach (Part part in element.partesFlyer)
                    {
                        part.PlacePart(element.Position);
                        Global.partes.Add(part);
                    }
                    foreach (Part part in elementB.partesFlyer)
                    {
                        part.PlacePart(elementB.Position);
                        Global.partes.Add(part);
                    }
                    if (!Global.soundmute)
                    {
                        Global.SEInstances[6].Play();
                    }
                    else
                    {
                        Global.SEInstances[6].Stop();
                    }
                    break; //como se modifica la lista es necesario salir del foreach
                }
                else
                {
                    gameover = false;
                }
            }
            if (gameover)
            {
                if (element.remove)
                {
                    indexToRemove = index; //Si una aeronave aterrizo de guarda su index en la lista para que sea eliminado de esta.
                }
                else
                {
                    indexToRemove = 100;
                }
                return(true);
            }
            else
            {
                if (element.remove)
                {
                    indexToRemove = index;
                }
                else
                {
                    indexToRemove = 100;
                }
                return(false);
            }
        }