示例#1
0
        protected void avaliarJogada()
        {
            KeyboardState newState = Keyboard.GetState();


            if (newState.IsKeyDown(Keys.Right))
            {
                aviao.direita();
            }

            if (newState.IsKeyDown(Keys.Left))
            {
                aviao.esquerda();
            }

            if (newState.IsKeyDown(Keys.Up))
            {
                aviao.frente();
            }

            if (newState.IsKeyDown(Keys.Down))
            {
                aviao.tras();
            }

            if ((newState.IsKeyDown(Keys.Space)) && (!tiroPreparado) && (tempoTiro <= 0))
            {
                tiroPreparado = true;
                tiro          = aviao.atirar(gt);
                if (tiro != null)
                {
                    tiro.Disparar();
                }

                tiroPreparado = false;
                tempoTiro     = 30;
                //tempoTiro = 100;
            }


            if ((newState.IsKeyUp(Keys.Space)) && (tiroPreparado))
            {
                /*tiro = aviao.atirar();
                 * tiro.Disparar();
                 * gt.Add(tiro);
                 * soundBank.PlayCue("Explosion");
                 * tiroPreparado = false;
                 * tempoTiro = 10;*/
            }


            if (newState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
        }
示例#2
0
        public GerenciadorTiro()
        {
            lista = new List <Tiro>(numTiros);

            for (int i = 0; i < numTiros; i++)
            {
                Tiro t = new Tiro(0, 0);
                lista.Add(t);
            }
        }
示例#3
0
        public Tiro atirar(GerenciadorTiro gt)
        {
            Tiro t = gt.getTiro();

            if (t != null)
            {
                t.pos    = this.pos;
                t.pos.X += 10;
                t.pos.Y += 5;
                t.Disparar();
            }
            return(t);
        }
示例#4
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     aviao          = new Aviao();
     tiro           = null;
     obstaculo      = null;
     tiroPreparado  = false;
     tempoTiro      = 0;
     gt             = new GerenciadorTiro();
     go             = new GerenciadorObstaculo();
     rnd            = new Random();
     IsMouseVisible = true;
     posbutton      = new Rectangle(250, 400, 300, 100);
     posButton2     = new Rectangle(250, 200, 300, 100);
     posButton3     = new Rectangle(250, 300, 300, 100);
     base.Initialize();
 }
示例#5
0
        public static void draw(Tiro tiro, SpriteBatch spriteBatch, Texture2D texture)
        {
            Rectangle r = new Rectangle((int)tiro.pos.X, (int)tiro.pos.Y, tiro.largura, tiro.altura);

            spriteBatch.Draw(texture, r, Color.White);
        }
示例#6
0
 public void Add(Tiro t)
 {
     lista.Add(t);
 }