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 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 #4
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 #5
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 #6
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';
 }