Esempio n. 1
0
        private void ProcesarThings()
        {
            if (thingASeguir != null)
            {
                galaxia.Procesar(segundosTranscurridos, thingASeguir.Centro, RadioSectoresCercanosAProcesar);
            }

            if (!enDemo)
            {
                if (naveJugador.Eliminado == true)
                {
                    DialogoReiniciar guiDialogoReiniciar = new DialogoReiniciar("Fuiste destruido.", true);

                    guiEngine.Root.AddChildWindow(
                        guiDialogoReiniciar,
                        new Point(
                            (guiEngine.Root.Size.Width - guiDialogoReiniciar.Size.Width) / 2,
                            (guiEngine.Root.Size.Height - guiDialogoReiniciar.Size.Height) / 2));

                    guiEngine.Root.Focus = guiDialogoReiniciar;
                }
            }
            else
            {
                segundosDemoEnElMismoThing += segundosTranscurridos;

                if (segundosDemoEnElMismoThing > 30.0f || thingASeguir == null || thingASeguir.Eliminado)
                {
                    segundosDemoEnElMismoThing = 0.0f;

                    //Busco un nuevo thing a seguir al azar

                    System.Random rnd = new System.Random((int)DateTime.Now.Ticks);
                    thingASeguir = null;

                    int intentos = 30;

                    while (thingASeguir == null && intentos > 0)
                    {
                        int x = rnd.Next(-galaxia.TamanioEnSectores.Width / 2, galaxia.TamanioEnSectores.Width / 2);
                        int y = rnd.Next(-galaxia.TamanioEnSectores.Height / 2, galaxia.TamanioEnSectores.Height / 2);

                        Sector sector = galaxia.GetSector(new SectorID(x, y));

                        foreach (Thing thing in sector.Things)
                        {
                            if (thing is ThingNave)
                            {
                                thingASeguir = thing;
                                break;
                            }
                        }

                        intentos--;
                    }
                }
            }
        }
        void reiniciar_Pressed(GUIButton btn)
        {
            DialogoReiniciar guiDialogoReiniciar = new DialogoReiniciar(null, false);

            Father.AddChildWindow(
                guiDialogoReiniciar,
                new Point(
                    (Father.Size.Width - guiDialogoReiniciar.Size.Width) / 2,
                    (Father.Size.Height - guiDialogoReiniciar.Size.Height) / 2));

            Father.Focus = guiDialogoReiniciar;

            Close();
        }