Esempio n. 1
0
        public void Update(GameTime gametime, KeyboardState keyboard)
        {
            if (visivel || disable)
            {
                if (scriptedAI)
                {
                    switch (currentAIPhase)
                    {
                    case AIPhase.Phase1:
                        Phase1(gametime);
                        break;

                    case AIPhase.Phase2:
                        Phase2(gametime);
                        break;

                    case AIPhase.Phase3:
                        Phase3(gametime);
                        break;

                    case AIPhase.Phase4:
                        Phase4(gametime);
                        break;

                    case AIPhase.Phase5:
                        Phase5(gametime);
                        break;

                    case AIPhase.Phase6:
                        Phase6(gametime);
                        break;

                    case AIPhase.Phase7:
                        Phase7(gametime);
                        break;

                    case AIPhase.Phase8:
                        Phase8(gametime);
                        break;
                    }
                }
                else
                {
                    if (keyboard.IsKeyDown(teclaDireita) && posicaoX + naveDrawRectangulo.Width + RAPIDEZ <= GameConstants.WINDOW_WIDTH)
                    {
                        posicaoX               += RAPIDEZ;
                        naveDrawRectangulo.X   += RAPIDEZ;
                        escudoDrawRectangulo.X += RAPIDEZ;
                        naveShape.Center.X     += RAPIDEZ;
                        escudoShape.Center.X   += RAPIDEZ;
                    }

                    if (keyboard.IsKeyDown(teclaEsquerda) && posicaoX - RAPIDEZ >= 0)

                    {
                        posicaoX               -= RAPIDEZ;
                        naveDrawRectangulo.X   -= RAPIDEZ;
                        escudoDrawRectangulo.X -= RAPIDEZ;
                        naveShape.Center.X     -= RAPIDEZ;
                        escudoShape.Center.X   -= RAPIDEZ;
                    }


                    if (keyboard.IsKeyDown(teclaDisparar) && vidaActual > 0 && disparou == false)
                    {
                        disparou = true;
                        if (Jogador.Jogador2 == jogador)
                        {
                            GameMLS.AdicionarBala(new Bala(texturaBala, jogador, posicaoX + naveDrawRectangulo.Width / 2 - texturaBala.Width / 2,
                                                           posicaoY, true));
                        }
                        else
                        {
                            GameMLS.AdicionarBala(new Bala(texturaBala, jogador, posicaoX + naveDrawRectangulo.Width / 2 - texturaBala.Width / 2,
                                                           posicaoY + naveDrawRectangulo.Height - texturaBala.Height, false));
                        }
                    }


                    if (keyboard.IsKeyDown(teclaActivarEscudo) && tempoEscudo <= 0 && escudoActivo == false)
                    {
                        escudoActivo = true;
                        escudoActual = ESCUDO;
                        tempoEscudo  = TEMPO_ARREFECIMENTO_ESCUDO;
                    }
                }



                if (disparou == true)
                {
                    tempoTiros += gametime.ElapsedGameTime.Ticks;
                }


                if (tempoTiros >= TEMPO_TIROS)
                {
                    disparou   = false;
                    tempoTiros = 0;
                }


                if (tempoEscudo > 0)
                {
                    tempoEscudo -= gametime.ElapsedGameTime.Ticks;
                }
            } //end if (visivel||disable)
        }     //end Update()
Esempio n. 2
0
 static void Main()
 {
     using (var game = new GameMLS())
         game.Run();
 }
Esempio n. 3
0
        void Phase4(GameTime gametime)
        {
            //30 seconds left and right shooting with shield
            if (tempoEscudo <= 0 && escudoActivo == false)
            {
                escudoActivo = true;
                escudoActual = ESCUDO;
                tempoEscudo  = TEMPO_ARREFECIMENTO_ESCUDO;
            }

            if (!switchSide)
            {
                if (tempoAI < PHASE4_TIME && vidaActual > 0 && posicaoX + naveDrawRectangulo.Width + RAPIDEZ <= GameConstants.WINDOW_WIDTH)
                {
                    posicaoX               += RAPIDEZ;
                    naveDrawRectangulo.X   += RAPIDEZ;
                    escudoDrawRectangulo.X += RAPIDEZ;
                    naveShape.Center.X     += RAPIDEZ;
                    escudoShape.Center.X   += RAPIDEZ;
                    if (disparou == false)
                    {
                        disparou = true;
                        if (Jogador.Jogador2 == jogador)
                        {
                            GameMLS.AdicionarBala(new Bala(texturaBala, jogador, posicaoX + naveDrawRectangulo.Width / 2 - texturaBala.Width / 2,
                                                           posicaoY, true));
                        }
                        else
                        {
                            GameMLS.AdicionarBala(new Bala(texturaBala, jogador, posicaoX + naveDrawRectangulo.Width / 2 - texturaBala.Width / 2,
                                                           posicaoY + naveDrawRectangulo.Height - texturaBala.Height, false));
                        }
                    }
                }
                else
                {
                    switchSide = true;
                }
            }

            else
            {
                if (tempoAI < PHASE4_TIME && vidaActual > 0 && posicaoX - RAPIDEZ >= 0)
                {
                    posicaoX               -= RAPIDEZ;
                    naveDrawRectangulo.X   -= RAPIDEZ;
                    escudoDrawRectangulo.X -= RAPIDEZ;
                    naveShape.Center.X     -= RAPIDEZ;
                    escudoShape.Center.X   -= RAPIDEZ;
                    if (disparou == false)
                    {
                        disparou = true;
                        if (Jogador.Jogador2 == jogador)
                        {
                            GameMLS.AdicionarBala(new Bala(texturaBala, jogador, posicaoX + naveDrawRectangulo.Width / 2 - texturaBala.Width / 2,
                                                           posicaoY, true));
                        }
                        else
                        {
                            GameMLS.AdicionarBala(new Bala(texturaBala, jogador, posicaoX + naveDrawRectangulo.Width / 2 - texturaBala.Width / 2,
                                                           posicaoY + naveDrawRectangulo.Height - texturaBala.Height, false));
                        }
                    }
                }
                else
                {
                    switchSide = false;
                }
            }

            if (tempoAI >= PHASE4_TIME)
            {
                currentAIPhase = AIPhase.Phase5;
                tempoAI        = 0;
            }
            else
            {
                tempoAI += gametime.ElapsedGameTime.Ticks;
            }
        }