Exemple #1
0
    public static bool Tile_Blocked(short Map_Num, short X, short Y, Game.Directions Direction, bool CountEntities = true)
    {
        short Next_X = X, Next_Y = Y;

        // Próximo azulejo
        NextTile(Direction, ref Next_X, ref Next_Y);

        // Verifica se o azulejo está bloqueado
        if (Tile_Blocked(Map_Num, (byte)Next_X, (byte)Next_Y))
        {
            return(true);
        }
        if (Lists.Map[Map_Num].Tile[Next_X, Next_Y].Block[(byte)Game.ReverseDirection(Direction)])
        {
            return(true);
        }
        if (Lists.Map[Map_Num].Tile[X, Y].Block[(byte)Direction])
        {
            return(true);
        }
        if (CountEntities && (HasPlayer(Map_Num, Next_X, Next_Y) > 0 || HasNPC(Map_Num, Next_X, Next_Y) > 0))
        {
            return(true);
        }
        return(false);
    }
Exemple #2
0
    private static void Spawn(byte Index, short Map_Num, byte x, byte y, Game.Directions Direction = 0)
    {
        short NPC_Index = Lists.Map[Map_Num].NPC[Index].Index;

        // Previne erros
        if (NPC_Index >= Lists.NPC.Length)
        {
            return;
        }

        // Define os dados
        Lists.Temp_Map[Map_Num].NPC[Index].Index     = NPC_Index;
        Lists.Temp_Map[Map_Num].NPC[Index].X         = x;
        Lists.Temp_Map[Map_Num].NPC[Index].Y         = y;
        Lists.Temp_Map[Map_Num].NPC[Index].Direction = Direction;
        Lists.Temp_Map[Map_Num].NPC[Index].Vital     = new short[(byte)Game.Vitals.Count];
        for (byte i = 0; i < (byte)Game.Vitals.Count; i++)
        {
            Lists.Temp_Map[Map_Num].NPC[Index].Vital[i] = Lists.NPC[NPC_Index].Vital[i];
        }

        // Envia os dados aos jogadores
        if (Socket.Device != null)
        {
            Send.Map_NPC(Map_Num, Index);
        }
    }
Exemple #3
0
    public static bool Tile_Blocked(short Map, byte X, byte Y, Game.Directions Direction)
    {
        short Next_X = X, Next_Y = Y;

        // Próximo azulejo
        NextTile(Direction, ref Next_X, ref Next_Y);

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

        // Verifica se o azulejo está bloqueado
        if (Lists.Map.Tile[Next_X, Next_Y].Attribute == (byte)Layer_Attributes.Block)
        {
            return(true);
        }
        if (Lists.Map.Tile[Next_X, Next_Y].Block[(byte)Game.ReverseDirection(Direction)])
        {
            return(true);
        }
        if (Lists.Map.Tile[X, Y].Block[(byte)Direction])
        {
            return(true);
        }
        if (HasPlayer(Map, Next_X, Next_Y) > 0 || HasNPC(Next_X, Next_Y) > 0)
        {
            return(true);
        }
        return(false);
    }
Exemple #4
0
    public static void NextTile(Game.Directions Direction, ref short X, ref short Y)
    {
        // Próximo azulejo
        switch (Direction)
        {
        case Game.Directions.Up: Y -= 1; break;

        case Game.Directions.Down: Y += 1; break;

        case Game.Directions.Right: X += 1; break;

        case Game.Directions.Left: X -= 1; break;
        }
    }
Exemple #5
0
    private static void Move(Game.Directions Direction)
    {
        // Verifica se o jogador pode se mover
        if (!CanMove())
        {
            return;
        }

        // Define a direção do jogador
        if (Lists.Player[MyIndex].Direction != Direction)
        {
            Lists.Player[MyIndex].Direction = Direction;
            Send.Player_Direction();
        }

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

        // Define a velocidade que o jogador se move
        if (Keyboard.IsKeyPressed(Keyboard.Key.LShift) && Graphics.RenderWindow.HasFocus())
        {
            Lists.Player[MyIndex].Movement = Game.Movements.Moving;
        }
        else
        {
            Lists.Player[MyIndex].Movement = Game.Movements.Walking;
        }

        // Movimento o jogador
        Send.Player_Move();

        // Define a Posição exata do jogador
        switch (Direction)
        {
        case Game.Directions.Up: Lists.Player[MyIndex].Y2 = Game.Grid; Lists.Player[MyIndex].Y -= 1; break;

        case Game.Directions.Down: Lists.Player[MyIndex].Y2 = Game.Grid * -1; Lists.Player[MyIndex].Y += 1; break;

        case Game.Directions.Right: Lists.Player[MyIndex].X2 = Game.Grid * -1; Lists.Player[MyIndex].X += 1; break;

        case Game.Directions.Left: Lists.Player[MyIndex].X2 = Game.Grid; Lists.Player[MyIndex].X -= 1; break;
        }
    }
Exemple #6
0
    private static void Player_Direction(byte Index, NetIncomingMessage Data)
    {
        Game.Directions Direction = (Game.Directions)Data.ReadByte();

        // Previne erros
        if (Direction < Game.Directions.Up || Direction > Game.Directions.Right)
        {
            return;
        }
        if (Lists.Temp_Player[Index].GettingMap)
        {
            return;
        }

        // Defini a direção do jogador
        Player.Character(Index).Direction = Direction;
        Send.Player_Direction(Index);
    }
Exemple #7
0
    private static bool Move(short Map_Num, byte Index, Game.Directions Direction, byte Movement = 1, bool CheckZone = false)
    {
        Lists.Structures.Map_NPCs Data = Lists.Temp_Map[Map_Num].NPC[Index];
        byte  x = Data.X, y = Data.Y;
        short Next_X = x, Next_Y = y;

        // Define a direção do NPC
        Lists.Temp_Map[Map_Num].NPC[Index].Direction = Direction;
        Send.Map_NPC_Direction(Map_Num, Index);

        // Próximo azulejo
        Map.NextTile(Direction, ref Next_X, ref Next_Y);

        // Próximo azulejo bloqueado ou fora do limite
        if (Map.OutLimit(Map_Num, Next_X, Next_Y))
        {
            return(false);
        }
        if (Map.Tile_Blocked(Map_Num, x, y, Direction))
        {
            return(false);
        }

        // Verifica se está dentro da zona
        if (CheckZone)
        {
            if (Lists.Map[Map_Num].Tile[Next_X, Next_Y].Zone != Lists.Map[Map_Num].NPC[Index].Zone)
            {
                return(false);
            }
        }

        // Movimenta o NPC
        Lists.Temp_Map[Map_Num].NPC[Index].X = (byte)Next_X;
        Lists.Temp_Map[Map_Num].NPC[Index].Y = (byte)Next_Y;
        Send.Map_NPC_Movement(Map_Num, Index, Movement);
        return(true);
    }
Exemple #8
0
    private static void Character(short Texture_Num, Point Position, Game.Directions Direction, byte Column, bool Hurt = false)
    {
        Rectangle Rec_Source = new Rectangle(), Rec_Destiny;
        Size      Size = TSize(Tex_Character[Texture_Num]);

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

        // Direção
        switch (Direction)
        {
        case Game.Directions.Up: Line = Game.Movement_Up; break;

        case Game.Directions.Down: Line = Game.Movement_Down; break;

        case Game.Directions.Left: Line = Game.Movement_Left; break;

        case Game.Directions.Right: Line = Game.Movement_Right; break;
        }

        // Define as propriedades dos retângulos
        Rec_Source.X      = Column * Size.Width / Game.Animation_Amount;
        Rec_Source.Y      = Line * Size.Height / Game.Animation_Amount;
        Rec_Source.Width  = Size.Width / Game.Animation_Amount;
        Rec_Source.Height = Size.Height / Game.Animation_Amount;
        Rec_Destiny       = new Rectangle(Position, Rec_Source.Size);

        // Demonstra que o personagem está sofrendo dano
        if (Hurt)
        {
            Color = new SFML.Graphics.Color(205, 125, 125);
        }

        // Desenha o personagem e sua sombra
        Render(Tex_Shadow, Rec_Destiny.Location.X, Rec_Destiny.Location.Y + Size.Height / Game.Animation_Amount - TSize(Tex_Shadow).Height + 5, 0, 0, Size.Width / Game.Animation_Amount, TSize(Tex_Shadow).Height);
        Render(Tex_Character[Texture_Num], Rec_Source, Rec_Destiny, Color);
    }
Exemple #9
0
        public Func <Enemy, ShootingPattern[]> GenerateShootingDirections()
        {
            if (isBreak)
            {
                return(x => new ShootingPattern[0]);
            }
            var randomPicture = rnd.Next(2, 6);
            var picture       = $"boss-bullet-{randomPicture}.png";

            switch (phase)
            {
            case 0:     //
                var random = rnd.Next(0, 2);
                if (random == 1)
                {
                    return(x => Directions.GetAroundVectors(16).Skip(16).Take(8)
                           .Select(z => new ShootingPattern
                    {
                        Direction = z,
                        BulletImage = picture
                    }).ToArray());
                }
                else
                {
                    return(x => Directions.GetAroundVectors(16).Skip(8).Take(8)
                           .Select(z => new ShootingPattern
                    {
                        Direction = z,
                        BulletImage = picture
                    }).ToArray());
                }

            case 1:
                return(x => Directions.GetAroundVectors(16)
                       .Select(z => new ShootingPattern
                {
                    Direction = z,
                    BulletImage = picture
                }).ToArray());

            case 2:
                return(x => new[] {
                    (Game.Player.Location - x.Location).Rotate(Math.PI / 20),
                    Game.Player.Location - x.Location,
                    (Game.Player.Location - x.Location).Rotate(-Math.PI / 20)
                }
                       .Select(z => new ShootingPattern
                {
                    Direction = z,
                    BulletImage = picture
                }).ToArray());

            case 3:
                return(x => Directions.GetAroundVectors(16)
                       .Select(z => new ShootingPattern
                {
                    Pattern = VectorMoves.FlyAndFall(x.Location, z),
                    Direction = Vector.Zero,
                    BulletImage = picture
                }).ToArray());

            case 4:
                return(x => Directions.GetAroundVectors(5)
                       .Select(z => new ShootingPattern
                {
                    Pattern = VectorMoves.FlyAndToTarget(x.Location, z, Game.Player.Location - x.Location),
                    Direction = Vector.Zero,
                    BulletImage = picture
                }).ToArray());

            default:
                return(x => Directions.GetRow(10, x.Location.Y)
                       .Select(z => new ShootingPattern
                {
                    Pattern = new VectorMove(z, 10, Game.Player.Location - x.Location),
                    Direction = Vector.Zero,
                    BulletImage = "boss-bullet-1.png"
                }).ToArray());
            }
        }