public static void NextTile(Jogo.Location Direction, ref short X, ref short Y)
    {
        // Next Tile
        switch (Direction)
        {
        case Jogo.Location.Above: Y -= 1; break;

        case Jogo.Location.Below: Y += 1; break;

        case Jogo.Location.Right: X += 1; break;

        case Jogo.Location.Left: X -= 1; break;
        }
    }
Exemple #2
0
    public static void Move(Jogo.Location Direction)
    {
        // Verifica se o Player pode se Move
        if (!CanMove())
        {
            return;
        }

        // Define a Direction do Player
        if (Lists.Player[MyIndex].Direction != Direction)
        {
            Lists.Player[MyIndex].Direction = Direction;
            Sending.Player_Direction();
        }

        // Verifica se o Tile seguinte está livre
        if (Map.Tile_Blocked(Lists.Player[MyIndex].Map, Lists.Player[MyIndex].X, Lists.Player[MyIndex].Y, Direction))
        {
            return;
        }

        // Define a Velocity que o Player se move
        if (Jogo.HoldKey_Shift)
        {
            Lists.Player[MyIndex].Movement = Jogo.Movements.Correndo;
        }
        else
        {
            Lists.Player[MyIndex].Movement = Jogo.Movements.Andando;
        }

        // Movement o Player
        Sending.Player_Move();

        // Define a Position exata do Player
        switch (Direction)
        {
        case Jogo.Location.Above: Lists.Player[MyIndex].Y2 = Jogo.Grade; Lists.Player[MyIndex].Y -= 1; break;

        case Jogo.Location.Below: Lists.Player[MyIndex].Y2 = Jogo.Grade * -1; Lists.Player[MyIndex].Y += 1; break;

        case Jogo.Location.Right: Lists.Player[MyIndex].X2 = Jogo.Grade * -1; Lists.Player[MyIndex].X += 1; break;

        case Jogo.Location.Left: Lists.Player[MyIndex].X2 = Jogo.Grade; Lists.Player[MyIndex].X -= 1; break;
        }
    }
    public static bool Tile_Blocked(short Map, byte X, byte Y, Jogo.Location Direction)
    {
        short Next_X = X, Next_Y = Y;

        // Next Tile
        NextTile(Direction, ref Next_X, ref Next_Y);

        // Verifica se está indo para uma ligação
        if (ForaDoLimite(Next_X, Next_Y))
        {
            if (Lists.Map.Ligação[(byte)Direction] == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }

        // Verifica se o Tile está Blocked
        if (Lists.Map.Tile[Next_X, Next_Y].Attribute == (byte)Tile_Attributes.Block)
        {
            return(true);
        }
        else if (Lists.Map.Tile[Next_X, Next_Y].Block[(byte)Jogo.DirectionInverse(Direction)])
        {
            return(true);
        }
        else if (Lists.Map.Tile[X, Y].Block[(byte)Direction])
        {
            return(true);
        }
        else if (ThereIsPlayer(Map, Next_X, Next_Y) > 0 || ThereIsNPC(Next_X, Next_Y) > 0)
        {
            return(true);
        }

        return(false);
    }
    public static void Character(short Texture, Point Position, Jogo.Location Direction, byte Coluna, bool Suffering = false)
    {
        Rectangle Fonte = new Rectangle(), Destino = new Rectangle();
        Size      Size = MySize(Tex_Character[Texture]);

        SFML.Graphics.Color Cor = new SFML.Graphics.Color(255, 255, 255);
        byte Line = 0;

        // Direction
        switch (Direction)
        {
        case Jogo.Location.Above: Line = Jogo.Movement_Above; break;

        case Jogo.Location.Below: Line = Jogo.Movement_Below; break;

        case Jogo.Location.Left: Line = Jogo.Movement_Left; break;

        case Jogo.Location.Right: Line = Jogo.Movement_Right; break;
        }

        // Define as propriedades dos retângulos
        Fonte.X      = Coluna * Size.Width / Jogo.Animation_Amount;
        Fonte.Y      = Line * Size.Height / Jogo.Animation_Amount;
        Fonte.Width  = Size.Width / Jogo.Animation_Amount;
        Fonte.Height = Size.Height / Jogo.Animation_Amount;
        Destino      = new Rectangle(Position, Fonte.Size);

        // Demonstra que o Character está Suffering dano
        if (Suffering)
        {
            Cor = new SFML.Graphics.Color(205, 125, 125);
        }

        // Desenha o Character e sua sombra
        Desenhar(Tex_Sombra, Destino.Location.X, Destino.Location.Y + Size.Height / Jogo.Animation_Amount - MySize(Tex_Sombra).Height + 5, 0, 0, Size.Width / Jogo.Animation_Amount, MySize(Tex_Sombra).Height);
        Desenhar(Tex_Character[Texture], Fonte, Destino, Cor);
    }