Exemplo n.º 1
0
 private void BuscarCombateSalvaje()
 {
     foreach (Hierba hierba in mapa.Hierbas)
     {
         if (protagonista.CollisionsWith(hierba))
         {
             if (r.Next(1, 100) <= 5 ? true : false)
             {
                 Combate combate = new Combate(
                     ref protagonista, CargarPokemonSalvaje(), this);
                 SdlHardware.ResetScroll();
                 bgSound.StopMusic();
                 combate.Run();
                 bgSound.BackgroundPlay();
             }
         }
     }
 }
Exemplo n.º 2
0
    private void ComprobarTeclas()
    {
        if (!protagonista.Hablando)
        {
            InvertirCoordenadas(false);

            if (SdlHardware.KeyPressed(SdlHardware.KEY_DOWN))
            {
                Moverse(0, protagonista.GetVelocidad(), Sprite.DOWN);
                BuscarCombateSalvaje();
            }
            else if (SdlHardware.KeyPressed(SdlHardware.KEY_UP))
            {
                Moverse(0, -protagonista.GetVelocidad(), Sprite.UP);
                BuscarCombateSalvaje();
            }
            else if (SdlHardware.KeyPressed(SdlHardware.KEY_LEFT))
            {
                Moverse(-protagonista.GetVelocidad(), 0, Sprite.LEFT);
                BuscarCombateSalvaje();
            }
            else if (SdlHardware.KeyPressed(SdlHardware.KEY_RIGHT))
            {
                Moverse(protagonista.GetVelocidad(), 0, Sprite.RIGHT);
                BuscarCombateSalvaje();
            }
            else if (SdlHardware.KeyPressed(SdlHardware.KEY_M))
            {
                SdlHardware.ResetScroll();
                bgSound.StopMusic();
                new Sound("data/sonidos/menu_jugador.mp3").PlayOnce();
                new MenuJugador(protagonista, fondo, dialogo, this).Run();
                bgSound.BackgroundPlay();
            }
        }
    }
Exemplo n.º 3
0
    public void Run()
    {
        string[] text =
        {
            "Press D to throw the dice",
            "Your game piece will move to the next box",
            "Press A, B or C to choose the answer",
            "Wait your turn",
            "Actual player is indicated above",
            "Press Q to quit the game",
            " ",
            "Try to use arrow keys to move",
            "the player only in this screen",
            " ",
            "Press R to Return"
        };

        Image background = new Image("data/board.png");
        Font  font18     = new Font("data/Joystix.ttf", 18);

        Player player = new Player();

        player.MoveTo(430, 550);
        short playerSpeed = 4;

        byte  color   = 255;
        short x       = 180;
        short y       = 180;
        short spacing = 40;

        do
        {
            SdlHardware.ClearScreen();
            SdlHardware.DrawHiddenImage(background, 0, 0);

            color = 255;
            y     = 180;
            for (int i = 0; i < text.Length; i++)
            {
                SdlHardware.WriteHiddenText(text[i],
                                            x, y,
                                            color, color, color,
                                            font18);
                color -= 15;
                y     += spacing;
            }
            player.DrawOnHiddenScreen();
            SdlHardware.ShowHiddenScreen();

            if (SdlHardware.KeyPressed(SdlHardware.KEY_RIGHT) &&
                (player.GetX() < 600))
            {
                player.ChangeDirection(Sprite.RIGHT);
                SdlHardware.ScrollHorizontally((short)(-playerSpeed));
                player.MoveTo(player.GetX() + playerSpeed, player.GetY());
                player.NextFrame();
            }
            if (SdlHardware.KeyPressed(SdlHardware.KEY_LEFT) &&
                (player.GetX() > 300))
            {
                player.ChangeDirection(Sprite.LEFT);
                SdlHardware.ScrollHorizontally(playerSpeed);
                player.MoveTo(player.GetX() - playerSpeed, player.GetY());
                player.NextFrame();
            }

            SdlHardware.Pause(40);
        }while (!SdlHardware.KeyPressed(SdlHardware.KEY_R));
        SdlHardware.ResetScroll();
    }
Exemplo n.º 4
0
    private void GestionarConversaciones()
    {
        if (SdlHardware.KeyPressed(SdlHardware.KEY_SPC))
        {
            foreach (Pc pc in mapa.Pcs)
            {
                if (protagonista.CollisionsWith(pc))
                {
                    SdlHardware.ResetScroll();
                    SdlHardware.Pause(100);
                    bgSound.StopMusic();
                    new Sound("data/sonidos/menu_jugador.mp3").PlayOnce();
                    pc.Run(ref protagonista, viejoScrollX, viejoScrollY);
                    bgSound.BackgroundPlay();
                }
            }
            foreach (Npc npc in mapa.Npcs)
            {
                if (protagonista.CollisionsWith(npc))
                {
                    switch (protagonista.currentDirection)
                    {
                    case Sprite.DOWN:
                        npc.ChangeDirection(Sprite.UP);
                        break;

                    case Sprite.UP:
                        npc.ChangeDirection(Sprite.DOWN);
                        break;

                    case Sprite.LEFT:
                        npc.ChangeDirection(Sprite.RIGHT);
                        break;

                    case Sprite.RIGHT:
                        npc.ChangeDirection(Sprite.LEFT);
                        break;
                    }

                    npc.Hablando          = true;
                    dibujarDialogo        = true;
                    protagonista.Hablando = true;
                }
            }
            SdlHardware.Pause(100);
        }
        foreach (Npc npc in mapa.Npcs)
        {
            if (npc.Hablando)
            {
                if (SdlHardware.KeyPressed(SdlHardware.KEY_SPC))
                {
                    if (npc.IndiceDialogo < npc.Dialogo.Count - 1)
                    {
                        npc.IndiceDialogo++;
                    }
                    else
                    {
                        npc.Hablando          = false;
                        protagonista.Hablando = false;
                        npc.IndiceDialogo     = 0;
                        if (npc.GetType().Name == "Enfermera")
                        {
                            foreach (Bestia b in protagonista.GetEquipo())
                            {
                                b.SetVida(b.GetMaxVida());
                            }
                        }
                    }
                    SdlHardware.Pause(40);
                }
            }
        }
    }
Exemplo n.º 5
0
    public void Run()
    {
        string[] text =
        {
            "Use arrow keys to move right or left",
            "Use spacebar to jump",
            "Arrows + spacebar to jump sidewards",
            "Beware of the moving enemies",
            "Press Q to quit the game",
            " ",
            "Press R to Return"
        };

        Image background = new Image("data/help.png");
        Font  font18     = new Font("data/Joystix.ttf", 18);

        Player player = new Player();

        player.MoveTo(510, 558);
        short playerSpeed = 4;

        byte  grey    = 200;
        short x       = 300;
        short y       = 250;
        short spacing = 40;

        do
        {
            // Draw items on screen
            SdlHardware.ClearScreen();
            SdlHardware.DrawHiddenImage(background, 0, 0);


            grey = 200;
            y    = 250;
            for (int i = 0; i < text.Length; i++)
            {
                SdlHardware.WriteHiddenText(text[i],
                                            x, y,
                                            grey, grey, grey,
                                            font18);
                grey -= 20;
                y    += spacing;
            }
            player.DrawOnHiddenScreen();
            SdlHardware.ShowHiddenScreen();

            // Animate the player (it is must fall or jump)
            player.Move();

            // Get user input to move the player as desired

            if (SdlHardware.KeyPressed(SdlHardware.KEY_RIGHT) &&
                (player.GetX() < 700))
            {
                player.ChangeDirection(Sprite.RIGHT);
                SdlHardware.ScrollHorizontally((short)(-playerSpeed));
                player.MoveTo(player.GetX() + playerSpeed, player.GetY());
                player.NextFrame();
            }
            if (SdlHardware.KeyPressed(SdlHardware.KEY_LEFT) &&
                (player.GetX() > 300))
            {
                player.ChangeDirection(Sprite.LEFT);
                SdlHardware.ScrollHorizontally(playerSpeed);
                player.MoveTo(player.GetX() - playerSpeed, player.GetY());
                player.NextFrame();
            }

            // And pause (25 fps)
            SdlHardware.Pause(40);
        }while (!SdlHardware.KeyPressed(SdlHardware.KEY_R));
        SdlHardware.ResetScroll();
    }