Example #1
0
 public char Update(KeyboardState ks, Tempo Time, Song[] Musicas)
 {
     if (Time.tempoRestante <= TimeSpan.FromSeconds(0))
     {
         MediaPlayer.Play(Musicas[2]);
         Time.tempoRestante = TimeSpan.FromSeconds(5);
         return '0';
     }
     if (Restante <= 0)
     {
         Time.ConverteTempo();
         Time.ResetaTempo();
         return '4';
     }
     if (ks.IsKeyUp(Keys.J))
     {
         apertado = false;
     }
     if (ks.IsKeyDown(Keys.J) && apertado == false)
     {
         apertado = true;
         //if (Time.Total.Milliseconds % 30 == 0)
         //{
             Restante--;
         //}
     }
     return '3';
 }
Example #2
0
 public char Update(MouseState ms, Tempo Time, Song[] Musicas)
 {
     if (Time.tempoRestante <= TimeSpan.FromSeconds(0))
     {
         MediaPlayer.Play(Musicas[3]);
         Time.ResetaTempo();
         return 'k';
     }
     Voce.Pos = new Vector2(ms.X, ms.Y);
     if (ms.X <= 0)
     {
         Voce.Pos.X = 100;
     }
     if (ms.X >= 924)
     {
         Voce.Pos.X = 924;
     }
     if (ms.Y <= 0)
     {
         Voce.Pos.Y = 100;
     }
     if (ms.Y >= 768)
     {
         Voce.Pos.Y = 768;
     }
     foreach (Persona b in Inimigos)
     {
         b.Pos.Y += 5;
         if (b.Pos.Y > 768)
         {
             if (b.Vivo == true)
             {
                 MediaPlayer.Play(Musicas[2]);
                 Time.tempoRestante = TimeSpan.FromSeconds(5);
                 return '0';
             }
             else
             {
                 Random _r = new Random();
                 b.Pos.X = _r.Next(824) + 100;
                 b.Pos.Y = 0;
                 b.Vivo = true;
             }
         }
     }
     Colide(Time);
     if(Time.tempoRestante <= TimeSpan.FromSeconds(0))
     {
         MediaPlayer.Play(Musicas[3]);
         Time.tempoRestante = TimeSpan.FromSeconds(6);
         return 'k';
     }
     return '6';
 }
Example #3
0
 public void Colide(Tempo Time)
 {
     Rectangle r1 = new Rectangle((int)Voce.Pos.X, (int)Voce.Pos.Y, (int)Voce.Img.Width, (int)Voce.Img.Height);
     foreach (Persona a in Inimigos)
     {
         Rectangle r2 = new Rectangle((int)a.Pos.X, (int)a.Pos.Y, (int)a.Img.Width, (int)a.Img.Height);
         if (r1.Intersects(r2))
         {
             a.Vivo = false;
             Time.Ptos += 25;
         }
     }
 }
Example #4
0
 public bool Colide(MouseState ms, Tempo time)
 {
     Rectangle r1 = new Rectangle((int)ms.X, (int)ms.Y, 5, 5);
     for (int a = 0; a < 15; a++)
     {
         Rectangle r2 = new Rectangle((int)Bolas[a].Pos.X, (int)Bolas[a].Pos.Y, (int)Bolas[a].Img.Width, (int)Bolas[a].Img.Height);
         if (r1.Intersects(r2))
         {
             Bolas[a].Vivo = false;
             time.Ptos += 100;
             return Verifica();
         }
     }
     return false;
 }
Example #5
0
 public bool Colide(Tempo Time)
 {
     for (int a = 0; a < Tiros.Count; a++)
     {
         Rectangle r1 = new Rectangle((int)Tiros[a].Pos.X, (int)Tiros[a].Pos.Y, (int)Tiros[a].Img.Width, (int)Tiros[a].Img.Height);
         for (int b = 0; b < Inimigos.Count; b++)
         {
             Rectangle r2 = new Rectangle((int)Inimigos[b].Pos.X, (int)Inimigos[b].Pos.Y, (int)Inimigos[b].Img.Width, (int)Inimigos[b].Img.Height);
             if (r1.Intersects(r2))
             {
                 Tiros.Remove(Tiros[a]);
                 Inimigos.Remove(Inimigos[b]);
                 Time.Ptos += 100;
                 return Verifica();
             }
         }
     }
     return false;
 }
Example #6
0
 protected override void Initialize()
 {
     //Tamanho da Tela
     graphics.PreferredBackBufferWidth = 1024;
     graphics.PreferredBackBufferHeight = 768;
     graphics.ApplyChanges();
     spriteBatch = new SpriteBatch(GraphicsDevice);
     spriteBatch.Begin();
     spriteBatch.Draw(Content.Load<Texture2D>("loading"), new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2), Color.White);
         Log = new Text.RealText.Login(this, Content.Load<SpriteFont>("font3"));
         teste = new Connection();
         Time = new Tempo();
         Time.globHighscore = teste.getHighscore();
         Time.globNome = teste.getName();
         Game1 = new Jogo1(Content.Load<Texture2D>("Inimigo"), Content.Load<Texture2D>("Nave"));
         Game2 = new Jogo2(Content.Load<Texture2D>("Ball"));
         Game3 = new Jogo3();
         Game4 = new Jogo4(Content.Load<Texture2D>("Inimigo"), Content.Load<Texture2D>("mouse"));
         Game5 = new Jogo5(Content.Load<Texture2D>("Inimigo"), Content.Load<Texture2D>("Nave"), Content.Load<Texture2D>("Tiro"));
         Game6 = new Jogo6(Content.Load<Texture2D>("Inimigo"), Content.Load<Texture2D>("mouse"));
         Divs = new Div();
         register = false;
     spriteBatch.End();
     base.Initialize();
 }
Example #7
0
 public char Update(KeyboardState ks, Tempo Time, Song[] Musicas)
 {
     if (Time.tempoRestante <= TimeSpan.FromSeconds(0))
     {
         MediaPlayer.Play(Musicas[2]);
         Time.tempoRestante = TimeSpan.FromSeconds(5);
         return '0';
     }
     if ((ks.IsKeyDown(Keys.Left) || (ks.IsKeyDown(Keys.A))) && Voce.Pos.X > 5)
     {
         if (ks.IsKeyDown(Keys.RightShift))
         {
             Voce.Pos.X -= 5;
         }
         else
         {
             Voce.Pos.X -= 7;
         }
     }
     if ((ks.IsKeyDown(Keys.Right) || (ks.IsKeyDown(Keys.D))) && Voce.Pos.X < 1000)
     {
         if (ks.IsKeyDown(Keys.RightShift))
         {
             Voce.Pos.X += 5;
         }
         else
         {
             Voce.Pos.X += 7;
         }
     }
     if (ks.IsKeyDown(Keys.Space) && Tiros.Count < 10 )
     {
         CriaTiro();
     }
     for (int a = 0; a < Tiros.Count;a++)
     {
         Tiros[a].Pos.Y -= 9;
         if (Tiros[a].Pos.Y <= 0)
         {
             Tiros.RemoveRange(0, 1);
         }
     }
     if (Colide(Time))
     {
         //MediaPlayer.Play(Musicas[3]);
         Time.ResetaTempo();
         return '6';
     }
     return '5';
 }
Example #8
0
        /*
         * Função de update, pública porque é chamada por fora
         * Note que ela pega parâmetros do programa principal, o keyboardstate, o Tempo (classe criada no workspace) e Song
         */
        public char Update(KeyboardState ks, Tempo Time, Song[] Musicas)
        {
            if (Time.tempoRestante <= TimeSpan.FromSeconds(0))
            {
                Time.ResetaTempo();
                return '2';
            }

            if ((ks.IsKeyDown(Keys.Left) || (ks.IsKeyDown(Keys.A))) && Voce.Pos.X > 5)
            {
                if(ks.IsKeyDown(Keys.RightShift))
                {
                    Voce.Pos.X -= 3;
                }
                else
                {
                    Voce.Pos.X -= 5;
                }
            }
            if ((ks.IsKeyDown(Keys.Right) || (ks.IsKeyDown(Keys.D))) && Voce.Pos.X < 1019)
            {
                if (ks.IsKeyDown(Keys.RightShift))
                {
                    Voce.Pos.X += 3;
                }
                else
                {
                    Voce.Pos.X += 5;
                }
            }
            Random _r = new Random();
            foreach (Persona b in Inimigos)
            {
                b.Pos.Y += 5;
                if (b.Pos.Y > Voce.Pos.Y)
                {
                    b.Pos.X = _r.Next(1024);
                    b.Pos.Y = -30;
                }
            }
            if (Colide()) //Note que a função colide só é usada aqui, por isso é private, mas vou explicar melhor quando chegar nela
            {
                MediaPlayer.Play(Musicas[2]);
                Time.tempoRestante = TimeSpan.FromSeconds(5);
                return '0';
            }
            return '1';
        }
Example #9
0
 public char Update(MouseState ms, Tempo Time, Song[] Musicas)
 {
     if (Time.tempoRestante <= TimeSpan.FromSeconds(0))
     {
         MediaPlayer.Play(Musicas[2]);
         Time.tempoRestante = TimeSpan.FromSeconds(5);
         return '0';
     }
     if (ms.LeftButton == ButtonState.Pressed && apertado == false)
     {
         apertado = true;
         //estado.LeftButton = ButtonState.Pressed;
         if (Colide(ms, Time))
         {
             Time.ConverteTempo();
             Time.ResetaTempo();
             return '3';
         }
     }
     if (ms.LeftButton == ButtonState.Released)
     {
         apertado = false;
     }
     return '2';
 }
Example #10
0
 public bool Login(Text.RealText.Login Log, Tempo Time)
 {
     try
     {
         String sql = "SELECT nome_user, senha_user, highscore_user, mortes_user, vitorias_user, tempo_user FROM tbUser WHERE nome_user = @name AND senha_user = @pass";
         MySqlCommand cmd = new MySqlCommand(sql, con);
         cmd.Parameters.AddWithValue("@name", Log.username);
         cmd.Parameters.AddWithValue("@pass", Log.pass);
         con.Open();
         MySqlDataReader dr;
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         while (dr.Read())
         {
             if (dr["nome_user"].ToString() == Log.username && dr["senha_user"].ToString() == Log.pass)
             {
                 Time.nome = Log.username;
                 Time.mortes = Convert.ToInt32(dr["mortes_user"]);
                 Time.highscore = Convert.ToInt32(dr["highscore_user"]);
                 Time.wins = Convert.ToInt32(dr["vitorias_user"]);
                 return true;
             }
         }
     }
     catch (Exception ex)
     {
         //throw ex;
         Time.nome = "guest";
         Time.mortes = 0;
         Time.highscore = 0;
         Time.wins = 0;
     }
     finally
     {
         con.Close();
     }
     Time.nome = "guest";
     Time.mortes = 0;
     Time.highscore = 0;
     Time.wins = 0;
     return false;
 }
Example #11
0
 public char Update(MouseState ms, Tempo Time, Song[] Musicas)
 {
     if (Time.tempoRestante <= TimeSpan.FromSeconds(0))
     {
         Time.ResetaTempo();
         return '5';
     }
     Voce.Pos.X = ms.X;
     if (ms.X > 1010)
     {
         Voce.Pos.X = ms.X;
     }
     if (ms.X < 0)
     {
         Voce.Pos.X = ms.X;
     }
     Voce.Pos.Y = ms.Y;
     if (ms.Y < 0)
     {
         Voce.Pos.Y = 0;
     }
     if (ms.Y > 750)
     {
         Voce.Pos.Y = 750;
     }
     if (Colide())
     {
         MediaPlayer.Play(Musicas[2]);
         Time.tempoRestante = TimeSpan.FromSeconds(5);
         return '0';
     }
     Movimenta();
     return '4';
 }